|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectscenic.ScenicGraphics
public class ScenicGraphics
ScenicGraphics class offers an easy to use interface for creating scene trees. Instead of creating scene graphs directly, Graphics class has a more traditional method-based interface. The Graphics class transforms the method calls into appropriate scene graphs. Paths can be created using methods that create lines, curves, arcs and rectangles These paths can then be either stroked, filled or clipped to. Text can also be drawn using simple method calls. The current affine transformation can easily be changed using different methods which translate, scale or rotate the current transformation. The Graphics object also has a stack which can be used to store and restore the state of the Graphics object.
| Constructor Summary | |
|---|---|
ScenicGraphics(SceneContainer scene)
Constructs a new Graphics object using the given SceneContainer as the root node. |
|
ScenicGraphics(SceneContainer scene,
java.awt.geom.AffineTransform transform)
Constructs a new Graphics object using the given SceneContainer as the root node. |
|
ScenicGraphics(ScenicGraphics parent)
Construct a new ScenicGraphics object that inherits the state of the given ScenicGraphics object. |
|
| Method Summary | |
|---|---|
void |
add(SceneNode node)
Adds a scene node to the scene. |
void |
arc(double x,
double y,
double xRadius,
double yRadius,
double rotation,
double startAngle,
double stopAngle)
Draws an elliptic arc starting from the given position. |
void |
arcTo(double xRadius,
double yRadius,
double rotation,
double startAngle,
double stopAngle)
Draws an elliptic arc starting from the current position. |
void |
clear()
Clears the current scene. |
void |
clip()
Clips to the area inside the current path. |
void |
clipTo(SceneNode clipScene)
Clips graphics using the given clip scene. |
void |
close()
Closes the current subpath. |
ScenicGraphics |
create()
Creates a copy of this graphics object. |
void |
curveTo(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
Draws a quadratic Bezier-curve using the given control points. |
void |
curveTo(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2,
java.awt.geom.Point2D p3)
Draws a cubic Bezier-curve using the given control points. |
void |
drawGlyphs(int[] glyphCodes,
float[] positions)
Draws the given glyphs using the current font, fill color and other settings. |
void |
drawImage(ScenicImage img)
Draws an image. |
void |
drawImage(ScenicImage img,
java.awt.geom.Rectangle2D sourceRect)
Draws the given part of an image. |
void |
drawText(java.lang.String text)
Draws the given text using the current font, fill color and other settings. |
void |
drawText(java.lang.String text,
float[] positions)
Draws the given text using the current font, fill color and other settings. |
void |
fill()
Fills the current path. |
void |
fillAndStroke()
Fills and strokes the current path. |
Path |
getPath()
Gets a Path object that contains the current path. |
double |
getPixelSize()
Gets the square root of the area of a 1 by 1 rectangle when transformed into screen coordinates. |
java.awt.geom.Rectangle2D |
getTextLogicalBounds(java.lang.String text)
Returns the logical bounds of the given text. |
java.awt.geom.AffineTransform |
getTransform()
Gets the total transformation of the current scene node. |
void |
lineTo(double x,
double y)
Draws a straight line to the given position. |
void |
moveTo(double x,
double y)
Begins a new subpath from the given position. |
void |
pop()
Pops the state from the stack. |
void |
push()
Pushes the state of this object into the stack. |
void |
rectangle(double x,
double y,
double width,
double height)
Draws a rectangle. |
void |
rotate(double angle)
Rotates the current transformation by the given angle. |
void |
rotate(double angle,
double pivotX,
double pivotY)
Rotates the current transformation around the given pivot point by the given angle. |
void |
roundedRectangle(double x,
double y,
double width,
double height,
double radius)
Draws a rectangle with rounded edges. |
void |
scale(double x,
double y)
Scales the current transformation matrix by the given amount. |
void |
setAntialias(boolean aa)
Sets antialiasing. |
void |
setAntialiasingFilter(Filter filter)
Sets the filter that is used for antialiasing. |
void |
setDashArray(float[] lineDashLengths)
Sets the line dash pattern. |
void |
setDashPhase(double lineDashPhase)
Sets the phase of the line dash pattern. |
void |
setEndCap(int lineCap)
Sets the line cap style. |
void |
setFillBrush(SceneNode brush)
Sets the brush used for filling paths and drawing text. |
void |
setFillColor(ScenicColor c)
Sets the color that is used for filling paths and drawing text. |
void |
setFont(java.awt.Font font)
Sets the current font. |
void |
setLineJoin(int lineJoin)
Sets the line join style. |
void |
setLineWidth(double width)
Sets the line width. |
void |
setMiterLimit(double miterLimit)
Sets the miter limit. |
void |
setStrokeBrush(SceneNode brush)
Sets the brush used for stroking paths. |
void |
setStrokeColor(ScenicColor c)
Sets the color that is used for stroking paths. |
void |
setTextPosition(double x,
double y)
Sets the text position. |
void |
setUsesFractionalFontMetrics(boolean b)
Sets whatever fractional metrics are used to calculate glyph bounds. |
void |
shear(double x,
double y)
Shears the current transformation matrix by the given amount. |
void |
stroke()
Strokes the current path. |
void |
transform(java.awt.geom.AffineTransform m)
Multiplies the current transformation matrix with the given affine transform. |
void |
translate(double dx,
double dy)
Translates the current transformation matrix by the given displacement. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ScenicGraphics(SceneContainer scene,
java.awt.geom.AffineTransform transform)
scene - The root node into which graphics is drawn.transform - The transformation matrix of the root node.public ScenicGraphics(SceneContainer scene)
scene - The root node into which graphics is drawn.public ScenicGraphics(ScenicGraphics parent)
parent - the parent object| Method Detail |
|---|
public ScenicGraphics create()
public void clear()
public void push()
public void pop()
public void transform(java.awt.geom.AffineTransform m)
m - the affine transform
public void translate(double dx,
double dy)
dx - x coordinate of the translationdy - y coordinate of the translation
public void scale(double x,
double y)
x - x coordinate of the scale factory - y coordinate of the scale factorpublic void rotate(double angle)
angle - rotation in degrees.
public void rotate(double angle,
double pivotX,
double pivotY)
angle - rotation in degrees.pivotX - x coordinate of the pivot point.pivotY - y coordinate of the pivot point.
public void shear(double x,
double y)
x - x coordinate of the shear factory - y coordinate of the shear factorpublic java.awt.geom.AffineTransform getTransform()
public double getPixelSize()
public void setStrokeColor(ScenicColor c)
c - stroke color.public void setStrokeBrush(SceneNode brush)
brush - brush used for stroking.public void setFillColor(ScenicColor c)
c - fill color.public void setFillBrush(SceneNode brush)
brush - brush used for filling.public void setFont(java.awt.Font font)
font - the font.
public void setTextPosition(double x,
double y)
x - x coordinate of the text position.y - y coordinate of the text position.public void setLineWidth(double width)
width - the line width.public void setEndCap(int lineCap)
lineCap - the line cap style.public void setLineJoin(int lineJoin)
lineJoin - the line join style.public void setMiterLimit(double miterLimit)
miterLimit - the miter limit.public void setDashArray(float[] lineDashLengths)
lineDashLengths - the line dash pattern.public void setDashPhase(double lineDashPhase)
lineDashPhase - the line dash phase.public void setAntialias(boolean aa)
aa - the antialiasing setting.public void setAntialiasingFilter(Filter filter)
filter - antialiasing filterpublic void setUsesFractionalFontMetrics(boolean b)
b - the fractional metrics setting.public void drawText(java.lang.String text)
text - the text to be drawn.
public void drawText(java.lang.String text,
float[] positions)
text - the text to be drawn.positions - the positions of the characters.
public void drawGlyphs(int[] glyphCodes,
float[] positions)
glyphCodes - the glyph codes.positions - the positions of the characters.public java.awt.geom.Rectangle2D getTextLogicalBounds(java.lang.String text)
text - the text.
public void moveTo(double x,
double y)
public void lineTo(double x,
double y)
public void curveTo(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
p1 - the second control point.p2 - the third control point.
public void curveTo(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2,
java.awt.geom.Point2D p3)
p1 - the second control point.p2 - the third control point.p3 - the fourth control point.
public void arcTo(double xRadius,
double yRadius,
double rotation,
double startAngle,
double stopAngle)
xRadius - the x radius of the ellipse.yRadius - the y radius of the ellipse.rotation - the rotation of the ellipse in degrees.startAngle - the start angle of the arc in degrees.stopAngle - the stop angle of the arc in degrees.
public void arc(double x,
double y,
double xRadius,
double yRadius,
double rotation,
double startAngle,
double stopAngle)
x - the x-coordinate of the starting point of the arc.y - the y-coordinate of the starting point of the arc.xRadius - the x radius of the ellipse.yRadius - the y radius of the ellipse.rotation - the rotation of the ellipse in degrees.startAngle - the start angle of the arc in degrees.stopAngle - the stop angle of the arc in degrees.
public void rectangle(double x,
double y,
double width,
double height)
x - the left side of the rectangle.y - the top of the rectangle.width - the width of the rectangle.height - the height of the rectangle.
public void roundedRectangle(double x,
double y,
double width,
double height,
double radius)
x - the left side of the rectangle.y - the top of the rectangle.width - the width of the rectangle.height - the height of the rectangle.radius - the radius of the rounded edges.public void close()
public void stroke()
public void fill()
public void fillAndStroke()
public void clip()
public void drawImage(ScenicImage img)
img - the image.
public void drawImage(ScenicImage img,
java.awt.geom.Rectangle2D sourceRect)
img - the image.sourceRect - the part of the image that is displayed.public Path getPath()
public void add(SceneNode node)
node - the scene node top be added.public void clipTo(SceneNode clipScene)
clipScene - the scene node that is used for clipping.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||