use of org.freehep.graphics2d.VectorGraphics in project abstools by abstools.
the class ExporterImpl method getGraphics.
private VectorGraphics getGraphics() {
VectorGraphics vectorGraphics;
if (orientation == null) {
orientation = dim.getWidth() <= dim.getHeight() ? "Portrait" : "Landscape";
}
if (type.equals("gif")) {
vectorGraphics = new GIFGraphics2D(stream, dim);
} else if (type.equals("png")) {
vectorGraphics = new ImageGraphics2D(stream, dim, "png");
} else if (type.equals("bmp")) {
vectorGraphics = new ImageGraphics2D(stream, dim, "bmp");
} else if (type.equals("jpg")) {
vectorGraphics = new ImageGraphics2D(stream, dim, "jpg");
} else if (type.equals("pdf")) {
PDFGraphics2D pdf = new PDFGraphics2D(stream, dim);
Properties properties = new Properties();
properties.setProperty(PDFGraphics2D.ORIENTATION, orientation);
properties.setProperty(PDFGraphics2D.PAGE_SIZE, format);
pdf.setProperties(properties);
vectorGraphics = pdf;
} else if (type.equals("ps")) {
PSGraphics2D ps = new PSGraphics2D(stream, dim);
Properties properties = new Properties();
properties.setProperty(PSGraphics2D.ORIENTATION, orientation);
properties.setProperty(PSGraphics2D.PAGE_SIZE, format);
ps.setProperties(properties);
ps.setMultiPage(true);
vectorGraphics = ps;
} else if (type.equals("emf")) {
vectorGraphics = new EMFGraphics2D(stream, dim);
} else if (type.equals("svg")) {
vectorGraphics = new SVGGraphics2D(stream, dim);
} else if (type.equals("swf")) {
vectorGraphics = new SWFGraphics2D(stream, dim);
} else {
throw new IllegalArgumentException("Unknown type: " + type);
}
return vectorGraphics;
}
use of org.freehep.graphics2d.VectorGraphics in project mzmine2 by mzmine.
the class SwingExportUtil method writeToEMF.
/**
* Writes swing to EMF
*
* @param panel
* @param fileName
* @throws Exception
*/
public static void writeToEMF(JComponent panel, File fileName) throws IOException {
// print the panel to pdf
int width = panel.getWidth();
int height = panel.getWidth();
logger.info(() -> MessageFormat.format("Exporting panel to EMF file (width x height; {0} x {1}): {2}", width, height, fileName.getAbsolutePath()));
VectorGraphics g = new EMFGraphics2D(fileName, new Dimension(width, height));
g.startExport();
panel.print(g);
g.endExport();
}
use of org.freehep.graphics2d.VectorGraphics in project mzmine2 by mzmine.
the class ChartExportUtil method writeChartToEMF.
public static void writeChartToEMF(JFreeChart chart, int width, int height, File name) throws IOException {
try {
VectorGraphics g = new EMFGraphics2D(name, new Dimension(width, height));
g.startExport();
Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, width, height);
chart.draw((Graphics2D) g, rectangle2d);
g.endExport();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw e;
}
}
use of org.freehep.graphics2d.VectorGraphics in project polyGembler by c-zhou.
the class LocPanel method paint.
public void paint(Graphics g) {
double h = getHeight();
this.y_0 = (2.0 / 6.0) * (h - 9);
this.y_1 = (4.0 / 6.0) * (h - 9);
this.y_2 = h - 2;
g.setColor(Color.white);
// g.setColor(Color.CYAN);
g.fillRect(0, 0, getWidth(), getHeight());
VectorGraphics vg = VectorGraphics.create(g);
vg.setFont(font10);
vg.setColor(Color.BLACK);
vg.setLineWidth(.5);
if (d != null) {
for (int i1 = 0; i1 < d.length; i1++) {
double di = d[i1] * 1000 * 1000;
double i = this.geti(di);
double x_start = getXLoc(di, Constants.useLocInHap());
double x_loc = getXLoc(di, true);
vg.drawLine(x_loc, y_0, x_loc, y_1);
vg.drawLine(x_loc, y_1, x_start, y_2);
String str = String.format(formatStr, d[i1]).trim() + "mb";
vg.drawString(str, x_loc, y_0);
prev_loc = x_loc;
}
} else {
// vg.drawLine(getX(0, true)-20, (h-2)/2, getX(noSnps-1, true)+20, (h-2)/2);
for (int i = 0; i < noSnps; i++) {
double x_loc = getX(i, true);
vg.drawLine(x_loc, y_0, x_loc, y_1);
vg.drawLine(x_loc, y_1, x_coor[i], y_2);
vg.drawLine(x_loc, y_0, x_coor[i], 2);
vg.drawLine(x_coor[i] - 5, y_2, x_coor[i] + 5, y_2);
vg.drawLine(x_coor[i] - 5, 2, x_coor[i] + 5, 2);
if (i == 0 || x_loc > prev_loc + 80) {
String str = String.format(formatStr, ((double) location.get(i)) / (1000.0 * 1000.0)).trim() + "mb";
// Format.sprintf("%7i",new Number[] {location.get(i)});
vg.drawString(str, x_loc - 11 * Constants.hmmFontSize / 4, y_0);
prev_loc = x_loc;
}
}
}
}
Aggregations