
public class SVGPlot extends Object
| Modifier and Type | Class and Description | 
|---|---|
| protected class  | SVGPlot.CloneNoExportClass to skip nodes during cloning that have the "noexport" attribute set. | 
| Modifier and Type | Field and Description | 
|---|---|
| private CSSClassManager | cssmanCSS class manager | 
| static double | DEFAULT_QUALITYDefault JPEG quality setting | 
| private Element | defsDefinitions element of the document. | 
| private boolean | disableInteractionsFlag whether Batik interactions should be disabled. | 
| private org.w3c.dom.svg.SVGDocument | documentSVG document we plot to. | 
| static String | NO_EXPORT_ATTRIBUTEAttribute to block export of element. | 
| private HashMap<String,WeakReference<Element>> | objWithIdManage objects with an id. | 
| private Element | rootRoot element of the document. | 
| private UpdateRunner | runnerRegisters changes of this SVGPlot. | 
| private Element | stylePrimary style information | 
| Constructor and Description | 
|---|
| SVGPlot()Create a new plotting document. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addCSSClassOrLogError(CSSClass cls)Convenience method to add a CSS class or log an error. | 
| protected org.w3c.dom.svg.SVGDocument | cloneDocument()Clone the SVGPlot document for transcoding. | 
| void | dispose()Clean up the plot. | 
| void | dumpDebugFile()Dump the SVG plot to a debug file. | 
| org.w3c.dom.svg.SVGPoint | elementCoordinatesFromEvent(Element tag,
                           Event evt)Convert screen coordinates to element coordinates. | 
| protected Collection<String> | getAllIds()Get all used DOM Ids in this plot. | 
| CSSClassManager | getCSSClassManager()Get the plots CSS class manager. | 
| Element | getDefs()Getter for definitions section | 
| boolean | getDisableInteractions()Get Batik disable default interactions flag. | 
| org.w3c.dom.svg.SVGDocument | getDocument()Retrieve the SVG document. | 
| Element | getIdElement(String id)Get an element by its id. | 
| Element | getRoot()Getter for root element. | 
| Element | getStyle()Deprecated. 
 Contents will be overwritten by CSS class manager! | 
| static boolean | hasFOPInstalled()Test whether FOP were installed (for PDF, PS and EPS output support). | 
| BufferedImage | makeAWTImage(int width,
            int height)Convert the SVG to a thumbnail image. | 
| void | putIdElement(String id,
            Element obj)Add an object id. | 
| void | saveAsANY(File file,
         int width,
         int height,
         double quality)Save a file trying to auto-guess the file type. | 
| void | saveAsEPS(File file)Transcode file to EPS. | 
| void | saveAsJPEG(File file,
          int width,
          int height)Transcode file to JPEG. | 
| void | saveAsJPEG(File file,
          int width,
          int height,
          double quality)Transcode file to JPEG. | 
| void | saveAsPDF(File file)Transcode file to PDF. | 
| void | saveAsPNG(File file,
         int width,
         int height)Transcode file to PNG. | 
| void | saveAsPS(File file)Transcode file to PS. | 
| void | saveAsSVG(File file)Save document into a SVG file. | 
| void | scheduleUpdate(Runnable runnable)Schedule an update. | 
| void | setDisableInteractions(boolean disable)Disable Batik predefined interactions. | 
| Element | svgCircle(double cx,
         double cy,
         double r)Create a SVG circle | 
| Element | svgElement(String name)Create a SVG element in the SVG namespace. | 
| Element | svgLine(double x1,
       double y1,
       double x2,
       double y2)Create a SVG line element | 
| Element | svgRect(double x,
       double y,
       double w,
       double h)Create a SVG rectangle | 
| Element | svgText(double x,
       double y,
       String text)Create a SVG text element. | 
| void | synchronizeWith(UpdateSynchronizer sync)Assign an update synchronizer. | 
| protected void | transcode(File file,
         org.apache.batik.transcoder.Transcoder transcoder)Transcode a document into a file using the given transcoder. | 
| void | unsynchronizeWith(UpdateSynchronizer sync)Detach from synchronization. | 
| void | updateStyleElement()Update style element - invoke this appropriately after any change to the
 CSS styles. | 
public static final double DEFAULT_QUALITY
public static final String NO_EXPORT_ATTRIBUTE
private org.w3c.dom.svg.SVGDocument document
private Element root
private Element defs
private Element style
private CSSClassManager cssman
private HashMap<String,WeakReference<Element>> objWithId
private UpdateRunner runner
private boolean disableInteractions
public void dispose()
public Element svgElement(String name)
name - node namepublic Element svgRect(double x, double y, double w, double h)
x - X coordinatey - Y coordinatew - Widthh - Heightpublic Element svgCircle(double cx, double cy, double r)
cx - center Xcy - center Yr - radiuspublic Element svgLine(double x1, double y1, double x2, double y2)
x1 - first point xy1 - first point yx2 - second point xy2 - second point ypublic Element svgText(double x, double y, String text)
x - first point xy - first point ytext - Content of text element.public org.w3c.dom.svg.SVGPoint elementCoordinatesFromEvent(Element tag, Event evt)
tag - Element to convert the coordinates forevt - Event objectpublic org.w3c.dom.svg.SVGDocument getDocument()
public Element getRoot()
public Element getDefs()
@Deprecated public Element getStyle()
public CSSClassManager getCSSClassManager()
updateStyleElement() to make changes
 take effect.public void addCSSClassOrLogError(CSSClass cls)
cls - CSS class to add.public void updateStyleElement()
public void saveAsSVG(File file) throws IOException, TransformerFactoryConfigurationError, TransformerException
file - Output filenameIOException - On write errorsTransformerFactoryConfigurationError - Transformation errorTransformerException - Transformation errorprotected void transcode(File file, org.apache.batik.transcoder.Transcoder transcoder) throws IOException, org.apache.batik.transcoder.TranscoderException
file - Output filetranscoder - Transcoder to useIOException - On write errorsorg.apache.batik.transcoder.TranscoderException - On input/parsing errorsprotected org.w3c.dom.svg.SVGDocument cloneDocument()
public void saveAsPDF(File file) throws IOException, org.apache.batik.transcoder.TranscoderException, ClassNotFoundException
file - Output filenameIOException - On write errorsorg.apache.batik.transcoder.TranscoderException - On input/parsing errors.ClassNotFoundException - PDF transcoder not installedpublic void saveAsPS(File file) throws IOException, org.apache.batik.transcoder.TranscoderException, ClassNotFoundException
file - Output filenameIOException - On write errorsorg.apache.batik.transcoder.TranscoderException - On input/parsing errors.ClassNotFoundException - PS transcoder not installedpublic void saveAsEPS(File file) throws IOException, org.apache.batik.transcoder.TranscoderException, ClassNotFoundException
file - Output filenameIOException - On write errorsorg.apache.batik.transcoder.TranscoderException - On input/parsing errors.ClassNotFoundException - EPS transcoder not installedpublic static boolean hasFOPInstalled()
public void saveAsPNG(File file, int width, int height) throws IOException, org.apache.batik.transcoder.TranscoderException
file - Output filenamewidth - Widthheight - HeightIOException - On write errorsorg.apache.batik.transcoder.TranscoderException - On input/parsing errors.public void saveAsJPEG(File file, int width, int height, double quality) throws IOException, org.apache.batik.transcoder.TranscoderException
file - Output filenamewidth - Widthheight - Heightquality - JPEG quality setting, between 0.0 and 1.0IOException - On write errorsorg.apache.batik.transcoder.TranscoderException - On input/parsing errors.public void saveAsJPEG(File file, int width, int height) throws IOException, org.apache.batik.transcoder.TranscoderException
file - Output filenamewidth - Widthheight - HeightIOException - On write errorsorg.apache.batik.transcoder.TranscoderException - On input/parsing errors.public void saveAsANY(File file, int width, int height, double quality) throws IOException, org.apache.batik.transcoder.TranscoderException, TransformerFactoryConfigurationError, TransformerException, ClassNotFoundException
file - File namewidth - Width (for pixel formats)height - Height (for pixel formats)quality - Quality (for lossy compression)IOException - on file write errors or unrecognized file extensionsorg.apache.batik.transcoder.TranscoderException - on transcoding errorsTransformerFactoryConfigurationError - on transcoding errorsTransformerException - on transcoding errorsClassNotFoundException - when the transcoder was not installedpublic BufferedImage makeAWTImage(int width, int height) throws org.apache.batik.transcoder.TranscoderException
width - Width of thumbnailheight - Height of thumbnailorg.apache.batik.transcoder.TranscoderExceptionpublic void dumpDebugFile()
public void putIdElement(String id, Element obj)
id - IDobj - Elementpublic Element getIdElement(String id)
id - IDprotected Collection<String> getAllIds()
public void scheduleUpdate(Runnable runnable)
runnable - Runnable to schedulepublic void synchronizeWith(UpdateSynchronizer sync)
sync - Update synchronizerpublic void unsynchronizeWith(UpdateSynchronizer sync)
sync - Update synchronizer to detach from.public boolean getDisableInteractions()
public void setDisableInteractions(boolean disable)
disable - Flag