This article describes how you can get started with the Jomic source code in order to contribute to it. In particular, it explains how to setup your development environment.
The jomic-developers mailing list is the preferred place to discuss issues related to development.
To contact me directly, use my SourceForge user page.
The source code is stored in a Subversion (SVN) repository. Subversion is an open source tool for version management of files. There are many tools to access information stored in repositories. This section explains how to do it using the command line client or Eclipse. For more information on Subversion, start at http://subversion.tigris.org/.
For more details on the Jomic Subversion repository, refer to http://sourceforge.net/svn/?group_id=103788.
In order for some shell scripts to work properly, set the
environment variable JOMIC_HOME
to this directory. In
bash, you can do this by adding the following line
to your .profile
:
export JOMIC_HOME=/Users/me/Programs/jomic
I also found the following aliases pretty useful to quickly go to this directory:
alias cdj="cd $JOMIC_HOME" alias cdjs="cd $JOMIC_HOME/source/net/sf/jomic"
Jomic is developed using Eclipse, an open source IDE available from http://eclipse.org/. The current version as of this writing is 3.2.2, which does not have built-in support for Subversion. Instead, you need a plug-in such as Subclipse. Once setup, perform the following steps to sync the Jomic project from the repository:
Start Eclipse.
Use
→ → .Select the wizard
→ .Enable "Create new a repository location". Click "Next".
Set "Url" to "https://jomic.svn.sourceforge.net/svnroot/jomic". Click "Next".
Select the folder to be checked out: "trunk/jomic". Click "Finish".
Once the checkout is complete, the project most likely contains compile errors. Refer to the section on building and running the application using eclipse on how to fix them.
In order to create every target of the build process, you need a couple of tools:
ant, a Java build tool available from http://ant.apache.org/. To enable image operations during the build, add JAI as external ant library. An easy way to achieve this is:
mkdir -p ~/.ant/lib cp $JOMIC_HOME/lib/*jai* ~/.ant/lib/
Python 2.6 or any later 2.x release, available from http://www.python.org/download/. Python 3.x will not work.
lxml, a Python library to process XML data, available from http://pypi.python.org/pypi/lxml/. If you are using a package manager for Linux or Mac OS X, it most likely already has a package available. Otherwise the easiest way to get it working is to use a pre build binary from the its PyPI page.
png2ico, a command line utility to convert PNG images to Windows icons, available from http://www.winterdrache.de/freeware/png2ico/.
You can omit some of these if for instance you do not want to build the documentation or Windows installer.
After syncing with the repositoy, the easiest way to build the
application is using ant, available from http://ant.apache.org/. All required external JARs are
already available in $JOMIC_HOME/lib
.
To create an initial build, run ant jomic.jar jomic-test.jar jomic-help.jar.
To run the application with the (official, utterly boring) standard test comic, use ant run.
To get a list what else you can do with ant, use ant -projecthelp .
Most likely you will get some compile errors, which will be fixed with the following steps:
Some background: Jomic's tests use the popular JUnit framework, for details see http://www.junit.org/. GUI testing is based on Jemmy, for details see http://jemmy.netbeans.org/. The coverage report is the result of Emma, for details see http://emma.sourceforge.net/.
To add your own tests, simply extend Junit's
TestCase
as usual. Take a look at
TestTools
, it features some methods to easily
obtain test data, in particular, comic archives. For GUI tests, extend
JomicApplicationTestCase
and implement your own
runTest()
. For a simple example on how to do
this, see MenuGoTest
.
A religious note: Jomic ended up as a Swing application because of the following reasons:
ComicView
is a JPanel
capable of visualizing a ComicModel
. It has to
deal with three problems:
Deciding whether to show one or two images is a lot more
difficult. ComicSheet
helps with that: a sheet
holds one or two images using the rules listed below. Figure 1, “Deciding whether to show one or two images” shows examples for
applications of these rules.
The first image has it own sheet, because it is the front page (ComicSheet 0).
If ComicImage.isDoublePage()
is true,
the image has its own sheet (ComicSheet 2 and 5).
If the last image starts at a new sheet, it has its own sheet (ComicSheet 6).
If the first image of a sheet is a single page image, but the next image is a double page image, it has its own sheet because the next image would not fit anymore (ComicSheet 4).
To render the images, Jomic uses a rather ugly approach. While Sun
released a powerful library for imaging (JAI), they could not get their
act together and include a Swing component with it that actually allows
to display such an image. Still, they included the undocumented
com.sun.media.jai.widget.DisplayJAI
. On the long
run, this is no satisfactory solutiuon. One of the JAI examples
containes IconJAI
, which displays a JAI image in
an Icon
. A bugfixed and cleaned up version of it
can be found in
net.sf.jomic.tools.IconJAI
.
From time to time, run ant checkstyle. This
creates a report that checks the code for various stylistic issues,
and generates a report in
$JOMIC_HOME/site/checkstyle-report.html
.
CheckStyle issue open at the time of the last release are available
from http://jomic.sourceforge.net/checkstyle-report.html.
If you are using Eclipse, you can also perform these checks
while typing: simple install the eclipse CheckStyle
plugin and import
$JOMIC_HOME/settings/checkstyle.xml
.
The checks are based on the default "Sun Checks", with some modifications to make the code easier to maintain and make it harder to shoot yourself in the foot. If you come from a C/C++ background, you might hate it. If you ever coded in Eiffel, there is nothing new here.
Use meaningful names, avoid the need for comments. CheckStyle lets you omit almost all comments with the following exceptions:
All classes must have a comment shortly describing what the class represents (and not what it "does")
All packages must have a
package.html
. It should contain at least
one short sentence summarizing the contents of the package. As a
template, use
$JOMIC_HOME/xml/package.html
.
Document open issues, known bugs/limitations and unclean solutions with todo comments, for example:
// TODO: use HashMap instead of array
Do not use the undocumented (but popular) @todo.
Run ant todo to get a report about all
todo comments found in
$JOMIC_HOME/site/todo-report.html
. Todo
comments open at the time of the last release are available from
http://jomic.sourceforge.net/todo-report.html.
If you declare new exceptions, make them extend
RuntimeException
, never use
Exception
. I mean it.
Use abbrevations only if you save at least 4 letters. "dir" for directory is ok, "src" for source is braindead.
Funtions and loops must have 1 exit only. Use "return" only as
last statement of a method. Do not use "break" at all; instead, use
for example a "while" loops with state variable to abort it, and
give the state variable a meaningful name such as
cancelled
.
Due performance considerations, all calls to
logger.debug()
and
logger.info()
must be wrapped inside an
if (logger.isXXXEnabled()) {...};
logger.warn/error/fatal()
won't need
this.
Clearly mark non-portable code with
// TODO: fix portability
Also consider adding some notes in the section on " Porting to additional platforms".
Some parts of Jomic are localized and ready to be translated to other languages. The implementation uses the usual machanisms provided by Java. This section gives a overview on how to work with them, and how to add support for additonal languages. For more details on Java localization, start with the internationalization thread in the Java Tutorial.
To add another language, perform the following steps:
Download the most current
bundle.properties
from: http://jomic.svn.sourceforge.net/viewvc/*checkout*/jomic/trunk/jomic/source/net/sf/jomic/tools/bundle.properties.
Copy it to bundle_*.properties
, where
"*" stands for the ISO
language code you want to translate to. For example, "de"
means German.
Change the English text snipplets right of the "=" to a text that means the same in your language.
You can find theses files in the repository at
/jomic/source/net/sf/common/bundle*.properties
. You
can browse this directory using the Subversion web interface at http://jomic.svn.sourceforge.net/viewvc/jomic/trunk/jomic/source/net/sf/jomic/tools/.
To download the most current version of a file, click its name and, on
the resulting page, on the first link named "download" near the top. In
most cases, you will only need the English
bundle.properties
.
The structure of these files is very simple: they consist of lines of the pattern "key = value", where key is the abstract name of the text snipplet under which it will be looked up by Jomic, for example "buttons.cancel". Value is the actual (language dependent) text to use in the user interface, for example, "Cancel" in English or "Abbrechen" in German.
For the above example, the file
bundle.properties
contains this line:
buttons.cancel=Cancel
The file
bundle_de.properties
defines the same key, but
assigns a different value to it:
buttons.cancel=Abbrechen
The "de" is the ISO-639 language code for German as specified. For other languages, see http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt.
If a Java application is running with the locale set to "de", it
attempty to resolve any localization keys by looking them up in
bundle_de.properties
. If it cannot find the key
there, is also looks it up in bundle.properties
.
This is nice because you will get something leggible on the screen if a
single key is missing from the properties file. This is also a bit
confusing because parts of the application will use different
languages.
To avoid this, you should update your
bundle_*.properties
from time to time. As generally
only a few text snipplets where added, there is no point in
re-translating the file again. Instead, you should use an editor
optimized for editing loalization property files. One such editor is
Zaval Java Resource Editor, available from http://zaval.org/products/jrc-editor/. In particular it
helps to find the entries that are availbele in
bundle.properties
but are missing in
bundle_*.properties
.
(In case you are working with the repository, you do not need to dowload and install the editor. Simply run ant edit-bundle to open all bundle*.properties in it.)
Open the patch tracker at http://sourceforge.net/tracker/?atid=635945&group_id=103788&func=browse.
Click "Submit new"
In the form, set category to "Localization".
Enter a summary, for example "Japanese Localization"
Enable the checkmark right to the text "Check to Upload and Attach a File"
Click the "Browse" button, and select your file (for example
bundles_jp.properties
).
Enter a description, for exampe "Japanese Localization".
Click the "Submit" button.
Using the tracker makes sure that everybody knows which localizations are currently worked on, and avoids duplicate effort. However, if you really can not figure out the patch tracker, you can also email your file to me.
The documentation is stored in
$JOMIC_HOME/site/
. Most of it is written in DocBook
XML, a set of tags for describing books, articles, and other prose
documents, particularly technical documentation. For more information
about DocBook, see for example http://www.docbook.org/, in particular http://docbook.org/tdg/en/html/docbook.html. Using
DocBook/XSL, the DocBook source can be transformed into other formats
such as XHTML, PDF, or JavaHelp. For details about DocBook/XSL, see
http://www.sagehill.net/docbookxsl/.
In practice, this is not all that complicated as most of the stuff is already setup to "just work" by using some simple ant rules. The only thing you need to install first ist tidy, a tool to check, fix, and reformat HTML, XHTML, and XML (and thus DocBook) files. It is available from http://tidy.sourceforge.net/.
Now you can edit the source documents, and create the documentation with ant:
Edit $JOMIC_HOME/site/user-guide.xml
, and
run ant user-guide to update the user guide in
$JOMIC_HOME/site/user-guide.html
Edit
$JOMIC_HOME/site/developer-guide.xml
, and run
ant developer-guide to update the developer guide
in $JOMIC_HOME/site/developer-guide.html
Edit $JOMIC_HOME/site/index.xml
, and run
ant site-index to update your local copy of the
homepage in $JOMIC_HOME/site/index.html
I'm not aware of any useful and free DocBook editor, so I suggest you use an XML editor, for example JEdit with its XML plugin, available from http://www.jedit.org/. This at least gives you syntax coloring.
Figures are stored in $JOMIC_HOME/images/
.
You can use OpenOffice to edit them, see http://www.openoffice.org/. Conversion to other formats
has to be done using OpenOffice's export function. (Yeah, this sucks.
Eventually this should all be SVG. Just gimme an easy to install,
non-braindead editor for that.)
Multi-layered images are stored in
$JOMIC_HOME/images/
and use PhotoShop's PSD format
or whatever format the person who did it considered useful.