|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Graphics
java.awt.Graphics2D
cwi.SVGGraphics.SVGGraphics
public class SVGGraphics
SVG generator for Java.
Using this class makes it easy(er) to generate SVG files from Java. The intention is to
use SVG as a kind of "screen dump", using possibly the same user methods as for the
generation of the screen content. This is the reason why the object is defined as
an extension of Graphics2D
: various methods which can use any
Graphics2D
instances can be used in conjunction with this class. The
approach is similar to the printing facilities in Java.
Here is a typical usage of the class:
SVGGraphics svg = SVGGraphics.create(yourCanvas); if( svg == null ) return; yourCanvas.yourDrawMethod(svg); svg.close();Note the usage of the
close
method, which is necessary to properly close
the SVG file.
Most of the graphics calls in Graphics2D
translate into SVG easily.
There are some differences, difficulties, or not-yet-implemented features, though, check the
comments on the individual methods themselves.
The generated SVG file includes a number of groups: one for each
different transformation and/or stroke settings. Gradient colours of Java are
separated into a distinct set of definitions.
Coordinates in the generated SVG file are simply passed on from Java, and the transformation matrices in the groups take care of the proper positioning. The only exception are the coordinates in the linear gradients in the definitions, where the coordinates are transformed before being stored in the file.
As mentioned before most of the Java calls can be translated into SVG easily. The only
major exception is the handling of images. In Java, images are pixels (by the time the
methods in Graphics
are called) whereas SVG refers to URL-s. I did not see any
obvious ways to store pixel information in SVG and, even if it was possible, it would be
a waste of bandwidth. The solution chosen in SVGGraphics
is to accept
only those Image
objects, whose property with a key "url"
has been set.
This url is then used as a reference in the SVG file.
The only problem with using "url"
key for an image that it is not immediately
obvious how one would set a property on an image. For reasons which I do not completely understand,
although there is a public getProperty
method for an Image
object,
there is no public setProperty
method. The only way I found was to use a special
image consumer filter to generate a new Image
instance with the property set. To
make life easier for the users of SVGGraphics
, a separate class, called
, is available. See the description of that class for further details
on how to use it. Note that the same restriction applies for the texture paint: the buffered image
which is used in a texture paint has to include the SVGImageFilter
"url"
property. If it is there,
a separate pattern specification (in SVG terms) is generated into the output.
The user might also want to look at the class
STest
which
I used for testing SVGGraphics
.
SVGImageFilter
Constructor Summary | |
---|---|
protected |
SVGGraphics()
Create a new object. |
protected |
SVGGraphics(java.io.PrintStream o,
java.awt.Component origin)
Create a new object. |
Method Summary | |
---|---|
void |
addRenderingHints(java.util.Map hints)
Sets the values of an arbitrary number of preferences for the rendering algorithms. |
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 |
clip(java.awt.Shape s)
Intersects the current Clip with the interior of the
specified Shape and sets the Clip to the
resulting intersection. |
void |
clipRect(int x,
int y,
int width,
int height)
Intersects the current clip with the specified rectangle. |
void |
close()
Close the object. |
void |
close(boolean closeFile)
Close the object. |
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 Graphics object. |
static SVGGraphics |
create(java.awt.Component origin)
Create a new SVGGraphics object through a file picker widget. |
static SVGGraphics |
create(java.io.PrintStream o,
java.awt.Component origin)
Create a new SVGGraphics object. |
void |
dispose()
This method is inherited from the superclass. |
void |
draw(java.awt.Shape s)
Strokes the outline of a Shape using the settings of the
current Graphics2D context. |
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 |
drawGlyphVector(java.awt.font.GlyphVector g,
float x,
float y)
Renders the text of the specified GlyphVector using the Graphics2D context's rendering attributes. |
void |
drawImage(java.awt.image.BufferedImage img,
java.awt.image.BufferedImageOp op,
int x,
int y)
Renders a BufferedImage . |
boolean |
drawImage(java.awt.Image img,
java.awt.geom.AffineTransform xform,
java.awt.image.ImageObserver obs)
Renders an image, applying a transform from image space into user space before drawing. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.Color bgcolor,
java.awt.image.ImageObserver obs)
Draws as much of the specified image as is currently available. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.image.ImageObserver obs)
Draws as much of the specified image as is currently available. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.Color bgcolor,
java.awt.image.ImageObserver obs)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver obs)
Draws as much of the specified image as has already been scaled to fit inside the specified rectangle. |
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 as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface. |
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 as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line. |
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 |
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 specified rectangle. |
void |
drawRenderableImage(java.awt.image.renderable.RenderableImage img,
java.awt.geom.AffineTransform xform)
Draws a renderable image |
void |
drawRenderedImage(java.awt.image.RenderedImage img,
java.awt.geom.AffineTransform xform)
Draws a rendered image |
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 iterator,
float x,
float y)
Renders the text of the specified iterator, using the Graphics2D context's current Paint . |
void |
drawString(java.text.AttributedCharacterIterator iterator,
int x,
int y)
Renders the text of the specified iterator, using the Graphics2D context's current Paint . |
void |
drawString(java.lang.String s,
float x,
float y)
Renders the text specified by the specified String ,
using the current Font and Paint attributes
in the Graphics2D context. |
void |
drawString(java.lang.String s,
int x,
int y)
Renders the text of the specified String , using the
current Font and Paint attributes in the
Graphics2D context. |
void |
fill(java.awt.Shape s)
Fills the interior of a Shape using the settings of the
Graphics2D context. |
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 |
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.Color |
getBackground()
Returns the background colour used for clearing a region. |
java.awt.Shape |
getClip()
Gets the current clipping area. |
java.awt.Rectangle |
getClipBounds()
Returns the bounding rectangle of the current clipping area. |
java.awt.Color |
getColor()
Gets this graphics context's current color. |
java.awt.Composite |
getComposite()
Returns the current Composite in the
Graphics2D context. |
java.awt.GraphicsConfiguration |
getDeviceConfiguration()
Returns the device configuration associated with this Graphics2D . |
java.awt.Font |
getFont()
Gets the current font. |
java.awt.FontMetrics |
getFontMetrics(java.awt.Font f)
Gets the font metrics for the specified font. |
java.awt.font.FontRenderContext |
getFontRenderContext()
Get the rendering context of the Font within this
Graphics2D context. |
java.awt.Paint |
getPaint()
Returns the current Paint of the
Graphics2D context. |
java.lang.Object |
getRenderingHint(java.awt.RenderingHints.Key hintKey)
Returns the value of a single preference for the rendering algorithms. |
java.awt.RenderingHints |
getRenderingHints()
Gets the preferences for the rendering algorithms. |
java.awt.Stroke |
getStroke()
Returns the current Stroke . |
java.awt.geom.AffineTransform |
getTransform()
Returns a copy of the current Transform in the
Graphics2D context. |
boolean |
hit(java.awt.Rectangle rect,
java.awt.Shape s,
boolean onStroke)
Checks whether or not the specified Shape intersects
the specified Rectangle, which is in device
space. |
void |
println(java.lang.String arg)
Print a line to the output. |
void |
println(java.lang.String[] arg)
Print a sequence of lines to the output. |
void |
printlnDef(java.lang.String arg)
Print a line to the defintion section. |
void |
rotate(double theta)
Concatenates the current Graphics2D
Transform with a rotation transform. |
void |
rotate(double theta,
double x,
double y)
Concatenates the current Graphics2D
Transform with a translated rotation
transform. |
void |
scale(double sx,
double sy)
Concatenates the current Graphics2D
Transform with a scaling transformation. |
void |
setBackground(java.awt.Color colour)
Sets the background colour for the Graphics2D context. |
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)
Store the current colour. |
void |
setComposite(java.awt.Composite comp)
Sets the current composite instance. |
void |
setFont(java.awt.Font font)
Sets the current font. |
void |
setPaint(java.awt.Paint paint)
Sets the Paint attribute for the
Graphics2D context. |
void |
setPaintMode()
Only plain paint mode is implemented for SVG. |
void |
setRenderingHint(java.awt.RenderingHints.Key hintKey,
java.lang.Object hintValue)
Sets the value of a single preference for the rendering algorithms. |
void |
setRenderingHints(java.util.Map hints)
Replaces the values of all preferences for the rendering algorithms with the specified hints . |
void |
setStroke(java.awt.Stroke s)
Sets the Stroke for the Graphics2D context. |
void |
setTransform(java.awt.geom.AffineTransform Tx)
Sets the Transform in the Graphics2D
context. |
void |
setXORMode(java.awt.Color c1)
Setting XOR mode. |
void |
shear(double shx,
double shy)
Concatenates the current Graphics2D
Transform with a shearing transform. |
void |
transform(java.awt.geom.AffineTransform Tx)
Composes an AffineTransform object with the
Transform in this Graphics2D according
to the rule last-specified-first-applied. |
void |
translate(double tx,
double ty)
Concatenates the current Graphics2D Transform
with a translation transform. |
void |
translate(int x,
int y)
Concatenates the current Graphics2D Transform . |
Methods inherited from class java.awt.Graphics2D |
---|
draw3DRect, fill3DRect |
Methods inherited from class java.awt.Graphics |
---|
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected SVGGraphics()
protected SVGGraphics(java.io.PrintStream o, java.awt.Component origin)
create
calls instead.
o
- output stream for the svg contentorigin
- the "parent" component. Its bounds will be used to determine the
svg width and height parameters. If null, the values 400 and 400 will be used.create(java.io.PrintStream, java.awt.Component)
Method Detail |
---|
public void println(java.lang.String[] arg)
arg
- texts to be put appende to the output streampublic void println(java.lang.String arg)
arg
- text to be put appende to the output streampublic void printlnDef(java.lang.String arg)
arg
- text to be put append to the output streampublic static SVGGraphics create(java.io.PrintStream o, java.awt.Component origin)
SVGGraphics
object.
o
- output stream for the svg contentorigin
- the "parent" component. Its bounds will be used to determine the
svg width and height parameters. If null, the values 400 and 400 will be used.
SVGGraphics
object.public static SVGGraphics create(java.awt.Component origin)
SVGGraphics
object through a file picker widget. The user can select a file
through the widget, which will be used for output.
origin
- the "parent" component. Its bounds will be used to determine the
svg width and height parameters. If null, the values 400 and 400 will be used.
public void close(boolean closeFile)
closeFile
- if true, a 'close' command will also be issued on the PrintStream
, too.public void close()
PrintStream
object will also be closed.
public void dispose()
close
. In this sense, using this method is an alternative
to the close
method.
dispose
in class java.awt.Graphics
close(boolean)
public java.awt.Graphics create()
Graphics
object that is
a copy of this Graphics
object. This method is mandated by the
superclass but,
for the case of SVG, it does not
really make sense, because the internal buffers are not be copied. The call is
here to make the java compiler happy...
create
in class java.awt.Graphics
public void translate(double tx, double ty)
Graphics2D
Transform
with a translation transform. A new group will be created in SVG.
translate
in class java.awt.Graphics2D
tx
- the distance to translate along the x-axisty
- the distance to translate along the y-axispublic void translate(int x, int y)
Graphics2D
Transform
. A new group will be created in SVG.
translate
in class java.awt.Graphics2D
x
- the x coordinate.y
- the y coordinate.public void rotate(double theta)
Graphics2D
Transform
with a rotation transform. A new group will be created in SVG.
x axis toward the positive y axis.
rotate
in class java.awt.Graphics2D
theta
- the angle of rotation in radianspublic void rotate(double theta, double x, double y)
Graphics2D
Transform
with a translated rotation
transform. A new group will be created in SVG.
rotate
in class java.awt.Graphics2D
theta
- the angle of rotation in radiansx, y
- coordinates of the origin of the rotationpublic void scale(double sx, double sy)
Graphics2D
Transform
with a scaling transformation. A new group will be created in SVG.
scale
in class java.awt.Graphics2D
sx
- the amount by which X coordinates in subsequent
rendering operations are multiplied relative to previous
rendering operations.sy
- the amount by which Y coordinates in subsequent
rendering operations are multiplied relative to previous
rendering operations.public void shear(double shx, double shy)
Graphics2D
Transform
with a shearing transform. A new group will be created in SVG.
shear
in class java.awt.Graphics2D
shx
- the multiplier by which coordinates are shifted in
the positive X axis direction as a function of their Y coordinateshy
- the multiplier by which coordinates are shifted in
the positive Y axis direction as a function of their X coordinatepublic void transform(java.awt.geom.AffineTransform Tx)
AffineTransform
object with the
Transform
in this Graphics2D
according
to the rule last-specified-first-applied. A new group will be created in SVG.
transform
in class java.awt.Graphics2D
Tx
- the AffineTransform
object to be composed with
the current Transform
setTransform(java.awt.geom.AffineTransform)
,
AffineTransform
public void setTransform(java.awt.geom.AffineTransform Tx)
Transform
in the Graphics2D
context. A new group will be created in SVG.
setTransform
in class java.awt.Graphics2D
Tx
- the AffineTransform
object to be used in the
rendering processpublic java.awt.geom.AffineTransform getTransform()
Transform
in the
Graphics2D
context.
getTransform
in class java.awt.Graphics2D
AffineTransform
in the
Graphics2D
context.public java.awt.Color getColor()
getColor
in class java.awt.Graphics
public void setColor(java.awt.Color c)
Color
also
implements the Paint
interface.
setColor
in class java.awt.Graphics
c
- new colour objectpublic void setPaint(java.awt.Paint paint)
Paint
attribute for the
Graphics2D
context.
The TexturePaint
requires that the image would
should have the "url" property!
setPaint
in class java.awt.Graphics2D
paint
- new paint objectpublic java.awt.Paint getPaint()
Paint
of the
Graphics2D
context.
getPaint
in class java.awt.Graphics2D
Graphics2D
Paint
,
which defines a color or pattern.public void setBackground(java.awt.Color colour)
Graphics2D
context.
setBackground
in class java.awt.Graphics2D
colour
- the background colour that is used in
subsequent calls to clearRect
public java.awt.Color getBackground()
getBackground
in class java.awt.Graphics2D
Color
,
which defines the background color.setBackground(java.awt.Color)
public void setPaintMode()
setPaintMode
in class java.awt.Graphics
public void setXORMode(java.awt.Color c1)
XOR mode is not implemented!
setXORMode
in class java.awt.Graphics
public void setStroke(java.awt.Stroke s)
Stroke
for the Graphics2D
context.
A new group will be created in SVG.
The only implementing class of this interface in Java 1.2 is BasicStroke
,
and this assumption is used in the code (to retrieve linewidth, dash array, etc.). If users
add their own Stroke
implementations, or if new ones appear in later releases
of Java, this has to be extended.
setStroke
in class java.awt.Graphics2D
s
- the Stroke
object to be used to stroke a
Shape
during the rendering processpublic java.awt.Stroke getStroke()
Stroke
.
getStroke
in class java.awt.Graphics2D
setStroke(java.awt.Stroke)
public void setComposite(java.awt.Composite comp)
The only implementing class of this interface in Java 1.2 is AlphaComposite
,
and this assumption is used in the code (to retrieve alpha values). If users
add their own Composite
implementations, or if new ones appear in later releases
of Java, this has to be extended.
The only used attribute of the composite class is the alpha value (through the
getAlpha()
) which is used to set the opacity. I would not know, at this moment,
how to translate the complicated composition rules of Java into SVG statements.
setComposite
in class java.awt.Graphics2D
comp
- the Composite
object to be used for rendering.public java.awt.Composite getComposite()
Composite
in the
Graphics2D
context.
getComposite
in class java.awt.Graphics2D
Graphics2D
Composite
,
which defines a compositing style.setComposite(java.awt.Composite)
public java.awt.Font getFont()
getFont
in class java.awt.Graphics
public void setFont(java.awt.Font font)
There are some small problems in implementing this method. Indeed, a java user can also set a "logical" font, ie, using a "logical" name for the font instead of the exact family. Of course, the set of available logical names in Java (Dialog, DialogInput, Monospaces, Serif, SansSerif, and Symbol) is not identical with SVG (more exactly, CSS). It is not clear in Java what Dialog and DialogInput mean and there is no such symbolic font name in CSS either. On a Windows NT environment Dialog seems to be mapped onto sans serif, and DialogInput seems to be mapped to monospaced, so this is what is used.
If "real" font family name is used, it is used without any change for SVG.
setFont
in class java.awt.Graphics
font
- the new fontpublic java.awt.FontMetrics getFontMetrics(java.awt.Font f)
This is only partially implemented. There is no real way of inquiring about font data in SVG, so this method is only approximative. As a help for the user, if the "parent" component has been set, then the font metrics generated by that component is returned.
getFontMetrics
in class java.awt.Graphics
f
- the specified font
public void drawString(java.lang.String s, int x, int y)
String
, using the
current Font
and Paint
attributes in the
Graphics2D
context.
drawString
in class java.awt.Graphics2D
s
- the string to be dislplayedx
- x coordinate for the start of the stringy
- y coordinate for the start of the stringpublic void drawString(java.lang.String s, float x, float y)
String
,
using the current Font
and Paint
attributes
in the Graphics2D
context.
drawString
in class java.awt.Graphics2D
str
- the string to be dislplayedx
- x coordinate for the start of the stringy
- y coordinate for the start of the stringpublic void drawString(java.text.AttributedCharacterIterator iterator, int x, int y)
Graphics2D
context's current Paint
.
This method is not yet implemented.
drawString
in class java.awt.Graphics2D
iterator
- character iteratorx
- x coordinate for the start of the stringy
- y coordinate for the start of the stringpublic void drawString(java.text.AttributedCharacterIterator iterator, float x, float y)
Graphics2D
context's current Paint
.
This method is not yet implemented.
drawString
in class java.awt.Graphics2D
iterator
- character iteratorx
- x coordinate for the start of the stringy
- y coordinate for the start of the stringpublic void drawGlyphVector(java.awt.font.GlyphVector g, float x, float y)
Graphics2D
context's rendering attributes.
This method is not yet implemented.
drawGlyphVector
in class java.awt.Graphics2D
g
- glyph vectorx
- x coordinate for the start of the stringy
- y coordinate for the start of the stringpublic java.awt.Rectangle getClipBounds()
setClip(null)
, this method returns
null
.
getClipBounds
in class java.awt.Graphics
null
if no clip is set.public void clipRect(int x, int y, int width, int height)
setClip(null)
,
the specified rectangle becomes the new clip.
The intersection of clips with existing shapes is not implemented yet.
In other words, this method is void, unless the current clip shape is not yet
set, in which case it is equivalent to a setClip
call.
clipRect
in class java.awt.Graphics
x
- upper left hand corner x coordinatey
- upper left hand corner y coordinatewidth
- width of the rectangleheight
- height of the rectanglepublic void setClip(int x, int y, int width, int height)
clipPath
is generated.
setClip
in class java.awt.Graphics
x
- upper left hand corner x coordinatey
- upper left hand corner y coordinatewidth
- width of the rectangleheight
- height of the rectanglepublic java.awt.Shape getClip()
getClip
in class java.awt.Graphics
public void setClip(java.awt.Shape clip)
In SVG, a clipPath
is generated.
setClip
in class java.awt.Graphics
clip
- the clip shapepublic void copyArea(int x, int y, int width, int height, int dx, int dy)
dx
and dy
.
This method is not yet implemented.
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 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 draw(java.awt.Shape s)
Shape
using the settings of the
current Graphics2D
context.
draw
in class java.awt.Graphics2D
s
- the Shape
to be renderedpublic void fill(java.awt.Shape s)
Shape
using the settings of the
Graphics2D
context. .
fill
in class java.awt.Graphics2D
s
- the Shape
to be filledpublic 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 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.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.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.public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
At present, the rounded rectangle is replaced by a plain rectangle. (SVG does not have the notion of rounded rectangle, and an appropriate path should be calculated instead, which has not been done.)
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.public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
At present, the rounded rectangle is replaced by a plain rectangle. (SVG does not have the notion of rounded rectangle, and an appropriate path should be calculated instead, which has not been done.)
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.public void drawOval(int x, int y, int width, int height)
An ellipse
statement is generated in SVG.
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.public void fillOval(int x, int y, int width, int height)
An ellipse
statement is generated in SVG.
fillOval
in class java.awt.Graphics
x
- the x coordinate of the upper left corner
of the oval to be filled.y
- the y coordinate of the upper left corner
of the oval to be filled.width
- the width of the oval to be filled.height
- the height of the oval to be filled.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.arcAngle
- the angular extent of the arc,
relative to the start angle.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 filled.y
- the y coordinate of the
upper-left corner of the arc to be filled.width
- the width of the arc to be filled.height
- the height of the arc to be filled.startAngle
- the beginning angle.arcAngle
- the angular extent of the arc,
relative to the start angle.Graphics.drawArc(int, int, int, int, int, int)
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
drawPolyline
in class java.awt.Graphics
xPoints
- an array of x pointsyPoints
- an array of y pointsnPoints
- the total number of pointsGraphics.drawPolygon(int[], int[], int)
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
drawPolygon
in class java.awt.Graphics
xPoints
- a an array of x
coordinates.yPoints
- a an array of y
coordinates.nPoints
- a the total number of points.public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
fillPolygon
in class java.awt.Graphics
xPoints
- a an array of x
coordinates.yPoints
- a an array of y
coordinates.nPoints
- a the total number of points.Graphics.drawPolygon(int[], int[], int)
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver obs)
The image has to have the property "url"
. See comments
on the class level for further details.
drawImage
in class java.awt.Graphics
img
- the specified image to be drawn.x
- the x coordinate.y
- the y coordinate.obs
- object to be notified as more of
the image is converted.public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver obs)
The image has to have the property "url"
. See comments
on the class level for further details.
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
- object to be notified as more of
the image is converted.public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)
The image has to have the property "url"
. See comments
on the class level for further details.
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
- object to be notified as more of
the image is converted.public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver obs)
The image has to have the property "url"
. See comments
on the class level for further details.
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
- object to be notified as more of
the image is converted.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)
Cutting part of the image is not yet implemented. (It would probably require to use some of the image filters defined in SVG, but this has not been checked.)
drawImage
in class java.awt.Graphics
img
- the specified image to be drawndx1
- 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
- object to be notified as more of the image is
scaled and converted.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)
Cutting part of the image is not yet implemented. (It would probably require to use some of the image filters defined in SVG, but this has not been checked.)
drawImage
in class java.awt.Graphics
img
- the specified image to be drawndx1
- 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.bgcolor
- the background color to paint under the
non-opaque portions of the image.observer
- object to be notified as more of the image is
scaled and converted.public boolean drawImage(java.awt.Image img, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver obs)
The method is implemented by enclosing a usual image call into a group with the right transformation.
The image has to have the property "url"
. See comments
on the class level for further details.
drawImage
in class java.awt.Graphics2D
img
- the Image
to be renderedxform
- the transformation from image space into user spaceobs
- the ImageObserver
to be notified as more of the Image
is converted
true
if the image could be displayed, and false
otherwise.public void drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)
BufferedImage
.
Handling of Buffered Images is not implemented.
drawImage
in class java.awt.Graphics2D
op
- the filter to be applied to the image before renderingimg
- the BufferedImage
to be renderedx, y
- the location in user space where the upper left
corner of the
image is renderedtransform(java.awt.geom.AffineTransform)
,
setTransform(java.awt.geom.AffineTransform)
,
setComposite(java.awt.Composite)
,
clip(java.awt.Shape)
,
setClip(int, int, int, int)
public void drawRenderedImage(java.awt.image.RenderedImage img, java.awt.geom.AffineTransform xform)
Handling of rendered images is not implemented.
drawRenderedImage
in class java.awt.Graphics2D
img
- the image to be renderedxform
- the transformation from image space into user spacetransform(java.awt.geom.AffineTransform)
,
setTransform(java.awt.geom.AffineTransform)
,
setComposite(java.awt.Composite)
,
clip(java.awt.Shape)
,
setClip(int, int, int, int)
public void drawRenderableImage(java.awt.image.renderable.RenderableImage img, java.awt.geom.AffineTransform xform)
Handling of renderable images is not implemented.
drawRenderableImage
in class java.awt.Graphics2D
img
- the image to be renderedxform
- the transformation from image space into user spacetransform(java.awt.geom.AffineTransform)
,
setTransform(java.awt.geom.AffineTransform)
,
setComposite(java.awt.Composite)
,
clip(java.awt.Shape)
,
setClip(int, int, int, int)
,
drawRenderedImage(java.awt.image.RenderedImage, java.awt.geom.AffineTransform)
public boolean hit(java.awt.Rectangle rect, java.awt.Shape s, boolean onStroke)
Shape
intersects
the specified Rectangle, which is in device
space.
hit
in class java.awt.Graphics2D
true
if there is a hit; false
otherwise.public void setRenderingHint(java.awt.RenderingHints.Key hintKey, java.lang.Object hintValue)
This method has no effect in SVG.
setRenderingHint
in class java.awt.Graphics2D
hintKey
- the key of the hint to be set.hintValue
- the value indicating preferences for the specified
hint category.RenderingHints
public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)
The returned values are constants and, in a sense, meaningless. The rendering quality depends on the quality of the SVG browser, and not the SVG file itself, so the assumption is that the browser is of the highest quality.
getRenderingHint
in class java.awt.Graphics2D
hintKey
- the key corresponding to the hint to get.
RenderingHints
class.RenderingHints
public void setRenderingHints(java.util.Map hints)
hints
.
The method is void and, in a sense, meaningless. The rendering quality depends on the quality of the SVG browser, and not the SVG file itself, so the assumption is that the browser is of the highest quality.
setRenderingHints
in class java.awt.Graphics2D
hints
- the rendering hints to be setRenderingHints
public void addRenderingHints(java.util.Map hints)
The method is void and, in a sense, meaningless. The rendering quality depends on the quality of the SVG browser, and not the SVG file itself, so the assumption is that the browser is of the highest quality.
addRenderingHints
in class java.awt.Graphics2D
hints
- the rendering hints to be setRenderingHints
public java.awt.RenderingHints getRenderingHints()
The returned values are constants and, in a sense, meaningless. The rendering quality depends on the quality of the SVG browser, and not the SVG file itself, so the assumption is that the browser is of the highest quality.
getRenderingHints
in class java.awt.Graphics2D
RenderingHints
that contains the current preferences.RenderingHints
public void clip(java.awt.Shape s)
Clip
with the interior of the
specified Shape
and sets the Clip
to the
resulting intersection.
This method has not been implemented yet.
clip
in class java.awt.Graphics2D
s
- the Shape
to be intersected with the current
Clip
. If s
is null
,
this method clears the current Clip
.public java.awt.font.FontRenderContext getFontRenderContext()
Font
within this
Graphics2D
context.
There is no real counterpart in SVG for this. As a help to the user, if the parent component has been set and there is a current font, the rendering context for that environment is returned. This might help in having an idea on how big the chain of character will be, for example.
getFontRenderContext
in class java.awt.Graphics2D
public java.awt.GraphicsConfiguration getDeviceConfiguration()
Graphics2D
.
The implementation is fake. Just to give an indication to the user, it returns the graphics configuration of the "parent" (i.e., "real") component, although this might be meaningless for the display of the SVG file.
getDeviceConfiguration
in class java.awt.Graphics2D
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |