|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jhotdraw.samples.svg.io.SVGOutputFormat
public class SVGOutputFormat
An output format for storing drawings as Scalable Vector Graphics SVG Tiny 1.2.
| Field Summary | |
|---|---|
private IXMLElement |
defs
This element holds all definitions of the SVG file. |
private IXMLElement |
document
Holds the document that is currently being written. |
private java.util.HashMap<Gradient,java.lang.String> |
gradientToIDMap
Maps gradients to ID's. |
private java.util.HashMap<IXMLElement,java.lang.String> |
identifiedElements
In this hash map we store all elements to which we have assigned an id. |
private static boolean |
isFloatPrecision
Set this variable to true if values should be written with float precision instead with double precision. |
private boolean |
isPrettyPrint
Set this to true for pretty printing. |
private int |
nextId
This is a counter used to create the next unique identification. |
private static java.util.HashMap<java.lang.Integer,java.lang.String> |
strokeLinecapMap
|
private static java.util.HashMap<java.lang.Integer,java.lang.String> |
strokeLinejoinMap
|
private java.net.URL |
url
|
| Constructor Summary | |
|---|---|
SVGOutputFormat()
Creates a new instance. |
|
| Method Summary | |
|---|---|
protected IXMLElement |
createCircle(IXMLElement doc,
double cx,
double cy,
double r,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createEllipse(IXMLElement doc,
double cx,
double cy,
double rx,
double ry,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createG(IXMLElement doc,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createImage(IXMLElement doc,
double x,
double y,
double w,
double h,
byte[] imageData,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createLine(IXMLElement doc,
double x1,
double y1,
double x2,
double y2,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createLinearGradient(IXMLElement doc,
double x1,
double y1,
double x2,
double y2,
double[] stopOffsets,
java.awt.Color[] stopColors,
double[] stopOpacities,
boolean isRelativeToFigureBounds,
java.awt.geom.AffineTransform transform)
|
protected IXMLElement |
createPath(IXMLElement doc,
BezierPath[] beziers,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createPolygon(IXMLElement doc,
java.awt.geom.Point2D.Double[] points,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createPolyline(IXMLElement doc,
java.awt.geom.Point2D.Double[] points,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createRadialGradient(IXMLElement doc,
double cx,
double cy,
double fx,
double fy,
double r,
double[] stopOffsets,
java.awt.Color[] stopColors,
double[] stopOpacities,
boolean isRelativeToFigureBounds,
java.awt.geom.AffineTransform transform)
|
protected IXMLElement |
createRect(IXMLElement doc,
double x,
double y,
double width,
double height,
double rx,
double ry,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createText(IXMLElement doc,
java.awt.geom.Point2D.Double[] coordinates,
double[] rotate,
javax.swing.text.StyledDocument text,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
protected IXMLElement |
createTextArea(IXMLElement doc,
double x,
double y,
double w,
double h,
javax.swing.text.StyledDocument text,
java.util.Map<AttributeKey,java.lang.Object> attributes)
|
java.awt.datatransfer.Transferable |
createTransferable(Drawing drawing,
java.util.List<Figure> figures,
double scaleFactor)
Creates a Transferable for the specified list of Figures. |
java.lang.String |
getFileExtension()
Returns the file extension for the output format. |
javax.swing.filechooser.FileFilter |
getFileFilter()
Return a FileFilter that can be used to identify files which can be stored with this output format. |
java.lang.String |
getId(IXMLElement element)
Gets a unique ID for the specified element. |
javax.swing.JComponent |
getOutputFormatAccessory()
Return a JFileChooser accessory that can be used to customize the output format. |
private void |
initStorageContext(IXMLElement root)
|
boolean |
isPrettyPrint()
|
void |
setPrettyPrint(boolean newValue)
|
static java.lang.String |
toColor(java.awt.Color color)
|
static java.lang.String |
toNumber(double number)
Returns a double array as a number attribute value. |
static java.lang.String |
toPath(BezierPath[] paths)
Returns a value as a SVG Path attribute. |
static java.lang.String |
toPoints(java.awt.geom.Point2D.Double[] points)
Returns a Point2D.Double array as a Points attribute value. |
static java.lang.String |
toTransform(java.awt.geom.AffineTransform t)
|
void |
write(java.io.File file,
Drawing drawing)
|
void |
write(java.io.OutputStream out,
Drawing drawing)
Writes a Drawing into an output stream. |
void |
write(java.io.OutputStream out,
Drawing drawing,
java.util.List<Figure> figures)
All other write methods delegate their work to here. |
void |
write(java.net.URI uri,
Drawing drawing)
Writes a Drawing into an URI. |
protected void |
writeAttribute(IXMLElement elem,
java.lang.String name,
double value,
double defaultValue)
|
protected void |
writeAttribute(IXMLElement elem,
java.lang.String name,
java.lang.String namespace,
double value,
double defaultValue)
|
protected void |
writeAttribute(IXMLElement elem,
java.lang.String name,
java.lang.String value,
java.lang.String defaultValue)
|
protected void |
writeAttribute(IXMLElement elem,
java.lang.String name,
java.lang.String namespace,
java.lang.String value,
java.lang.String defaultValue)
|
protected void |
writeCircleElement(IXMLElement parent,
SVGEllipseFigure f)
|
protected void |
writeElement(IXMLElement parent,
Figure f)
|
protected void |
writeEllipseElement(IXMLElement parent,
SVGEllipseFigure f)
|
private void |
writeFontAttributes(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> a)
|
protected void |
writeGElement(IXMLElement parent,
SVGGroupFigure f)
|
protected void |
writeImageElement(IXMLElement parent,
SVGImageFigure f)
|
protected void |
writeLineElement(IXMLElement parent,
SVGPathFigure f)
|
protected void |
writeOpacityAttribute(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> m)
|
protected void |
writePathElement(IXMLElement parent,
SVGPathFigure f)
|
protected void |
writePolygonElement(IXMLElement parent,
SVGPathFigure f)
|
protected void |
writePolylineElement(IXMLElement parent,
SVGPathFigure f)
|
protected void |
writeRectElement(IXMLElement parent,
SVGRectFigure f)
|
protected void |
writeShapeAttributes(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> m)
|
protected void |
writeTextAreaElement(IXMLElement parent,
SVGTextAreaFigure f)
|
protected void |
writeTextElement(IXMLElement parent,
SVGTextFigure f)
|
protected void |
writeTransformAttribute(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> a)
|
private void |
writeViewportAttributes(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> a)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.net.URL url
private int nextId
private java.util.HashMap<IXMLElement,java.lang.String> identifiedElements
private IXMLElement defs
private IXMLElement document
private java.util.HashMap<Gradient,java.lang.String> gradientToIDMap
private boolean isPrettyPrint
private static final java.util.HashMap<java.lang.Integer,java.lang.String> strokeLinejoinMap
private static final java.util.HashMap<java.lang.Integer,java.lang.String> strokeLinecapMap
private static final boolean isFloatPrecision
| Constructor Detail |
|---|
public SVGOutputFormat()
| Method Detail |
|---|
public javax.swing.filechooser.FileFilter getFileFilter()
OutputFormat
getFileFilter in interface OutputFormatpublic javax.swing.JComponent getOutputFormatAccessory()
OutputFormat
getOutputFormatAccessory in interface OutputFormatpublic void setPrettyPrint(boolean newValue)
public boolean isPrettyPrint()
protected void writeElement(IXMLElement parent,
Figure f)
throws java.io.IOException
java.io.IOException
protected void writeCircleElement(IXMLElement parent,
SVGEllipseFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createCircle(IXMLElement doc,
double cx,
double cy,
double r,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected IXMLElement createG(IXMLElement doc,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected IXMLElement createLinearGradient(IXMLElement doc,
double x1,
double y1,
double x2,
double y2,
double[] stopOffsets,
java.awt.Color[] stopColors,
double[] stopOpacities,
boolean isRelativeToFigureBounds,
java.awt.geom.AffineTransform transform)
throws java.io.IOException
java.io.IOException
protected IXMLElement createRadialGradient(IXMLElement doc,
double cx,
double cy,
double fx,
double fy,
double r,
double[] stopOffsets,
java.awt.Color[] stopColors,
double[] stopOpacities,
boolean isRelativeToFigureBounds,
java.awt.geom.AffineTransform transform)
throws java.io.IOException
java.io.IOException
protected void writeEllipseElement(IXMLElement parent,
SVGEllipseFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createEllipse(IXMLElement doc,
double cx,
double cy,
double rx,
double ry,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writeGElement(IXMLElement parent,
SVGGroupFigure f)
throws java.io.IOException
java.io.IOException
protected void writeImageElement(IXMLElement parent,
SVGImageFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createImage(IXMLElement doc,
double x,
double y,
double w,
double h,
byte[] imageData,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writePathElement(IXMLElement parent,
SVGPathFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createPath(IXMLElement doc,
BezierPath[] beziers,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writePolygonElement(IXMLElement parent,
SVGPathFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createPolygon(IXMLElement doc,
java.awt.geom.Point2D.Double[] points,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writePolylineElement(IXMLElement parent,
SVGPathFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createPolyline(IXMLElement doc,
java.awt.geom.Point2D.Double[] points,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writeLineElement(IXMLElement parent,
SVGPathFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createLine(IXMLElement doc,
double x1,
double y1,
double x2,
double y2,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writeRectElement(IXMLElement parent,
SVGRectFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createRect(IXMLElement doc,
double x,
double y,
double width,
double height,
double rx,
double ry,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writeTextElement(IXMLElement parent,
SVGTextFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createText(IXMLElement doc,
java.awt.geom.Point2D.Double[] coordinates,
double[] rotate,
javax.swing.text.StyledDocument text,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writeTextAreaElement(IXMLElement parent,
SVGTextAreaFigure f)
throws java.io.IOException
java.io.IOException
protected IXMLElement createTextArea(IXMLElement doc,
double x,
double y,
double w,
double h,
javax.swing.text.StyledDocument text,
java.util.Map<AttributeKey,java.lang.Object> attributes)
throws java.io.IOException
java.io.IOException
protected void writeShapeAttributes(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> m)
throws java.io.IOException
java.io.IOException
protected void writeOpacityAttribute(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> m)
throws java.io.IOException
java.io.IOException
protected void writeTransformAttribute(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> a)
throws java.io.IOException
java.io.IOException
private void writeFontAttributes(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> a)
throws java.io.IOException
java.io.IOException
private void writeViewportAttributes(IXMLElement elem,
java.util.Map<AttributeKey,java.lang.Object> a)
throws java.io.IOException
java.io.IOException
protected void writeAttribute(IXMLElement elem,
java.lang.String name,
java.lang.String value,
java.lang.String defaultValue)
protected void writeAttribute(IXMLElement elem,
java.lang.String name,
java.lang.String namespace,
java.lang.String value,
java.lang.String defaultValue)
protected void writeAttribute(IXMLElement elem,
java.lang.String name,
double value,
double defaultValue)
protected void writeAttribute(IXMLElement elem,
java.lang.String name,
java.lang.String namespace,
double value,
double defaultValue)
public static java.lang.String toPath(BezierPath[] paths)
public static java.lang.String toNumber(double number)
public static java.lang.String toPoints(java.awt.geom.Point2D.Double[] points)
throws java.io.IOException
java.io.IOException
public static java.lang.String toTransform(java.awt.geom.AffineTransform t)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String toColor(java.awt.Color color)
public java.lang.String getFileExtension()
OutputFormat
getFileExtension in interface OutputFormat
public void write(java.net.URI uri,
Drawing drawing)
throws java.io.IOException
OutputFormat
write in interface OutputFormaturi - The uri.drawing - The drawing.
java.io.IOException
public void write(java.io.File file,
Drawing drawing)
throws java.io.IOException
java.io.IOException
public void write(java.io.OutputStream out,
Drawing drawing)
throws java.io.IOException
OutputFormat
write in interface OutputFormatout - The output stream.drawing - The drawing.
java.io.IOException
public void write(java.io.OutputStream out,
Drawing drawing,
java.util.List<Figure> figures)
throws java.io.IOException
java.io.IOExceptionprivate void initStorageContext(IXMLElement root)
public java.lang.String getId(IXMLElement element)
public java.awt.datatransfer.Transferable createTransferable(Drawing drawing,
java.util.List<Figure> figures,
double scaleFactor)
throws java.io.IOException
OutputFormat
createTransferable in interface OutputFormatdrawing - The drawing.figures - A list of figures of the drawing.scaleFactor - The factor to be used, when the Transferable creates
an image with a fixed size from the figures.
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||