public class SVGPlot
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static org.w3c.dom.DOMImplementation |
BATIK_DOM
Batik DOM implementation.
|
private static java.lang.String[] |
BATIK_DOMS
DOM implementations to try.
|
private CSSClassManager |
cssman
CSS class manager
|
static float |
DEFAULT_QUALITY
Default JPEG quality setting
|
private org.w3c.dom.Element |
defs
Definitions element of the document.
|
private boolean |
disableInteractions
Flag whether Batik interactions should be disabled.
|
private org.w3c.dom.svg.SVGDocument |
document
SVG document we plot to.
|
static java.lang.String |
NO_EXPORT_ATTRIBUTE
Attribute to block export of element.
|
private java.util.HashMap<java.lang.String,java.lang.ref.WeakReference<org.w3c.dom.Element>> |
objWithId
Manage objects with an id.
|
private org.w3c.dom.Element |
root
Root element of the document.
|
private UpdateRunner |
runner
Registers changes of this SVGPlot.
|
private org.w3c.dom.Element |
style
Primary 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(org.w3c.dom.Element tag,
org.w3c.dom.events.Event evt)
Convert screen coordinates to element coordinates.
|
protected java.util.Collection<java.lang.String> |
getAllIds()
Get all used DOM Ids in this plot.
|
CSSClassManager |
getCSSClassManager()
Get the plots CSS class manager.
|
org.w3c.dom.Element |
getDefs()
Getter for definitions section
|
boolean |
getDisableInteractions()
Get Batik disable default interactions flag.
|
org.w3c.dom.svg.SVGDocument |
getDocument()
Retrieve the SVG document.
|
static org.w3c.dom.DOMImplementation |
getDomImpl()
Get a suitable SVG DOM implementation from Batik 1.7 or 1.8.
|
org.w3c.dom.Element |
getIdElement(java.lang.String id)
Get an element by its id.
|
org.w3c.dom.Element |
getRoot()
Getter for root element.
|
org.w3c.dom.Element |
getStyle()
Deprecated.
Contents will be overwritten by CSS class manager!
|
java.awt.image.BufferedImage |
makeAWTImage(int width,
int height)
Convert the SVG to a thumbnail image.
|
void |
putIdElement(java.lang.String id,
org.w3c.dom.Element obj)
Add an object id.
|
void |
saveAsANY(java.io.File file,
int width,
int height,
float quality)
Save a file trying to auto-guess the file type.
|
void |
saveAsEPS(java.io.File file)
Transcode file to EPS.
|
void |
saveAsJPEG(java.io.File file,
int width,
int height)
Transcode file to JPEG.
|
void |
saveAsJPEG(java.io.File file,
int width,
int height,
float quality)
Transcode file to JPEG.
|
void |
saveAsPDF(java.io.File file)
Transcode file to PDF.
|
void |
saveAsPNG(java.io.File file,
int width,
int height)
Transcode file to PNG.
|
void |
saveAsPS(java.io.File file)
Transcode file to PS.
|
void |
saveAsSVG(java.io.File file)
Save document into a SVG file.
|
void |
scheduleUpdate(java.lang.Runnable runnable)
Schedule an update.
|
void |
setDisableInteractions(boolean disable)
Disable Batik predefined interactions.
|
org.w3c.dom.Element |
svgCircle(double cx,
double cy,
double r)
Create a SVG circle
|
org.w3c.dom.Element |
svgElement(java.lang.String name)
Create a SVG element in the SVG namespace.
|
org.w3c.dom.Element |
svgElement(java.lang.String name,
java.lang.String cssclass)
Create a SVG element in the SVG namespace.
|
org.w3c.dom.Element |
svgLine(double x1,
double y1,
double x2,
double y2)
Create a SVG line element
|
org.w3c.dom.Element |
svgRect(double x,
double y,
double w,
double h)
Create a SVG rectangle
|
org.w3c.dom.Element |
svgText(double x,
double y,
java.lang.String text)
Create a SVG text element.
|
void |
synchronizeWith(UpdateSynchronizer sync)
Assign an update synchronizer.
|
protected void |
transcode(java.io.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 float DEFAULT_QUALITY
public static final java.lang.String NO_EXPORT_ATTRIBUTE
private static final org.w3c.dom.DOMImplementation BATIK_DOM
private static final java.lang.String[] BATIK_DOMS
private org.w3c.dom.svg.SVGDocument document
private org.w3c.dom.Element root
private org.w3c.dom.Element defs
private org.w3c.dom.Element style
private CSSClassManager cssman
private java.util.HashMap<java.lang.String,java.lang.ref.WeakReference<org.w3c.dom.Element>> objWithId
private UpdateRunner runner
private boolean disableInteractions
public static org.w3c.dom.DOMImplementation getDomImpl()
public void dispose()
public org.w3c.dom.Element svgElement(java.lang.String name)
name
- node namepublic org.w3c.dom.Element svgElement(java.lang.String name, java.lang.String cssclass)
name
- node namecssclass
- CSS classpublic org.w3c.dom.Element svgRect(double x, double y, double w, double h)
x
- X coordinatey
- Y coordinatew
- Widthh
- Heightpublic org.w3c.dom.Element svgCircle(double cx, double cy, double r)
cx
- center Xcy
- center Yr
- radiuspublic org.w3c.dom.Element svgLine(double x1, double y1, double x2, double y2)
x1
- first point xy1
- first point yx2
- second point xy2
- second point ypublic org.w3c.dom.Element svgText(double x, double y, java.lang.String text)
x
- first point xy
- first point ytext
- Content of text element.public org.w3c.dom.svg.SVGPoint elementCoordinatesFromEvent(org.w3c.dom.Element tag, org.w3c.dom.events.Event evt)
tag
- Element to convert the coordinates forevt
- Event objectpublic org.w3c.dom.svg.SVGDocument getDocument()
public org.w3c.dom.Element getRoot()
public org.w3c.dom.Element getDefs()
@Deprecated public org.w3c.dom.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(java.io.File file) throws java.io.IOException, javax.xml.transform.TransformerFactoryConfigurationError, javax.xml.transform.TransformerException
file
- Output filenamejava.io.IOException
- On write errorsjavax.xml.transform.TransformerFactoryConfigurationError
- Transformation errorjavax.xml.transform.TransformerException
- Transformation errorprotected void transcode(java.io.File file, org.apache.batik.transcoder.Transcoder transcoder) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException
file
- Output filetranscoder
- Transcoder to usejava.io.IOException
- On write errorsorg.apache.batik.transcoder.TranscoderException
- On input/parsing errorsprotected org.w3c.dom.svg.SVGDocument cloneDocument()
public void saveAsPDF(java.io.File file) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException, java.lang.ClassNotFoundException
file
- Output filenamejava.io.IOException
- On write errorsorg.apache.batik.transcoder.TranscoderException
- On input/parsing errors.java.lang.ClassNotFoundException
- PDF transcoder not installedpublic void saveAsPS(java.io.File file) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException, java.lang.ClassNotFoundException
file
- Output filenamejava.io.IOException
- On write errorsorg.apache.batik.transcoder.TranscoderException
- On input/parsing errors.java.lang.ClassNotFoundException
- PS transcoder not installedpublic void saveAsEPS(java.io.File file) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException, java.lang.ClassNotFoundException
file
- Output filenamejava.io.IOException
- On write errorsorg.apache.batik.transcoder.TranscoderException
- On input/parsing errors.java.lang.ClassNotFoundException
- EPS transcoder not installedpublic void saveAsPNG(java.io.File file, int width, int height) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException
file
- Output filenamewidth
- Widthheight
- Heightjava.io.IOException
- On write errorsorg.apache.batik.transcoder.TranscoderException
- On input/parsing errors.public void saveAsJPEG(java.io.File file, int width, int height, float quality) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException
file
- Output filenamewidth
- Widthheight
- Heightquality
- JPEG quality setting, between 0.0 and 1.0java.io.IOException
- On write errorsorg.apache.batik.transcoder.TranscoderException
- On input/parsing errors.public void saveAsJPEG(java.io.File file, int width, int height) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException
file
- Output filenamewidth
- Widthheight
- Heightjava.io.IOException
- On write errorsorg.apache.batik.transcoder.TranscoderException
- On input/parsing errors.public void saveAsANY(java.io.File file, int width, int height, float quality) throws java.io.IOException, org.apache.batik.transcoder.TranscoderException, javax.xml.transform.TransformerFactoryConfigurationError, javax.xml.transform.TransformerException, java.lang.ClassNotFoundException
file
- File namewidth
- Width (for pixel formats)height
- Height (for pixel formats)quality
- Quality (for lossy compression)java.io.IOException
- on file write errors or unrecognized file extensionsorg.apache.batik.transcoder.TranscoderException
- on transcoding errorsjavax.xml.transform.TransformerFactoryConfigurationError
- on transcoding errorsjavax.xml.transform.TransformerException
- on transcoding errorsjava.lang.ClassNotFoundException
- when the transcoder was not installedpublic java.awt.image.BufferedImage makeAWTImage(int width, int height) throws org.apache.batik.transcoder.TranscoderException
width
- Width of thumbnailheight
- Height of thumbnailorg.apache.batik.transcoder.TranscoderException
public void dumpDebugFile()
public void putIdElement(java.lang.String id, org.w3c.dom.Element obj)
id
- IDobj
- Elementpublic org.w3c.dom.Element getIdElement(java.lang.String id)
id
- IDprotected java.util.Collection<java.lang.String> getAllIds()
public void scheduleUpdate(java.lang.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
- FlagCopyright © 2019 ELKI Development Team. License information.