Class SemanticSVGGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
org.freehep.graphics2d.VectorGraphics
org.freehep.graphics2d.AbstractVectorGraphics
org.freehep.graphicsio.VectorGraphicsIO
org.freehep.graphicsio.AbstractVectorGraphicsIO
de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D
- All Implemented Interfaces:
org.freehep.graphics2d.VectorGraphicsConstants
public class SemanticSVGGraphics2D
extends org.freehep.graphicsio.AbstractVectorGraphicsIO
This class implements the Scalable Vector Graphics output. SVG specifications
can be found at http://www.w3c.org/Graphics/SVG/
The current implementation is based on REC-SVG11-20030114
- Version:
- $Id: freehep-graphicsio-svg/src/main/java/org/freehep/graphicsio/svg/SVGGraphics2D.java 4c4708a97391 2007/06/12 22:32:31 duns $ - Added capabilities to add semantic information to the svg, ie key/value pairs within the 'klighd' namespace. - Allow comments to be switched off. - Corrected direction of color gradients. - Added support for multi-line text and proper font sizing.
- Author:
- Mark Donszelmann, uru
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringuse style="font-size:20" instaed of font-size="20" seestyle(java.util.Properties)for detailsstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.freehep.graphicsio.AbstractVectorGraphicsIO
CLIP, EMIT_ERRORS, EMIT_WARNINGS, TEXT_AS_SHAPESFields inherited from interface org.freehep.graphics2d.VectorGraphicsConstants
NUMBER_OF_HORIZ_ALIGNMENTS, NUMBER_OF_SYMBOLS, NUMBER_OF_VERTICAL_ALIGNMENTS, SYMBOL_BOX, SYMBOL_CIRCLE, SYMBOL_CROSS, SYMBOL_DIAMOND, SYMBOL_DN_TRIANGLE, SYMBOL_HLINE, SYMBOL_PLUS, SYMBOL_STAR, SYMBOL_UP_TRIANGLE, SYMBOL_VLINE, TEXT_BASELINE, TEXT_BOTTOM, TEXT_CENTER, TEXT_LEFT, TEXT_RIGHT, TEXT_TOP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSemanticSVGGraphics2D(SemanticSVGGraphics2D graphics, boolean doRestoreOnDispose) SemanticSVGGraphics2D(File file, Component component) SemanticSVGGraphics2D(File file, Dimension size) SemanticSVGGraphics2D(OutputStream os, Component component) SemanticSVGGraphics2D(OutputStream os, Dimension size) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSemanticData(KlighdSemanticDiagramData nextSemanticData) voidvoidcopyArea(int x, int y, int width, int height, int dx, int dy) create()create(double x, double y, double width, double height) static Path2DcreateAWTPath(org.eclipse.swt.graphics.PathData pathData) Builds up a AWTPath2Daccording to a given SWT GeometryPathData.voiddispose()voidDraws the shape using the current paint as bordervoiddrawString(String string, double x, double y) Copied fromAbstractVectorGraphicsIOto change the handling of text as shapes.voidendGroup()voidFills the shape without a border using the current paintstatic StringfixedPrecision(double d) converts the double value to a representing stringprotected floatprotected floatgetAdjustedFontHeight(int height, int ascent, int descent, boolean firstLine) static Propertiesprotected org.eclipse.swt.graphics.FontDatagetFontData(Font font) floatGets the height of the current font.KLighD uses SWT to estimate font sizes, hence we do the same when exporting svgs.protected PrintWriterprotected StringgetPath(PathIterator path) protected static StringgetPathContent(PathIterator path) voidpushComment(Stack<String> stack, String s) voidGet the bounding box for this image.static voidsetDefaultProperties(Properties newProperties) voidsetNextTextLength(double textLength) voidvoidsetWriteComments(boolean writeComments) voidsetXORMode(Color c1) voidstartGroup(KlighdSemanticDiagramData nextSemanticData) protected StringtextLength(Double nextLength) toString()voidprotected voidwriteCap(int cap) protected voidvoidprotected voidwriteDash(float[] dash, float phase) protected voidprotected voidprotected voidvoidWrite out the header of this SVG file.protected voidwriteImage(RenderedImage image, AffineTransform xform, Color bkg) protected voidwriteJoin(int join) protected voidwriteMiterLimit(float limit) protected voidwritePaint(Color c) protected voidwritePaint(GradientPaint paint) protected voidwritePaint(Paint p) protected voidwritePaint(TexturePaint paint) protected voidprotected voidwriteSetTransform(AffineTransform transform) protected voidwriteString(String str, double x, double y) voidWrites the font definitions and callswriteGraphicsRestore()to close all open XML Tagsprotected voidwriteTransform(AffineTransform transform) protected voidwriteWidth(float width) Methods inherited from class org.freehep.graphicsio.AbstractVectorGraphicsIO
addRenderingHints, clearRect, clip, clipRect, clipRect, createShape, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawRenderableImage, drawRenderedImage, drawString, endExport, getClip, getClipBounds, getClipBounds, getComponent, getComposite, getFontMetrics, getFontRenderContext, getRenderingHint, getRenderingHints, getSize, getStroke, getTransform, handleException, overLine, printComment, resetClip, rotate, scale, setClip, setClip, setClip, setColor, setComposite, setFont, setPaint, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, startExport, transform, translate, writeDash, writeError, writeGraphicsState, writeStroke, writeWarning, writeWarningMethods inherited from class org.freehep.graphicsio.VectorGraphicsIO
copyResourceTo, copyResourceToMethods inherited from class org.freehep.graphics2d.AbstractVectorGraphics
clearRect, createShape, drawArc, drawArc, drawLine, drawLine, drawOval, drawOval, drawPolygon, drawPolygon, drawPolyline, drawPolyline, drawRect, drawRect, drawRoundRect, drawRoundRect, drawString, drawString, drawString, drawString, drawString, drawString, drawString, drawString, drawSymbol, drawSymbol, drawSymbol, fillAndDraw, fillAndDrawSymbol, fillAndDrawSymbol, fillArc, fillArc, fillOval, fillOval, fillPolygon, fillPolygon, fillRect, fillRect, fillRoundRect, fillRoundRect, fillSymbol, fillSymbol, fillSymbol, getBackground, getColor, getColorMode, getCreator, getFont, getPaint, getPrintColor, getProperties, getProperty, getPropertyColor, getPropertyDimension, getPropertyDouble, getPropertyInsets, getPropertyInt, getPropertyRectangle, hit, initProperties, isDeviceIndependent, isProperty, rotate, setBackground, setColorMode, setCreator, setDeviceIndependent, setLineWidth, setLineWidth, setProperties, translateMethods inherited from class org.freehep.graphics2d.VectorGraphics
create, create, fill, getSymbol, getTextAlignment, getXalignment, getYalignmentMethods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRectMethods inherited from class java.awt.Graphics
drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipRect, hitClip
-
Field Details
-
VERSION_1_1
- See Also:
-
TRANSPARENT
-
BACKGROUND
-
BACKGROUND_COLOR
-
VERSION
-
COMPRESS
-
STYLABLE
use style="font-size:20" instaed of font-size="20" seestyle(java.util.Properties)for details -
IMAGE_SIZE
-
EXPORT_IMAGES
-
EXPORT_SUFFIX
-
WRITE_IMAGES_AS
-
FOR
-
TITLE
-
EMBED_FONTS
-
DESCRIPTION
-
ADDITIONAL_ROOT_DATA
-
CSS
-
version
- See Also:
-
-
Constructor Details
-
SemanticSVGGraphics2D
- Throws:
IOException
-
SemanticSVGGraphics2D
- Throws:
IOException
-
SemanticSVGGraphics2D
-
SemanticSVGGraphics2D
-
SemanticSVGGraphics2D
-
-
Method Details
-
getDefaultProperties
-
setDefaultProperties
-
getAdjustedFontHeight
protected float getAdjustedFontHeight() -
dispose
public void dispose()- Overrides:
disposein classorg.freehep.graphicsio.AbstractVectorGraphicsIO
-
setBoundingBox
public void setBoundingBox()Get the bounding box for this image. -
setWriteComments
public void setWriteComments(boolean writeComments) - Parameters:
writeComments- the writeComments to set
-
writeHeader
Write out the header of this SVG file.- Specified by:
writeHeaderin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeBackground
- Specified by:
writeBackgroundin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeTrailer
Writes the font definitions and callswriteGraphicsRestore()to close all open XML Tags- Specified by:
writeTrailerin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
closeStream
- Specified by:
closeStreamin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
create
- Specified by:
createin classorg.freehep.graphics2d.VectorGraphics
-
create
- Specified by:
createin classorg.freehep.graphics2d.VectorGraphics
-
writeGraphicsSave
- Specified by:
writeGraphicsSavein classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeGraphicsRestore
- Specified by:
writeGraphicsRestorein classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
draw
Draws the shape using the current paint as border- Specified by:
drawin classorg.freehep.graphics2d.VectorGraphics- Parameters:
shape- Shape to draw
-
fill
Fills the shape without a border using the current paint- Specified by:
fillin classorg.freehep.graphics2d.VectorGraphics- Parameters:
shape- Shape to be filled with the current paint
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) - Specified by:
copyAreain classorg.freehep.graphics2d.VectorGraphics
-
writeImage
- Specified by:
writeImagein classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
setNextTextLength
public void setNextTextLength(double textLength) -
drawString
Copied fromAbstractVectorGraphicsIOto change the handling of text as shapes. Draws the string at (x, y). If TEXT_AS_SHAPES is setAbstractVectorGraphicsIO.drawGlyphVector(java.awt.font.GlyphVector, float, float)is used, otherwisewriteString(String, double, double)for a more direct output of the string.- Overrides:
drawStringin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Parameters:
string-x-y-
-
writeString
- Specified by:
writeStringin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
getAdjustedFontHeight
protected float getAdjustedFontHeight(int height, int ascent, int descent, boolean firstLine) -
textLength
-
getFontMetrics
KLighD uses SWT to estimate font sizes, hence we do the same when exporting svgs.- Overrides:
getFontMetricsin classGraphics
-
getFontHeight
public float getFontHeight()Gets the height of the current font.- Returns:
- The current font height.
-
writeTransform
- Specified by:
writeTransformin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeSetTransform
- Overrides:
writeSetTransformin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeClip
- Specified by:
writeClipin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeSetClip
- Specified by:
writeSetClipin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeWidth
- Overrides:
writeWidthin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeCap
- Overrides:
writeCapin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeJoin
- Overrides:
writeJoinin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeMiterLimit
- Overrides:
writeMiterLimitin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeDash
- Overrides:
writeDashin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
setPaintMode
public void setPaintMode()- Specified by:
setPaintModein classorg.freehep.graphics2d.VectorGraphics
-
setXORMode
- Specified by:
setXORModein classorg.freehep.graphics2d.VectorGraphics
-
writePaint
- Specified by:
writePaintin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writePaint
- Specified by:
writePaintin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writePaint
- Specified by:
writePaintin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writePaint
- Specified by:
writePaintin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
writeFont
- Specified by:
writeFontin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
getDeviceConfiguration
- Specified by:
getDeviceConfigurationin classorg.freehep.graphics2d.VectorGraphics
-
writeComment
- Specified by:
writeCommentin classorg.freehep.graphicsio.AbstractVectorGraphicsIO- Throws:
IOException
-
pushComment
-
toString
- Specified by:
toStringin classorg.freehep.graphics2d.VectorGraphics
-
getPathContent
-
getPath
-
addSemanticData
-
startGroup
-
endGroup
public void endGroup() -
createAWTPath
Builds up a AWTPath2Daccording to a given SWT GeometryPathData.- Parameters:
pathData- provides the segments the new path shall contain. the device to create the path on- Returns:
- the desired
Path2Dobject.
-
getFontData
-
fixedPrecision
converts the double value to a representing string- Parameters:
d- double value to convert- Returns:
- same as string
-
getOutputStream
-