Skip to content

Commit

Permalink
Added a reference menu
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceUB committed Aug 31, 2018
1 parent 73bc0f2 commit 5552bcc
Show file tree
Hide file tree
Showing 11 changed files with 826 additions and 18 deletions.
42 changes: 27 additions & 15 deletions README.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
<h1><a id="Vincents_IPA_typer_0"></a>Vincent’s IPA typer</h1>
<p>This program is supposed to get a coded (abbreviated) message as an input, and output the corresponding symbol</p>
<h2><a id="How_to_run_the_program_4"></a>How to run the program</h2>
<p>Perquisites: You must have at least Java 8 installed</p>
<p>Perquisites:</p>
<ol>
<li>You must have at least Java 9 installed (<a href="http://www.oracle.com/technetwork/java/javase/downloads/jre10-downloads-4417026.html">Lastest JRE</a>)</li>
<li>You must have a computer with:
<ol>
<li>At least 50MB of RAM (More recommended)</li>
<li>At least 1.6MB of free storage space (More recommended)</li>
<li>A usable console or GUI</li>
<li>Internet connection (optional)</li>
</ol>
</li>
<li>If in GUI mode, a web browser is recommended</li>
</ol>
<p>If you want to do it like a normal person, just double press the jarfile downloaded.</p>
<p>If you:</p>
<ol>
Expand All @@ -16,15 +28,15 @@ <h2><a id="How_to_run_the_program_4"></a>How to run the program</h2>
<li>Otherwise, type <code>java -jar &lt;full path of the jarfile&gt;/&lt;the jarfile&gt;.jar</code></li>
<li>Press enter</li>
</ol>
<h2><a id="How_to_correctly_input_21"></a>How to correctly input</h2>
<h2><a id="How_to_correctly_input_28"></a>How to correctly input</h2>
<p>Each letter is split into separate sections, separated by periods (.), in the order as follows:</p>
<p>(For consonants): Voicing, Place of articulation, Manner of articulation</p>
<p>(For vowels): Height, Backness, Roundedness</p>
<p>Diacritics, Suprasegmentals: Type, Symbol</p>
<p>In each of these sections, you put an abbreviation for the symbol’s name (see below)</p>
<p>If you want to write multiple symbols in one input, just separate them with spaces</p>
<h3><a id="Consonants_34"></a>Consonants</h3>
<h4><a id="Voicing_35"></a>Voicing</h4>
<h3><a id="Consonants_41"></a>Consonants</h3>
<h4><a id="Voicing_42"></a>Voicing</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand All @@ -43,7 +55,7 @@ <h4><a id="Voicing_35"></a>Voicing</h4>
</tr>
</tbody>
</table>
<h4><a id="Place_of_Articulation_40"></a>Place of Articulation</h4>
<h4><a id="Place_of_Articulation_47"></a>Place of Articulation</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand Down Expand Up @@ -114,7 +126,7 @@ <h4><a id="Place_of_Articulation_40"></a>Place of Articulation</h4>
</tr>
</tbody>
</table>
<h4><a id="Manner_of_articulation_58"></a>Manner of articulation</h4>
<h4><a id="Manner_of_articulation_65"></a>Manner of articulation</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand Down Expand Up @@ -162,8 +174,8 @@ <h4><a id="Manner_of_articulation_58"></a>Manner of articulation</h4>
</tbody>
</table>
<p>*Instead of Sibilant, use Fricative. The program will correct you</p>
<h3><a id="Vowels_73"></a>Vowels</h3>
<h4><a id="Height_74"></a>Height</h4>
<h3><a id="Vowels_80"></a>Vowels</h3>
<h4><a id="Height_81"></a>Height</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand Down Expand Up @@ -210,7 +222,7 @@ <h4><a id="Height_74"></a>Height</h4>
</tr>
</tbody>
</table>
<h4><a id="Backness_84"></a>Backness</h4>
<h4><a id="Backness_91"></a>Backness</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand All @@ -233,7 +245,7 @@ <h4><a id="Backness_84"></a>Backness</h4>
</tr>
</tbody>
</table>
<h4><a id="Roundedness_90"></a>Roundedness</h4>
<h4><a id="Roundedness_97"></a>Roundedness</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand All @@ -252,8 +264,8 @@ <h4><a id="Roundedness_90"></a>Roundedness</h4>
</tr>
</tbody>
</table>
<h3><a id="Diacritics__Suprasegmentals_96"></a>Diacritics &amp; Suprasegmentals</h3>
<h4><a id="Type_97"></a>Type</h4>
<h3><a id="Diacritics__Suprasegmentals_103"></a>Diacritics &amp; Suprasegmentals</h3>
<h4><a id="Type_104"></a>Type</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand All @@ -276,7 +288,7 @@ <h4><a id="Type_97"></a>Type</h4>
</tr>
</tbody>
</table>
<h4><a id="Suprasegmentals_104"></a>Suprasegmentals</h4>
<h4><a id="Suprasegmentals_111"></a>Suprasegmentals</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand Down Expand Up @@ -323,7 +335,7 @@ <h4><a id="Suprasegmentals_104"></a>Suprasegmentals</h4>
</tr>
</tbody>
</table>
<h4><a id="Diacritics_117"></a>Diacritics</h4>
<h4><a id="Diacritics_124"></a>Diacritics</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand Down Expand Up @@ -426,7 +438,7 @@ <h4><a id="Diacritics_117"></a>Diacritics</h4>
</tr>
</tbody>
</table>
<h4><a id="Superscripted_Letters_144"></a>Superscripted Letters</h4>
<h4><a id="Superscripted_Letters_151"></a>Superscripted Letters</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ This program is supposed to get a coded (abbreviated) message as an input, and o

## How to run the program

Perquisites: You must have at least Java 8 installed
Perquisites:
1. You must have at least Java 9 installed ([Lastest JRE](http://www.oracle.com/technetwork/java/javase/downloads/jre10-downloads-4417026.html))
2. You must have a computer with:
1. At least 50MB of RAM (More recommended)
2. At least 1.6MB of free storage space (More recommended)
3. A usable console or GUI
4. Internet connection (optional)
3. If in GUI mode, a web browser is recommended

If you want to do it like a normal person, just double press the jarfile downloaded.

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<target>8</target>
<source>8</source>
<target>9</target>
<source>9</source>
</configuration>
</plugin>
<plugin>
Expand Down
156 changes: 156 additions & 0 deletions src/main/java/io/github/vkb24312/IPA/MainFrame.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
package io.github.vkb24312.IPA;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseWheelEvent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Properties;

class MainFrame extends JFrame {
//region The components
private JMenuBar menuBar;
private JMenu reference;
private JMenu IPAChart;
private JMenuItem IPAChartFull;
private JMenuItem IPAChartConsonants;
private JMenuItem IPAChartVowels;
private JMenuItem IPAChartSpecials;
private JMenuItem wikipediaHelp;
private JMenuItem correctInput;
private JPanel panel;
private JPanel inputPanel;
private JLabel inputFieldLabel;
Expand Down Expand Up @@ -43,6 +58,7 @@ class MainFrame extends JFrame {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

initFont();
initMenuBar();
initPanel();
initInput();
initOutput();
Expand All @@ -51,6 +67,120 @@ class MainFrame extends JFrame {
setFontAll(font);
}

private void initMenuBar(){
//region Create everything
menuBar = new JMenuBar();

reference = new JMenu("Reference");

IPAChart = new JMenu("IPA Chart");
IPAChartFull = new JMenuItem("Full Chart");
IPAChartConsonants = new JMenuItem("Consonants");
IPAChartVowels = new JMenuItem("Vowels");
IPAChartSpecials = new JMenuItem("Diacritics and Suprasegmentals");
try {
ImageIcon wikipediaIcon = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("images/Wikipedia-logo-v2.png")));
wikipediaHelp = new JMenuItem("Wikipedia Reference", wikipediaIcon);
} catch (IOException e) {
wikipediaHelp = new JMenuItem("Wikipedia Reference");
e.printStackTrace();
}
correctInput = new JMenuItem("How to correctly input");

IPAChart.add(IPAChartFull);
IPAChart.add(IPAChartConsonants);
IPAChart.add(IPAChartVowels);
IPAChart.add(IPAChartSpecials);

reference.add(wikipediaHelp);
reference.add(correctInput);
reference.add(IPAChart);

menuBar.add(reference);
//endregion

setJMenuBar(menuBar);

//region Set action listeners
wikipediaHelp.addActionListener(l -> {
try {
Desktop.getDesktop().browse(new URI("https://en.wikipedia.org/wiki/H:IPA"));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});

correctInput.addActionListener(l -> {
if(!new File("temp.html").exists()){
try {
InputStream inStream = getClass().getClassLoader().getResourceAsStream("READMEs/README.html");
FileOutputStream fos = new FileOutputStream("temp.html");

inStream.transferTo(fos);

new File("temp.html").deleteOnExit();
} catch (IOException e){
e.printStackTrace();
}
}


try{
if(InetAddress.getByName("github.com").isReachable(1000)) {
Desktop.getDesktop().browse(new URI("https://github.com/vkb24312/IPA-Converter/blob/master/README.md#how-to-correctly-input"));
return;
} else outputFieldLabel.setText("No Internet Connection");
} catch (IOException | URISyntaxException e) {
outputFieldLabel.setText("Something went wrong");
e.printStackTrace();
}

try {
Desktop.getDesktop().browse(new File("temp.html").toURI());
} catch (IOException e) {
e.printStackTrace();
}

});

IPAChartConsonants.addActionListener(l -> {
try {
new PictureFrame(ImageIO.read(getClass().getClassLoader().getResourceAsStream("images/IPA_Charts/CONSONANTS.png")));
} catch (IOException e) {
outputFieldLabel.setText("Something went wrong");
e.printStackTrace();
}
});

IPAChartVowels.addActionListener(l -> {
try {
new PictureFrame(ImageIO.read(getClass().getClassLoader().getResourceAsStream("images/IPA_Charts/VOWELS.png")));
} catch (IOException e) {
outputFieldLabel.setText("Something went wrong");
e.printStackTrace();
}
});

IPAChartSpecials.addActionListener(l -> {
try {
new PictureFrame(ImageIO.read(getClass().getClassLoader().getResourceAsStream("images/IPA_Charts/SPECIALS.png")));
} catch (IOException e) {
outputFieldLabel.setText("Something went wrong");
e.printStackTrace();
}
});

IPAChartFull.addActionListener(l -> {
try {
new PictureFrame(ImageIO.read(getClass().getClassLoader().getResourceAsStream("images/IPA_Charts/FULL.png")));
} catch (IOException e) {
outputFieldLabel.setText("Something went wrong");
e.printStackTrace();
}
});
//endregion
}

private void initPanel(){
panel = new JPanel(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
Expand Down Expand Up @@ -151,4 +281,30 @@ private void updateOutput(){
outputField.setText(output.toString());
outputFieldLabel.setText("Double click text to select");
}
}

class PictureFrame extends JFrame{
private Image _image;

PictureFrame(Image image){
super("Picture");
if(image.getHeight(null)>Toolkit.getDefaultToolkit().getScreenSize().height || image.getWidth(null)>Toolkit.getDefaultToolkit().getScreenSize().width) {
int originalHeight = image.getHeight(null);
int originalWidth = image.getWidth(null);
int i = 1;
while(originalHeight/i>Toolkit.getDefaultToolkit().getScreenSize().height || originalWidth/i>Toolkit.getDefaultToolkit().getScreenSize().width) {
i++;
}
setSize(image.getWidth(null) / i, image.getHeight(null) / i);
} else setSize(image.getWidth(null), image.getHeight(null));
_image = image;

setVisible(true);
}

@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(_image, 0, 0, getWidth(), getHeight(), null);
}
}
Loading

0 comments on commit 5552bcc

Please sign in to comment.