How to use jlibeps?

The package to import is:

import org.sourceforge.jlibeps.epsgraphics.*;


If you want to paint a Graphics2D in an EPS file, you can do that:

FileOutputStream finalImage = new FileOutputStream(file);
EpsGraphics2D g = new EpsGraphics2D("Title", finalImage, 0, 0, 500, 500);
paint(g);
g.flush();
g.close();
finalImage.close();


Or:

FileOutputStream finalImage = new FileOutputStream(file);
EpsGraphics2D g = new EpsGraphics2D("Title", finalImage, 0, 0, 500, 500);
g.setColor(Color.RED);
g.drawLine(0,0,100,100);
g.flush();
g.close();
finalImage.close();


Or if you want to get the EPS code:

EpsGraphics2D g = new EpsGraphics2D();
g.setColor(Color.RED);
g.drawLine(0,0,100,100);
String EPSCode = g.toString();