|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph2.Output
org.faceless.graph2.SVGOutput
public class SVGOutput
A subclass of Output
which allows the finished Graph to be rendered to SVG.
At it's simplest, something like this would generally do:
Graph graph = makeMyGraph(); SVGOutput out = new SVGOutput(100,100); graph.draw(out); out.writeSVG(new OutputStreamWriter(new FileOutputStream("Graph.svg"), "UTF-8"), true);
Graph.draw(org.faceless.graph2.Output)
,
Graph.setMetaData(java.lang.String, java.lang.String)
Constructor Summary | |
---|---|
SVGOutput(int width,
int height)
Create a new SVGOutput |
|
SVGOutput(int width,
int height,
Paint background)
Create a new SVGOutput |
Method Summary | |
---|---|
String |
getTrace(String name)
Return the path taken by the specified line series. |
void |
setXMLExtras(String extraxml,
String svgatts)
Add additional XML to the XVG object and/or additional attributes to the <svg> tag. |
void |
writeSVG(Writer writer,
boolean header)
Write the SVG data to the specified writer. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SVGOutput(int width, int height)
width
- the width of the image in user unitsheight
- the height of the image in user unitspublic SVGOutput(int width, int height, Paint background)
width
- the width of the imageheight
- the height of the imagebackground
- the background color of the SVG, or null
for no backgroundMethod Detail |
---|
public void setXMLExtras(String extraxml, String svgatts)
<svg>
tag. Additional XML is specified with the extraxml
parameter, and is added immediately after the <svg>
tag. Additional
attributes for the <svg>
tag are specified with the svgatts
parameter. Both parameters may be null. As an example, calling
setXMLExtras("<script xlink:href=\"myscript.js\" />", "xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
would result in SVG that looks something like this (features
set by this call in bold):
<svg width="300" height="300" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"< <script xlink:href="myscript.js" /> <g><polygon ...
extraxml
- the XML which should be inserted immediately after the <svg> tag. May be null.svgatts
- any additional attributes for the <svg> tag. May be null.public void writeSVG(Writer writer, boolean header) throws IOException
Write the SVG data to the specified writer. For standalone SVG documents,
the header
flag should be set to true to generate the
<?xml version="1.0"...
header, and
the DOCTYPE line defining the output as an SVG document.
Note that when writing to an OutputStreamWriter
or FileWriter
,
the encoding of the XML header will be set to match the encoding of that Writer.
This implies that if you want to control the encoding of the XML, make sure you
set the encoding explicitly when creating the OutputStreamWriter
object,
eg. new OutputStreamWriter(stream, "UTF-8")
instead of
new OutputStreamWriter(stream)
writer
- the Writer
to write the finished SVG to.header
- whether to include the "<?xml"... header and the DOCTYPE.
IOException
public String getTrace(String name)
ImageOutput.getAreas()
method - given a line
series called "Prices", passing in the string "trace.graph.series.Prices"
will return a String containing a list of comma-separated points which define
the path taken by that series. There is no reason for end users to call this
method.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |