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.

Constructor Index

 o Painter(Graphics)
Create a Painter from a Graphics.

Method Index

 o clearRect(float, float, float, float)
Clears the specified rectangle by filling it with the current background color of the current drawing surface.
 o clipRect(Area)
Clips to a rectangle.
 o copyArea(float, float, float, float, float, float)
Copies an area of the screen.
 o draw3DRect(float, float, float, float, boolean)
Draws a highlighted 3-D rectangle.
 o 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.
 o drawBytes(byte[], int, int, float, float)
Draws the specified bytes using the current font and color.
 o drawChars(char[], int, int, float, float)
Draws the specified characters using the current font and color.
 o drawImage(Image, float, float, Color, ImageObserver)
Draws the specified image at the specified coordinate (x, y), with the given solid background Color.
 o drawImage(Image, float, float, float, float, Color, ImageObserver)
Draws the specified image inside the specified rectangle, with the given solid background Color.
 o drawImage(Image, float, float, float, float, ImageObserver)
Draws the specified image inside the specified rectangle.
 o drawImage(Image, float, float, ImageObserver)
Draws the specified image at the specified coordinate (x, y).
 o drawLine(float, float, float, float)
Draws a line between the coordinates (x1,y1) and (x2,y2).
 o drawOval(float, float, float, float)
Draws an oval inside the specified rectangle using the current color.
 o drawPolygon(float[], float[], int)
Draws a polygon defined by an array of x points and y points.
 o drawRect(float, float, float, float)
Draws the outline of the specified rectangle using the current color.
 o drawRoundRect(float, float, float, float, float, float)
Draws an outlined rounded corner rectangle using the current color.
 o drawString(String, float, float)
Draws the specified String using the current font and color.
 o fill3DRect(float, float, float, float, boolean)
Paints a highlighted 3-D rectangle using the current color.
 o fillArc(float, float, float, float, int, int)
Fills an arc using the current color.
 o fillOval(float, float, float, float)
Fills an oval inside the specified rectangle using the current color.
 o fillPolygon(float[], float[], int)
Fills a polygon with the current color using an even-odd fill rule (otherwise known as an alternating rule).
 o fillRect(float, float, float, float)
Fills the specified rectangle with the current color.
 o fillRoundRect(float, float, float, float, float, float)
Draws a rounded rectangle filled in with the current color.
 o getClipRect()
Returns the area of the current clipping area.
 o getColor()
Gets the current color.
 o getFont()
Gets the current font.
 o getFontMetrics(Font)
Gets the current font sizes for the specified font.
 o getFontSizes()
Gets the current font sizes.
 o getGraphics()
Get the original Graphics object.
 o setColor(Color)
Sets the current color to the specified color.
 o setFont(Font)
Sets the font for all subsequent text-drawing operations.
 o setPaintMode()
Sets the paint mode to overwrite the destination with the current color.
 o setXORMode(Color)
Sets the paint mode to alternate between the current color and the new specified color.
 o toString()
Returns a String object representing this Painters's value.
 o translate(float, float)
Translates the specified parameters into the origin of the graphics context.

Constructors

 o Painter
  protected Painter(Graphics graphics)
Create a Painter from a Graphics.

Methods

 o 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.
 o 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
 o getColor
  public Color getColor()
Gets the current color.
See Also:
setColor
 o 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
 o setPaintMode
  public void setPaintMode()
Sets the paint mode to overwrite the destination with the current color.
 o 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
 o getFont
  public Font getFont()
Gets the current font.
See Also:
setFont
 o 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
 o getFontSizes
  public FontMetrics getFontSizes()
Gets the current font sizes.
See Also:
getFont
 o getFontMetrics
  public FontMetrics getFontMetrics(Font f)
Gets the current font sizes for the specified font.
Parameters:
f - the specified font
See Also:
getFont, getFontMetrics
 o getClipRect
  public Area getClipRect()
Returns the area of the current clipping area.
See Also:
clipRect
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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