Class sgraphics.Painter
All Packages Class Hierarchy This Package Previous Next Index
Class sgraphics.Painter
java.lang.Object
|
+----sgraphics.Painter
- public class Painter
- extends Object
Painter is a wrapper around awt.Graphics that uses dimensions of type float.
-
Painter(Graphics)
- Create a Painter from a Graphics.
-
clearRect(float, float, float, float)
- Clears the specified rectangle by filling it with the current background color
of the current drawing surface.
-
clipRect(Area)
- Clips to a rectangle.
-
copyArea(float, float, float, float, float, float)
- Copies an area of the screen.
-
draw3DRect(float, float, float, float, boolean)
- Draws a highlighted 3-D rectangle.
-
drawArc(float, float, float, float, int, int)
- Draws an arc bounded by the specified rectangle starting at
startAngle, where 0 degrees is at the 3-o'clock position, and
extending for arcAngle degrees.
-
drawBytes(byte[], int, int, float, float)
- Draws the specified bytes using the current font and color.
-
drawChars(char[], int, int, float, float)
- Draws the specified characters using the current font and color.
-
drawImage(Image, float, float, Color, ImageObserver)
- Draws the specified image at the specified coordinate (x, y),
with the given solid background Color.
-
drawImage(Image, float, float, float, float, Color, ImageObserver)
- Draws the specified image inside the specified rectangle,
with the given solid background Color.
-
drawImage(Image, float, float, float, float, ImageObserver)
- Draws the specified image inside the specified rectangle.
-
drawImage(Image, float, float, ImageObserver)
- Draws the specified image at the specified coordinate (x, y).
-
drawLine(float, float, float, float)
- Draws a line between the coordinates (x1,y1) and (x2,y2).
-
drawOval(float, float, float, float)
- Draws an oval inside the specified rectangle using the current color.
-
drawPolygon(float[], float[], int)
- Draws a polygon defined by an array of x points and y points.
-
drawRect(float, float, float, float)
- Draws the outline of the specified rectangle using the current color.
-
drawRoundRect(float, float, float, float, float, float)
- Draws an outlined rounded corner rectangle using the current color.
-
drawString(String, float, float)
- Draws the specified String using the current font and color.
-
fill3DRect(float, float, float, float, boolean)
- Paints a highlighted 3-D rectangle using the current color.
-
fillArc(float, float, float, float, int, int)
- Fills an arc using the current color.
-
fillOval(float, float, float, float)
- Fills an oval inside the specified rectangle using the current color.
-
fillPolygon(float[], float[], int)
- Fills a polygon with the current color using an
even-odd fill rule (otherwise known as an alternating rule).
-
fillRect(float, float, float, float)
- Fills the specified rectangle with the current color.
-
fillRoundRect(float, float, float, float, float, float)
- Draws a rounded rectangle filled in with the current color.
-
getClipRect()
- Returns the area of the current clipping area.
-
getColor()
- Gets the current color.
-
getFont()
- Gets the current font.
-
getFontMetrics(Font)
- Gets the current font sizes for the specified font.
-
getFontSizes()
- Gets the current font sizes.
-
getGraphics()
- Get the original Graphics object.
-
setColor(Color)
- Sets the current color to the specified color.
-
setFont(Font)
- Sets the font for all subsequent text-drawing operations.
-
setPaintMode()
- Sets the paint mode to overwrite the destination with the
current color.
-
setXORMode(Color)
- Sets the paint mode to alternate between the current color
and the new specified color.
-
toString()
- Returns a String object representing this Painters's value.
-
translate(float, float)
- Translates the specified parameters into the origin of the graphics context.
Painter
protected Painter(Graphics graphics)
- Create a Painter from a Graphics.
getGraphics
public Graphics getGraphics()
- Get the original Graphics object. This is not normally used; however, if it
is neccessary to use utility classes that need the Graphics object use
the Sgraphics class to convert to and from resolution independent units.
- Returns:
- the graphics object.
translate
public void translate(float x,
float y)
- Translates the specified parameters into the origin of the graphics context. All subsequent
operations on this graphics context will be relative to this origin.
- Parameters:
- x - the x coordinate
- y - the y coordinate
getColor
public Color getColor()
- Gets the current color.
- See Also:
- setColor
setColor
public void setColor(Color c)
- Sets the current color to the specified color. All subsequent graphics operations
will use this specified color.
- Parameters:
- c - the color to be set
- See Also:
- Color, getColor
setPaintMode
public void setPaintMode()
- Sets the paint mode to overwrite the destination with the
current color.
setXORMode
public void setXORMode(Color c1)
- Sets the paint mode to alternate between the current color
and the new specified color. When drawing operations are
performed, pixels which are the current color will be changed
to the specified color and vice versa. Pixels of colors other
than those two colors will be changed in an unpredictable, but
reversible manner - if you draw the same figure twice then all
pixels will be restored to their original values.
- Parameters:
- c1 - the second color
getFont
public Font getFont()
- Gets the current font.
- See Also:
- setFont
setFont
public void setFont(Font font)
- Sets the font for all subsequent text-drawing operations.
- Parameters:
- font - the specified font
- See Also:
- Font, getFont, drawString, drawBytes, drawChars
getFontSizes
public FontMetrics getFontSizes()
- Gets the current font sizes.
- See Also:
- getFont
getFontMetrics
public FontMetrics getFontMetrics(Font f)
- Gets the current font sizes for the specified font.
- Parameters:
- f - the specified font
- See Also:
- getFont, getFontMetrics
getClipRect
public Area getClipRect()
- Returns the area of the current clipping area.
- See Also:
- clipRect
clipRect
public void clipRect(Area area)
- Clips to a rectangle. The resulting clipping area is the
intersection of the current clipping area and the specified
area. Graphic operations have no effect outside of the
clipping area.
- Parameters:
- area - the clip area.
- See Also:
- getClipRect
copyArea
public void copyArea(float x,
float y,
float width,
float height,
float dx,
float dy)
- Copies an area of the screen.
- Parameters:
- x - the x-coordinate of the source
- y - the y-coordinate of the source
- width - the width
- height - the height
- dx - the horizontal distance
- dy - the vertical distance
drawLine
public void drawLine(float x1,
float y1,
float x2,
float y2)
- Draws a line between the coordinates (x1,y1) and (x2,y2). The line is drawn
below and to the left of the logical coordinates.
- Parameters:
- x1 - the first point's x coordinate
- y1 - the first point's y coordinate
- x2 - the second point's x coordinate
- y2 - the second point's y coordinate
fillRect
public void fillRect(float x,
float y,
float width,
float height)
- Fills the specified rectangle with the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- See Also:
- drawRect, clearRect
drawRect
public void drawRect(float x,
float y,
float width,
float height)
- Draws the outline of the specified rectangle using the current color.
Use drawRect(x, y, width-1, height-1) to draw the outline inside the specified
rectangle.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- See Also:
- fillRect, clearRect
clearRect
public void clearRect(float x,
float y,
float width,
float height)
- Clears the specified rectangle by filling it with the current background color
of the current drawing surface.
Which drawing surface it selects depends on how the graphics context
was created.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- See Also:
- fillRect, drawRect
drawRoundRect
public void drawRoundRect(float x,
float y,
float width,
float height,
float arcWidth,
float arcHeight)
- Draws an outlined rounded corner rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- arcWidth - the horizontal diameter of the arc at the four corners
- arcHeight - the horizontal diameter of the arc at the four corners
- See Also:
- fillRoundRect
fillRoundRect
public void fillRoundRect(float x,
float y,
float width,
float height,
float arcWidth,
float arcHeight)
- Draws a rounded rectangle filled in with the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- arcWidth - the horizontal diameter of the arc at the four corners
- arcHeight - the horizontal diameter of the arc at the four corners
- See Also:
- drawRoundRect
draw3DRect
public void draw3DRect(float x,
float y,
float width,
float height,
boolean raised)
- Draws a highlighted 3-D rectangle.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- raised - a boolean that states whether the rectangle is raised or not
fill3DRect
public void fill3DRect(float x,
float y,
float width,
float height,
boolean raised)
- Paints a highlighted 3-D rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- raised - a boolean that states whether the rectangle is raised or not
drawOval
public void drawOval(float x,
float y,
float width,
float height)
- Draws an oval inside the specified rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- See Also:
- fillOval
fillOval
public void fillOval(float x,
float y,
float width,
float height)
- Fills an oval inside the specified rectangle using the current color.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- See Also:
- drawOval
drawArc
public void drawArc(float x,
float y,
float width,
float height,
int startAngle,
int arcAngle)
- Draws an arc bounded by the specified rectangle starting at
startAngle, where 0 degrees is at the 3-o'clock position, and
extending for arcAngle degrees. Positive values for arcAngle
indicate counter-clockwise rotations, negative values indicate
clockwise rotations.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- startAngle - the beginning angle
- arcAngle - the angle of the arc (relative to startAngle).
- See Also:
- fillArc
fillArc
public void fillArc(float x,
float y,
float width,
float height,
int startAngle,
int arcAngle)
- Fills an arc using the current color. This generates a pie shape.
The extent of the arc is the same as is described for the drawArc
method.
- Parameters:
- x - the x coordinate
- y - the y coordinate
- width - the width of the arc
- height - the height of the arc
- startAngle - the beginning angle
- arcAngle - the angle of the arc (relative to startAngle).
- See Also:
- drawArc
drawPolygon
public void drawPolygon(float xPoints[],
float yPoints[],
int nPoints)
- Draws a polygon defined by an array of x points and y points.
- Parameters:
- xPoints - an array of x points
- yPoints - an array of y points
- nPoints - the total number of points
- See Also:
- fillPolygon
fillPolygon
public void fillPolygon(float xPoints[],
float yPoints[],
int nPoints)
- Fills a polygon with the current color using an
even-odd fill rule (otherwise known as an alternating rule).
- Parameters:
- xPoints - an array of x points
- yPoints - an array of y points
- nPoints - the total number of points
- See Also:
- drawPolygon
drawString
public void drawString(String str,
float x,
float y)
- Draws the specified String using the current font and color.
The x,y position is the starting point of the baseline of the String.
- Parameters:
- str - the String to be drawn
- x - the x coordinate
- y - the y coordinate
- See Also:
- drawChars, drawBytes
drawChars
public void drawChars(char data[],
int offset,
int length,
float x,
float y)
- Draws the specified characters using the current font and color.
- Parameters:
- data - the array of characters to be drawn
- offset - the start offset in the data
- length - the number of characters to be drawn
- x - the x coordinate
- y - the y coordinate
- See Also:
- drawString, drawBytes
drawBytes
public void drawBytes(byte data[],
int offset,
int length,
float x,
float y)
- Draws the specified bytes using the current font and color.
- Parameters:
- data - the data to be drawn
- offset - the start offset in the data
- length - the number of bytes that are drawn
- x - the x coordinate
- y - the y coordinate
- See Also:
- drawString, drawChars
drawImage
public boolean drawImage(Image img,
float x,
float y,
ImageObserver observer)
- Draws the specified image at the specified coordinate (x, y). If the image is
incomplete the image observer will be notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- observer - notifies if the image is complete or not
- See Also:
- Image, ImageObserver
drawImage
public boolean drawImage(Image img,
float x,
float y,
float width,
float height,
ImageObserver observer)
- Draws the specified image inside the specified rectangle. The image is
scaled if necessary. If the image is incomplete the image observer will be
notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- observer - notifies if the image is complete or not
- See Also:
- Image, ImageObserver
drawImage
public boolean drawImage(Image img,
float x,
float y,
Color bgcolor,
ImageObserver observer)
- Draws the specified image at the specified coordinate (x, y),
with the given solid background Color. If the image is
incomplete the image observer will be notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- observer - notifies if the image is complete or not
- See Also:
- Image, ImageObserver
drawImage
public boolean drawImage(Image img,
float x,
float y,
float width,
float height,
Color bgcolor,
ImageObserver observer)
- Draws the specified image inside the specified rectangle,
with the given solid background Color. The image is
scaled if necessary. If the image is incomplete the image
observer will be notified later.
- Parameters:
- img - the specified image to be drawn
- x - the x coordinate
- y - the y coordinate
- width - the width of the rectangle
- height - the height of the rectangle
- observer - notifies if the image is complete or not
- See Also:
- Image, ImageObserver
toString
public String toString()
- Returns a String object representing this Painters's value.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index