本文整理匯總了Java中org.apache.batik.svggen.SVGGraphics2D.fillRect方法的典型用法代碼示例。如果您正苦於以下問題:Java SVGGraphics2D.fillRect方法的具體用法?Java SVGGraphics2D.fillRect怎麽用?Java SVGGraphics2D.fillRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.batik.svggen.SVGGraphics2D
的用法示例。
在下文中一共展示了SVGGraphics2D.fillRect方法的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);
}
}