當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。