本文整理汇总了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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}