本文整理汇总了Java中org.apache.batik.svggen.SVGGraphics2DIOException类的典型用法代码示例。如果您正苦于以下问题:Java SVGGraphics2DIOException类的具体用法?Java SVGGraphics2DIOException怎么用?Java SVGGraphics2DIOException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SVGGraphics2DIOException类属于org.apache.batik.svggen包,在下文中一共展示了SVGGraphics2DIOException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSVG
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
* Create a SVG image. The image handler will write all images files to
* "res/images".
*
* @param p the drawable component.
* @param outStream the the output stream.
* @throws UnsupportedEncodingException error on unsupported encoding.
* @throws SVGGraphics2DIOException error on error to conversion.
*/
private void generateSVG(Drawable p, OutputStream outStream) throws UnsupportedEncodingException, SVGGraphics2DIOException {
DOMImplementation domImpl
= GenericDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document myFactory = domImpl.createDocument(svgNS, "svg", null);
SVGGeneratorContext ctx
= SVGGeneratorContext.createDefault(myFactory);
GenericImageHandler ihandler = new CachedImageHandlerPNGEncoder("res/images", null);
ctx.setGenericImageHandler(ihandler);
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
TurtleState ts = new TurtleState();
p.draw(svgGenerator, ts);
// Create the SVG DOM tree.
Writer out = new OutputStreamWriter(outStream, "UTF-8");
svgGenerator.stream(out, true);
}
示例2: Dimension
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
public void 字組成svg(String 組字式, OutputStream 輸出檔案)
throws UnsupportedEncodingException, SVGGraphics2DIOException
{
DOMImplementation domImpl = GenericDOMImplementation
.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document document = domImpl.createDocument(svgNS, "svg", null);
boolean useCSS = true; // we want to use CSS style
// attributes
// Create an instance of the SVG Generator.
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
svgGenerator.setSVGCanvasSize(new Dimension(字型大細, 字型大細));
組字(組字式, svgGenerator);
OutputStreamWriter svgOutput = new java.io.OutputStreamWriter(輸出檔案,
"UTF-8");
svgGenerator.stream(svgOutput, useCSS);
return;
}
示例3: generateGIF
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
* Create an animated GIF.
*
* @param p the drawable component.
* @param canvas the canvas.
* @param filename the file to write to.
* @throws UnsupportedEncodingException error on unsupported encoding.
* @throws SVGGraphics2DIOException error on error to conversion.
* @throws IOException error writing to file.
*/
private void generateGIF(final Drawable p, final BufferedImageProvider canvas, String filename) throws UnsupportedEncodingException, SVGGraphics2DIOException, IOException {
final ImageOutputStream output = new FileImageOutputStream(new File(filename));
final GifSequenceWriter writer = new GifSequenceWriter(output, canvas.getBufferedImage().getType(), 1, true);
final BufferedImage image = canvas.getBufferedImage();
final Graphics2D g2d = image.createGraphics();
DrawListener dl = (Drawable sender) -> {
try {
writer.writeToSequence(image);
} catch (IOException ex) {
}
};
p.addListener(dl);
TurtleState ts = new TurtleState();
ts.width = image.getWidth();
ts.height = image.getHeight();
p.draw(g2d, ts);
writer.close();
p.removeListener(dl);
org.tros.utils.logging.Logging.getLogFactory().getLogger(LogoMenuBar.class).info("{0} animation is complete!", filename);
JOptionPane.showMessageDialog(parent, MessageFormat.format("{0} animation is complete!", filename), "Animated GIF Sequence Complete", JOptionPane.INFORMATION_MESSAGE);
}
示例4: outputToSVG
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
*
* @param file
*/
public void outputToSVG(File file) {
// Get a DOMImplementation.
DOMImplementation domImpl
= GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document document = domImpl.createDocument(svgNS, "svg", null);
// Create an instance of the SVG Generator.
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
// Ask the test to render into the SVG Graphics2D implementation.
paint(svgGenerator);
// Finally, stream out SVG to the standard output using
// UTF-8 encoding.
boolean useCSS = true; // we want to use CSS style attributes
Writer out = null;
try {
out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
} catch (FileNotFoundException fileNotFoundException) {
} catch (UnsupportedEncodingException unsupportedEncodingException) {
}
try {
svgGenerator.stream(out, useCSS);
} catch (SVGGraphics2DIOException sVGGraphics2DIOException) {
}
}
示例5: outputToSVG
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
*
* @param file
*/
public void outputToSVG(File file) {
// Get a DOMImplementation.
DOMImplementation domImpl
= GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document document = domImpl.createDocument(svgNS, "svg", null);
// Create an instance of the SVG Generator.
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
// Ask the test to render into the SVG Graphics2D implementation.
paint(svgGenerator, false);
// Finally, stream out SVG to the standard output using
// UTF-8 encoding.
boolean useCSS = true; // we want to use CSS style attributes
Writer out = null;
try {
out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
} catch (FileNotFoundException | UnsupportedEncodingException fileNotFoundException) {
}
try {
svgGenerator.stream(out, useCSS);
} catch (SVGGraphics2DIOException sVGGraphics2DIOException) {
System.out.println(sVGGraphics2DIOException.getMessage());
}
// aug 2013
// read svg file back in to add clip size to comments
}
示例6: outputToSVG
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
*
* @param file
*/
public void outputToSVG(File file) {
// Get a DOMImplementation.
DOMImplementation domImpl
= GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document document = domImpl.createDocument(svgNS, "svg", null);
// Create an instance of the SVG Generator.
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
// Ask the test to render into the SVG Graphics2D implementation.
paint(svgGenerator);
// Finally, stream out SVG to the standard output using
// UTF-8 encoding.
boolean useCSS = true; // we want to use CSS style attributes
Writer out = null;
try {
out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
} catch (FileNotFoundException | UnsupportedEncodingException fileNotFoundException) {
}
try {
svgGenerator.stream(out, useCSS);
} catch (SVGGraphics2DIOException sVGGraphics2DIOException) {
}
svgGenerator.dispose();
}
示例7: export
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
public void export(JComponent component, File file) {
if (component == null || file == null)
throw new IllegalArgumentException();
String fileName = file.getAbsolutePath();
if (!fileName.endsWith(".svg"))
fileName += ".svg";
// Get a DOMImplementation.
DOMImplementation domImpl = GenericDOMImplementation
.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document doc = domImpl.createDocument(svgNS, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
ctx.setComment("Generated by MuLaViTo with Batik SVG");
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
// Prepare export: Exchange background color.
Color c = component.getBackground();
component.setBackground(Color.WHITE);
component.paint(svgGenerator);
component.setBackground(c);
// Modify export.
svgGenerator.setSVGCanvasSize(component.getSize());
// Export.
try {
svgGenerator.stream(fileName);
} catch (SVGGraphics2DIOException e) {
e.printStackTrace();
}
}
示例8: export
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
public void export(JComponent component, File file) {
if (component == null || file == null)
throw new IllegalArgumentException();
String fileName = file.getAbsolutePath();
if (!fileName.endsWith(".svg"))
fileName += ".svg";
// Get a DOMImplementation.
DOMImplementation domImpl = GenericDOMImplementation
.getDOMImplementation();
// Create an instance of org.w3c.dom.Document.
String svgNS = "http://www.w3.org/2000/svg";
Document doc = domImpl.createDocument(svgNS, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
ctx.setComment("Generated by MuLaViTo with Batik SVG");
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
// Prepare export: Exchange background color.
Color c = component.getBackground();
component.setBackground(Color.WHITE);
component.paint(svgGenerator);
component.setBackground(c);
// Modify export.
svgGenerator.setSVGCanvasSize(component.getSize());
// Export.
try {
svgGenerator.stream(fileName);
} catch (SVGGraphics2DIOException e) {
e.printStackTrace();
}
}
示例9: convert
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
* Converts {@code RandomSignature} to {@code Signature}.
* @param randomSignature random signature
* @return {@code Signature} object
*/
private Signature convert(RandomSignature randomSignature) {
Signature signature = new Signature();
/* Birth date */
Date tmpBirthDate = randomSignature.getPerson().dateOfBirth().toDate();
LocalDate birthDate = tmpBirthDate
.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
/* Address */
Address adr = randomSignature.getPerson().getAddress();
String address = adr.streetNumber() + ", " + adr.street() + ", "
+ adr.getPostalCode() + ", " + adr.getCity();
/* Signature date */
// TODO: fix signature date
// Date tmpSignatureDate = randomSignature.getSignatureDate().toDate();
// LocalDate signatureDate = tmpSignatureDate
// .toInstant()
// .atZone(ZoneId.systemDefault())
// .toLocalDate();
signature.setFirstName(randomSignature.getPerson().firstName());
signature.setLastName(randomSignature.getPerson().lastName());
signature.setBirthDate(birthDate);
signature.setAddress(address);
signature.setIdCardNumber(randomSignature.getPerson().nationalIdentityCardNumber());
// TODO: set sign
Document document = domImpl.createDocument(
BatikConfig.SVG_NAMESPACE_URI, "svg", null);
SVGGraphics2D graphics = new SVGGraphics2D(document);
graphics.draw(randomSignature.getSign());
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
String xml = "";
try {
graphics.stream(writer);
xml = new String(out.toByteArray());
} catch (SVGGraphics2DIOException e) {
e.printStackTrace();
}
SignSvg sign = new SignSvg();
sign.setData(xml);
signature.setSign(sign);
return signature;
}
示例10: write
import org.apache.batik.svggen.SVGGraphics2DIOException; //导入依赖的package包/类
/**
* @param out
* @throws SVGGraphics2DIOException
*/
public void write(Writer out) throws SVGGraphics2DIOException {
this.svgGen.stream(out, true);
}