|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
All drawing operations of the API take place on a Device
object. This interface defines the abstraction which decouples client code
from any particular Widget Toolkit.
Colors are represented as integer values. The itemization of the colors
components in hexadecimal code is as follows:
0xaarrggbb
where
aa means the alpha component
rr means the red component
gg means the green component
bb means the blue component
A Device uses StrokeFormat objects to draw lines or the
current color value set to it if the current StrokeFormat is
null.
A Device uses PaintFormat objects to fill areas or the
current color value set to it if the current PaintFormat is
null
A Device uses FontFormat objects to output text. If the
current FontFormat is null, the Device uses the
current color value and the default font.
StrokeFormat,
PaintFormat,
FontFormat| Field Summary | |
static int |
DRAW_FILL
Constant used with the different draw-methods of the Device interface and determine what to draw |
static int |
DRAW_OUTLINE
Constant used with the different draw-methods of the Device interface and determine what to draw |
| Method Summary | |
void |
clearClip()
Clears the currently used clip rectangle. |
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 |
dispose()
Disposes this AWTDevice. |
void |
drawArc(int flags,
int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws a circular or elliptical arc covering the specified rectangle. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
This method draws a line from the starting coordinate given by x1 and y1 to the ending coordinate given
by x2 and y2. |
void |
drawOval(int flags,
int x,
int y,
int width,
int height)
Draws an oval. |
void |
drawPolygon(int flags,
int[] ptX,
int[] ptY,
int ptCount)
This method draws a closed polygon. |
void |
drawPolyline(int[] ptX,
int[] ptY,
int ptCount)
This method draws a polyline. |
void |
drawRect(int flags,
int x,
int y,
int width,
int height)
This methods draws the rectangle defined by the given parameters. |
void |
drawRoundRect(int flags,
int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a round-cornered rectangle using this graphic contexts currently set Stroke- and PaintFormat. |
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. |
Boundary |
getClipBounds()
Returns the bounding rectangle of the current clipping area. |
Boundary |
getClipBounds(Boundary boundary)
Returns the bounding rectangle of the current clipping area. |
FontFormat |
getFontFormat()
Returns the FontFormat currently used for text drawing
operations. |
PaintFormat |
getPaintFormat()
Returns the current PaintFormat the Device uses
to fill areas. |
StrokeFormat |
getStrokeFormat()
Returns the current StrokeFormat the Device
uses for drawing lines. |
Transform2D |
getTransform()
Returns a copy of the current AffineTransform in the
Device. |
boolean |
hitClip(int x,
int y,
int width,
int height)
Returns true if the specified rectangular area intersects
the bounding rectangle of the current clipping area. |
void |
initiate()
Initializes this Device.
|
boolean |
isAntialiasing()
Returns true if antialising is enabled for
this Device, otherwise false is returned. |
boolean |
isInhibitLT2RBFlip()
|
boolean |
isInhibitYFlip()
|
boolean |
isPrinting()
|
void |
setAntialiasing(boolean antialiasing)
Enables or disables antialiasing for this Device |
void |
setClip(int x,
int y,
int width,
int height)
Sets the current clip to the rectangle specified by the given coordinates. |
void |
setClipBounds(Boundary boundary)
Sets the current clip to the rectangle specified by the given coordinates. |
void |
setFontFormat(FontFormat fontFormat)
Sets the FontFormat that will be used for all
subsequent text drawing operations. |
void |
setFontFormatData(java.lang.Object[] fontFormatData)
Because all formats get pooled, illustrators and users need an easy way to change them. |
void |
setInhibitLT2RBFlip(boolean inhibitLT2RBFlip)
|
void |
setInhibitYFlip(boolean inhibitYFlip)
|
void |
setIsPrinting(boolean isPrinting)
|
void |
setPaintFormat(PaintFormat paintFormat)
Sets the PaintFormat the Device should use
for filling areas. |
void |
setPaintFormatData(java.lang.Object[] paintFormatData)
Sets the PaintFormat rendering data the Device
should use for filling areas.
|
void |
setPaintMode()
Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color. |
void |
setStrokeFormat(StrokeFormat strokeFormat)
Sets the StrokeFormat the Device should use for
drawing lines or borders around rectangles and polygons. |
void |
setStrokeFormatData(java.lang.Object[] strokeFormatData)
Sets the StrokeFormat rendering data the Device
should use for drawing lines or borders around rectangles and polygons.
|
void |
setTransform(Transform2D xform)
Sets the Transform2D in the Device. |
void |
setXORMode(int xorAlternationColor)
Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color. |
void |
translate(int x,
int y)
This method translates the origin of this devise to the point given by x and y in the actual coordinate of this
device. |
| Field Detail |
public static final int DRAW_OUTLINE
Device interface and determine what to draw
public static final int DRAW_FILL
Device interface and determine what to draw
| Method Detail |
public void initiate()
Device.
public void dispose()
AWTDevice. After disposing the instance
may not longer be used.
Device is no longer in a valid state.
public void setAntialiasing(boolean antialiasing)
Device
antialiasing - true indicates that
anti-aliasing should be enabled, false disables it.public boolean isAntialiasing()
true if antialising is enabled for
this Device, otherwise false is returned.
true if antialising is enabled for
this Device, otherwise false is returned.public StrokeFormat getStrokeFormat()
StrokeFormat the Device
uses for drawing lines.
StrokeFormat or nullpublic void setStrokeFormat(StrokeFormat strokeFormat)
StrokeFormat the Device should use for
drawing lines or borders around rectangles and polygons. When invoking
this method the StrokeFormat is used instead of the color
value the Device currently uses. If the Device
should use the current color value, this method has to be called with a
null parameter.
strokeFormat - the StrokeFormat to use when drawing
lines or borders, or nullpublic void setStrokeFormatData(java.lang.Object[] strokeFormatData)
StrokeFormat rendering data the Device
should use for drawing lines or borders around rectangles and polygons.
When invoking this method the StrokeFormat is used instead of
the color value the Device currently uses. If the
Device should use the current color value, this method has
to be called with a null parameter.
The given array has to consist of three Integer objects.
The meaning of the value is defined by its position in the array. The
following list specifies the valid index positions:
strokeFormatData - the StrokeFormat rendering data to
use when drawing lines or borders, or nullpublic PaintFormat getPaintFormat()
PaintFormat the Device uses
to fill areas.
PaintFormat or nullpublic void setPaintFormat(PaintFormat paintFormat)
PaintFormat the Device should use
for filling areas. If the current color should be used, this method
has to be called with a null parameter.
paintFormat - the PaintFormat to use when filling
areas, or nullpublic void setPaintFormatData(java.lang.Object[] paintFormatData)
PaintFormat rendering data the Device
should use for filling areas.
When invoking this method the PaintFormat is used instead of the
color value the Device> currently uses. If the
Device should use the current color value, this method has
to be called with a null parameter.
Overall eight values of the given array are estimated.
REVIEWJAVADOC: Device.java : what do you mean by "estimated"???
The meaning of each value is defined by its position in the array. The following
table specifies the valid index positions and object types:
| Index | Type |
|---|---|
RenderingData.VALUEINDEX_PAINT_STYLE |
Integer |
RenderingData.VALUEINDEX_PAINT_COLORBACK |
Integer |
RenderingData.VALUEINDEX_PAINT_COLORFORE |
Integer |
RenderingData.VALUEINDEX_PAINT_GRADIENTTYPE |
Integer |
RenderingData.VALUEINDEX_PAINT_PATTERNTYPE |
Integer |
RenderingData.VALUEINDEX_PAINT_TEXTURE |
Texture |
RenderingData.VALUEINDEX_PAINT_TRANSPARENCY |
Integer |
RenderingData.VALUEINDEX_PAINT_TRANSPARENT |
Boolean |
paintFormatData - the PaintFormat rendering data to
use when filling areas, or nullpublic FontFormat getFontFormat()
FontFormat currently used for text drawing
operations.
FontFormatpublic void setFontFormat(FontFormat fontFormat)
FontFormat that will be used for all
subsequent text drawing operations. When the default color and font
of the Device should be used, the method has to be called
with a null parameter.
fontFormat - the FontFormat to use when drawing text,
or nullpublic void setFontFormatData(java.lang.Object[] fontFormatData)
FontFormat rendering data that will be used for all
subsequent text drawing operations. When the Device
should use the current color value and the default font of the
device, however, this method has to be called with a null parameter.
At this time, four values of the given array are estimated.
REVIEWJAVADOC: There is that word "estimated" again!!!
The meaning
of each value is defined by its position in the array. The following
list specifies the valid index positions and object types:
| Index | Type |
|---|---|
RenderingData.VALUEINDEX_FONT_SIZE |
Integer |
RenderingData.VALUEINDEX_FONT_WEIGHT |
Integer |
RenderingData.VALUEINDEX_FONT_FAMILY |
String |
RenderingData.VALUEINDEX_FONT_ITALIC |
Boolean |
fontFormatData - the FontFormat rendering data to use
when drawing text, or null
public void translate(int x,
int y)
x and y in the actual coordinate of this
device. All coordinates in subsequent calls to drawing methods are
assumed to be relative to the new origin.
x - the x coordinate of the new originy - the y coordinate of the new originpublic Transform2D getTransform()
AffineTransform in the
Device.
AffineTransform in the
Device.public void setTransform(Transform2D xform)
Transform2D in the Device.
xform - the Transform2D object to be used in the
rendering processpublic void setPaintMode()
public void setXORMode(int xorAlternationColor)
xorAlternationColor - the XOR alternation color
public void setClip(int x,
int y,
int width,
int height)
x - the left coordinate of the new clip rectangley - the top coordinate of the new clip rectanglewidth - the extent of the new clip rectangle in x directionheight - the extent of the new clip rectangle in y direction
public void clipRect(int x,
int y,
int width,
int height)
x - the x coordinate of the rectangle to intersect the clip withy - the y coordinate of the rectangle to intersect the clip withwidth - the width of the rectangle to intersect the clip withheight - the height of the rectangle to intersect the clip with
public boolean hitClip(int x,
int y,
int width,
int height)
true if the specified rectangular area intersects
the bounding rectangle of the current clipping area. The coordinates in
the rectangle are relative to the coordinate system origin of this
graphics context.
x - the x coordinate of the rectangle to test against the clipy - the y coordinate of the rectangle to test against the clipwidth - the width of the rectangle to test against the clipheight - the height of the rectangle to test against the clip
true if the specified rectangular area intersects
the bounding rectangle of the current clipping area.public Boundary getClipBounds()
public Boundary getClipBounds(Boundary boundary)
getClipBounds() in that an existing Boundary is
used instead of allocating a new one. This method refers to the user
clip, which is independent of the clipping associated with device bounds
and window visibility. If no clip has previously been set, or if the clip
has been cleared using setClip(null), this method returns
the specified Boundary.
boundary - the rectangular boundary where the current clipping area
is copied to. Any current values in this rectangle are overwritten.
public void setClipBounds(Boundary boundary)
boundary - the new bounding rectangle to clip againstpublic void clearClip()
public void drawLine(int x1,
int y1,
int x2,
int y2)
x1 and y1 to the ending coordinate given
by x2 and y2.
x1 - the starting coordinate x valuey1 - the starting coordinate y valuex2 - the ending coordinate x valuey2 - the ending coordinate y value
public void drawRect(int flags,
int x,
int y,
int width,
int height)
x and y. The right
coordinates are calculated by x + width and the bottom
coordinates are calculated by y + height.
flags - bitwise combined flags that determine what to draw.x - the left coordinate of the rectangle.y - the top coordinate of the rectangle.width - the extent in x direction.height - the extent in y direction.
public void clearRect(int x,
int y,
int width,
int height)
x - the x coordinate of the rectangle to be cleary - the y coordinate of the rectangle to be clearwidth - the width of the rectangle to be clearheight - the height of the rectangle to be clear
public void drawRoundRect(int flags,
int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Stroke- and PaintFormat. The
left and right edges of the rectangle are at x and
x + width, respectively. The top and bottom edges of the
rectangle are at y and y + height.
flags - bitwise combined flags that determine what to drawx - the x coordinate of the rectangle to be drawny - the y coordinate of the rectangle to be drawnwidth - the width of the rectangle to be drawnheight - the height of the rectangle to be drawnarcWidth - the horizontal diameter of the arc at the four cornersarcHeight - the vertical diameter of the arc at the four corners
public void drawOval(int flags,
int x,
int y,
int width,
int height)
flags - bitwise combined flags that determine what to drawx - the x coordinate of the upper left corner of the oval to be
drawny - the y coordinate of the upper left corner of the oval to be
drawnwidth - the width of the oval to be drawnheight - the height of the oval to be drawn
public void drawArc(int flags,
int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
startAngle and extends for
arcAngle degrees, using the current color of the
Device. Angles are interpreted in such a manner that a
degree of 0 belongs to the 3 o'clock position. A positive value
indicates a counter-clockwise rotation while a negative value
indicates a clockwise rotation. The center of the arc is the center
of the rectangle whose origin is (x, y) and whose size is
specified by the width and height arguments. The resulting arc
covers an area width + 1 pixels wide by height + 1
pixels tall. The angles are specified relative to the non-square
extents of the bounding rectangle such that 45 degrees always falls
on the line from the center of the ellipse to the upper right corner
of the bounding rectangle. As a result, if the bounding rectangle is
noticeably longer in one axis than the other, the angles to the
start and end of the arc segment will be skewed farther along the
longer axis of the bounds.
flags - bitwise combined flags that determine what to drawx - the x coordinate of the upper-left corner of the arc to be
drawny - the y coordinate of the upper-left corner of the arc to be
drawnwidth - the width of the arc to be drawnheight - the height of the arc to be drawnstartAngle - the beginning anglearcAngle - the angular extent of the arc, relative to the start
angle
public void drawPolyline(int[] ptX,
int[] ptY,
int ptCount)
ptX - the x coordinates of the pointsptY - the y coordinates of the pointsptCount - the amount of points the polygon consist of
public void drawPolygon(int flags,
int[] ptX,
int[] ptY,
int ptCount)
flags - bitwise combined flags that determine what to drawptX - the x coordinates of the pointsptY - the y coordinates of the pointsptCount - the amount of points the polygon consist of
public void drawString(java.lang.String str,
int x,
int y)
str - the string to be drawnx - the x coordinatey - the y coordinatepublic void setIsPrinting(boolean isPrinting)
public boolean isPrinting()
public void setInhibitLT2RBFlip(boolean inhibitLT2RBFlip)
public boolean isInhibitLT2RBFlip()
public void setInhibitYFlip(boolean inhibitYFlip)
public boolean isInhibitYFlip()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||