|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Graphics | +--com.jinsight.svg.SVGGraphics
This class extends the abstract class java.awt.Graphics, implementing
painting methods to achieve the corresponding drawing effects with the
SVG language. SVG stands for Scalable Vector Graphics and it consists
of a sequence of XML elements describing two-dimensional
graphics. More in-depth information can be obtained in the W3C(World
Wide Web Consortium) web site(http://www.w3.org/TR/SVG).
Being an extension of java.awt.Graphics, an instance of this class can
be passed to the paint(java.awt.Graphics)
method of
Component objects. Each of the drawing methods invoked from the
paint
method generates one or more strings adhering to
the equivalent SVG syntax to the AWT methods. The strings are
sequentially concatenated to make up the whole SVG compliant set of
XML elements. The encoded string can be retrieved with the method
SVGGraphics.getSVG()
and be outputted to a file with the
'.svg' extension.
SVGEncoder
Method Summary | |
void |
addSVGListener(SVGListener svgListener)
Adds an SVGListener object to this SVG graphic context. |
void |
clearRect(int x,
int y,
int width,
int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface. |
void |
clipRect(int x,
int y,
int width,
int height)
Intersects the current clip with the specified rectangle. |
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Copies an area of the component by a distance specified by dx and dy. |
java.awt.Graphics |
create()
Creates a new Graphics object that is a copy of this SVGGraphics object. |
void |
dispose()
Disposes of an internal BufferedImage's graphics context and resets this graphics context. |
void |
draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draws a 3-D highlighted outline of the specified rectangle. |
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws the outline of a circular or elliptical arc covering the specified rectangle. |
void |
drawBytes(byte[] data,
int offset,
int length,
int x,
int y)
Draws the text given by the specified byte array, using this graphics context's current font and color. |
void |
drawChars(char[] data,
int offset,
int length,
int x,
int y)
Draws the text given by the specified character array, using this graphics context's current font and color. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.Color bgColor,
java.awt.image.ImageObserver observer)
Draws an image at the specified rectangle. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.image.ImageObserver observer)
Draws an image at the specified coordinates.The image is drawn with its top-left corner at (x, y) in this graphics context's coordinate space. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.Color bgColor,
java.awt.image.ImageObserver observer)
Draws an image inside the specified rectangle, scaling it if necessary. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer)
Draws an image inside the specified rectangle, scaling it if necessary. |
boolean |
drawImage(java.awt.Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.Color bgColor,
java.awt.image.ImageObserver observer)
Draws an image inside the specified area of the destination drawable surface, scaling it if necessary. |
boolean |
drawImage(java.awt.Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.image.ImageObserver observer)
Draws an image inside the specified area of the destination drawable surface, scaling it if necessary. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system. |
void |
drawOval(int x,
int y,
int width,
int height)
Draws the outline of an oval. |
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a closed polygon defined by arrays of x and y coordinates. |
void |
drawPolygon(java.awt.Polygon p)
Draws the outline of a polygon defined by the specified Polygon object. |
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a sequence of connected lines defined by arrays of x and y coordinates. |
void |
drawRect(int x,
int y,
int width,
int height)
Draws the outline of the specified rectangle. |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws an outlined round-cornered rectangle using this graphics context's current color. |
void |
drawString(java.text.AttributedCharacterIterator aci,
int x,
int y)
This method has not been implemented yet. |
void |
drawString(java.lang.String str,
int x,
int y)
Draws the text given by the specified string, using this graphics context's current font and color. |
void |
fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
Paints a 3-D highlighted rectangle filled with the current color. |
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Fills a circular or elliptical arc covering the specified rectangle. |
void |
fillOval(int x,
int y,
int width,
int height)
Fills an oval bounded by the specified rectangle with the current color. |
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Fills a closed polygon defined by arrays of x and y coordinates. |
void |
fillPolygon(java.awt.Polygon p)
Fills the polygon defined by the specified Polygon object with the graphics context's current color. |
void |
fillRect(int x,
int y,
int width,
int height)
Fills the specified rectangle. |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Fills the specified rounded corner rectangle with the current color. |
java.awt.Shape |
getClip()
Gets the current clipping area. |
java.awt.Rectangle |
getClipBounds()
Returns the bounding rectangle of the current clipping area. |
java.awt.Rectangle |
getClipBounds(java.awt.Rectangle r)
Returns the bounding rectangle of the current clipping area. |
java.awt.Color |
getColor()
Gets this graphics context's current color. |
java.awt.Font |
getFont()
Gets the current font. |
java.awt.FontMetrics |
getFontMetrics()
Gets the font metrics of the current font. |
java.awt.FontMetrics |
getFontMetrics(java.awt.Font f)
Gets the font metrics for the specified font. |
java.lang.String |
getSVG()
Returns the svg encoded string. |
int |
getSVGLinesCount()
Returns the number of SVG lines processed. |
boolean |
hitClip(int x,
int y,
int width,
int height)
Returns true if the specified rectangular area might intersect the current clipping area. |
void |
removeAllSVGListeners()
Removes all SVGListener objects from this SVG graphic context. |
void |
removeSVGListener(SVGListener svgListener)
Removes an SVGListener object from this SVG graphic context. |
void |
setBackground(java.awt.Color bg)
Sets the background color. |
void |
setClip(int x,
int y,
int width,
int height)
Sets the current clip to the rectangle specified by the given coordinates. |
void |
setClip(java.awt.Shape clip)
Sets the current clipping area to an arbitrary clip shape. |
void |
setColor(java.awt.Color c)
Sets this graphic context's current color to the specified color. |
void |
setCountEnabled(boolean isCountEnabled)
Enables/disables count of SVG processed lines. |
void |
setDTD(java.lang.String dtd)
Sets the SVG DTD. |
void |
setFont(java.awt.Font font)
Sets this graphics context's font to the specified font. |
void |
setIdentifier(java.lang.String identifier)
Sets the XML SVG identifier. |
void |
setOpeningInstruction(java.lang.String openingInstruction)
Sets the XML opening instruction. |
void |
setPaintMode()
This method has not been implemented. |
void |
setSVGNameSpace(java.lang.String svgNameSpace)
Sets the SVG name space. |
void |
setXLinkNameSpace(java.lang.String xlinkNameSpace)
Sets the XLink name space. |
void |
setXORMode(java.awt.Color c)
This method has not been implemented. |
java.lang.String |
toString()
Returns a string representation of this graphics context. |
void |
translate(int x,
int y)
Translates the origin of the graphics context to the point (x, y) in the current coordinate system. |
Methods inherited from class java.awt.Graphics |
create, finalize, getClipRect |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public void addSVGListener(SVGListener svgListener)
svgListener
- An SVGListener object.removeSVGListener(com.jinsight.svg.SVGListener)
,
removeAllSVGListeners()
,
SVGEvent
public void removeSVGListener(SVGListener svgListener)
svgListener
- An SVGListener object.addSVGListener(com.jinsight.svg.SVGListener)
,
removeAllSVGListeners()
,
SVGEvent
public void removeAllSVGListeners()
svgListener
- An SVGListener object.addSVGListener(com.jinsight.svg.SVGListener)
,
removeSVGListener(com.jinsight.svg.SVGListener)
,
SVGEvent
public void setCountEnabled(boolean isCountEnabled)
isCountEnabled
- A boolean value(true/false).SVGListener
public int getSVGLinesCount()
setCountEnabled(boolean)
public void setOpeningInstruction(java.lang.String openingInstruction)
openingInstruction
- A String object.public void setIdentifier(java.lang.String identifier)
identifier
- A String object.public void setDTD(java.lang.String dtd)
dtd
- A String object.public void setSVGNameSpace(java.lang.String svgNameSpace)
svgNameSpace
- A String object.public void setXLinkNameSpace(java.lang.String xlinkNameSpace)
xlinkNameSpace
- A String object.public void setColor(java.awt.Color c)
setColor
in class java.awt.Graphics
c
- The new rendering color.public void setBackground(java.awt.Color bg)
bg
- A Color object.public void clearRect(int x, int y, int width, int height)
clearRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to clear.y
- The y coordinate of the rectangle to clear.width
- The width of the rectangle to clear.height
- The height of the rectangle to clear.drawRect(int, int, int, int)
,
fillRect(int, int, int, int)
,
setColor(java.awt.Color)
public void clipRect(int x, int y, int width, int height)
clipRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to intersect the clip with.y
- The y coordinate of the rectangle to intersect the clip with.width
- The width of the rectangle to intersect the clip with.height
- The height of the rectangle to intersect the clip with.public void setClip(int x, int y, int width, int height)
setClip
in class java.awt.Graphics
x
- The x coordinate of the new clip rectangle.y
- The y coordinate of the new clip rectangle.width
- The width of the new clip rectangle.height
- The height of the new clip rectangle.public void setClip(java.awt.Shape clip)
setClip
in class java.awt.Graphics
clip
- The Shape
to use to set the clip.public java.awt.Shape getClip()
getClip
in class java.awt.Graphics
A
- Shape object representing the current clipping area, or null
if no clip is set.public java.awt.Rectangle getClipBounds()
getClipBounds
in class java.awt.Graphics
public java.awt.Rectangle getClipBounds(java.awt.Rectangle r)
getClipBounds()
in that an existing rectangle is used instead of
allocating a new one. If no clip has previously been set, or if the clip has been
cleared using setClip(null), this method returns the specified Rectangle.getClipBounds
in class java.awt.Graphics
The
- rectangle where the current clipping area is copied to. Any current
values in this rectangle are overwritten.public boolean hitClip(int x, int y, int width, int height)
hitClip
in class java.awt.Graphics
x
- The x coordinate of the rectangle to test against the clip.y
- The y coordinate of the rectangle to test against the clip.width
- The width of the rectangle to test against the clip.height
- The height of the rectangle to test against the clip.public void draw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to be drawn.y
- The y coordinate of the rectangle to be drawn.width
- The width of the rectangle to be drawn.height
- The height of the rectangle to be drawn.raised
- a boolean that determines whether the rectangle appears to
be raised above the surface or sunk into the surface.fill3DRect(int, int, int, int, boolean)
public void fill3DRect(int x, int y, int width, int height, boolean raised)
fill3DRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to be filled.y
- The y coordinate of the rectangle to be filled.width
- The width of the rectangle to be filled.height
- The height of the rectangle to be filled.raised
- A boolean value that determines whether the rectangle appears to be
raised above the surface or etched into the surface.public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
drawArc
in class java.awt.Graphics
x
- The x coordinate of the upper-left corner of the arc to be drawn.y
- The y coordinate of the upper-left corner of the arc to be drawn.width
- The width of the arc to be drawn.height
- The height of the arc to be drawn.startAngle
- The beginning angle.endAngle
- The angular extend of the arc, relative to the start angle.fillArc(int, int, int, int, int, int)
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
fillArc
in class java.awt.Graphics
x
- The x coordinate of the upper-left corner of the arc to be drawn.y
- The y coordinate of the upper-left corner of the arc to be drawn.width
- The width of the arc to be drawn.height
- The height of the arc to be drawn.startAngle
- The beginning angle.endAngle
- The angular extend of the arc, relative to the start angle.fillArc(int, int, int, int, int, int)
public void drawRect(int x, int y, int width, int height)
drawRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to be drawn.y
- The y coordinate of the rectangle to be drawn.width
- The width of the rectangle to be drawn.height
- The height of the rectangle to be drawn.fillRect(int, int, int, int)
,
clearRect(int, int, int, int)
public void fillRect(int x, int y, int width, int height)
fillRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to be filled.y
- The y coordinate of the rectangle to be filled.width
- The width of the rectangle to be filled.height
- The height of the rectangle to be filled.clearRect(int, int, int, int)
,
drawRect(int, int, int, int)
public void drawLine(int x1, int y1, int x2, int y2)
drawLine
in class java.awt.Graphics
x1
- The first point's x coordinate.y1
- The first point's y coordinate.x2
- The second point's x coordinate.y2
- The second point's y coordinate.public void drawOval(int x, int y, int width, int height)
drawOval
in class java.awt.Graphics
x
- The x coordinate of the upper left corner of the oval to be drawn.y
- The y coordinate of the upper left corner of the oval to be drawn.width
- The width of the oval to be drawn.height
- The height of the oval to be drawn.fillOval(int, int, int, int)
public void fillOval(int x, int y, int width, int height)
fillOval
in class java.awt.Graphics
x
- The x coordinate of the upper left corner of the oval to be drawn.y
- The y coordinate of the upper left corner of the oval to be drawn.width
- The width of the oval to be drawn.height
- The height of the oval to be drawn.drawOval(int, int, int, int)
public void drawPolygon(java.awt.Polygon p)
drawPolygon
in class java.awt.Graphics
p
- The polygon to draw.drawPolygon(int[] xPoints,int[] yPoints,int nPoints)
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
nPoints
. The figure is automatically closed by drawing a line connecting
the final point to the first point, if those points are different.drawPolygon
in class java.awt.Graphics
xPoints
- An array of x coordinates.yPoints
- An array of y coordinates.nPoints
- The total number of points.drawPolygon(Polygon p)
public void fillPolygon(java.awt.Polygon p)
fillPolygon
in class java.awt.Graphics
p
- The polygon to fill.fillPolygon(int[] xPoints,int[] yPoints, int nPoints)
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
nPoints
. The figure is automatically closed
by drawing a line connecting the final point to the
first point, if those points are different.fillPolygon
in class java.awt.Graphics
xPoints
- An array of x coordinates.yPoints
- An array of y coordinates.nPoints
- The total number of points.fillPolygon(Polygon p)
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
drawPolyline
in class java.awt.Graphics
xPoints
- An array of x points.yPoints
- An array of y points.nPoints
- The total number of points.public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to be drawn.y
- The y coordinate of the rectangle to be drawn.width
- The width of the rectangle to be drawn.height
- The height of the rectangle to be drawn.arcWidth
- The horizontal diameter of the arc at the four corners.archeight
- The vertical diameter of the arc at the four corners.fillRoundRect(int, int, int, int, int, int)
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
in class java.awt.Graphics
x
- The x coordinate of the rectangle to be filled.y
- The y coordinate of the rectangle to be filled.width
- The width of the rectangle to be filled.height
- The height of the rectangle to be filled.arcWidth
- The horizontal diameter of the arc at the four corners.archeight
- The vertical diameter of the arc at the four corners.drawRoundRect(int, int, int, int, int, int)
public void drawString(java.lang.String str, int x, int y)
drawString
in class java.awt.Graphics
str
- The string to be drawn.x
- The x coordinate.y
- The y coordinate.drawBytes(byte[], int, int, int, int)
,
drawChars(char[], int, int, int, int)
public void drawBytes(byte[] data, int offset, int length, int x, int y)
drawBytes
in class java.awt.Graphics
data
- The data to be drawn.offset
- The start offset in the data.length
- The number of bytes that are drawn.x
- The x coordinate of the baseline of the text.y
- The y coordinate of the baseline of the text.drawString(java.lang.String, int, int)
,
drawChars(char[], int, int, int, int)
public void drawChars(char[] data, int offset, int length, int x, int y)
drawChars
in class java.awt.Graphics
data
- The array of characters to be drawn.offset
- The start offset in the data.length
- The number of characters to be drawn.x
- The x coordinate of the baseline of the text.y
- The y coordinate of the baseline of the text.drawString(java.lang.String, int, int)
,
drawBytes(byte[], int, int, int, int)
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- The specified image to be drawn.x
- The x coordinate.y
- The y coordinate.observer
- An ImageObserver object.public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- The specified image to be drawn.x
- The x coordinate.y
- The y coordinate.width
- The width of the rectangle.height
- The height of the rectangle.observer
- An ImageObserver object.public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgColor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- The specified image to be drawn.x
- The x coordinate.y
- The y coordinate.bgColor
- The background color to paint under the non-opaque portions of the image.observer
- An ImageObserver object.public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgColor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- The specified image to be drawn.x
- The x coordinate.y
- The y coordinate.width
- The width of the rectangle.height
- The height of the rectangle.bgColor
- The background color to paint under the non-opaque portions of the image.observer
- An ImageObserver object.public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- The specified image to be drawn.dx1
- The x coordinate of the first corner of the destination rectangle.dy1
- The y coordinate of the first corner of the destination rectangle.dx2
- The x coordinate of the second corner of the destination rectangle.dy2
- the y coordinate of the second corner of the destination rectangle.sx1
- The x coordinate of the first corner of the source rectangle.sy1
- The y coordinate of the first corner of the source rectangle.sx2
- The x coordinate of the second corner of the source rectangle.sy2
- The y coordinate of the second corner of the source rectangle.observer
- An ImageObserver object.public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgColor, java.awt.image.ImageObserver observer)
drawImage
in class java.awt.Graphics
img
- The specified image to be drawn.dx1
- The x coordinate of the first corner of the destination rectangle.dy1
- The y coordinate of the first corner of the destination rectangle.dx2
- The x coordinate of the second corner of the destination rectangle.dy2
- the y coordinate of the second corner of the destination rectangle.sx1
- The x coordinate of the first corner of the source rectangle.sy1
- The y coordinate of the first corner of the source rectangle.sx2
- The x coordinate of the second corner of the source rectangle.sy2
- The y coordinate of the second corner of the source rectangle.observer
- An ImageObserver object.public void copyArea(int x, int y, int width, int height, int dx, int dy)
copyArea
in class java.awt.Graphics
x
- The x coordinate of the source rectangle.y
- The y coordinate of the source rectangle.width
- The width of the source rectangle.height
- The height of the source rectangle.dx
- The horizontal distance to copy the pixels.dy
- The vertical distance to copy the pixels.public void translate(int x, int y)
translate
in class java.awt.Graphics
x
- The x coordinate.y
- The y coordinate.public java.awt.Color getColor()
getColor
in class java.awt.Graphics
setColor(java.awt.Color)
public java.awt.Font getFont()
getFont
in class java.awt.Graphics
setFont(java.awt.Font)
public java.awt.FontMetrics getFontMetrics()
getFontMetrics
in class java.awt.Graphics
getFont()
,
getFontMetrics(Font f)
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
getFontMetrics
in class java.awt.Graphics
getFontMetrics()
,
getFont()
public void setFont(java.awt.Font font)
setFont
in class java.awt.Graphics
font
- The font.getFont()
public java.lang.String toString()
toString
in class java.awt.Graphics
public java.awt.Graphics create()
create
in class java.awt.Graphics
public void dispose()
copyArea
.
Different from the overriden method, a call to dispose
simply resets this graphics context, making it possible to reuse
it after an SVG encoding process has ended.dispose
in class java.awt.Graphics
public java.lang.String getSVG()
paint(Graphics g)
method of the encoded component has
returned.public void drawString(java.text.AttributedCharacterIterator aci, int x, int y)
drawString
in class java.awt.Graphics
public void setXORMode(java.awt.Color c)
setXORMode
in class java.awt.Graphics
public void setPaintMode()
setPaintMode
in class java.awt.Graphics
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |