本文整理汇总了Java中de.erichseifert.vectorgraphics2d.PDFGraphics2D类的典型用法代码示例。如果您正苦于以下问题:Java PDFGraphics2D类的具体用法?Java PDFGraphics2D怎么用?Java PDFGraphics2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PDFGraphics2D类属于de.erichseifert.vectorgraphics2d包,在下文中一共展示了PDFGraphics2D类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: saveGraph
import de.erichseifert.vectorgraphics2d.PDFGraphics2D; //导入依赖的package包/类
/**
* Save the chart as pdf.
*
* @param chart
* chart that should be saved.
* @param fileName
* file name under which the chart should be saved.
* @throws IOException
* i/o exception
*/
public static void saveGraph(final Chart chart, final String fileName)
throws IOException {
final int width = (int) PageSize.A4.getWidth();
final int height = (int) PageSize.A4.getHeight();
VectorGraphics2D g = new PDFGraphics2D(0.0, 0.0, width, height);
chart.paint(g, width, height);
// Write the vector graphic output to a file
FileOutputStream file = new FileOutputStream(fileName + ".pdf");
try {
file.write(g.getBytes());
} finally {
file.close();
}
}
开发者ID:adamIqbal,项目名称:Health,代码行数:29,代码来源:FreqBar.java
示例2: exportAsPDF
import de.erichseifert.vectorgraphics2d.PDFGraphics2D; //导入依赖的package包/类
private void exportAsPDF(File file, MainWindow mainWindow, HiC hic, final JPanel hiCPanel,
final int w, final int h) {
try {
PDFGraphics2D g = new PDFGraphics2D(0, 0, w, h);
plotDataOnGraphics(g, mainWindow, w, h, hic, hiCPanel);
writeGraphicsToFile(g, file);
} catch (Exception e) {
System.err.println("Export PDF failed " + e);
}
}
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:11,代码来源:SaveImageDialog.java
示例3: toPdf
import de.erichseifert.vectorgraphics2d.PDFGraphics2D; //导入依赖的package包/类
String toPdf(double width, double height, double margin) {
Graphics2D g2 = new PDFGraphics2D(0, 0,
margin + width + margin,
margin + height + margin);
draw(AWTDrawVisitor.forVectorGraphics(g2),
new Rectangle2D.Double(margin, margin, width, height));
g2.dispose();
return g2.toString();
}
开发者ID:johnmay,项目名称:efficient-bits,代码行数:10,代码来源:AbstractDepiction.java
示例4: serialize
import de.erichseifert.vectorgraphics2d.PDFGraphics2D; //导入依赖的package包/类
@Override
public void serialize(File f, ProcessModel m) throws Exception {
Graphics2D g2;
// Create new ProcessEditor
ProcessEditor editor = new ProcessEditor(m);
editor.setEditable(false);
// Set preferred size
editor.setSize(editor.getPreferredSize().width,
editor.getPreferredSize().height);
/** SOURCE CODE FOR VECTORGRAPHICS2D FOLLOWS */
PDFGraphics2D pdfOutput = new PDFGraphics2D(
editor.getBounds().x,
editor.getBounds().y,
editor.getBounds().width,
editor.getBounds().height);
pdfOutput.setFontRendering(VectorGraphics2D.FontRendering.VECTORS);
editor.paint(pdfOutput);
byte[] output = pdfOutput.getBytes();
FileOutputStream fo = new FileOutputStream(f);
fo.write(output);
fo.close();
/** SOURCE CODE FOR ITEXT FOLLOWS
Document document = new Document(new Rectangle(
editor.getBounds().x,
editor.getBounds().y,
editor.getBounds().width,
editor.getBounds().height
));
PdfWriter writer;
writer = PdfWriter.getInstance(document, new FileOutputStream(f));
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(editor.getSize().width, editor.getSize().height);
g2 = tp.createGraphicsShapes(editor.getSize().width, editor.getSize().height);
editor.paintComponent(g2);
g2.dispose();
cb.addTemplate(tp, 0, 0);
document.close();
*/
}
开发者ID:frapu78,项目名称:processeditor,代码行数:54,代码来源:PDFExporter.java
注:本文中的de.erichseifert.vectorgraphics2d.PDFGraphics2D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论