Category: ‘Java’

Simple Bayesian Network Inference Using Netica and JavaBayes

Jun 07 2012

If you have ever needed to work with Bayesian networks and conditional probabilities, you may have searched around for some libraries you can use. This article describes how to use two libraries with Java API support – Netica and JavaBayes – to set up a simple Bayesian network and calculate inferences. Netica is a commercial product with support for multiple […]

Vector Graphics Processing in Java

Aug 02 2011

Most common computer images are stored as arrays of pixel data or raster graphics. Formats such as PNG, and JPEG are classic examples of this. Vector Graphics are stored as operations that are instead “code” for drawing the image on the fly. In this article we will explore using a few different open source libraries to convertEMF, Postscript […]

Highlight text using Lucene

Mar 06 2011

The following code illustrates how to use the Lucene highlighter to highlight text in any String. import; import; import; import; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.queryParser.QueryParser; import; import; import; import org.apache.lucene.util.Version; public class LuceneHighlighter { public static String highlight(String pText, String pQuery) throws Exception { Analyzer analyzer = […]

Scale an Image in Java

Mar 06 2011

Java has a rich Image manipulation layer. The following code shows how you can scale an input BufferedImage. import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import; import; import; import javax.imageio.ImageIO; public class ImageUtil { public static BufferedImage scale(BufferedImage pImage, int pWidth, int pHeight) { int type = pImage.getType() == 0 ? […]