The DictionaryForMIDs-Creator Developper's Documentation
Architecture
DictionaryForMIDs-Creator (DfM-Creator) |
Main Layer: Provides access to the other DictionaryForMIDs tools through the DfM-Creator GUI. |
||||
DictdToDictionaryForMIDs |
DictionaryGeneration |
BitmapFontGenerator |
JarCreator |
This layer contains the user interface. |
|
DictdToDictionaryForMIDs converts an input dictionary file that is in the Dict protocol format (Dictd) into a single Comma-Separated-Value (CSV file) that is the input dictionary file for DictionaryGeneration. |
DictionaryGeneration reads the input CSV file along with the file DictionaryForMIDs.properties to generate dictionary files, index files and searchlist files in the DictionaryForMIDs format. |
BitmapFontGenerator is used to generate bitmap fonts for mobiles devices that may not support some character encodings or other language characters like the chinese characters for instance. |
JarCreator assembles all the necessary files in order for you to have a DictionaryForMIDs midlet. It then packs them in some empty DfM.jar/jad files. |
This layer contains functionalities for the DictionaryForMIDs tools. |
Source code overview
DictionaryForMIDs-Creator
Overview of the packages
Package | Description |
de.kugihan.DfMCreator | Contains the class files for DictionaryForMIDs-Creator |
de.kugihan.I18n-L10n | Contains the string/translation bundle files |
de.kugihan.dictionaryformids.dictdtodictionaryformids | Contains the class files for DictdToDictionaryForMIDs |
de.kugihan.dictionaryformids.dictgen | Contains the class files for DictionaryGeneration |
de.kugihan.dictionaryformids.dictgen.dictionaryupdate | Contains the DictionaryUpdate class files |
de.kugihan.fonttoolkit | Contains the BitmapFontGenerator class files |
de.kugihan.jarCreator | Contains the class files for JarCreator |
edu.hws.eck.mdb | Contains the single class (I18n) that handles |
org.dict.kernel | Contains the sources for JDictd that are used by |
org.dict.server | Contains the sources for JDictd that are used by |
org.dict.zip | Contains the sources for JDictd that are used by |
Overview of the classes
Java Class | Function |
AboutBox | Pop-up window that shows some information about |
CheckCSVFileIntegrity | Provides a GUI to enable the user to check |
ContentPropertiesCreator | Helps in creating the languageXContentNN properties. |
DfMCreatorExceptions | Contains the personalized exceptions for DfM-Creator. |
DfMCreatorMain | This is the main class, the main window. Almost |
DictdToDfMConvSteps | This is an interface not a class. Contains |
HelpContents | A window that displays help files for DfM-Creator. |
InputDialog | A small text input dialog that is used by |
PreferencesBox | The preferences window for DfM-Creator. |
PropertiesEditor | The PropertiesEditor window. This makes it |
PropertiesPreview | Previews the values entered/selected in the |
RegexpUtils | Regular expression utilities that are used to |
SumWinBFG | BitmapFontGeneration Preferences Summary Window. |
SumWinDictdToDfM | DictdToDictionaryForMIDs Preferences Summary Window. |
SumWinDictGen | DictionaryGeneration Preferences Summary Window. |
SumWinJarCreator | JarCreator Preferences Summary Window. |
Important subroutines
DfMCreatorMain (the main window that holds the other tabs)
addFontTKToDfMCreatorTabbedPane()
The font generator tab holds the FontToolkit created by Sean Kernohan.
When i started creating the DfM-Creator, i did not want to have to write
a new GUI from scratch for the BitmapFontGenerator. So, i decided to modify
the FontToolkit and integrate it in the DfM-Creator. The code in this subroutine
does what is necessary to get the FontToolkit to work with the DfM-Creator.
The other modifications were done directly in the FontToolkit sources.
getFile() shows a file chooser to let the user
choose a file and return the it's path.
Parameter: dirsOnly; a boolean value that toggles on/off the possibility of
chowing directories only or files and directories.
trim() removes trailing slashes or backslashes at the end of a string. It is used here mainly to trim trailing slashes/backslashes from the paths to the input and output files and directories provided by the user. Works for both Windows and Linux (i.e, for \ and /).
printAnyMsg() prints a JOptionPane message dialog.
The parameters are the following:
- message; the text of the message
- winText; the title of the windows
- infType; the type of the message
setTheLocale() gets and sets the default locale. It can also test other locales during debug sessions for example.
savePreferences() saves the preferences (for now, only the look and feel preferences are concerned.)
applyPreferences() applies the saved preferences at program startup.
OwnTextFieldCheck() and OwnEncTextFieldCheck() check if the "Choose Your Own" radio buttons in the DictdToDictionaryForMIDs tab are selected in order to enable/disable the little text areas that let the user provide her own choices instead of the ones given by default. These radio buttons exist for encoding and separator character choices.
setDictdToDfMVals() checks the validity of the values entered by the
user and passes them to DictdToDictionaryForMIDs if they are valid.
Exceptions thrown by this subroutine:
- FileNotFoundException
- de.kugihan.DfMCreator.DfMCreatorExceptions.DBNameTextFieldIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.DBPathTextFieldIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.OutCSVFileTextFieldIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.DBFolderNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.DBINIFileNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.OutCSVFileCantBeWritten
setDictGenVals() checks and sets the values up for DictionaryGeneration.
Exceptions thrown by this subroutine:
- FileNotFoundException
- de.kugihan.DfMCreator.DfMCreatorExceptions.PropFileErrorException
- de.kugihan.DfMCreator.DfMCreatorExceptions.SourceFileTFIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.DirectoryDestinationTFIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.PropertyPathTFIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.SourceFileNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.SourceFileNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.PropertyPathNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.DirectoryDestinationNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.CantCreateDestDir
setJCVals() checks and sets the values up for JarCreator.
Exceptions thrown by this subroutine:
- FileNotFoundException
- de.kugihan.DfMCreator.DfMCreatorExceptions.BadDictDirNameException
- de.kugihan.DfMCreator.DfMCreatorExceptions.DictionaryDirectoryNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.PropFileErrorException
- de.kugihan.DfMCreator.DfMCreatorExceptions.EmptyDfMJarJadDirDoesNotExist
- de.kugihan.DfMCreator.DfMCreatorExceptions.EmptyDfMFileNotFound
- de.kugihan.DfMCreator.DfMCreatorExceptions.OutputDirectoryNotAccessible
- de.kugihan.DfMCreator.DfMCreatorExceptions.InputCSVFilesTFIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.EmptyDfMDirTFIsEmpty
- de.kugihan.DfMCreator.DfMCreatorExceptions.OutputDirTFIsEmpty
DictdConvDoAll
this subroutine does all the required operations in order for us to
be able to convert a dictd dictionary file with DictdToDictionaryForMIDs.
DictGenDoAll()
this subroutine is like the above mentioned one, but it is proper to
DictionaryGeneration.
JarCreatorDoAll()
this subroutine is like the above mentioned ones, but it is proper to
DictionaryGeneration.
PropertiesEditor window
showInputDialog()
Shows an input dialog and returns its content.
Parameter: winTitle; the title of the window.
Returns: the value entered by the user.
filterSepChar()
Processes the selected item of one of the four separator character ComboBoxes
and returns the actual separator character corresponding to the selected item.
Parameter: combobox
Returns: value; the selected separator character
showMoreInfo()
shows some extra information about the properties.
launches a file open dialog in order to let the user choose a DictionaryForMIDs.properties file that she wishes to edit and then launches the PropertiesPreview window. The user can then edit the file manually and then save it.
viewAndOrEdit()
launches the PropertiesPreview window with the values
selected/entered by the user in the PropertiesEditor. Here also the user
can edit the file manually before saving it. Note that the name of the file is
automatically set by the PropertiesPreview and is DictionaryForMIDs.properties.
showSamplePropFile()
shows a sample DictionaryForMIDs.properties file.
validateValues()
validates the values entered by the user in the PropertiesEditor.
Checks if the required values are all provided, if some TextFields are empty or not and so forth.
setValuesInPropTextArea()
sets the values entered/selected by the user in
the PropertiesPreview window.
updateNumOfLang()
updates/shows/hides some values/TextFields/CheckBoxes etc.
according to the number of languages selected in the numOfLangCmbBox ComboBox.
getInputOptionDialog()
shows the InputDialog window.
Parameter: label
Parameter: winTitle
Returns: String S
showContentPropsCreator()
shows the ContentProperties-Creator window.
checkInfoTextContents()
checks the content of the InfoText TextField
to match it against the regular expression patterns present in the
RegexpUtils class in order to make sure the user provided a URL or an
email address for the maintainer(s) of the dictionary file that is about
to be set up in the empty DictionaryForMIDs.jar/jad files.
Throws: IllegalArgumentException if the text does not
contain an URL or an email address.
ContentProperties-Creator window
updateNumOfContentDec()
This subroutine updates (shows or hides some components) the ContentProperties-Creator's
window according to the number of content declaration chosen for a particular language.
getRGBCodes()
This converts the selected item's name of the color ComboBoxes into a RGB color code and returns it.
Parameter: comboBox, the ComboBox that is passed, from which the selected item's name will
be converted into a RGB color code.
Returns: the String colorCode
setTheContentNNProperties()
This saves the content settings that were chosen by the user into the content variables located as
public static variables in the PropertiesEditor Class.
class Task extends SwingWorker
Preferences window
For the time being, the Preferences window offers the possibility to customize
only the Look and Feel settings. It enables the user to select which look and feel
should the DictionaryForMIDs-Creator have. The list that is displayed, varies from
one operating system to another but whatever
the operating system, if you installed JDK-7u2 or later, you should have the Nimbus,
the Metal and the CDE/Motif look and feels installed. Note that to compile/build the
DictionaryForMIDs-Creator you need JDK-7u2 or later.
setLookAndFeelPrefs()
In the List that displays the intalled look and feels, the values
are displayed as follows by this code snipet that was copied:
// add the look and feel names to
// the list that the user will see
listModel.addElement(info.getName());// add the actual class names to the
// array list that will be used to
// actually set the selected L & F
lookAndFeelClassNames.add(info.getClassName());In fact, the order of the index in the list from which the user selects among the installed look and feels (info.getName()) is the same as the index order of the arraylist lookAndFeelClassNames; consequently, we use info.getName to get the names of the look and feels (names are better than the ugly class names), and then we use the actual class names that were stored in the arraylist lookAndFeelClassNames to pass them to the subroutine savePreferences() in order for it to save them.
CheckCSVFileIntegrity
checkCSVFileIntegrity()
Main subroutine that checks the integrity of a CSV file entered by the user.
it calls the subroutine below to do the actual checking.
checkCsvFileFormat()
Copied from DictionaryGeneration in order to adapt it to DfM-Creator.
Checks a CSV file's integrity.
Parameter: csvFileName the input csv-file's name.
Exceptions: DictionaryException, IOException
RegexpUtils
validateURL() checks if a string contains a URL, URI, URN.Parameter: input the input string
Returns: true or false
Throws: Exception
validateEmail() checks if a string contains an email address.
Parameter: input the input string
Returns: true or false
Throws: Exception
Summary windows
-
DictdToDictionaryForMIDs preferences summary window:
fillDictdConvSummaryTextPane()
fillDictdConvSummaryTextPane() gets all the needed information
and formats them correctly so as to have a clear and neat
summary of the Bitmap Font Generation preferences entered
by the user.deleteCSVFile()
deleteCSVFile() is used to delete the incomplete output csv file if the conversion process is aborted by the user.class Task extends SwingWorker
SwinWorker class named Task that is used to actually launch the dictionary conversion process in a new thread.
In the DictionaryForMIDs-Creator, almost all SwingWorker classes are called Task, however, they do not belong to the same classes and therefore do not do the same things. We could have used just about any valid variable/class name instead of Task. -
DictionaryGeneration preferences summary window:
fillDictGenSummaryTextArea()
Does the same thing as the above mentioned summary subroutine but for DictionaryGeneration.class Task extends SwingWorker
SwingWorker class named Task that is to DictionaryGeneration what the above mentioned Task class is to DictdToDictionaryForMIDs. -
JarCreator preferences summary window:
fillJarCreationSummaryTextArea()
Does the same thing as the above mentioned summary subroutines but for JarCreatorclass Task extends SwingWorker
SwingWorker class named Task that is to JarCreator what the above mentioned Task class is to DictionaryGeneration. -
BitmapFontGeneration preferences summary window:
fillBFGSummaryTextArea()
Does the same thing as the above mentioned summary subroutines but for BitmapFontGenerationThough the BitmapFontGeneration also has a preferences summary window, it does not have a SwingWorker class that handles the font generation process. The FontToolkit class already has a thread class that does for the BitmapFontGenerator, what the SwingWorker classes do for DictdToDictionaryForMIDs, DictionaryGeneration and JarCreator.
Subroutines that call the other windows
showPrefsWin() shows the preferences window.
showHelpWindow() shows the help window.
showAbout() shows the about window.
showPropWin() shows the PropertiesEditor Window.
showCSVFileCheckWin() shows the csvfile check window.
Getting the source code
You can download the current source code either from the Subversion repository or from this web site as a zip file.
Downloading the Source Code from SVN
The sources for DictionaryForMIDs-Creator are maintained in
SourceForge SVN repository.
Read the description on how to access the
DictionaryForMIDs SVN repository.
You can also use the "Download GNU tarball" link on the
subversion web frontend to download the DictionaryForMIDs-Creator sources.
Downloading the Source Code as ZIP file
A zip file containing a stable release of DfM-Creator is available
on this web site. Please bear in mind that this zip file contains sometimes
sources that are outdated. If you want to get the latest development sources,
always go to the subversion repository. To check out the repository, code:
svn co https://dictionarymid.svn.sourceforge.net/svnroot/dictionarymid dictionarymid
Download the latest stable sources on this page
Note that these are only the DfM-Creator sources. For development purposes you will need some other tools/applications that are dependencies to DfM-Creator. To get all the dependencies, download at least the trunk directory from the subversion repository. To download only the trunk repository, code:svn co https://svn.code.sf.net/p/dictionarymid/code/trunk dictionarymid_trunk
Building the tools and applications
Dependencies between the tools and applications
The following dependencies exist between the tools and applications:
- DictionaryForMIDs-Creator depends DictionaryForMIDs, JavaSE and JavaME Therefore, make sure the DictionaryForMIDs-Creator sources remain under trunk/DictionaryForMIDs-Creator. During the build process, the sources for DictionaryForMIDs, JavaSE and JavaME are expected to be respectively in trunk/DictionaryForMIDs, trunk/JavaSE and trunk/JavaME. Otherwise, the build will fail! The best way to be sure that you got everything right is to keep the directory tree after checking the DictionaryForMIDs repository out.
Building the tools and applications with build.xml
Due to the complexity of DictionaryForMIDs-Creator, the only supported build
method is through the use of the build.xml file that in under the directory
trunk/Build.
You must have Apache-Ant and Antenna (preferably the latest versions).
Antenna is already present in the above mentioned build directory.
Before proceeding to the build, you must:
- Have the file build.xml in the trunk/Build directory
-
Have Oracle Java JDK-7u2 or later (can be downloaded somewhere at:
http://www.oracle.com/technetwork/java/javase/downloads/index.html) -
Have Oracle Java ME SDK 3.0 installed or Sun Java Wireless Toolkit 2.5.2
(can be downloaded somewhere at:
http://www.oracle.com/technetwork/java/javame/javamobile/download/sdk/index.html) - Set wtk.home to your WTK installation directory
-
Have Apache Ant installed on your system (in the PATH)
(can be downloaded somewhere at:
http://ant.apache.org/bindownload.cgi) -
Have antenna-bin-xxx.jar in the build directory (build directory has a version of antenna
but it is most of the time outdated. The latest version can be downloaded somewhere at:
http://antenna.sourceforge.net/)
Important note: the source files are UTF-8 encoded. If you are using the old
Sun WTK (for versions <= 2.5.2), you must
set in the file ktools.properties (found somewhere under wtklib) the following
property:
javac.encoding=UTF-8
Written by Karim Mahamane, Author of DfM-Creator. Inspired by this file written by Gert Nuber, creator of DictionaryForMIDs.