本文整理汇总了Java中net.sf.epsgraphics.EpsGraphics类的典型用法代码示例。如果您正苦于以下问题:Java EpsGraphics类的具体用法?Java EpsGraphics怎么用?Java EpsGraphics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EpsGraphics类属于net.sf.epsgraphics包,在下文中一共展示了EpsGraphics类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderGraph
import net.sf.epsgraphics.EpsGraphics; //导入依赖的package包/类
@Override
public void renderGraph(JGraph<?> graph, File file) throws PortException {
// Get graph bounds. If not available, do nothing (probably empty graph)
Rectangle2D bounds = graph.getGraphBounds();
if (bounds == null) {
return;
}
try (FileOutputStream fos = new FileOutputStream(file);) {
EpsGraphics g2d = new EpsGraphics(graph.getModel()
.getName(), fos, 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight(),
ColorMode.COLOR_RGB);
// Render
toGraphics(graph, g2d);
// Cleanup
g2d.close();
} catch (IOException e) {
throw new PortException(e);
}
}
示例2: exportToEPS
import net.sf.epsgraphics.EpsGraphics; //导入依赖的package包/类
public static void exportToEPS(File file, int width, int height, JFreeChart chart) throws GraphException, IOException
{
FileOutputStream fileOutputStream = new FileOutputStream(file);
EpsGraphics g2d = new EpsGraphics(chart.getTitle().getText(), fileOutputStream, 0, 0, width, height, ColorMode.COLOR_RGB);
// Don't export fonts as vectors, no hope of getting same font as publication.
// g2d.setAccurateTextMode(false); // Does not rotate y-axis label.
chart.draw(g2d, new Rectangle(width, height));
g2d.close();
g2d.dispose();
}
示例3: close
import net.sf.epsgraphics.EpsGraphics; //导入依赖的package包/类
public void close() throws IOException {
if (figureFormat.equals(Constant.PNG)) {
// png output
File outputPNG = new File(figureName + ".png");
ImageIO.write(pngImage, "png", outputPNG);
} else if (figureFormat.equals(Constant.EPS)) {
((EpsGraphics) graphWriter).close();
epsImage.close();
}
graphWriter.dispose();
bedWriter.close();
}
示例4: close
import net.sf.epsgraphics.EpsGraphics; //导入依赖的package包/类
public void close() throws IOException {
if (figureFormat.equals(PNG)) {
// png output
File outputPNG = new File(figureName.endsWith(".png") ? figureName : figureName + "." + PNG);
ImageIO.write(pngImage, PNG, outputPNG);
} else if (figureFormat.equals(EPS)) {
((EpsGraphics) graphWriter).close();
epsImage.close();
}
graphWriter.dispose();
}
示例5: exportToEPS
import net.sf.epsgraphics.EpsGraphics; //导入依赖的package包/类
/**
* Exports the current graph to EPS.
*
* @param file the eps file to export to.
* @throws IOException if IO goes wrong.
*/
public void exportToEPS(File file) throws IOException {
EpsGraphics dummy = new EpsGraphics("Title", new ByteArrayOutputStream(),
0, 0, 1, 1, ColorMode.BLACK_AND_WHITE);
NLPInstance filtered = filterInstance();
Dimension dim = renderer.render(filtered, dummy);
EpsGraphics g = new EpsGraphics("Title", new FileOutputStream(file), 0, 0,
(int) dim.getWidth() + 2, (int) dim.getHeight(), ColorMode.COLOR_RGB);
renderer.render(filtered, g);
g.flush();
g.close();
}
示例6: export
import net.sf.epsgraphics.EpsGraphics; //导入依赖的package包/类
/**
* Export jfreechart to image format. File must have an extension like jpg,
* png, pdf, svg or eps. Otherwise export will fail.
*
* @param file
* Destination The file
* @param chart
* JFreechart the chart object
*
* @param width
* The width of the image
* @param height
* The height of the image
*
* @throws Exception
* An exception
*/
public static void export(File file, JFreeChart chart, int width, int height) throws Exception {
FileOutputStream out = new FileOutputStream(file);
Graphics2D g = new EpsGraphics(file.getName(), out, 0, 0, width, height, ColorMode.COLOR_RGB);
chart.draw(g, new Rectangle2D.Double(0, 0, width, height));
out.write(g.toString().getBytes());
out.close();
}