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


Java SVGGraphics2D.setColor方法代码示例

本文整理汇总了Java中org.apache.batik.svggen.SVGGraphics2D.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java SVGGraphics2D.setColor方法的具体用法?Java SVGGraphics2D.setColor怎么用?Java SVGGraphics2D.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.batik.svggen.SVGGraphics2D的用法示例。


在下文中一共展示了SVGGraphics2D.setColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveImage

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
public void saveImage(File f, int w, int h, boolean raster) throws IOException { 
 if (raster) {
  BufferedImage im = 
	   new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
  Graphics g = im.getGraphics();
  Graphics2D g2 = (Graphics2D)g;
  g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
  mainPanel.paintComponent(g,0,0,w,h);
  ImageIO.write(im, "png", f);
  g.dispose();
 } else {
  DOMImplementation domImpl =
	   GenericDOMImplementation.getDOMImplementation();
  // Create an instance of org.w3c.dom.Document
  Document document = domImpl.createDocument(null, "svg", null);
  // Create an instance of the SVG Generator
  SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
  svgGenerator.setSVGCanvasSize(new Dimension(w,h));
  // Ask the test to render into the SVG Graphics2D implementation
  svgGenerator.setColor(Color.white);        
  svgGenerator.fillRect(0,0,w,h);
  mainPanel.paintComponent(svgGenerator,50,50,w-100,h-100);

  // Finally, stream out SVG to the standard output using UTF-8
  // character to byte encoding
  boolean useCSS = true; // we want to use CSS style attribute
  Writer out = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
  svgGenerator.stream(out, useCSS);
 }
}
 
开发者ID:seqcode,项目名称:seqcode-core,代码行数:31,代码来源:RegionPanel.java

示例2: saveImage

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
public void saveImage(File f, int w, int h, boolean raster) 
   throws IOException { 
	if(raster){
		if(transparent)
			this.setOpaque(false);
		this.setSize(new Dimension(w, h));
		repaint();
        BufferedImage im = 
            new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = im.createGraphics();
        graphics.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        this.print(graphics);
        graphics.dispose();
        ImageIO.write(im, "png", f);
	}else{
        DOMImplementation domImpl =
            GenericDOMImplementation.getDOMImplementation();
        // Create an instance of org.w3c.dom.Document
        Document document = domImpl.createDocument(null, "svg", null);
        // Create an instance of the SVG Generator
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
        svgGenerator.setSVGCanvasSize(new Dimension(w,h));
        // Ask the test to render into the SVG Graphics2D implementation
        if(!transparent){
        	svgGenerator.setColor(Color.white);        
        	svgGenerator.fillRect(0,0,w,h);
        }
        this.paintComponent(svgGenerator);

        // Finally, stream out SVG to the standard output using UTF-8
        // character to byte encoding
        boolean useCSS = true; // we want to use CSS style attribute
        FileOutputStream outStream = new FileOutputStream(f);
        Writer out = new OutputStreamWriter(outStream, "UTF-8");
        svgGenerator.stream(out, useCSS);
        outStream.flush();
        outStream.close();
	}
}
 
开发者ID:seqcode,项目名称:seqcode-core,代码行数:40,代码来源:ProfilePanel.java

示例3: saveImage

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
public void saveImage(File f, int w, int h, boolean raster) 
   throws IOException { 
	if(raster){
		if(transparent)
			this.setOpaque(false);
        BufferedImage im = 
            new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = im.createGraphics();
        graphics.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        this.print(graphics);
        graphics.dispose();
        ImageIO.write(im, "png", f);
	}else{
        DOMImplementation domImpl =
            GenericDOMImplementation.getDOMImplementation();
        // Create an instance of org.w3c.dom.Document
        Document document = domImpl.createDocument(null, "svg", null);
        // Create an instance of the SVG Generator
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
        svgGenerator.setSVGCanvasSize(new Dimension(w,h));
        // Ask the test to render into the SVG Graphics2D implementation
        if(!transparent){
        	svgGenerator.setColor(Color.white);
        	svgGenerator.fillRect(0,0,w,h);
        }
        this.paintComponent(svgGenerator);

        // Finally, stream out SVG to the standard output using UTF-8
        // character to byte encoding
        boolean useCSS = true; // we want to use CSS style attribute
        FileOutputStream outStream = new FileOutputStream(f);
        Writer out = new OutputStreamWriter(outStream, "UTF-8");
        svgGenerator.stream(out, useCSS);
        outStream.flush();
        outStream.close();
	}
}
 
开发者ID:seqcode,项目名称:seqcode-core,代码行数:38,代码来源:ProfileLinePanel.java

示例4: saveImage

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
/**
 * Save image
 * If raster is false, save a SVG, otherwise save a PNG
 * 
 */
public void saveImage(File f, int w, int h, boolean raster) 
throws IOException { 
	if (raster) {
        BufferedImage im = 
            new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics g = im.getGraphics();
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        chart.draw(g2, new Rectangle(0,0,w,h));
        ImageIO.write(im, "png", f);
    }else{
     DOMImplementation domImpl =
         GenericDOMImplementation.getDOMImplementation();
     // Create an instance of org.w3c.dom.Document
     Document document = domImpl.createDocument(null, "svg", null);
     // Create an instance of the SVG Generator
     SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
     svgGenerator.setSVGCanvasSize(new Dimension(w,h));
     // Ask the test to render into the SVG Graphics2D implementation
     svgGenerator.setColor(Color.white);        
     svgGenerator.fillRect(0,0,w,h);
     chart.draw(svgGenerator, new Rectangle(0,0,w,h));
	
     // Finally, stream out SVG to the standard output using UTF-8
     // character to byte encoding
     boolean useCSS = true; // we want to use CSS style attribute
     FileOutputStream outStream = new FileOutputStream(f);
     Writer out = new OutputStreamWriter(outStream, "UTF-8");
     svgGenerator.stream(out, useCSS);
     outStream.flush();
     outStream.close();
    }
}
 
开发者ID:seqcode,项目名称:seqcode-core,代码行数:39,代码来源:ScatterPlot.java

示例5: saveImage

import org.apache.batik.svggen.SVGGraphics2D; //导入方法依赖的package包/类
public void saveImage(File f, int w, int h, boolean raster) 
throws IOException { 

    if (raster) {
        BufferedImage im = 
            new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics g = im.getGraphics();
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        paintItem(g, 0, 0, w, h);
        ImageIO.write(im, "png", f);
    } else {
        DOMImplementation domImpl =
            GenericDOMImplementation.getDOMImplementation();
        // Create an instance of org.w3c.dom.Document
        Document document = domImpl.createDocument(null, "svg", null);
        // Create an instance of the SVG Generator
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
        svgGenerator.setSVGCanvasSize(new Dimension(w,h));
        // Ask the test to render into the SVG Graphics2D implementation
        svgGenerator.setColor(Color.white);        
        svgGenerator.fillRect(0,0,w,h);
        paintItem(svgGenerator,25,25,w-50,h-50);

        // Finally, stream out SVG to the standard output using UTF-8
        // character to byte encoding
        boolean useCSS = true; // we want to use CSS style attribute
        Writer out = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
        svgGenerator.stream(out, useCSS);
    }
}
 
开发者ID:seqcode,项目名称:seqcode-core,代码行数:32,代码来源:AbstractPaintable.java


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