Alternative approaches for Maps with primitive values

While profiling the current state of OpenPatrician I noted that there are maps that are quite memory intensive and they have primitive values. As the map cannot hold primitive values they need to be boxed into their corresponding object, which adds overhead. Therefore I asked about alternative approaches. To figure out what meets my requirement best I did a small benchmark of my own comparing some of the available collection libraries.

„Alternative approaches for Maps with primitive values“ weiterlesen

Evaluate Bezière curve

One of the tasks for the coming release of OpenPatrician is a better representation of the price development of wares with respect to the amount that is available. The idea is to define the curve visually and then transform the parameters of the curve into a formula that allows the computation of the price of the ware, given an available amount.
A natural choice for that is to define the curve as a Bezière curve with is very intuitive to tweak until the curve looks the way you want.

„Evaluate Bezière curve“ weiterlesen

Documentation generation with the Compiler API

Documentation of code has a tendency to become obsolete quickly. For that reason most often the only documentation is the code itself and if you are lucky some JavaDoc that is more or less up to date. For that reason I already started some time ago to generate additional documentation by doing static code analysis on my OpenPatrician project. So far this was done mainly with the Reflection API and it was sufficient to figure out what Spring beans there are and where they are used.

The next documentation task was to figure out which class posts what event type on which EventBus and which class handles the event. Or more simple what are the Event producers and what are the Event consumers and mapping them to see how the event messages flow. As the publishing of the events (in the terminology of Guava EventBus ‚post‘) happens within a method, simple reflection will not yield the desired results. Therefore I turned to the Compiler API that can be found in the tools.jar. As that API is poorly documented by JavaDoc and there are not that many examples, I decided to write this post as a means to provide another example.

„Documentation generation with the Compiler API“ weiterlesen

Serializing Java Objects

There are various ways to serialize Java Objects. This be came an issue for me in the context of the save game feature for OpenPatrician. So it was clear from the start that the output format should be XML. As The project already uses JAXB to generate some classes from XSD this seemed to be an obvious choice. Another option turned out to be XStream.
„Serializing Java Objects“ weiterlesen

Mountain Range in Gimp

Maps contain usually some mountains and are a projection from above. One way to distinguish the height level is by using colors as this is typically done by relief maps. The map that I’m creating uses color for different kinds of vegetation. Therefore there needs to be another approach. This image tutorial follows the same path as this video tutorial.

„Mountain Range in Gimp“ weiterlesen