Developer's Guide

From OpenRocket wiki
Revision as of 10:51, 13 March 2010 by Plaa (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page contains information on the inner workings of OpenRocket and is meant primarily for developers interested in developing OpenRocket.

In addition to this page, information can be found in the Technical documentation chapter 5.

Obtaining the source code

Source packages for OpenRocket are available in the SourceForge repository.

Alternatively, the most recent development version can be obtained from the SVN repository. It can be retrieved simply using the command

$ svn co https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk OpenRocket

The above URL may be used to connect to the repository with other Subversion clients as well.

Notes for Newer Eclipse Users

You can get the Galileo version of Eclipse from the Eclipse Download Site. You should either pull Eclipse IDE for Java Developers or Eclipse for RCP/Plug-in Developers. I'm using Eclipse IDE for Java Developers. Neither of these is at the top of the list so be careful to pick the version.

When you create a workspace to load the project in, be sure to go in and set the default JRE and Java compliance to 1.6. Even if you've already set the system default for your computer to use Java 6 and you're running the IDE with Java 6, workspaces will default to Java 5 stuff. You need compliance at 1.6 or you'll get a lot of compile errors - particularly around use of @Override.

CompilerComplianceLevel.png
JavaBuildPath.png

If you're getting errors, look at the build path and verify that you see 1.6 in the build path as shown above.


Rocket design loading and saving

(This section is based on email correspondence)


All file reading/writing is performed in the package net.sf.openrocket.file and subpackages. To implement a new document loader it is necessary to extend the class RocketLoader and implement the abstract method loadFromStream(InputStream). This method simply loads the document and returns an OpenRocketDocument object.

An OpenRocketDocument contains all the information about an opened document, primarily the rocket structure and the simulations. The rocket structure is a simple tree-like structure of RocketComponents. All of the components are in the package .rocketcomponent. A diagram of their hierarchy and a short explanation of each class is available in my thesis section 5.1 (http://openrocket.sourceforge.net/documentation.html)

I've implemented a simple XML reading framework (based on SAX), which simplifies reading by assuming that XML elements can contain only other elements or text content, but not both. Both the OpenRocket and Rocksim format abide with this restriction.

The framework is in the package .file.simplesax. The primary class that will be extended is ElementHandler, which contains three methods. openElement() is called when a new subelement is found, and it returns a new ElementHandler to handle that element (which can be the object itself), or null in order to ignore that element and all of its contents (for example for unknown elements). closeElement() is called when the subelement ends, and endHandler() is called when the element of the current handler ends. The JavaDoc should provide the necessary details.

There are a few ready handlers, the most useful of which will probably be PlainTextHandler. This handler accepts only text content and ignores all subelements. If the XML file contains <element>value</element>, then the handler can return a PlainTextHandler and handle the content within the closeElement() method, removing the need to write a specialized handler for that element.

The XML reading is initiated by calling SimpleSAX.readXML() with the input source and the initial ElementHandler.

The OpenRocket document loading is implemented in .file.openrocket.OpenRocketLoader. Here I've used a bit more boilerplate code to be able to define most of the rocket structure preferences without needing separate handlers for them.