I have tons of files laying around, mostly of the manually named in a iffy. Naturally this results in some misspellings. If you want to use the file name as an input for further automated processing, like categorizing of images, this greatly diminishes the value of your collection. Therefore I looked into methods of adaptive correction. I choose an adaptive approach because I do not want to use a prefabricated dictionary, where certain words might be missing or in my case, the use of different languages makes this approach useless. Of course these techniques are not limited to file names but can also be applied to a text.
„String comparison in Java“ weiterlesen
Schlagwort: Java
Access resources in a jar
Normally you would not even have to bother with this; imagine you have an application that uses a FilenameFilter to retrieve some resource from within your project. Say you want to load all image files in a specific location that conform to „/images/imagePrefix*_imageSuffix.png“. To create a FilenameFilter to retrieve a list of all file names that conform to that pattern is not that difficult. So you have an application that runs happily ever after … until you create a jar file from your project.
Game development in Java
Does this image seem familiar to you? If it does you are right, it is Sid Meier’s Railroad Tycoon from 1990. Or isn’t it? In fact it is not. Currently I am trying to recode this game in Java.
„Game development in Java“ weiterlesen
Custom Look&Feel in Java
The first question to why you feel you need to create your own Look and feel (L&F). I guess you did that and came up with a good enough reason and now you are questioning yourself how to go about to achieve this. This articles gives some pointers that I came across while I implemented the custom Look and Feel for OpenPatrician. These are especially points that I found nowhere on the web mentioned and I had to figure it out the hard way.
„Custom Look&Feel in Java“ weiterlesen
Creating custom Font in Java
Creating a custom font from a TrueTypeFont file in Java is not that hard. However there are some pitfalls:
- The font size in in pt (Points) where a point is 1/72 of an inch, that is for a normal person about 3.5mm.
- The created Font has an initial size of 1pt
- The font size is passed as Float but rounded to the nearest Integer
- Passing an Integer for the font size does not work (results in unchanged font size)
public Font createDefaultFont(int size)throws FontFormatException, IOException{ Font font = Font.createFont( Font.TRUETYPE_FONT, getClass().getResourceAsStream( "/"+defaultFont) ); return font.deriveFont((float)size); }
Here defaultFont
is the filename of the TrueType Font.