i need to enhance jawi converter application using syllable word, but i don't know how to start it. The previous version, the coding is not working for syllable,so i need to change some coding to make it done convert correctly.Here some of code that i have to enhance.
amalinaishak 0 Newbie Poster
The attachment preview is chopped off after the first 10 KB. Please download the entire file.
package jawi;
/****
This is a system that enable to convert from Rumi Text to Jawi Text and vice versa.
****/
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.StringTokenizer;
import java.text.Bidi.*;
import java.text.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Font;
import java.awt.print.*;
import java.awt.Container;
import java.awt.datatransfer.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.border.LineBorder;
import javax.swing.SwingConstants;
import javax.swing.SwingConstants.*;
import javax.swing.undo.*;
import javax.swing.event.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.Action;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.StyledEditorKit.*;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import javax.swing.text.html.*;
import javax.swing.table.*;
import java.util.Vector;
import java.util.EventObject;
import java.text.SimpleDateFormat;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.UIManager;
//import jawi.*;
//import jawi.OJFileChangedDialog.*;
public class JCRJawi_Converter extends JFrame implements Printable//change
{
public JCRKeyboard ojkeyboard;
static boolean showKeyboard = true;
static boolean rightDirection = true;
private javax.swing.JButton jbShowKeyboard;
private javax.swing.JButton jbNoKeyboard;
private javax.swing.JPanel jpKeyboardPanel;
private javax.swing.JPanel jpStatusbar;
private javax.swing.JScrollPane jscScroller;
private javax.swing.JLabel tfColNo;
public int wrx = 1;
// Create Panel
JPanel contentPane;
private JPanel jPanel1 = new JPanel();
private JPanel jPanel2 = new JPanel();
private JPanel jPanel3 = new JPanel();
private JPanel jPanel4 = new JPanel();
private JPanel jPanel5 = new JPanel();
private JPanel JawiConPanel = new JPanel();
private JPanel HowToUsePanel = new JPanel();
private JPanel MelayuPanel = new JPanel();
public DefaultStyledDocument m_doc;
private RTFEditorKit m_kit=new RTFEditorKit();
JFileChooser fc;
private String m_fontName = "K-Jawi Arial";
private String one;
private int m_fontSize = 0;
private boolean m_skipUpdate;
private int m_xStart = -1;
private int m_xFinish = -1;
public StyleContext m_context;
private StyledDocument doc;
Document doc1;
public boolean opened = false;
public File Opened_File;
public File Saved_Once;
public boolean new_file=false;
public boolean saved_once=false;
FileInputStream fInput;
private int countEvent;
private JCRFileChangedDialog fileChangedDialog;
private JCRExistsDialog existsDialog;
private JCRErrorDialog errorDialog;
private JViewport view_port;
boolean document_has_changed;
// Menu bar
JMenuBar jMenu = new JMenuBar();
//MenuFile
JMenu jMenuFile = new JMenu();
private JMenuItem jMenuFileNew = new JMenuItem();
private JMenuItem jMenuFileOpen = new JMenuItem();
private JMenuItem jMenuFileSave = new JMenuItem(); //Save
private JMenuItem jMenuFileSaveAs = new JMenuItem(); //SaveAs
private JMenuItem jMenuFileExit = new JMenuItem();
private JMenuItem jMenuFilePrint = new JMenuItem();//print
private JMenuItem previewItem = new JMenuItem();//priview
private JMenu jMenuEdit = new JMenu();
private JMenuItem jMenuEditUndo = new JMenuItem();
private JMenuItem jMenuEditRedo = new JMenuItem();
private JMenuItem jMenuEditCut = new JMenuItem();
private JMenuItem jMenuEditCopy = new JMenuItem();
private JMenuItem jMenuEditPaste = new JMenuItem();
private JMenuItem jMenuEditClear = new JMenuItem();
private JMenuItem ItemSearchWord= new JMenuItem();
private JMenuItem jMenuEditParagraph = new JMenuItem();
private JMenu jMenuHelp = new JMenu();
private JMenuItem jMenuHelpAbout = new JMenuItem();
// Popup menu - rigth click
private JPopupMenu jPopupMenu = new JPopupMenu();
private JMenuItem jMenuUndo = new JMenuItem();
private JMenuItem jMenuRedo = new JMenuItem();
private JMenuItem jMenuCut = new JMenuItem();
private JMenuItem jMenuCopy = new JMenuItem();
private JMenuItem jMenuPaste = new JMenuItem();
private JMenuItem jMenuClear = new JMenuItem();
// Tool bar
private JToolBar jToolBar = new JToolBar();
private JButton jButtonNew = new JButton();
private JButton jButtonOpen = new JButton();
private JButton jButtonSave = new JButton();//Save
private JButton jButtonSaveAs = new JButton();//Save
private JButton bPreview = new JButton();//priview
private JButton jButtonPrint = new JButton();//print
private JButton jButtonFind = new JButton();//find
private JButton jButtonCut = new JButton();
private JButton jButtonCopy = new JButton();
private JButton jButtonPaste = new JButton();
private JButton jButtonUndo = new JButton();
private JButton jButtonRedo = new JButton();
private JButton jButtonHelp = new JButton();
private JButton jButtonword = new JButton();
private JButton jButtonMaintain = new JButton();//maintain
private JButton jButtonHighLight = new JButton();//highlight
private JToggleButton jbPrint1;
private JToggleButton jbPrint2;
private JToggleButton jbPrint3;
private JToggleButton jbPrint4;
private JToggleButton jbPrint5;
private JToggleButton jbPrint6;
private JComboBox jcbFontList;
private JComboBox jcbFontSize;
// Create textarea, radiobutton & convert button
private JScrollPane jawiScrollPane = new JScrollPane();
private JTextPane JawiTextPane = new JTextPane();
private JScrollPane rumiScrollPane = new JScrollPane();
private JTextPane RumiTextPane = new JTextPane();
private JRadioButton jRadioButtonRUMI = new JRadioButton();
private JRadioButton jRadioButtonJAWI = new JRadioButton();
private JButton jbtConvert = new JButton();
public FindDialog m_findDialog;
public SplashScreen splash;
private PrintView printView;
//******************** Font Bar vareabls ********************
private JToggleButton bold_button=new JToggleButton(new StyledEditorKit.BoldAction());
private JToggleButton italic_button=new JToggleButton(new StyledEditorKit.ItalicAction());
private JToggleButton under_line_button=new JToggleButton(new StyledEditorKit.UnderlineAction());
// GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
// private String font_names[]=ge.getAvailableFontFamilyNames();
private String font_sizes[]={"10","12","14","16","18","20","22","24","26","28","32","36","40","46","52","60","72"};
// private JComboBox font_name=new JComboBox(font_names);
private JComboBox font_size=new JComboBox(font_sizes);
// Create Tab Pane
private JTabbedPane jtpAbout = new JTabbedPane();
// Create Label to hold Image for help
private JLabel JawiCon = new JLabel(new ImageIcon(getClass().getResource("/image/About.png")));
private JLabel H2UMelayu = new JLabel(new ImageIcon(getClass().getResource("/image/MalayCaraGuna.png")));
private JLabel H2UJawi = new JLabel(new ImageIcon(getClass().getResource("/image/JawiCaraGuna.png")));
/**********************************************************
* Virtual Converter Title *
**********************************************************/
private char penukar[] = {'\u06A4','\u0646','\u0648','\u06A9','\u0631'};
private String converter = new String(penukar); //change from pengalih to penukar
/*********************************************************
* Jawi text for menu bar *
**********************************************************/
private char file[] = {'\u0641','\u0627','\u0674','\u064A','\u0644'};
private char newdoc[] = {'\u0686', '\u064A','\u06A4','\u062A','\u0627','\u0020','\u062F','\u0648','\u0643','\u0648','\u0645','\u0646','\u0020','\u0628','\u0627','\u0631','\u0648'};
private char opendoc[] = {'\u0628','\u0648','\u06A9','\u0020','\u062F','\u0648','\u0643','\u0648','\u0645','\u0646'};
private char sdoc[] = {'\u0633','\u064A','\u0645','\u06A4','\u0646','\u0020','\u0633','\u0628','\u0627','\u06AC','\u0627','\u064A'};
private char ssdoc[] = {'\u0633','\u064A','\u0645','\u06A4','\u0646'};
private char helpmenu[] = {'\u0628','\u0646','\u062A','\u0648','\u0627','\u0646'};
private char editmenu[] = {'\u0627','\u064A','\u062F','\u064A','\u062A'};
private char undomenu[] = {'\u0628','\u0648','\u0627','\u062A','\u0020','\u0627','\u0635','\u0644'};
private char redomenu[] = {'\u0628','\u0648','\u0627','\u062A','\u0020','\u0633','\u0645','\u0648','\u0644','\u0627'};
private char cutmenu[] = {'\u06A4','\u0648','\u062A','\u0648','\u06A0'};
private char copymenu[] = {'\u0633','\u0627','\u0644','\u064A','\u0646'};
private char pastemenu[] = {'\u062A','\u0645','\u06A4','\u0644'};
private char aboutmenu[] = {'\u0645','\u06A0','\u0646','\u0627','\u0674','\u064A'};
private char keluar[] = {'\u06A9','\u0644','\u0648','\u0627','\u0631'};
private char padam[] = {'\u06A4','\u0627','\u062F','\u0645'};
private char semua[] = {'\u0633','\u0645','\u0648','\u0627'};
private char cara[] = {'\u0686','\u0627','\u0631','\u0627'};
private char guna[] = {'\u06AC','\u0648','\u0646','\u0627'};
private char melayu[] = {'\u0645','\u0644','\u0627','\u064A','\u0648'};
private char tulisan[] = {'\u062A','\u0648','\u0644','\u064A','\u0633','\u0646'};
private char findw[] = {'\u0686','\u0627','\u0631','\u064A','\u0020','\u06AF','\u0646','\u062A','\u064A','\u0020','\u06A4','\u0631','\u0643','\u0627','\u062A','\u0627','\u0674','\u0646'};
private char ppdoc[] = {'\u06A4','\u0631','\u0627','\u062A','\u
stephen84s 550 Nearly a Posting Virtuoso Featured Poster
Please use code tags, if you wish us to go through the code. Also I hope you have indented the code correctly, because honestly I do not think any one will dare try to go through such a big file, especially if it is not presentable.
To use code tags, all you have to do is place the content inside, [code=java] and [/code] tags. Also please be kind enough to mention what is going wrong in your code, is it a compilation error or a runtime problem, and paste us the actual output which the compiler or the JRE is throwing up at you.
quuba 81 Posting Pro
The text is difficult to read. Many parts repeated. I do not have information regarding the form of data from the database.
Whether the database is online? What is the difference between the Front / BackJavi / RumiUnicode? What is the difference between-ke, di-,di_Abd? (sufix,prefix,infix). What is the meaning of .,@!/% and others?
In this way writing program is very easy to make mistakes.
I have attached two files for analysis .
/*
* j3c
*/
package jawi;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class Naombor {
private static Map<Character, Character> mapRJ = new HashMap<Character, Character>();
private static Map<Character, Character> mapJR = new HashMap<Character, Character>();
private static void fill() {
put('\u0030', '\u0660'); //0// Naombor Rumi // nombor Jawi
put('\u0031', '\u0661'); //1// Naombor Rumi // nombor Jawi
put('\u0032', '\u0662'); //2// Naombor Rumi // nombor Jawi
put('\u0033', '\u0663'); //3// Naombor Rumi // nombor Jawi
put('\u0034', '\u0664'); //4// Naombor Rumi // nombor Jawi
put('\u0035', '\u0665'); //5// Naombor Rumi // nombor Jawi
put('\u0036', '\u0666'); //6// Naombor Rumi // nombor Jawi
put('\u0037', '\u0667'); //7// Naombor Rumi // nombor Jawi
put('\u0038', '\u0668'); //8// Naombor Rumi // nombor Jawi
put('\u0039', '\u0669'); //9// Naombor Rumi // nombor Jawi
//total 20
}
public static Character rumiToJavi(Character s) {
return mapRJ.get(s);
}
public static Character javiToRumi(Character s) {
return mapJR.get(s);
}
//fill
private static void put(Character cR, Character cJ) {
mapRJ.put(cR, cJ);
mapJR.put(cJ, cR);
}
static {
fill();
}
public static void main(String args[]) {
for (int i = 0; i < 10; i++) {
Character c = Character.forDigit(i, 10);
System.out.print(c);
System.out.print("|");
System.out.print(SyllableWord.get(rumiToJavi(c)));
System.out.print("|");
System.out.print(javiToRumi(rumiToJavi(c)));
System.out.println();
}
System.out.println();
Iterator<Character> iterRJ = mapRJ.keySet().iterator();
while (iterRJ.hasNext()) {
Character next = iterRJ.next();
System.out.println(next + "|" + javiToRumi(mapRJ.get(next)) + "||||");
char[] c = Character.toChars(Character.codePointAt(new char[]{next}, 0));
for (int i = 0; i < c.length; i++) {
System.out.print(c[i]);
}
System.out.println();
}
System.out.println("mapR.size=" + mapRJ.size());
//toChars(int codePoint)
// Converts the specified character (Unicode code point) to its UTF-16 representation stored in a char array.
//////////////////
System.out.println("===============");
char[] def = new char[10];
for (int i = 0; i < def.length; i++) {
def[i] = Character.forDigit(i, 10);
}
for (int i = 0; i < def.length; i++) {
System.out.print("char=");
System.out.print(def[i]);
System.out.print(" codePoint=");
System.out.println(Integer.toHexString(Character.codePointAt(def, i)) + " hexal");
}
System.out.println("========rumiToJavi=======");
def = new char[10];
for (int i = 0; i < def.length; i++) {
def[i] = rumiToJavi(Character.forDigit(i, 10));
}
for (int i = 0; i < def.length; i++) {
System.out.print("char=");
System.out.print(def[i]);
System.out.print(" codePoint=");
System.out.println(Integer.toHexString(Character.codePointAt(def, i)) + " hexal");
}
}
}
/*
* j3c
*/
package jawi;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
public class SyllableWord {
//TODO make maps unmodifiedable
private static Map<String, Character> map = new HashMap<String, Character>();
private static Map<Character, String> mapR = new HashMap<Character, String>();
private static void fill() {
put("u0020", '\u0020'); //
put("u002D", '\u002D');//- //-
put("u002E", '\u002E');//. //.
put("u0030", '\u0030'); //0// Naombor Rumi
put("u0031", '\u0031'); //1// Naombor Rumi
put("u0032", '\u0032'); //2// Naombor Rumi
put("u0033", '\u0033'); //3// Naombor Rumi
put("u0034", '\u0034'); //4// Naombor Rumi
put("u0035", '\u0035'); //5// Naombor Rumi
put("u0036", '\u0036'); //6// Naombor Rumi
put("u0037", '\u0037'); //7// Naombor Rumi
put("u0038", '\u0038'); //8// Naombor Rumi
put("u0039", '\u0039'); //9// Naombor Rumi
put("u0042", '\u0042');//B //B
put("u004B", '\u004B');//K //K
put("u004D", '\u004D');//K? //M
put("u0050", '\u0050');//M? //P
put("u0052", '\u0052');//R //R
put("u0054", '\u0054');//T //T
put("u0055", '\u0055');//U //U
put("u0057", '\u0057');//W //W
put("u0059", '\u0059');//Y //Y
put("u0061", '\u0061');//a //a
put("u0065", '\u0065');//e //e
put("u006B", '\u006B');//k //k
///
put("u061B", '\u061B');//koma titik
put("u061F", '\u061F');//tanda soal
put("u0621", '\u0621');//hamzah bawah
put("u0623", '\u0623');//alif hamzah atas
put("u0624", '\u0624');//wau hamzah
put("u0625", '\u0625');//alif hamzah Bawah
put("u0626", '\u0626');//ya hamzah
put("u0627", '\u0627');
put("u0628", '\u0628');
put("u0629", '\u0629');//ta marbutah
put("u062A", '\u062A');//ta
put("u062B", '\u062B');
put("u062C", '\u062C');
put("u062D", '\u062D');
put("u062E", '\u062E');
put("u062F", '\u062F');
put("u0630", '\u0630');
put("u0631", '\u0631');
put("u0632", '\u0632');
put("u0633", '\u0633');
put("u0634", '\u0634');
put("u0635", '\u0635');
put("u0636", '\u0636');
put("u0637", '\u0637');
put("u0638", '\u0638');
put("u0639", '\u0639');
put("u063A", '\u063A');
put("u0640", '\u0640');//sengkang penyambung
put("u0641", '\u0641');
put("u0642", '\u0642');
put("u0643", '\u0643');//kaf hamzah
put("u0644", '\u0644');
put("u0645", '\u0645');
put("u0646", '\u0646');
put("u0647", '\u0647');//ha penuh//ha tunggal boleh bersambung//ha tunggal boleh sambung
put("u0648", '\u0648');
put("u0649", '\u0649');//ya X titik
put("u064A", '\u064A');//ya
put("u0660", '\u0660');// nombor Jawi
put("u0661", '\u0661');// nombor Jawi
put("u0662", '\u0662');// nombor Jawi
put("u0663", '\u0663');// nombor Jawi
put("u0664", '\u0664');// nombor Jawi
put("u0665", '\u0665');// nombor Jawi
put("u0666", '\u0666');// nombor Jawi
put("u0667", '\u0667');// nombor Jawi
put("u0668", '\u0668');// nombor Jawi
put("u0669", '\u0669');// nombor Jawi
put("u066C", '\u066C');//koma
put("u0674", '\u0674');//hamzah 3/4
put("u0686", '\u0686');//cha
put("u06A0", '\u06A0');//nga
put("u06A4", '\u06A4');//pa
put("u06A9", '\u06A9');//kaf
put("u06AF", '\u06AF');//ga
put("u06BD", '\u06BD');//nya
put("u06BE", '\u06BE');//ha simpul
put("u06CF", '\u06CF');//va
put("u06D5", '\u06D5');//ha tunggal
///
put("uFB8E", '\uFB8E');//kaf tunggal
put("uFE95", '\uFE95');//ta tunggal
put("uFEA1", '\uFEA1');//hah tunggal
put("uFEB1", '\uFEB1');//shin tunggal
//total 88
}
public static Character get(String s) {
return map.get(s);
}
public static String get(Character c) {
return mapR.get(c);
}
private static void put(String string, Character c) {
map.put(string, c);
mapR.put(c, string);
}
static {
fill();
}
// syllabe is the same as syllableWord if pos=0
public static String syllable(String in) {
int pos = 0;
return syllableWord(in, pos);
}
public static String syllableWord(String in, int pos) {
StringTokenizer st = new StringTokenizer(in);
int countJawi = st.countTokens();
char[] jawiChar = new char[countJawi];
int k = 0;
while (st.hasMoreTokens()) {
jawiChar[k++] = SyllableWord.get(st.nextToken());
}
StringBuffer out = new StringBuffer(new String(jawiChar));
switch (pos) {
case 1:
return out.append(".").toString();
case 2:
return out.append("\u066C").toString();//koma
case 3:
return out.append("@").toString();
case 4:
return out.append("!").toString();
case 5:
return out.append("/").toString();
case 6:
return out.append("%").toString();
case 7:
return out.insert(0, "\u06A9").toString();//kaf
case 8:
return out.insert(0, "\u062F").toString();
case 9:
return out.insert(0, "\u0639\u0628\u062F\u0627\u0644").toString();
default:
return out.toString();
// pos = 0; //???
}
}
public static void main(String args[]) {
//some tests
/*
Iterator<String> iter = map.keySet().iterator();
while (iter.hasNext()) {
String next = iter.next();
System.out.println(next + "|" + map.get(next));
}
System.out.println("map.size=" + map.size());
*/
//
Iterator<Character> iterR = mapR.keySet().iterator();
while (iterR.hasNext()) {
Character next = iterR.next();
System.out.print(next + "|" + mapR.get(next) + "|||");
char[] c1 = Character.toChars(next);
for (int i = 0; i < c1.length; i++) {
System.out.print(c1[i]);
}
System.out.print("|||");
char[] c = Character.toChars(Character.codePointAt(new char[]{next}, 0));
for (int i = 0; i < c.length; i++) {
System.out.print(c[i]);
}
System.out.println();
}
System.out.println("mapR.size=" + mapR.size());
}
}
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.