|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.refractions.udig.ui.graphics.AWTGraphics
public class AWTGraphics
Field Summary | |
---|---|
java.awt.Graphics2D |
g
|
Fields inherited from interface net.refractions.udig.ui.graphics.ViewportGraphics |
---|
ALIGN_BOTTOM, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, LINE_DASH, LINE_DASHDOT, LINE_DASHDOTDOT, LINE_DOT, LINE_SOLID, LINE_SOLID_ROUNDED |
Constructor Summary | |
---|---|
AWTGraphics(java.awt.Graphics2D g)
|
|
AWTGraphics(java.awt.Graphics2D g,
int dpi)
Construct a AWTGraphics with the indicated dpi |
Method Summary | |
---|---|
void |
clearRect(int x,
int y,
int width,
int height)
Fills the specified rectangle with the background color. |
void |
dispose()
Disposes of any resources the graphics might be hanging on to. |
void |
draw(java.awt.Shape s)
Draws the outline of shape using the color, clip & transform. |
void |
drawImage(java.awt.Image image,
int x,
int y)
Draws an Image . |
void |
drawImage(java.awt.Image image,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2)
Draws a portion of the image to the target location on the viewport graphics. |
void |
drawImage(java.awt.image.RenderedImage image,
int x,
int y)
Draws an image. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line from x1,y1 to x2,y2 |
void |
drawOval(int x,
int y,
int width,
int height)
Draws an Oval - only the boundary |
void |
drawPath(Path path)
Draws the outline of the path using the color, clip and transform. |
void |
drawRect(int x,
int y,
int width,
int height)
Draws a rectangle - only the boundary. |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a round cornered rectangle |
void |
drawString(java.lang.String string,
int x,
int y,
int alignx,
int aligny)
Draws a string. |
void |
fill(java.awt.Shape s)
Fills the interior of a Shape using the foreground color, clip & transform. |
void |
fillGradientRectangle(int x,
int y,
int width,
int height,
java.awt.Color startColor,
java.awt.Color endColor,
boolean isVertical)
Fills a rectangle using a gradient paint |
void |
fillOval(int x,
int y,
int width,
int height)
Fills an Oval |
void |
fillPath(Path path)
Fills the interior of the path with the forground color. |
void |
fillRect(int x,
int y,
int width,
int height)
Fills a rectangle. |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Fills a round cornered rectangle using the foreground color |
java.awt.Color |
getBackgroundColor()
Gets the current background color value |
java.awt.Shape |
getClip()
Gets the area that can be drawn in. |
java.awt.Color |
getColor()
Gets the current Color value |
int |
getDPI()
Get the dots per inch, used to scale fonts, but you can scale anything you want based on this value (for example a scalebar). |
int |
getFontAscent()
Gets the ascent of the current font, which is the distance the font rises
above its baseline . |
int |
getFontHeight()
Gets the height of the current font TODO at some point maybe this could be broken out to getFontMetrics(), and a create FontMetrics object that maps between SWT and AWT. |
GC |
getGC()
Gets the SWT graphics if applicable. |
java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String str)
Returns the bounds of a String. |
java.awt.geom.AffineTransform |
getTransform()
|
void |
setBackground(java.awt.Color c)
Sets the background color to draw with. |
void |
setClip(java.awt.Rectangle r)
Sets the clip. |
void |
setClipBounds(java.awt.Rectangle newBounds)
Sets the clip area. |
void |
setColor(java.awt.Color c)
Sets the foreground color to draw with. |
void |
setDPI(int dpi)
Set the viewport graphics to use the provided dpi. |
void |
setFont(java.awt.Font f)
Make use of the provided font. |
void |
setLineDash(int[] dash)
Sets the line dash pattern |
void |
setLineWidth(int width)
Sets the line width of the graphics (in pixels). |
void |
setStroke(int style,
int width)
Sets the stroke color to draw with. |
void |
setTransform(java.awt.geom.AffineTransform transform)
Modifies the graphics so that further draws us minX,minY as the origin and maxX and maxY as the width and height of the display area. |
int |
stringWidth(java.lang.String str)
Returns the length in pixels of the given string, or -1 if this operation is not available. |
static java.awt.image.BufferedImage |
toAwtImage(ImageData swtImageData)
Deprecated. use AWTSWTImageUtils |
void |
translate(java.awt.Point offset)
Sets the draw offset. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.awt.Graphics2D g
Constructor Detail |
---|
public AWTGraphics(java.awt.Graphics2D g)
public AWTGraphics(java.awt.Graphics2D g, int dpi)
g
- dpi
- Method Detail |
---|
public void draw(java.awt.Shape s)
ViewportGraphics
shape
using the color, clip & transform.
Reference description from Graphics2d: Shape
using the settings of the current Graphics2D
context. The rendering attributes
applied include the Clip
, Transform
, Paint
,
Composite
and Stroke
attributes.
draw
in interface ViewportGraphics
s
- the Shape
to be renderedViewportGraphics.draw(java.awt.Shape)
public void fill(java.awt.Shape s)
ViewportGraphics
Shape
using the foreground color, clip & transform.
Reference description from Graphics2d:
Shape
using the settings of the Graphics2D
context. The rendering attributes applied
include the Clip
, Transform
, Paint
, and
Composite
.
fill
in interface ViewportGraphics
s
- the Shape
to be filled
ViewportGraphics.draw(java.awt.Shape)
public void setColor(java.awt.Color c)
ViewportGraphics
setColor
in interface ViewportGraphics
c
- The new color.ViewportGraphics.setColor(java.awt.Color)
public void setBackground(java.awt.Color c)
ViewportGraphics
setBackground
in interface ViewportGraphics
c
- The new color.ViewportGraphics.setBackground(java.awt.Color)
public void setFont(java.awt.Font f)
Please note that the provided AWT Font makes use of a size in *points* (which are documented to be 72 DPI). Internally we adjust this size by the getDPI() value for this AWTGraphics.
setFont
in interface ViewportGraphics
f
- Font in 72 dpipublic void setClip(java.awt.Rectangle r)
ViewportGraphics
setClip
in interface ViewportGraphics
r
- the rectangle to clip to.ViewportGraphics.setClip(java.awt.Rectangle)
public void fillRect(int x, int y, int width, int height)
ViewportGraphics
fillRect
in interface ViewportGraphics
x
- the starting x coordinatey
- the starting y coordinatewidth
- the width of the rectangle.height
- the height of the rectangle.ViewportGraphics.fillRect(int, int, int, int)
public void translate(java.awt.Point offset)
ViewportGraphics
translate
in interface ViewportGraphics
offset
- The amount the draw is offset in the graphics.ViewportGraphics.translate(java.awt.Point)
public void clearRect(int x, int y, int width, int height)
ViewportGraphics
clearRect
in interface ViewportGraphics
x
- The starting corner's x-coordinate.y
- The starting corner's y-coordinate.width
- the width of the rectangleheight
- the height of the rectangleViewportGraphics.clearRect(int, int, int, int)
public void drawImage(java.awt.image.RenderedImage image, int x, int y)
ViewportGraphics
drawImage
in interface ViewportGraphics
x
- The x coordinate of the image top left corner of the image.y
- The y coordinate of the image top left corner of the image.net.refractions.udig.ui.graphics.ViewportGraphics#drawImage(javax.media.jai.PlanarImage,
int, int)
public void drawString(java.lang.String string, int x, int y, int alignx, int aligny)
ViewportGraphics
drawString
in interface ViewportGraphics
string
- The string to draw.x
- the x coordinate of the location where the of the string will be placed.y
- the y coordinate of the location where the of the string will be placed.alignx
- horizontal alignment, ViewportGraphics.ALIGN_LEFT
, ViewportGraphics.ALIGN_MIDDLE
or ViewportGraphics.ALIGN_RIGHT
aligny
- vertical alignment, ViewportGraphics.ALIGN_BOTTOM
, ViewportGraphics.ALIGN_MIDDLE
or ViewportGraphics.ALIGN_TOP
net.refractions.udig.ui.graphics.ViewportGraphics#drawString(String, int, int)
public void setTransform(java.awt.geom.AffineTransform transform)
ViewportGraphics
setTransform
in interface ViewportGraphics
ViewportGraphics.setTransform(java.awt.geom.AffineTransform)
public void drawImage(java.awt.Image image, int x, int y)
ViewportGraphics
Image
.
drawImage
in interface ViewportGraphics
x
- The x coordinate of the image top left corner of the image.y
- The y coordinate of the image top left corner of the image.ViewportGraphics.drawImage(java.awt.Image, int, int)
public void drawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2)
ViewportGraphics
drawImage
in interface ViewportGraphics
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.public int getFontHeight()
ViewportGraphics
getFontHeight
in interface ViewportGraphics
public int stringWidth(java.lang.String str)
ViewportGraphics
stringWidth
in interface ViewportGraphics
public int getFontAscent()
ViewportGraphics
ascent
of the current font, which is the distance the font rises
above its baseline
.
getFontAscent
in interface ViewportGraphics
public java.awt.geom.Rectangle2D getStringBounds(java.lang.String str)
ViewportGraphics
getStringBounds
in interface ViewportGraphics
public static java.awt.image.BufferedImage toAwtImage(ImageData swtImageData)
AWTSWTImageUtils
swtImageData
-
public void drawLine(int x1, int y1, int x2, int y2)
ViewportGraphics
drawLine
in interface ViewportGraphics
public java.awt.geom.AffineTransform getTransform()
getTransform
in interface ViewportGraphics
public void dispose()
ViewportGraphics
dispose
in interface ViewportGraphics
public void drawPath(Path path)
ViewportGraphics
drawPath
in interface ViewportGraphics
public void fillPath(Path path)
ViewportGraphics
fillPath
in interface ViewportGraphics
path
- the path to fill.public void drawRect(int x, int y, int width, int height)
ViewportGraphics
drawRect
in interface ViewportGraphics
x
- the starting x coordinatey
- the starting y coordinatewidth
- the width of the rectangle.height
- the height of the rectangle.public void drawOval(int x, int y, int width, int height)
ViewportGraphics
drawOval
in interface ViewportGraphics
x
- the starting x coordinatey
- the starting y coordinatewidth
- the width of the Oval.height
- the height of the Oval.public void fillOval(int x, int y, int width, int height)
ViewportGraphics
fillOval
in interface ViewportGraphics
x
- the starting x coordinatey
- the starting y coordinatewidth
- the width of the Oval.height
- the height of the Oval.public java.awt.Shape getClip()
ViewportGraphics
getClip
in interface ViewportGraphics
public void setClipBounds(java.awt.Rectangle newBounds)
ViewportGraphics
setClipBounds
in interface ViewportGraphics
newBounds
- new clip areapublic java.awt.Color getBackgroundColor()
ViewportGraphics
getBackgroundColor
in interface ViewportGraphics
public java.awt.Color getColor()
ViewportGraphics
getColor
in interface ViewportGraphics
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
ViewportGraphics
drawRoundRect
in interface ViewportGraphics
x
- the x component of the upper left cornery
- the y component of the upper left cornerwidth
- the width of the rectangleheight
- the height of the rectanglearcWidth
- the horizontal diameter of the arc
at the four corners.arcHeight
- the vertical diameter of the arc
at the four cornerspublic void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
ViewportGraphics
fillRoundRect
in interface ViewportGraphics
x
- the x component of the upper left cornery
- the y component of the upper left cornerwidth
- the width of the rectangleheight
- the height of the rectanglearcWidth
- the horizontal diameter of the arc
at the four corners.arcHeight
- the vertical diameter of the arc
at the four cornerspublic void setLineDash(int[] dash)
ViewportGraphics
setLineDash
in interface ViewportGraphics
dash
- the pattern of dashes.public void setLineWidth(int width)
ViewportGraphics
If you need to make your drawing device independent please consider making use of the DPI setting.
g.setLineWith( width ); // BEFORE
g.setLineWith( (width * g.getDPI()) / 72 ); // AFTER
Where 72 is chosen because that is what a Java image resolutions
is assumed to be by default.
setLineWidth
in interface ViewportGraphics
public void setStroke(int style, int width)
ViewportGraphics
setStroke
in interface ViewportGraphics
style
- The style of line to draw.width
- the width, in pixels, to draw lines with.ViewportGraphics.setStroke(int, int)
public int getDPI()
ViewportGraphics
getDPI
in interface ViewportGraphics
public void setDPI(int dpi)
Please note the DPI setting is only used to control font size.
public void fillGradientRectangle(int x, int y, int width, int height, java.awt.Color startColor, java.awt.Color endColor, boolean isVertical)
ViewportGraphics
fillGradientRectangle
in interface ViewportGraphics
x
- the x component of the upper left cornery
- the y component of the upper left cornerwidth
- the width of the rectangleheight
- the height of the rectanglestartColor
- the first color used in the gradient paintendColor
- the last color used in the gradient paintisVertical
- orientation of the gradientpublic GC getGC()
ViewportGraphics
getGC
in interface ViewportGraphics
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |