maclib
Class GrafPort

java.lang.Object
  extended by maclib.GrafPort

public final class GrafPort
extends java.lang.Object

A GrafPort object implements QuickDraw-like drawing and event routines onto an object of class DrawingApplet, used for a drawing panel. The DrawingApplet provides automatic repaint, using an off-screen image, and also listeners for keyboard and mouse events. Usual GrafPort constructors initialize a DrawingFrame, which contains this DrawingApplet.

Version:
01 mar 2005
Author:
Philippe Chassignet, Ecole Polytechnique
See Also:
DrawingFrame, DrawingApplet, MacLib

Field Summary
static int BLACK_COLOR
          Used to specify one of the standard painting color.
static int BLUE_COLOR
          Used to specify one of the standard painting color.
static int BOLD
          Used to specify a text style.
static int CONTROL
          Used to encode the control modifier in the button state.
static int CYAN_COLOR
          Used to specify one of the standard painting color.
static java.lang.String DIALOG
          Used to specify one of the standard text font.
static java.lang.String DIALOG_INPUT
          Used to specify one of the standard text font.
static int GREEN_COLOR
          Used to specify one of the standard painting color.
static int ITALIC
          Used to specify a text style.
static int MAGENTA_COLOR
          Used to specify one of the standard painting color.
static int META
          Used to encode the meta modifier in the button state.
static java.lang.String MONOSPACED
          Used to specify one of the standard text font.
static int NONE
          Used to specify no modifier in the button state.
static int PAT_COPY
          Used to specify the normal painting mode.
static int PAT_XOR
          Used to specify the normal painting mode.
static int PLAIN
          Used to specify a text style.
static int RED_COLOR
          Used to specify one of the standard painting color.
static java.lang.String SANS_SERIF
          Used to specify one of the standard text font.
static java.lang.String SERIF
          Used to specify one of the standard text font.
static int SHIFT
          Used to encode the shift modifier in the button state.
static int WHITE_COLOR
          Used to specify one of the standard painting color.
static int YELLOW_COLOR
          Used to specify one of the standard painting color.
 
Constructor Summary
GrafPort()
          Constructs and initializes a GrafPort and an attached DrawingFrame having : the title "Drawing", the default initial size for the frame, the default size for the off-screen image
GrafPort(java.lang.String title)
          Constructs and initializes a GrafPort and an attached DrawingFrame having : the specified title, the default initial size for the frame, the default size for the off-screen image
GrafPort(java.lang.String title, int width, int height)
          Constructs and initializes a GrafPort and an attached DrawingFrame having : the specified title, the specified initial size for the frame, the default final size for the off-screen image
GrafPort(java.lang.String title, int width, int height, int fullWidth, int fullHeight)
          Constructs and initializes a GrafPort and an attached DrawingFrame having : the specified title, the specified initial size for the frame, the specified final size for the off-screen image
 
Method Summary
 void backColor(java.awt.Color color)
          Sets the current background color, used when erasing or inverting, as specified by the given java.awt.Color object.
 void backColor(int color)
          Sets the current background color, used when erasing or inverting, as specified by one of the height constant flags : BLACK_COLOR, WHITE_COLOR, RED_COLOR, GREEN_COLOR, BLUE_COLOR, CYAN_COLOR, MAGENTA_COLOR or YELLOW_COLOR.
 boolean button()
          Returns the state of the mouse button for the attached drawing panel.
 int buttonState()
          Returns the int value that describes the modifier keys state at the time of the last mouse pressed event.
 int charWidth(char c)
          Returns the width in pixels of the given character.
 java.awt.Image createImage(java.awt.image.ImageProducer producer)
          Creates an image from the specified image producer.
 java.awt.Image createImage(int width, int height)
          Creates an off-screen drawable image to be used for double buffering.
 void dispose()
          Disposes of this GrafPort and attached objects.
 void drawChar(char c)
          Draws the given character.
 boolean drawImage(java.awt.Image img)
          Draws the given image, starting at location (0,0).
 void drawLine(int x1, int y1, int x2, int y2)
          Draws a line from the location that is specified by x1 and y1 to the location that is specified by x2 and y2 (in coordinates relative to the drawing panel).
 void drawString(java.lang.String s)
          Draws the given text string.
 void drawText(char[] textBuf, int firstByte, int byteCount)
          Draws the specified text.
 void eraseArc(Rect r, int startAngle, int arcAngle)
          Paints inside a wedge of the oval that fits inside the specified rectangle, using the background color.
 void eraseOval(Rect r)
          Paints inside the oval that fits inside the specified rectangle, using the background color.
 void erasePolygon(Point[] points, int pCount)
          Paints inside the specified polygon, using the background color.
 void eraseRect(Rect r)
          Paints inside the specified rectangle, using the background color.
 void eraseRoundRect(Rect r, int arcWidth, int arcHeight)
          Paints inside the specified rounded-corner rectangle, using the background color.
 void finalize()
          Called by the garbage collector when there are no more reference to this GrafPort.
 void foreColor(java.awt.Color color)
          Sets the current pen color, used for drawing lines or text and painting shapes, as specified by the given java.awt.Color object.
 void foreColor(int color)
          Sets the current pen color, used for drawing lines or text and painting shapes, as specified by one of the height constant flags : BLACK_COLOR, WHITE_COLOR, RED_COLOR, GREEN_COLOR, BLUE_COLOR, CYAN_COLOR, MAGENTA_COLOR or YELLOW_COLOR.
 void frameArc(Rect r, int startAngle, int arcAngle)
          Draws an arc of outline just inside the oval that fits inside the specified rectangle.
 void frameOval(Rect r)
          Draws an outline just inside the oval that fits inside the specified rectangle.
 void framePolygon(Point[] points, int pCount)
          Draws an outline of the specified polygon.
 void frameRect(Rect r)
          Draws an outline just inside the specified rectangle.
 void frameRoundRect(Rect r, int arcWidth, int arcHeight)
          Draws an outline just inside the specified rounded-corner rectangle.
 Point getClick()
          Waits until the mouse button is pressed and then released in the attached drawing panel.
 Rect getDrawingRect()
          Gets the drawing bounds of the attached drawing panel.
 FontInfo getFontInfo()
          Returns the metric informations about the current font as a FontInfo object.
 char getKey()
          Returns the char corresponding to the last keyboard event in the drawing panel.
 Point getMouse()
          Returns the current mouse location (relative to the attached drawing panel) as a PointPoint object.
 DrawingApplet getPanel()
          Returns the drawing panel attached to this GrafPort.
 Point getPen()
          Returns the current pen location (relative to the attached drawing panel) as a Point object.
 void hideDrawing()
          Hides the attached drawing panel.
 void invertArc(Rect r, int startAngle, int arcAngle)
          Inverts pixels inside a wedge of the oval that fits inside the specified rectangle.
 void invertCircle(int x, int y, int r)
          Inverts pixels inside the specified circle.
 void invertOval(Rect r)
          Inverts pixels inside the oval that fits inside the specified rectangle.
 void invertPolygon(Point[] points, int pCount)
          Inverts pixels inside the specified polygon.
 void invertRect(Rect r)
          Inverts pixels inside the specified rectangle.
 void invertRoundRect(Rect r, int arcWidth, int arcHeight)
          Inverts pixels inside the specified rounded-corner rectangle.
 boolean keyPressed()
          Checks whether the char, corresponding to the last keyboard event occured in the drawing panel, is still available.
 void line(int dh, int dv)
          Draws a line from the current pen location to the location that is at distance of dh horizontally and dv vertically.
 void lineTo(int h, int v)
          Draws a line from the current pen location to the location that is specified by h and v (in coordinates relative to the drawing panel).
 void move(int dh, int dv)
          Translates the coordinates of the pen by the specified displacement vector.
 void moveTo(int h, int v)
          Sets the coordinates of the pen (relative to the drawing panel) to the specified location.
 void paintArc(Rect r, int startAngle, int arcAngle)
          Paints inside a wedge of the oval that fits inside the specified rectangle.
 void paintCircle(int x, int y, int r)
          Paints inside the specified circle.
 void paintOval(Rect r)
          Paints inside the oval that fits inside the specified rectangle.
 void paintPolygon(Point[] points, int pCount)
          Paints inside the specified polygon.
 void paintRect(Rect r)
          Paints inside the specified rectangle.
 void paintRoundRect(Rect r, int arcWidth, int arcHeight)
          Paints inside the specified rounded-corner rectangle.
 void penMode(int mode)
          Sets the current transfer mode, used for drawing lines and painting shapes, to be one of the two constant flags PAT_COPY or PAT_XOR.
 void penNormal()
          Resets the initial state, that is the mode and size, of the pen.
 void penSize(int width, int height)
          Sets the dimensions of the rectangular pen, used for drawing lines and framed shapes.
 void reset()
          Resets the drawing context attached to this GrafPort.
 void resize(int width, int height)
          Sets the size of the attached drawing panel as specified.
 void setDrawingRect(Rect r)
          Sets the bounds of the attached drawing panel as specified by the given Rect object.
 void showDrawing()
          Makes the attached drawing panel visible and brings it to the front.
 void showStatus(java.lang.String s)
          Prints a string of text (for user information).
 int stringWidth(java.lang.String s)
          Returns the width in pixels of the given text string.
 void textFace(int face)
          Sets the style of the font used for drawing text, it should be one of the followings constants : PLAIN, BOLD, ITALIC or BOLD+ITALIC.
 void textFont(java.lang.String name)
          Sets the name of the font used for drawing text.
 void textSize(int size)
          Sets the size of the font used for drawing text.
 int textWidth(char[] textBuf, int firstByte, int byteCount)
          Returns the width in pixels of the specified text.
 java.lang.String toString()
          Returns a string representation of the state of this GrafPort.
 boolean trackMouse(Point p)
          Waits until the mouse button is released, after being pressed, or until the mouse location is dragged.
 void waitClickDown()
          Waits until the mouse button is pressed in the attached drawing panel.
 void waitClickUp()
          Waits until the mouse button is released after being pressed in the attached drawing panel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PAT_COPY

public static final int PAT_COPY
Used to specify the normal painting mode.

See Also:
penMode(int), Constant Field Values

PAT_XOR

public static final int PAT_XOR
Used to specify the normal painting mode.

See Also:
penMode(int), Constant Field Values

BLACK_COLOR

public static final int BLACK_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

WHITE_COLOR

public static final int WHITE_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

RED_COLOR

public static final int RED_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

GREEN_COLOR

public static final int GREEN_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

BLUE_COLOR

public static final int BLUE_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

CYAN_COLOR

public static final int CYAN_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

MAGENTA_COLOR

public static final int MAGENTA_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

YELLOW_COLOR

public static final int YELLOW_COLOR
Used to specify one of the standard painting color.

See Also:
foreColor(int), backColor(int), Constant Field Values

DIALOG

public static final java.lang.String DIALOG
Used to specify one of the standard text font.

See Also:
textFont(String), Constant Field Values

DIALOG_INPUT

public static final java.lang.String DIALOG_INPUT
Used to specify one of the standard text font.

See Also:
textFont(String), Constant Field Values

SANS_SERIF

public static final java.lang.String SANS_SERIF
Used to specify one of the standard text font.

See Also:
textFont(String), Constant Field Values

SERIF

public static final java.lang.String SERIF
Used to specify one of the standard text font.

See Also:
textFont(String), Constant Field Values

MONOSPACED

public static final java.lang.String MONOSPACED
Used to specify one of the standard text font.

See Also:
textFont(String), Constant Field Values

PLAIN

public static final int PLAIN
Used to specify a text style.

See Also:
textFace(int), Constant Field Values

BOLD

public static final int BOLD
Used to specify a text style.

See Also:
textFace(int), Constant Field Values

ITALIC

public static final int ITALIC
Used to specify a text style.

See Also:
textFace(int), Constant Field Values

NONE

public static final int NONE
Used to specify no modifier in the button state.

See Also:
buttonState(), Constant Field Values

SHIFT

public static final int SHIFT
Used to encode the shift modifier in the button state.

See Also:
buttonState(), Constant Field Values

CONTROL

public static final int CONTROL
Used to encode the control modifier in the button state.

See Also:
buttonState(), Constant Field Values

META

public static final int META
Used to encode the meta modifier in the button state.

See Also:
buttonState(), Constant Field Values
Constructor Detail

GrafPort

public GrafPort(java.lang.String title,
                int width,
                int height,
                int fullWidth,
                int fullHeight)
Constructs and initializes a GrafPort and an attached DrawingFrame having :

Parameters:
title - the name given to the created DrawingFrame
width - the initial width of the frame
height - the initial height of the frame
fullWidth - the final width of the off-screen image
fullHeight - the final height of the off-screen image

GrafPort

public GrafPort(java.lang.String title,
                int width,
                int height)
Constructs and initializes a GrafPort and an attached DrawingFrame having :

Parameters:
title - the name given to the created DrawingFrame
width - the initial width of the frame
height - the initial height of the frame
See Also:
DrawingStuff.DEFAULT_SCREEN_WIDTH, DrawingStuff.DEFAULT_SCREEN_HEIGHT

GrafPort

public GrafPort(java.lang.String title)
Constructs and initializes a GrafPort and an attached DrawingFrame having :

Parameters:
title - the name given to the created DrawingFrame
See Also:
DrawingFrame.DEFAULT_FRAME_WIDTH, DrawingFrame.DEFAULT_FRAME_HEIGHT, DrawingStuff.DEFAULT_SCREEN_WIDTH, DrawingStuff.DEFAULT_SCREEN_HEIGHT

GrafPort

public GrafPort()
Constructs and initializes a GrafPort and an attached DrawingFrame having :

See Also:
DrawingFrame.DEFAULT_FRAME_WIDTH, DrawingFrame.DEFAULT_FRAME_HEIGHT, DrawingStuff.DEFAULT_SCREEN_WIDTH, DrawingStuff.DEFAULT_SCREEN_HEIGHT
Method Detail

reset

public void reset()
Resets the drawing context attached to this GrafPort. Also, it clears the content of the drawing panel.


dispose

public void dispose()
Disposes of this GrafPort and attached objects.


finalize

public void finalize()
Called by the garbage collector when there are no more reference to this GrafPort.

Overrides:
finalize in class java.lang.Object

setDrawingRect

public void setDrawingRect(Rect r)
Sets the bounds of the attached drawing panel as specified by the given Rect object.

Parameters:
r - a Rect object that specifies the new screen coordinates
See Also:
resize(int, int), getDrawingRect()

resize

public void resize(int width,
                   int height)
Sets the size of the attached drawing panel as specified.

Parameters:
width - the width of the panel in pixels
height - the height of the panel in pixels
See Also:
setDrawingRect(Rect)

getDrawingRect

public Rect getDrawingRect()
Gets the drawing bounds of the attached drawing panel.

Returns:
a new Rect object filled with the screen coordinates of the drawing area
See Also:
setDrawingRect(Rect)

showDrawing

public void showDrawing()
Makes the attached drawing panel visible and brings it to the front.


hideDrawing

public void hideDrawing()
Hides the attached drawing panel.


button

public boolean button()
Returns the state of the mouse button for the attached drawing panel.

Returns:
true if the button is currently down after being pressed in the drawing panel; false otherwise

waitClickDown

public void waitClickDown()
Waits until the mouse button is pressed in the attached drawing panel.


waitClickUp

public void waitClickUp()
Waits until the mouse button is released after being pressed in the attached drawing panel.


getMouse

public Point getMouse()
Returns the current mouse location (relative to the attached drawing panel) as a PointPoint object.

Returns:
the PointPoint object giving the mouse location

getClick

public Point getClick()
Waits until the mouse button is pressed and then released in the attached drawing panel. Returns the mouse location (relative to the drawing panel) at the release time as a Point object.

Returns:
the PointPoint object giving the mouse location

trackMouse

public boolean trackMouse(Point p)
Waits until the mouse button is released, after being pressed, or until the mouse location is dragged. Stores the issued mouse location (relative to the attached drawing panel) in the given point.

Parameters:
p - the Point object to be modified

buttonState

public int buttonState()
Returns the int value that describes the modifier keys state at the time of the last mouse pressed event. The returned value is either NONE, or a combination of the SHIFT, CONTROL and META (for the Alt key) constant flags.

Returns:
the modifier keys state as an int value
See Also:
NONE, SHIFT, CONTROL, META

keyPressed

public boolean keyPressed()
Checks whether the char, corresponding to the last keyboard event occured in the drawing panel, is still available.

Returns:
true if any char available; false otherwise

getKey

public char getKey()
Returns the char corresponding to the last keyboard event in the drawing panel. If no char is available, will block until a new keyboard event occurs. The char is made unavailable for further calls.

Returns:
the last key char

penMode

public void penMode(int mode)
Sets the current transfer mode, used for drawing lines and painting shapes, to be one of the two constant flags PAT_COPY or PAT_XOR.

The initial pen mode is PAT_COPY.

Parameters:
mode - the specified painting mode
See Also:
PAT_COPY, PAT_XOR

penSize

public void penSize(int width,
                    int height)
Sets the dimensions of the rectangular pen, used for drawing lines and framed shapes.

The initial pen size is 1x1.

Parameters:
width - the new width for the pen
height - the new height for the pen

penNormal

public void penNormal()
Resets the initial state, that is the mode and size, of the pen. The pen location is not changed.

See Also:
penMode(int), penSize(int, int)

foreColor

public void foreColor(java.awt.Color color)
Sets the current pen color, used for drawing lines or text and painting shapes, as specified by the given java.awt.Color object.

The initial pen color is as specified by java.awt.Color.black.

Parameters:
color - the Color object

foreColor

public void foreColor(int color)
Sets the current pen color, used for drawing lines or text and painting shapes, as specified by one of the height constant flags : BLACK_COLOR, WHITE_COLOR, RED_COLOR, GREEN_COLOR, BLUE_COLOR, CYAN_COLOR, MAGENTA_COLOR or YELLOW_COLOR.

The initial pen color is as specified by BLACK_COLOR.

Parameters:
color - the specified color flag
See Also:
BLACK_COLOR, WHITE_COLOR, RED_COLOR, GREEN_COLOR, BLUE_COLOR, CYAN_COLOR, MAGENTA_COLOR, YELLOW_COLOR

backColor

public void backColor(java.awt.Color color)
Sets the current background color, used when erasing or inverting, as specified by the given java.awt.Color object.

The initial background color is as specified by java.awt.Color.white.

Parameters:
color - the Color object

backColor

public void backColor(int color)
Sets the current background color, used when erasing or inverting, as specified by one of the height constant flags : BLACK_COLOR, WHITE_COLOR, RED_COLOR, GREEN_COLOR, BLUE_COLOR, CYAN_COLOR, MAGENTA_COLOR or YELLOW_COLOR.

The initial background color is as specified by WHITE_COLOR.

Parameters:
color - the specified color flag
See Also:
BLACK_COLOR, WHITE_COLOR, RED_COLOR, GREEN_COLOR, BLUE_COLOR, CYAN_COLOR, MAGENTA_COLOR, YELLOW_COLOR

getPen

public Point getPen()
Returns the current pen location (relative to the attached drawing panel) as a Point object.

Returns:
the Point object giving the pen location

moveTo

public void moveTo(int h,
                   int v)
Sets the coordinates of the pen (relative to the drawing panel) to the specified location.

No drawing is performed.

Parameters:
h - the horizontal coordinate of the new location
v - the vertical coordinate of the new location

move

public void move(int dh,
                 int dv)
Translates the coordinates of the pen by the specified displacement vector.

No drawing is performed.

Parameters:
dh - the horizontal displacement
dv - the vertical displacement

textFont

public void textFont(java.lang.String name)
Sets the name of the font used for drawing text. Some supported fonts are given by the followings constants : DIALOG, DIALOG_INPUT, SANS_SERIF, SERIF or MONOSPACED.

The initial text font is as specified by SERIF.

Parameters:
the - name of the new font used for drawing text
See Also:
DIALOG, DIALOG_INPUT, SANS_SERIF, SERIF, MONOSPACED

textSize

public void textSize(int size)
Sets the size of the font used for drawing text.

The initial text size is 12.

Parameters:
the - new size for drawing text

textFace

public void textFace(int face)
Sets the style of the font used for drawing text, it should be one of the followings constants : PLAIN, BOLD, ITALIC or BOLD+ITALIC.

The initial text style is as specified by PLAIN.

Parameters:
the - code of the new style for drawing text
See Also:
PLAIN, BOLD, ITALIC

getFontInfo

public FontInfo getFontInfo()
Returns the metric informations about the current font as a FontInfo object.

Returns:
the FontInfo object

line

public void line(int dh,
                 int dv)
Draws a line from the current pen location to the location that is at distance of dh horizontally and dv vertically. The pen location becomes this new location.

Parameters:
dh - the horizontal displacement
dv - the vertical displacement
See Also:
penMode(int), penSize(int, int), foreColor(java.awt.Color)

lineTo

public void lineTo(int h,
                   int v)
Draws a line from the current pen location to the location that is specified by h and v (in coordinates relative to the drawing panel). The pen location becomes this new location.

Parameters:
h - the horizontal coordinate of the new location
v - the vertical coordinate of the new location
See Also:
penMode(int), penSize(int, int), foreColor(java.awt.Color)

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line from the location that is specified by x1 and y1 to the location that is specified by x2 and y2 (in coordinates relative to the drawing panel). The pen location becomes the second location.

Parameters:
x1 - the horizontal coordinate of the first location
y1 - the vertical coordinate of the first location
x2 - the horizontal coordinate of the second location
y2 - the vertical coordinate of the second location
See Also:
penMode(int), penSize(int, int), foreColor(java.awt.Color)

frameRect

public void frameRect(Rect r)
Draws an outline just inside the specified rectangle. The pen location is not changed.

Parameters:
r - a Rect object that specifies the rectangle to be framed
See Also:
penMode(int), penSize(int, int), foreColor(java.awt.Color)

paintRect

public void paintRect(Rect r)
Paints inside the specified rectangle.

Parameters:
r - a Rect object that specifies the rectangle to be painted
See Also:
penMode(int), foreColor(java.awt.Color)

eraseRect

public void eraseRect(Rect r)
Paints inside the specified rectangle, using the background color.

Parameters:
r - a Rect object that specifies the rectangle to be erased
See Also:
backColor(java.awt.Color)

invertRect

public void invertRect(Rect r)
Inverts pixels inside the specified rectangle. Every white pixel becomes black and reciprocally. Pixels of other colors are changed in an undefined but reversible manner.

Parameters:
r - a Rect object that specifies the rectangle to be inverted

frameOval

public void frameOval(Rect r)
Draws an outline just inside the oval that fits inside the specified rectangle. The pen location is not changed.

Parameters:
r - a Rect object that specifies the oval to be framed
See Also:
penMode(int), penSize(int, int), foreColor(java.awt.Color)

paintOval

public void paintOval(Rect r)
Paints inside the oval that fits inside the specified rectangle.

Parameters:
r - a Rect object that specifies the oval to be painted
See Also:
penMode(int), foreColor(java.awt.Color)

eraseOval

public void eraseOval(Rect r)
Paints inside the oval that fits inside the specified rectangle, using the background color.

Parameters:
r - a Rect object that specifies the oval to be erased
See Also:
backColor(java.awt.Color)

invertOval

public void invertOval(Rect r)
Inverts pixels inside the oval that fits inside the specified rectangle. Every white pixel becomes black and reciprocally. Pixels of other colors are changed in an undefined but reversible manner.

Parameters:
r - a Rect object that specifies the oval to be inverted

paintCircle

public void paintCircle(int x,
                        int y,
                        int r)
Paints inside the specified circle.

Parameters:
x - the x coordinate of the center of the circle
y - the y coordinate of the center of the circle
r - the radius of the circle
See Also:
penMode(int), foreColor(java.awt.Color)

invertCircle

public void invertCircle(int x,
                         int y,
                         int r)
Inverts pixels inside the specified circle. Every white pixel becomes black and reciprocally. Pixels of other colors are changed in an undefined but reversible manner.

Parameters:
x - the x coordinate of the center of the circle
y - the y coordinate of the center of the circle
r - the radius of the circle

frameRoundRect

public void frameRoundRect(Rect r,
                           int arcWidth,
                           int arcHeight)
Draws an outline just inside the specified rounded-corner rectangle. The pen location is not changed.

Parameters:
r - a Rect object that specifies the shape to be framed
arcWidth - the horizontal diameter of curvature for the corners arcs
arcHeight - the vertical diameter of curvature for the corners arcs
See Also:
penMode(int), penSize(int, int), foreColor(java.awt.Color)

paintRoundRect

public void paintRoundRect(Rect r,
                           int arcWidth,
                           int arcHeight)
Paints inside the specified rounded-corner rectangle.

Parameters:
r - a Rect object that specifies the shape to be painted
arcWidth - the horizontal diameter of curvature for the corners arcs
arcHeight - the vertical diameter of curvature for the corners arcs
See Also:
penMode(int), foreColor(java.awt.Color)

eraseRoundRect

public void eraseRoundRect(Rect r,
                           int arcWidth,
                           int arcHeight)
Paints inside the specified rounded-corner rectangle, using the background color.

Parameters:
r - a Rect object that specifies the shape to be erased
arcWidth - the horizontal diameter of curvature for the corners arcs
arcHeight - the vertical diameter of curvature for the corners arcs
See Also:
backColor(java.awt.Color)

invertRoundRect

public void invertRoundRect(Rect r,
                            int arcWidth,
                            int arcHeight)
Inverts pixels inside the specified rounded-corner rectangle. Every white pixel becomes black and reciprocally. Pixels of other colors are changed in an undefined but reversible manner.

Parameters:
r - a Rect object that specifies the shape to be inverted
arcWidth - the horizontal diameter of curvature for the corners arcs
arcHeight - the vertical diameter of curvature for the corners arcs

frameArc

public void frameArc(Rect r,
                     int startAngle,
                     int arcAngle)
Draws an arc of outline just inside the oval that fits inside the specified rectangle. The startAngle parameter indicates where the arc begins and is treated mod 360. The arcAngle parameters defines the extent of the arc. The angles are given in degrees. A positive angle goes clockwise. Zero degree is at l2 o'clock. The pen location is not changed.

Parameters:
r - a Rect object that specifies the shape to be framed
startAngle - indicates where the arc begins
arcAngle - defines the extent of the arc
See Also:
penMode(int), penSize(int, int), foreColor(java.awt.Color)

paintArc

public void paintArc(Rect r,
                     int startAngle,
                     int arcAngle)
Paints inside a wedge of the oval that fits inside the specified rectangle. The startAngle parameter indicates where the arc begins and is treated mod 360. The arcAngle parameters defines the extent of the arc. The angles are given in degrees. A positive angle goes clockwise. Zero degree is at l2 o'clock.

Parameters:
r - a Rect object that specifies the shape to be painted
startAngle - indicates where the arc begins
arcAngle - defines the extent of the arc
See Also:
penMode(int), foreColor(java.awt.Color)

eraseArc

public void eraseArc(Rect r,
                     int startAngle,
                     int arcAngle)
Paints inside a wedge of the oval that fits inside the specified rectangle, using the background color. The startAngle parameter indicates where the arc begins and is treated mod 360. The arcAngle parameters defines the extent of the arc. The angles are given in degrees. A positive angle goes clockwise. Zero degree is at l2 o'clock.

Parameters:
r - a Rect object that specifies the shape to be erased
startAngle - indicates where the arc begins
arcAngle - defines the extent of the arc
See Also:
backColor(java.awt.Color)

invertArc

public void invertArc(Rect r,
                      int startAngle,
                      int arcAngle)
Inverts pixels inside a wedge of the oval that fits inside the specified rectangle. Every white pixel becomes black and reciprocally. Pixels of other colors are changed in an undefined but reversible manner. The startAngle parameter indicates where the arc begins and is treated mod 360. The arcAngle parameters defines the extent of the arc. The angles are given in degrees. A positive angle goes clockwise. Zero degree is at l2 o'clock.

Parameters:
r - a Rect object that specifies the shape to be inverted
startAngle - indicates where the arc begins
arcAngle - defines the extent of the arc

framePolygon

public void framePolygon(Point[] points,
                         int pCount)
Draws an outline of the specified polygon.

Parameters:
points - an array of the Point objects that specify the polygon to be framed
pCount - the number of points
See Also:
MacLib.newPointArray(int), penMode(int), penSize(int, int), foreColor(java.awt.Color)

paintPolygon

public void paintPolygon(Point[] points,
                         int pCount)
Paints inside the specified polygon. The area inside the polygon is defined using the even-odd fill rule.

Parameters:
points - an array of the Point objects that specify the polygon to be painted
pCount - the number of points
See Also:
MacLib.newPointArray(int), penMode(int), foreColor(java.awt.Color)

erasePolygon

public void erasePolygon(Point[] points,
                         int pCount)
Paints inside the specified polygon, using the background color. The area inside the polygon is defined using the even-odd fill rule.

Parameters:
points - an array of the Point objects that specify the polygon to be erased
pCount - the number of points
See Also:
MacLib.newPointArray(int), backColor(java.awt.Color)

invertPolygon

public void invertPolygon(Point[] points,
                          int pCount)
Inverts pixels inside the specified polygon. The area inside the polygon is defined using the even-odd fill rule. Every white pixel becomes black and reciprocally. Pixels of other colors are changed in an undefined but reversible manner.

Parameters:
points - an array of the Point objects that specify the polygon to be inverted
pCount - the number of points
See Also:
MacLib.newPointArray(int)

stringWidth

public int stringWidth(java.lang.String s)
Returns the width in pixels of the given text string. This value is added to the pen horizontal coordinate when the string is drawn.

Parameters:
s - the string to be measured
Returns:
the width of the given string
See Also:
drawString(java.lang.String)

textWidth

public int textWidth(char[] textBuf,
                     int firstByte,
                     int byteCount)
Returns the width in pixels of the specified text. This value is added to the pen horizontal coordinate when the specified text is drawn.

Parameters:
textBuf - the array of characters that stores the text
firstByte - indicates where the measured text begins
byteCount - indicates the number of characters to be measured
Returns:
the width of the specified text
See Also:
drawText(char[], int, int)

charWidth

public int charWidth(char c)
Returns the width in pixels of the given character. This value is added to the pen horizontal coordinate when the char is drawn.

Parameters:
c - the character to be measured
Returns:
the width of the given character
See Also:
drawChar(char)

drawString

public void drawString(java.lang.String s)
Draws the given text string. The string is placed beginning at the current pen location and extending to the right. The pen location ends up to the right of the last character in the string.

Parameters:
s - the string to be drawn
See Also:
moveTo(int, int), foreColor(java.awt.Color), textFont(java.lang.String), textSize(int), textFace(int)

drawText

public void drawText(char[] textBuf,
                     int firstByte,
                     int byteCount)
Draws the specified text. The text is placed beginning at the current pen location and extending to the right. The pen location ends up to the right of the last character in the string.

Parameters:
textBuf - the array of characters that stores the text
firstByte - indicates where the drawn text begins
byteCount - indicates the number of characters to be drawn
See Also:
moveTo(int, int), foreColor(java.awt.Color), textFont(java.lang.String), textSize(int), textFace(int)

drawChar

public void drawChar(char c)
Draws the given character. The char is placed beginning at the current pen location and extending to the right. The pen location ends up to the right of the character.

Parameters:
c - the character to be drawn
See Also:
moveTo(int, int), foreColor(java.awt.Color), textFont(java.lang.String), textSize(int), textFace(int)

createImage

public java.awt.Image createImage(java.awt.image.ImageProducer producer)
Creates an image from the specified image producer.

Parameters:
producer - the image producer
Returns:
the image produced.

createImage

public java.awt.Image createImage(int width,
                                  int height)
Creates an off-screen drawable image to be used for double buffering.

Parameters:
width - the specified width.
height - the specified height.
Returns:
an off-screen drawable image, which can be used for double buffering.

getPanel

public DrawingApplet getPanel()
Returns the drawing panel attached to this GrafPort.


drawImage

public boolean drawImage(java.awt.Image img)
Draws the given image, starting at location (0,0).

Parameters:
img - the Image object to be drawn
Returns:
true if the image has been completely drawn.
See Also:
Graphics.drawImage(Image, int, int, java.awt.image.ImageObserver)

showStatus

public void showStatus(java.lang.String s)
Prints a string of text (for user information). In the case of a GrafPort explicitely constructed, the string is printed on System.out. In the case of the GrafPort that is initialized by a DrawingApplet, the string is forwarded to the showStatus method of the applet.

Parameters:
s - the string to be printed
See Also:
Applet.showStatus(java.lang.String)

toString

public java.lang.String toString()
Returns a string representation of the state of this GrafPort.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of internal parameters