当前位置: 首页>>代码示例>>Java>>正文


Java EPSDocumentGraphics2D类代码示例

本文整理汇总了Java中org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D的典型用法代码示例。如果您正苦于以下问题:Java EPSDocumentGraphics2D类的具体用法?Java EPSDocumentGraphics2D怎么用?Java EPSDocumentGraphics2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EPSDocumentGraphics2D类属于org.apache.xmlgraphics.java2d.ps包,在下文中一共展示了EPSDocumentGraphics2D类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
  try {
    OutputStream out = new FileOutputStream("example_eps_simple.eps");
    EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
    g2d.setGraphicContext(new GraphicContext());
    g2d.setCustomTextHandler(new NativeTextHandler(g2d, null));
    g2d.setupDocument(out, 200, 100);
    g2d.setFont(new Font("Helvetica", Font.PLAIN, 12));
    g2d.drawString("Hi there Helvetica", 50, 50);
    g2d.finish();
    out.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:19,代码来源:ExampleEPSSimple.java

示例2: main

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
  try {
    String configFile = "examples/fop-eps.xconf";
    DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
    Configuration c = cfgBuilder.buildFromFile(configFile);

    FontInfo fontInfo = PDFDocumentGraphics2DConfigurator.createFontInfo(c, false);

    OutputStream out = new FileOutputStream("example_eps.eps");
    EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
    g2d.setGraphicContext(new GraphicContext());
    g2d.setCustomTextHandler(new NativeTextHandler(g2d, fontInfo));
    g2d.setupDocument(out, 200, 100);
    g2d.setFont(new Font("Arial", Font.PLAIN, 12));
    g2d.drawString("Hi there Arial", 50, 50);
    g2d.finish();
    out.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:25,代码来源:ExampleEPS.java

示例3: run

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
public void run() {

	try {
	    
	    if (fileType.equals(FileType.EMF)) {
		OutputStream out2 = new java.io.FileOutputStream(file);
		EMFGraphics2D g2d2 = new EMFGraphics2D(out2,new Dimension(width,height));
		g2d2.startExport();
		chart.draw(g2d2,new Rectangle(width,height));
		g2d2.endExport();
		g2d2.closeStream();
	    }
	    
	    if (fileType.equals(FileType.EPS)) {
		OutputStream out = new java.io.FileOutputStream(file);
		EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
		g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
		g2d.setupDocument(out,width, height);
		chart.draw(g2d,new Rectangle(width,height));
		g2d.finish();
		out.flush();
		out.close();
	    }
	} catch (IOException e) {
	    MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Unable to save image.");
	    e.printStackTrace();
	}
    }
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:29,代码来源:SaveImage.java

示例4: actionPerformed

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
/**
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
    public void actionPerformed(final ActionEvent e) {
      // clear file filters (uncool API)
      FileFilter[] farr = this.m_filechooser.getChoosableFileFilters();
      for (int i = 0; i < farr.length; i++) {
        this.m_filechooser.removeChoosableFileFilter(farr[i]);
      }

      String extension = "eps";
      this.m_filechooser
          .addChoosableFileFilter(new FileFilterExtensions(new String[] {extension }));
      int ret = this.m_filechooser.showSaveDialog(this.m_chart);
      if (ret == JFileChooser.APPROVE_OPTION) {
        File file = new File(this.m_filechooser.getSelectedFile().getAbsolutePath() + "."
            + extension);
        // get the encoding
        try {
          FileOutputStream outStream = new FileOutputStream(file);
          
          EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(true);
          g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
          g2d.setupDocument(outStream, this.m_chart.getWidth(),this.m_chart.getHeight()); 

//          org.sourceforge.jlibeps.epsgraphics.EpsGraphics2D g = new org.sourceforge.jlibeps.epsgraphics.EpsGraphics2D(
//              "Title", outStream, 0, 0, this.m_chart.getWidth(), this.m_chart.getHeight());
          //g.scale(0.24, 0.24);

          
          this.m_chart.paint(g2d);
//          g.flush();
//          g.close();
          outStream.close();
        } catch (IOException e1) {
          e1.printStackTrace();
        }
      }

    }
 
开发者ID:lcm-proj,项目名称:lcm,代码行数:41,代码来源:Chart2DActionSaveEpsSingletonApacheFop.java

示例5: exportToImageFile

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
public static void exportToImageFile(ChartViewer chartNode, File file, ImgFileType fileType) {

    final JFreeChart chart = chartNode.getChart();
    final int width = (int) chartNode.getWidth();
    final int height = (int) chartNode.getHeight();

    try {

      switch (fileType) {

        case JPG:
          ExportUtils.writeAsJPEG(chart, width, height, file);
          break;

        case PNG:
          ExportUtils.writeAsPNG(chart, width, height, file);
          break;

        case SVG:
          setDrawSeriesLineAsPath(chart, true);
          ExportUtils.writeAsSVG(chart, width, height, file);
          setDrawSeriesLineAsPath(chart, false);
          break;

        case PDF:
          setDrawSeriesLineAsPath(chart, true);
          ExportUtils.writeAsPDF(chart, width, height, file);
          setDrawSeriesLineAsPath(chart, false);
          break;

        case EMF:
          FileOutputStream out2 = new FileOutputStream(file);
          setDrawSeriesLineAsPath(chart, true);
          EMFGraphics2D g2d2 = new EMFGraphics2D(out2, new Dimension(width, height));
          g2d2.startExport();
          chart.draw(g2d2, new Rectangle(width, height));
          g2d2.endExport();
          setDrawSeriesLineAsPath(chart, false);
          break;

        case EPS:
          FileOutputStream out = new FileOutputStream(file);
          setDrawSeriesLineAsPath(chart, true);
          EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
          g2d.setGraphicContext(new GraphicContext());
          g2d.setupDocument(out, width, height);
          chart.draw(g2d, new Rectangle(width, height));
          g2d.finish();
          setDrawSeriesLineAsPath(chart, false);
          out.close();
          break;

      }

    } catch (IOException e) {
      MZmineGUI.displayMessage("Unable to save image: " + e.getMessage());
      e.printStackTrace();
    }
  }
 
开发者ID:mzmine,项目名称:mzmine3,代码行数:60,代码来源:JFreeChartUtils.java

示例6: toEPSGraphicFile

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
public void toEPSGraphicFile(File file, int width, int height) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);

    // otherwise toolbar appears
    plotToolBar.setVisible(false);

    EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
    g2d.setGraphicContext(new GraphicContext());
    g2d.setupDocument(fos, width, height);


    Image image = createImage(getWidth(), getHeight());
    paint(image.getGraphics());
    image = new ImageIcon(image).getImage();

    g2d.drawImage(image, 0, 0, Color.WHITE, null);

    g2d.finish();
    // make it reappear
    plotToolBar.setVisible(true);


}
 
开发者ID:scalalab,项目名称:scalalab,代码行数:24,代码来源:PlotPanel.java

示例7: print

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
/**
 * Prints the chart on a single page.
 *
 * @param g  the graphics context.
 * @param pf  the page format to use.
 * @param pageIndex  the index of the page. If not <code>0</code>, nothing 
 *                   gets print.
 *
 * @return The result of printing.
 */
public int print(Graphics g, PageFormat pf, int pageIndex) {

   if (pageIndex != 0) {
      return NO_SUCH_PAGE;
   }
   /** this works but the curve is made of little pieces */
   Graphics2D g2 = (Graphics2D) g;
   double x = pf.getImageableX();
   double y = pf.getImageableY();
   double w = pf.getImageableWidth();
   double h = pf.getImageableHeight();
   this.chart.draw(g2, new Rectangle2D.Double(x, y, w, h), this.anchor,
           null);
   
   if (printToPrinter)  return PAGE_EXISTS;
   // The rest should be moved up to the export eps action listener so it's not done per page'
   // Show export dialog
   JFileChooser fileChooser = new JFileChooser();
   ExtensionFileFilter filter = new ExtensionFileFilter(
           localizationResources.getString("PostScript_Files"), ".eps");
   fileChooser.addChoosableFileFilter(filter);
   String filename="";
   int option = fileChooser.showSaveDialog(this);
   if (option == JFileChooser.APPROVE_OPTION) {
      filename = fileChooser.getSelectedFile().getPath();
      if (isEnforceFileExtensions()) {
         if (!filename.endsWith(".eps") || !filename.endsWith(".ps")) {
            filename = filename + ".eps";
         }
      } else
         return NO_SUCH_PAGE;
   }
    
   try {
      OutputStream out = new java.io.FileOutputStream(new File(filename));
      out = new java.io.BufferedOutputStream(out);

      //Instantiate the EPSDocumentGraphics2D instance
      EPSDocumentGraphics2D g2dps = new EPSDocumentGraphics2D(false);
      g2dps.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
      //Set up the document size
      g2dps.setupDocument(out, (int)w, (int)h+200);

      //Paint a bounding box
      g2dps.drawRect((int)x, (int)y, (int)w, (int)h);
      this.chart.draw(g2dps, new Rectangle2D.Double(x, y, w, h), this.anchor,
              null);


      //A few rectangles rotated and with different color

      //Cleanup
      g2dps.finish();
      out.flush();
      out.close();
   }
   catch(java.io.IOException e){
      return NO_SUCH_PAGE;
   }
   return PAGE_EXISTS;
   
}
 
开发者ID:opensim-org,项目名称:opensim-gui,代码行数:73,代码来源:ChartPanel.java

示例8: createDocumentGraphics2D

import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; //导入依赖的package包/类
/** {@inheritDoc} */
protected AbstractPSDocumentGraphics2D createDocumentGraphics2D() {
    return new EPSDocumentGraphics2D(false);
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:5,代码来源:EPSTranscoder.java


注:本文中的org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。