|
UC Berkeley Group for User Interface Research Updated November 17, 2000 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Graphics | +--java.awt.Graphics2D | +--edu.berkeley.guir.lib.satin.graphics.SatinGraphics
The Satin Graphics context, an extension of Graphics2D. Has some additional capabilities, such as drawing with Styles, and a stack of Transforms.
This software is distributed under the Berkeley Software License.
Revisions: - SATIN-v1.0-1.0.0, Apr 15 1999, JH Created class - SATIN-v2.1-1.0.0, Aug 11 2000, JH Touched for SATIN release
Fields inherited from interface edu.berkeley.guir.lib.satin.graphics.GraphicsConstants |
BOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT, CENTER, HIGH_QUALITY, HIGHEST_QUALITY, LEFT, LOW_QUALITY, LOWEST_QUALITY, MEDIUM_QUALITY, RIGHT, TOP, TOP_LEFT, TOP_RIGHT |
Constructor Summary | |
SatinGraphics()
Be sure the call setGraphics() before using. |
|
SatinGraphics(Graphics2D newG)
Create a wrapper around the specified Graphics2D object. |
Method Summary | |
void |
addRenderingHints(Map hints)
|
static Point |
calculateNewPosition(Shape shape,
int pos)
Shift an object to have new coordinates. |
static Point |
calculateTranslation(Shape shape,
int x,
int y,
int pos)
Calculate how much a Shape should be translated along x- and y- such that the specified position of the Shape will be at the specified (x,y) coordinate. |
void |
clearAllTransforms()
Clear out all transforms. |
void |
clearRect(int x,
int y,
int width,
int height)
|
void |
clip(Shape s)
|
void |
clipRect(int x,
int y,
int width,
int height)
|
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
|
Graphics |
create()
|
Graphics |
create(int x,
int y,
int width,
int height)
|
void |
dispose()
|
void |
dontIgnoreTransforms()
Restore the current transforms. |
void |
draw(Shape s)
|
void |
draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
|
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
|
void |
drawBytes(byte[] data,
int offset,
int length,
int x,
int y)
|
void |
drawChars(char[] data,
int offset,
int length,
int x,
int y)
|
void |
drawGlyphVector(GlyphVector gv,
float x,
float y)
|
void |
drawImage(BufferedImage img,
BufferedImageOp op,
int x,
int y)
Transparency not implemented for this method yet. |
boolean |
drawImage(Image img,
AffineTransform xform,
ImageObserver obs)
|
boolean |
drawImage(Image img,
int x,
int y,
Color bgcolor,
ImageObserver observer)
|
boolean |
drawImage(Image img,
int x,
int y,
ImageObserver observer)
|
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
ImageObserver observer)
|
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer)
|
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
Color bgcolor,
ImageObserver observer)
|
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer)
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
|
void |
drawOval(int x,
int y,
int width,
int height)
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
|
void |
drawPolygon(Polygon p)
|
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
|
void |
drawRect(int x,
int y,
int width,
int height)
|
void |
drawRect(int x,
int y,
int width,
int height,
int pos)
|
void |
drawRect(Rectangle rect)
This is a convenience method, since Java doesn't let you just draw Rectangles. |
void |
drawRect(Rectangle rect,
int pos)
Draw a Rectangle, and qualify what the coordinates are supposed to be. |
void |
drawRenderableImage(RenderableImage img,
AffineTransform xform)
|
void |
drawRenderedImage(RenderedImage img,
AffineTransform xform)
|
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
|
void |
drawString(AttributedCharacterIterator iterator,
float x,
float y)
|
void |
drawString(AttributedCharacterIterator iterator,
int x,
int y)
|
void |
drawString(String s,
float x,
float y)
|
void |
drawString(String str,
int x,
int y)
|
void |
drawString(String str,
int x,
int y,
int pos)
Draw a String at the specified coordinates, and qualifying what the coordinates are supposed to be. |
void |
fill(Shape s)
|
void |
fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
|
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
|
void |
fillOval(int x,
int y,
int width,
int height)
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
|
void |
fillPolygon(Polygon p)
|
void |
fillRect(int x,
int y,
int width,
int height)
|
void |
fillRect(int x,
int y,
int width,
int height,
int pos)
Fills the Rectangle. |
void |
fillRect(Rectangle rect,
int pos)
Fills the Rectangle. |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
|
void |
finalize()
|
Color |
getBackground()
|
Shape |
getClip()
|
Rectangle |
getClipBounds()
|
Rectangle |
getClipBounds(Rectangle r)
|
Rectangle |
getClipRect()
|
Color |
getColor()
|
Composite |
getComposite()
|
GraphicsConfiguration |
getDeviceConfiguration()
|
Font |
getFont()
|
FontMetrics |
getFontMetrics()
|
FontMetrics |
getFontMetrics(Font f)
|
FontRenderContext |
getFontRenderContext()
|
Graphics2D |
getGraphics()
Get the current Graphics context. |
Point |
getOrigin()
Get where the current origin is. |
Paint |
getPaint()
|
Object |
getRenderingHint(RenderingHints.Key hintKey)
|
RenderingHints |
getRenderingHints()
|
Stroke |
getStroke()
|
Style |
getStyle()
Get the current drawing Style. |
AffineTransform |
getTransform()
|
float |
getTransparency()
Get the current transparency value. |
boolean |
hit(Rectangle rect,
Shape s,
boolean onStroke)
|
boolean |
hitClip(int x,
int y,
int width,
int height)
|
void |
ignoreTransforms()
Temporarily ignore the current transform, restoring it to the default transform. |
void |
popOrigin()
Go back to the previous origin coordinates. |
void |
popStyle()
Pop a Style off the Stack, restoring the previous Style. |
void |
popTransform()
Undo the last transform. |
void |
pushOrigin(int x,
int y)
Specify where the origin of the graphics should be relative to. |
void |
pushOrigin(Point pt)
Specify where the origin of the graphics should be relative to. |
void |
pushStyle(Style s)
Push a new Style onto the Stack for this Graphics to use. |
void |
pushTransform(AffineTransform tx)
Apply a new transform to this SatinGraphics context. |
void |
rotate(double theta)
Applies the specified transformation. |
void |
rotate(double theta,
double x,
double y)
Applies the specified transformation. |
void |
scale(double sx,
double sy)
Applies the specified transformation. |
void |
setBackground(Color color)
|
void |
setClip(int x,
int y,
int width,
int height)
|
void |
setClip(Shape clip)
|
void |
setColor(Color c)
Sets the current style to use the specified Color. |
void |
setComposite(Composite comp)
|
void |
setDefaultTransform(AffineTransform tx)
Set the transform that will be used when ignoreTransforms() is called. |
void |
setFont(Font font)
Sets the current style to use the specified Color. |
void |
setGraphics(Graphics2D newG)
Set the graphics context to draw with. |
void |
setPaint(Paint paint)
|
void |
setPaintMode()
|
void |
setRenderingHint(RenderingHints.Key hintKey,
Object hintValue)
|
void |
setRenderingHints(Map hints)
|
void |
setRenderQuality(int value)
Set the quality / speed level of rendering. |
void |
setStroke(Stroke s)
Sets the current style to use the specified Stroke. |
void |
setTransform(AffineTransform Tx)
Sets the current transform to the specified AffineTransform. |
void |
setTransparency(float val)
Set the overall transparency of all things drawn in this Graphics context. |
void |
setXORMode(Color c1)
|
void |
shear(double shx,
double shy)
Applies the specified transformation. |
String |
toString()
|
void |
transform(AffineTransform Tx)
Applies the specified transformation. |
void |
translate(double tx,
double ty)
Applies the specified transformation. |
void |
translate(int x,
int y)
Applies the specified transformation. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SatinGraphics()
public SatinGraphics(Graphics2D newG)
newG
- is the Graphics2D object we will delegate to.Method Detail |
public final void setRenderQuality(int value)
setGraphics(Graphics2D)
.
Use one of the following values as the parameter for quality:
GraphicsConstants.HIGHEST_QUALITY
GraphicsConstants.HIGH_QUALITY
GraphicsConstants.MEDIUM_QUALITY
GraphicsConstants.LOW_QUALITY
GraphicsConstants.LOWEST_QUALITY
public final void setGraphics(Graphics2D newG)
newG
- is the graphics context to set to.public final Graphics2D getGraphics()
public final void pushStyle(Style s)
s
- is the Style to use.getStyle()
,
popStyle()
public final void popStyle()
getStyle()
,
pushStyle(edu.berkeley.guir.lib.satin.objects.Style)
public final Style getStyle()
popStyle()
,
pushStyle(Style)
public final void setTransparency(float val)
val
- is a value between 0 and 1, 0 meaning fully transparent and
1 meaning fully solid.public final float getTransparency()
public final void pushOrigin(int x, int y)
x
- is the origin's new x-position.y
- is the origin's new y-position.getOrigin()
,
popOrigin()
,
pushTransform(java.awt.geom.AffineTransform)
public final void pushOrigin(Point pt)
pt
- is the new origin.getOrigin()
,
popOrigin()
,
pushOrigin(int, int)
public final void popOrigin()
getOrigin()
,
pushOrigin(java.awt.Point)
,
pushOrigin(int, int)
public final Point getOrigin()
popOrigin()
,
pushOrigin(java.awt.Point)
,
pushOrigin(int, int)
public final void clearAllTransforms()
public final void setDefaultTransform(AffineTransform tx)
public final void ignoreTransforms()
dontIgnoreTransforms()
is called.
This method is useful for Sticky views, like
StickyViewWrapper
and
StickyZViewWrapper
.
Be sure to call dontIgnoreTransforms()
before you push or
pop any transforms from the stack. Really bad things [tm] will happen
if you don't.
public final void dontIgnoreTransforms()
ignoreTransforms()
has been called earlier.public final void pushTransform(AffineTransform tx)
tx
- is the AffineTransform to apply.popTransform()
public final void popTransform()
pushTransform(java.awt.geom.AffineTransform)
public static Point calculateNewPosition(Shape shape, int pos)
Suppose you have a Rectangle, and you want to draw it such that it is centered at (0,0). Just call calculateNewPosition(rect, SatinGraphics.CENTER) to figure out where the top-left corner of the Rectangle should be drawn. Pretty neat, eh?
shape
- is some shape to draw.pos
- specifies where to shift the drawing to
(GraphicsConstants.CENTER
,
GraphicsConstants.TOP_LEFT
, etc).public static Point calculateTranslation(Shape shape, int x, int y, int pos)
For example, say you already have a circle, and want to draw this circle with (0,0) as its center. Just call calculateTranslation(circle, 0, 0, CENTER) to figure out how much the shape should be translated.
shape
- is the Shape to determine how much to move. Make sure
that the coordinates of shape are in the same coordinate
system as x and y below.x
- is the x-coordinate to move it to.y
- is the y-coordinate to move it to.pos
- is the position that x and y represent
(GraphicsConstants.CENTER
,
GraphicsConstants.TOP_LEFT
, etc).public void drawString(String str, int x, int y, int pos)
For example, if you want to draw a String with its top-right corner at position (100,200), just call drawString(str, 100, 200, SatinGraphics.TOP_RIGHT).
x
- is the x-coordinate of where to draw.y
- is the y-coordinate of where to draw (it actually does not
matter that y is usually the bottom and not the top
coordinate, since we are specifying where to draw anyway).pos
- specifies what (x,y) are relative to the bounding box
(GraphicsConstants.CENTER
,
GraphicsConstants.TOP_LEFT
, etc).public void drawRect(Rectangle rect)
public void drawRect(Rectangle rect, int pos)
For example, let's suppose you have a Rectangle. You can draw this Rectangle normally. However, this method lets you shift it around a little. If you specify position BOTTOM_RIGHT, then the Rectangle is translated such that it's bottom-right corner is now where it's top-left corner used to be. Basically, any position you specify will translate the Rectangle such that the position will be translated to where the top-left corner is.
rect
- is the Rectangle to draw.pos
- specifies what (x,y) are relative to the bounding box
(GraphicsConstants.CENTER
,
GraphicsConstants.TOP_LEFT
, etc).public void drawRect(int x, int y, int width, int height, int pos)
x
- is the left side of the rectangle.y
- is the top of the rectangle.width
- is the width of the rectangle to draw.height
- is the height of the rectangle to draw.pos
- specifies what (x,y) are relative to the bounding box
(GraphicsConstants.CENTER
,
GraphicsConstants.TOP_LEFT
, etc).drawRect(java.awt.Rectangle, int)
public void fillRect(Rectangle rect, int pos)
rect
- is the Rectangle to draw.pos
- specifies what (x,y) are relative to the bounding box
(GraphicsConstants.CENTER
,
GraphicsConstants.TOP_LEFT
, etc).drawRect(java.awt.Rectangle, int)
public void fillRect(int x, int y, int width, int height, int pos)
x
- is the left side of the rectangle.y
- is the top of the rectangle.width
- is the width of the rectangle to draw.height
- is the height of the rectangle to draw.pos
- specifies what (x,y) are relative to the bounding box
(GraphicsConstants.CENTER
,
GraphicsConstants.TOP_LEFT
, etc).drawRect(java.awt.Rectangle, int)
public final void dispose()
dispose
in class Graphics
public final void finalize()
finalize
in class Graphics
public boolean hitClip(int x, int y, int width, int height)
hitClip
in class Graphics
public Graphics create()
create
in class Graphics
public Graphics create(int x, int y, int width, int height)
create
in class Graphics
public final void copyArea(int x, int y, int width, int height, int dx, int dy)
copyArea
in class Graphics
public final void addRenderingHints(Map hints)
addRenderingHints
in class Graphics2D
Graphics2D.addRenderingHints(java.util.Map)
public final void setColor(Color c)
Also automatically applies transparency.
setColor
in class Graphics
public final void setFont(Font font)
setFont
in class Graphics
public final void setPaintMode()
setPaintMode
in class Graphics
public final void setXORMode(Color c1)
setXORMode
in class Graphics
public final void setClip(int x, int y, int width, int height)
setClip
in class Graphics
public final void setClip(Shape clip)
setClip
in class Graphics
public final void clipRect(int x, int y, int width, int height)
clipRect
in class Graphics
public Color getColor()
getColor
in class Graphics
public Font getFont()
getFont
in class Graphics
public FontMetrics getFontMetrics()
getFontMetrics
in class Graphics
public FontMetrics getFontMetrics(Font f)
getFontMetrics
in class Graphics
public Rectangle getClipBounds()
getClipBounds
in class Graphics
public Shape getClip()
getClip
in class Graphics
public Rectangle getClipRect()
getClipRect
in class Graphics
public Rectangle getClipBounds(Rectangle r)
getClipBounds
in class Graphics
public final void drawLine(int x1, int y1, int x2, int y2)
drawLine
in class Graphics
public final void fillRect(int x, int y, int width, int height)
fillRect
in class Graphics
public final void drawRect(int x, int y, int width, int height)
drawRect
in class Graphics
public final void clearRect(int x, int y, int width, int height)
clearRect
in class Graphics
public final void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
in class Graphics
public final void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
in class Graphics
public final void drawOval(int x, int y, int width, int height)
drawOval
in class Graphics
public final void fillOval(int x, int y, int width, int height)
fillOval
in class Graphics
public final void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
drawArc
in class Graphics
public final void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
fillArc
in class Graphics
public final void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
drawPolyline
in class Graphics
public final void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
drawPolygon
in class Graphics
public final void drawPolygon(Polygon p)
drawPolygon
in class Graphics
public final void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
fillPolygon
in class Graphics
public final void fillPolygon(Polygon p)
fillPolygon
in class Graphics
public final void drawString(String str, int x, int y)
drawString
in class Graphics2D
public final void drawChars(char[] data, int offset, int length, int x, int y)
drawChars
in class Graphics
public final void drawBytes(byte[] data, int offset, int length, int x, int y)
drawBytes
in class Graphics
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
drawImage
in class Graphics
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
public FontRenderContext getFontRenderContext()
getFontRenderContext
in class Graphics2D
public boolean hit(Rectangle rect, Shape s, boolean onStroke)
hit
in class Graphics2D
public GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration
in class Graphics2D
public final void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
setRenderingHint
in class Graphics2D
public Object getRenderingHint(RenderingHints.Key hintKey)
getRenderingHint
in class Graphics2D
public final void setRenderingHints(Map hints)
setRenderingHints
in class Graphics2D
public RenderingHints getRenderingHints()
getRenderingHints
in class Graphics2D
public Color getBackground()
getBackground
in class Graphics2D
public Stroke getStroke()
getStroke
in class Graphics2D
public AffineTransform getTransform()
getTransform
in class Graphics2D
public Paint getPaint()
getPaint
in class Graphics2D
public Composite getComposite()
getComposite
in class Graphics2D
public final void setStroke(Stroke s)
setStroke
in class Graphics2D
s
- is a BasicStroke, not a Stroke (which is rather useless as
currently defined).ClassCastException
- if s is not a BasicStroke.public final void setTransform(AffineTransform Tx)
Please note that it is inherently dangerous to call this unless you know
the original AffineTransform that came with this graphics context, as
well as the AffineTransform to convert between virtual and screen
coordinates (We save this value in txDefaultTransform
, but
don't mess around with it unless you have to).
Instead of calling this method, you probably want to use
transform(AffineTransform)
instead, which just applies a
transform to the current transform.
setTransform
in class Graphics2D
public final void translate(int x, int y)
translate
in class Graphics2D
public final void translate(double tx, double ty)
translate
in class Graphics2D
public final void rotate(double theta)
rotate
in class Graphics2D
public final void rotate(double theta, double x, double y)
rotate
in class Graphics2D
public final void scale(double sx, double sy)
scale
in class Graphics2D
public final void shear(double shx, double shy)
shear
in class Graphics2D
public final void transform(AffineTransform Tx)
transform
in class Graphics2D
public final void clip(Shape s)
clip
in class Graphics2D
public final void setComposite(Composite comp)
setComposite
in class Graphics2D
public final void setPaint(Paint paint)
setPaint
in class Graphics2D
public final void setBackground(Color color)
setBackground
in class Graphics2D
public final void draw(Shape s)
draw
in class Graphics2D
public final void draw3DRect(int x, int y, int width, int height, boolean raised)
draw3DRect
in class Graphics2D
public final void drawGlyphVector(GlyphVector gv, float x, float y)
drawGlyphVector
in class Graphics2D
public final void fill3DRect(int x, int y, int width, int height, boolean raised)
fill3DRect
in class Graphics2D
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
drawImage
in class Graphics2D
public final void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
drawImage
in class Graphics2D
public final void drawRenderedImage(RenderedImage img, AffineTransform xform)
drawRenderedImage
in class Graphics2D
public final void drawRenderableImage(RenderableImage img, AffineTransform xform)
drawRenderableImage
in class Graphics2D
public final void drawString(String s, float x, float y)
drawString
in class Graphics2D
public final void drawString(AttributedCharacterIterator iterator, int x, int y)
drawString
in class Graphics2D
public final void drawString(AttributedCharacterIterator iterator, float x, float y)
drawString
in class Graphics2D
public final void fill(Shape s)
fill
in class Graphics2D
public String toString()
toString
in class Graphics
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |