Class Graphics
All Packages Class Hierarchy This Package Previous Next Index
Class Graphics
public class netscape.application.Graphics
extends java.lang.Object
{
/* Fields
*/
public final static int CENTERED;
public final static int LEFT_JUSTIFIED;
public final static int RIGHT_JUSTIFIED;
/* Constructors
*/
public Graphics(View);
public Graphics(Bitmap);
/* Methods
*/
public Bitmap buffer();
public void clearClipRect();
public Rect clipRect();
public Color color();
public int debugOptions();
public void dispose();
public void drawArc(Rect, int, int);
public void drawArc(int, int, int, int, int, int);
public void drawBitmapAt(Bitmap, int, int);
public void drawBitmapScaled(Bitmap, int, int, int, int);
public void drawBytes(byte[], int, int, int, int);
public void drawChars(char[], int, int, int, int);
public void drawLine(int, int, int, int);
public void drawOval(Rect);
public void drawOval(int, int, int, int);
public void drawPoint(int, int);
public void drawPolygon(int[], int[], int);
public void drawPolygon(Polygon);
public void drawRect(Rect);
public void drawRect(int, int, int, int);
public void drawRoundedRect(Rect, int, int);
public void drawRoundedRect(int, int, int, int, int, int);
public void drawString(String, int, int);
public void drawStringInRect(String, int, int, int, int, int);
public void drawStringInRect(String, Rect, int);
public void fillArc(Rect, int, int);
public void fillArc(int, int, int, int, int, int);
public void fillOval(Rect);
public void fillOval(int, int, int, int);
public void fillPolygon(int[], int[], int);
public void fillPolygon(Polygon);
public void fillRect(Rect);
public void fillRect(int, int, int, int);
public void fillRoundedRect(Rect, int, int);
public void fillRoundedRect(int, int, int, int, int, int);
public Font font();
public boolean isDrawingBuffer();
public void popState();
public void pushState();
public void setClipRect(Rect, boolean);
public void setClipRect(Rect);
public void setColor(Color);
public void setDebugOptions(int);
public void setFont(Font);
public void setPaintMode();
public void setXORMode(Color);
public void sync();
public String toString();
public void translate(int, int);
public Point translation();
public int xTranslation();
public int yTranslation();
}
Object subclass representing a drawing context, either onscreen or
offscreen. Onscreen Graphics are created either for the Applet frame
or ExternalWindows by passing a RootView to the constructor.
Offscreen Graphics are created for Bitmaps, by passing the Bitmap to
the constructor. Graphics maintain a stack of graphics states,
manipulated by the pushState() and popState() methods. When a
state is popped, the graphics state reverts to whatever it was before
the most recent push (i.e. color, font, clip rectangle, etc).
You typically never construct Graphics instances directly, rather you
work with them inside of View drawView() methods to draw to
the screen.
Fields
LEFT_JUSTIFIED
public final static int LEFT_JUSTIFIED
- String display style.
CENTERED
public final static int CENTERED
- String display style.
RIGHT_JUSTIFIED
public final static int RIGHT_JUSTIFIED
- String display style.
Constructors
Graphics
public Graphics(View view)
- Constructs a Graphics object suitable for drawing onscreen. It is
untranslated, so the (0, 0) coordinate is in the upper-left
corner of the RootView. You should explictly destroy Graphics
objects, using the dispose() method, because they consume
resources and are limited in number.
Graphics
public Graphics(Bitmap aBitmap)
- Constructs a Graphics object suitable for drawing offscreen. It is
untranslated, so the (0, 0) coordinate is in the Bitmap's upper-left
corner.
Methods
pushState
public void pushState()
- Creates an entry in the Graphics state stack. Each call to
pushState() should be paired with a call to popState().
Any changes to the Graphics object between the calls will be flushed
after the popState().
- See Also:
- popState
popState
public void popState()
- Restores the Graphics object to its condition before the most recent
pushState() call. All fonts, colors, clipping rectangles and
translations will be restored.
setFont
public void setFont(Font aFont)
- Sets the Font used for text drawing operations.
font
public Font font()
- Returns the Font used for drawing operations.
- See Also:
- setFont
setColor
public void setColor(Color aColor)
- Sets the color to be used for drawing and filling lines and shapes.
color
public Color color()
- Returns the color used for drawing lines and filling regions.
- See Also:
- setColor
translate
public void translate(int x,
int y)
- Alters the coordinate system so that all drawing, filling, and
clipping operations implicitly have x and y added to
their positions. If there is any current translation, the total
translation is the sum of the old and new translations.
- See Also:
- xTranslation, yTranslation, translation
xTranslation
public int xTranslation()
- Returns the X-coordinate of the Graphics' coordinate system origin.
- See Also:
- translate
yTranslation
public int yTranslation()
- Returns the Y-coordinate of the Graphics' coordinate system origin.
- See Also:
- translate
translation
public Point translation()
- Returns the amount of translation performed on the current graphics
context. Each pushState() creates a context with no
translation. Subsequent calls to translate offset all
drawing operations by the aggregate amount of translation.
- See Also:
- translate
setClipRect
public void setClipRect(Rect rect,
boolean intersect)
- Sets the rectangle within which drawing can occur. Any drawing
occurring outside of this rectangle will not appear. If
intersect is true, this method intersects
rect with the current clipping rectangle to produce the new
clipping rectangle.
setClipRect
public void setClipRect(Rect rect)
- Sets the rectangle within which drawing can occur. Any drawing
occurring outside of this rectangle will not appear. Intersects
rect with the current clipping rectangle to produce the new
clipping rectangle.
- See Also:
- setClipRect
clipRect
public Rect clipRect()
- Returns the Graphics object's current clipping rectangle. All drawing
operations are clipped to this Rect.
- See Also:
- setClipRect
clearClipRect
public void clearClipRect()
- Clears the clipping rectangle so that drawing can occur anywhere
within the Graphics' drawing region.
- See Also:
- setClipRect, clipRect
buffer
public Bitmap buffer()
- Returns the Bitmap associated with the Graphics. Returns
null if the Graphics is not drawing into a Bitmap.
isDrawingBuffer
public boolean isDrawingBuffer()
- Returns true if the Graphics was created from a Bitmap.
dispose
public void dispose()
- Destroys the Graphics object and any resources associated with it.
sync
public void sync()
- Forces any pending drawing operations to be sent to the native
graphics system for onscreen drawing.
setPaintMode
public void setPaintMode()
- Sets the paint mode to overwrite the destination with the current
color.
- See Also:
- setXORMode
setXORMode
public void setXORMode(Color aColor)
- Sets the paint mode to alternate between the current color and
aColor.
- See Also:
- setPaintMode
drawRect
public void drawRect(Rect aRect)
- Draws aRect using the current color.
drawRect
public void drawRect(int x,
int y,
int width,
int height)
- Draws the rectangle
(x, y, width, height) using
the current color.
fillRect
public void fillRect(Rect aRect)
- Fills aRect using the current color.
fillRect
public void fillRect(int x,
int y,
int width,
int height)
- Fills the rectangle
(x, y, width, height) using the current
color.
drawRoundedRect
public void drawRoundedRect(Rect aRect,
int arcWidth,
int arcHeight)
- Draws a rectangle with rounded corners in aRect,
as determined by arcWidth and arcHeight.
drawRoundedRect
public void drawRoundedRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
- Draws a rectangle with rounded corners in the rectangle
(x, y, width, height), as determined by
arcWidth and arcHeight.
fillRoundedRect
public void fillRoundedRect(Rect aRect,
int arcWidth,
int arcHeight)
- Fills a rectangle with rounded corners in aRect,
as determined by arcWidth and arcHeight.
fillRoundedRect
public void fillRoundedRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
- Fills a rectangle with rounded corners in the rectangle
(x, y, width, height), as determined by
arcWidth and arcHeight.
drawLine
public void drawLine(int x1,
int y1,
int x2,
int y2)
- Draws a line from the point (x1, y1) to the
point (x2, y2) in the current color.
drawPoint
public void drawPoint(int x,
int y)
- Draws the point (x, y) in the current color.
drawOval
public void drawOval(Rect aRect)
- Draws an oval inside aRect in the current color.
drawOval
public void drawOval(int x,
int y,
int width,
int height)
- Draws an oval inside the rect
(x, y, width, height) in the
current color.
fillOval
public void fillOval(Rect aRect)
- Fills an oval inside aRect in the current color.
fillOval
public void fillOval(int x,
int y,
int width,
int height)
- Fills an oval inside the rect
(x, y, width, height) in the
current color.
drawArc
public void drawArc(Rect aRect,
int startAngle,
int arcAngle)
- Draws an arc in aRect from startAngle for
arcAngle degrees.
drawArc
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
- Draws an arc in aRect from startAngle for
arcAngle degrees.
fillArc
public void fillArc(Rect aRect,
int startAngle,
int arcAngle)
- Fills an arc in aRect from startAngle for
arcAngle degrees.
fillArc
public void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
- Fills an arc in aRect from startAngle for
arcAngle degrees.
drawPolygon
public void drawPolygon(int xPoints[],
int yPoints[],
int nPoints)
- Draws the polygon described by xPoints and yPoints
using the current color. Both arrays must have at least
nPoints integers.
drawPolygon
public void drawPolygon(Polygon polygon)
- Draws polygon using the current color.
fillPolygon
public void fillPolygon(int xPoints[],
int yPoints[],
int nPoints)
- Fills the polygon described by xPoints and yPoints
using the current color. Both arrays must have at least
nPoints integers.
fillPolygon
public void fillPolygon(Polygon polygon)
- Fills polygon using the current color.
drawBitmapAt
public void drawBitmapAt(Bitmap bitmap,
int x,
int y)
- Displays bitmap at the point (x, y).
drawBitmapScaled
public void drawBitmapScaled(Bitmap bitmap,
int x,
int y,
int width,
int height)
- Draws bitmap at the point (x, y), scaled in the
X-dimension to have width width and the Y-dimension to
have height height.
drawStringInRect
public void drawStringInRect(String aString,
int x,
int y,
int width,
int height,
int justification)
- Draws aString in the rectangle defined by
(x, y, width, height).
justification specifies the text's justification, one of
LEFT_JUSTIFIED, CENTERED, or RIGHT_JUSTIFIED.
drawStringInRect() does not clip to the rectangle, but instead
uses this rectangle and the desired justification to compute the point
at which to begin drawing the text.
- See Also:
- drawString
drawStringInRect
public void drawStringInRect(String aString,
Rect aRect,
int justification)
- Draws aString in aRect, according to
the justification justification.
- See Also:
- drawStringInRect
drawString
public void drawString(String aString,
int x,
int y)
- Draws aString at the point (x, y) using the
current font and color.
- See Also:
- drawStringInRect
drawBytes
public void drawBytes(byte data[],
int offset,
int length,
int x,
int y)
- Draws length bytes of data, beginning offset bytes
into the array, using the current font and color, at the point
(x, y).
drawChars
public void drawChars(char data[],
int offset,
int length,
int x,
int y)
- Draws length characters of data, beginning offset
characters into the array, using the current font and color, at the
point (x, y).
toString
public String toString()
- Returns the Graphic's String representation.
- Overrides:
- toString in class Object
setDebugOptions
public void setDebugOptions(int debugOptions)
- Activates Graphics debugging options. Graphics instances only support
a debugOption value of 0.
The DebugGraphics subclass supports other values to enable diagnostic
output on graphics operations.
- See Also:
- DebugGraphics
debugOptions
public int debugOptions()
- Returns the current debug option setting. Graphics instances only
a debug option value of 0.
The DebugGraphics subclass supports other values to enable diagnostic
output on graphics operations.
- See Also:
- setDebugOptions, DebugGraphics
All Packages Class Hierarchy This Package Previous Next Index