The de·caff Commons provide a wild mix of open source Java classes used in various projects on this site.
Various blog posts here will also refer to these classes.
The de·caff Commons (CC for the rest of this page) are licensed under the ISC License, which readsCopyright © YEAR-YEAR Andreas M. Rammelt
The CC are pure Java, the minimal necessary Java version is now 1.8.
The CC come in 5 modules.
|caff-generics||jar||src||ant||zip / online||Helper classes for functional programming in Java 7|
|caff-common||jar||src||ant||zip / online
(incl. the above)
|Various tools, requires caff-generics above|
|caff-common-swing||jar||src||ant||zip / online
(incl. both above)
|GUI related classes, requires both above modules.|
|support-wmf||jar||src||ant||zip / online||Excerpt from Apache Batik to draw WMF, independent of other modules. Not a part of the CC, but included here to allow to download possible changes as the license requires.|
|vector-icons||—||—||—||—||Not yet finished support for hi-res icons. included in git access.|
You can also clone the complete CC git repository (including 3rd party code) from
The caff-generics module (see online javadoc) provides various helper classes for functional programming. With Java 1.8 it is no longer as useful as before, so it’s mostly included because it is still in use (at least by de·caff software).
Especially this module (online javadoc) contains a wide variety of different functionality.
A bit of this functionality already has made it into blog postings here on de·caff: * Enum Bit Masks: a type-safe bitflag implementation. * Give Java Applications More Memory: give your application more memory without user interaction.
This module (online javadoc) mainly provides helpers for automatic settings management. This allows to define a few simple constants, and manage preferences and user editing automatically. If you happen do know my de·caff Viewer have a look at its settings dialog. The complete dialog is automatically constructed from some simple constants which define the available settings and their grouping. E.g. here is all what is behind the quite complex View tab./** Internal preference property for the background color in the views. */ private static final SwingColorPreferenceProperty PP_BG_COLOR = new SwingColorPreferenceProperty(ViewSettingsProvider.PROPERTY_BACKGROUND_COLOR, "ppBgColor", Utility.getColorParameter("dxfviewer.bgcolor", DEFAULT_BACKGROUND_COLOR)); /** Internal preference group for view color settings. */ private static final EditablePreferenceGroup PG_VIEW_COLORS = new EditablePreferenceGroup("pgViewColors", false, PP_BG_COLOR); /** Internal preference property for the coordinate system on/off state. */ private static final SwingBooleanPreferenceProperty PP_CS_ON = new SwingBooleanPreferenceProperty(ViewSettingsProvider.PROPERTY_DISPLAYING_COORDINATES_SYSTEM, "ppCsOn", true); /** Internal constant for south west placement of coordinates system. */ private static final IntegerEnumValue ENUM_CS_SOUTH_WEST = new IntegerEnumValue("enCsSW", ViewConstants.COORDS_SW); /** Internal constant for south east placement of coordinates system. */ private static final IntegerEnumValue ENUM_CS_SOUTH_EAST = new IntegerEnumValue("enCsSE", ViewConstants.COORDS_SE); /** Internal constant for north east placement of coordinates system. */ private static final IntegerEnumValue ENUM_CS_NORTH_EAST = new IntegerEnumValue("enCsNE", ViewConstants.COORDS_NE); /** Internal constant for north west placement of coordinates system. */ private static final IntegerEnumValue ENUM_CS_NORTH_WEST = new IntegerEnumValue("enCsNW", ViewConstants.COORDS_NW); /** Internal preference property for coordinates system placement. */ private static final SwingEnumPreferenceProperty
Above I use the convention that
PG_ is used for groups of preferences, and
PP_ is used for preference
Starting from the end you see the constant
PREFERENCES_VIEW which groups the three settings for
color, coordinate system and miscellaneous settings (which is exactly what you find in the tab as bordered panels).
So if you look for the last preference group
you’ll just find another constant grouping 6 preference settings. E.g. the last one of these (
is a boolean property which is either
false. The strings starting with
From the above constants the tab in the dialog is automatically created, indeed all tabs are again in another group from which the whole dialog is made in a single call. Loading the preferences and storing them is just one call to this root group each, and listeners can connect to the constants or just read their value when required. Adding another preference setting now just means adding an appropriate constant, its i18n resources and adding this constant to the group where it belongs.
Here’s the view tab as created from the above code:
This module is not part of the CC. It is the WMF related code extracted from Apache Batik, and included here to fulfill the license.
Caveat: currently not in a state which others can easily use.
Support for vector icons allowing easier adaption to different screen resolutions.
Running under the name of VIC this is used in the de·caff Viewer to allow changing the resolution of the GUI. Basically a kind of stripped-down SVG it provides a way to define vector graphic icons. I dropped SVG because nowadays decent SVG libraries are larger than my viewer (which is already a really complex program). VIC basically uses a simple file representation of Java Shapes and Paints. Runtime representation of VIC comes with a footprint of some 80kB for some 20 classes.
Some useful classes (like conversion from SVG to VIC) are not included. If you are really interested drop me a note and I’ll see what I can do.