Class GpadComponent

java.lang.Object
  |
  +--GpadComponent

public abstract class GpadComponent
extends java.lang.Object

A gpad component is an object that contains graphical operations to be performed on the Paintlet canvas. The user can run the component and supply parameter values to it by interacting with a Gpad GUI.

The GpadComponent class is the abstract superclass of all gpad components.

Gpad components are developed by extending GpadComponent and implementing initComponent and runComponent. Component parameters are added within initComponent. Other initialization normally found in a constructor should be defined here. Gpad components should not define a constructor.

User-supplied parameter values are obtained in runComponent. This is followed by the specification of drawing operations using the methods of the GpadComponent class.

The width of the Paintlet canvas is 416 pixels and the height is 388 pixels. The constants GpadParm.WIDTH and GpadParm.HEIGHT should be used to refer to these values.

Version:
1.19.1, Feb 16, 2002
Author:
Joseph E. Dever
See Also:
GpadParm, GpadException, GpadParmException, GpadFilter, GpadCurve, GpadAnimation

Field Summary
 GpadParm gparm
          Container for parameter values.
 boolean parameters
          Flag indicating whether component has parameters.
 
Constructor Summary
GpadComponent()
          Class constructor.
 
Method Summary
 void addParameter(java.lang.String parmName, int parmType)
          Adds a parameter to the component of the specified name and type.
 GpadParm getGpadParm()
          Retrieves the GpadParm object associated with this gpad component.
 java.awt.Choice getVariableChoice(java.lang.String paramName)
          Invoked when a variable parameter type is selected on this component.
 void gpAnimate(GpadAnimation gpa)
          Runs an animation sequence specified by the GpadAnimation parameter.
 void gpApplyCurve(GpadCurve gpc)
          Applies the curve generation specified by the GpadCurve parameter to the canvas.
 void gpApplyFilter(GpadFilter gpf)
          Applies the filter operation specified by the GpadFilter parameter.
 void gpBlend(int x, int y)
          Applies a semi-transparent swatch of paint at the point (x,y).
 void gpBlendText(java.lang.String s, int x, int y, int w, boolean jagged)
          Draws the specified string with the gpBlend method.
 void gpCircle(int x, int y, int w, int h)
          Deprecated. Replaced by gpOval
 java.awt.Image gpCreateImage(java.awt.image.MemoryImageSource mis)
          Returns an Image created from the specified MemoryImageSource.
 void gpDrawImage(java.awt.Image img, int x, int y)
          Draws the specified image with the top-left corner at the point (x,y).
 void gpDrawImage(java.awt.Image img, int x, int y, int w, int h)
          Draws the specified image, scaled, with the top-left corner at the point (x,y).
 void gpDrawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2)
          Draws the specified image, scaled, with as much of the image as is currently available.
 void gpDrawImageBrush(java.util.Vector v, int startPtX, int startPtY)
          Draws the current image brush at the coordinates specified by the collection of points in the vector.
 void gpDrawLineMeasuredText(java.text.AttributedString as, java.awt.Point p, float wrapWidth)
          Draws the AttributedString parameter as a paragraph of text with a specified wrapping width.
 java.awt.Point gpDrawLineMeasuredText(java.text.AttributedString as, java.awt.Point p, float wrapWidth, boolean b)
          Deprecated. No replacement
 void gpDrawShape(java.awt.Shape s)
          Draws the Shape specified by parameter s.
 void gpDrawStringCentered(java.lang.String s, java.awt.Rectangle r)
          Draws the text given by the specified string centered in the parameter rectangle.
 void gpDrawStringLowerLeft(java.lang.String s, java.awt.Rectangle r)
          Draws the text given by the specified string at the lower left region of the parameter rectangle.
 void gpDrawStringLowerRight(java.lang.String s, java.awt.Rectangle r)
          Draws the text given by the specified string at the lower right region of the parameter rectangle.
 void gpDrawStringUpperLeft(java.lang.String s, java.awt.Rectangle r)
          Draws the text given by the specified string at the upper left region of the parameter rectangle.
 void gpDrawStringUpperRight(java.lang.String s, java.awt.Rectangle r)
          Draws the text given by the specified string at the upper right region of the parameter rectangle.
 void gpFillBackground(java.awt.Color c)
          Fills the Paintlet canvas with the specified color.
 java.awt.Image gpGetCanvasImage()
          Returns the canvas Image.
 java.awt.Image gpGetImage(java.io.File f)
          Returns the specified File parameter as an Image.
 java.awt.Image gpGetImageBrush()
          Returns the currently selected image brush.
 int gpGetImageBrushHeight()
          Returns the height of the current image brush.
 int gpGetImageBrushWidth()
          Returns the width of the current image brush.
 int gpGetImageHeight(java.awt.Image img)
          Returns the height of the specified image.
 int gpGetImageWidth(java.awt.Image img)
          Returns the width of the specified image.
 java.awt.geom.Rectangle2D gpGetStringBounds(java.lang.String s)
          Returns the bounding rectangle of the specified string.
 int gpGetStringHeight(java.lang.String s)
          Returns the height of the specified string.
 int gpGetStringHeight(java.lang.String s, java.awt.Font f)
          Returns the height of the string when drawn in the specified font.
 int gpGetStringWidth(java.lang.String s)
          Returns the width of the specified string.
 int gpGetStringWidth(java.lang.String s, java.awt.Font f)
          Returns the width of the string when drawn in the specified font.
 void gpImageBack()
          Tiles the canvas with the current image brush.
 void gpImageBack(boolean b, int horz, int vert)
          Tiles the canvas with the current image brush at specified horizontal and vertical intervals.
 void gpImageText(java.lang.String s, int x, int y)
          Draws the specified string with the current image brush.
 void gpLine(int x, int y, int x1, int y1)
          Draws a line between the points (x,y) and (x1,y1).
 void gpOval(int x, int y, int w, int h)
          Draws an oval.
 void gpPaintImgCircle(java.awt.Point startPt, java.awt.Point endPt)
          Draws a circle using the current image brush.
 void gpPaintImgLine(int x1, int y1, int x2, int y2)
          Draws a line using the current image brush.
 void gpQuadCurve(int x1, int y1, int x2, int y2, int x3, int y3)
          Draws a quadradic curve from the start point (x1,y1) to the end point (x3,y3) where (x2,y2) is the control point.
 void gpRectangle(int x, int y, int w, int h)
          Draws a rectangle.
 void gpRepaint()
          Repaints the entire canvas.
 void gpRepaint(int x, int y, int w, int h)
          Repaints a region of the canvas.
 void gpRestoreDefaults()
          Sets Paintlet's rendering variables to their default values.
 void gpSaveCanvas(java.lang.String name, java.awt.Rectangle r)
          Deprecated. Replaced by gpSaveCanvasToJPG
 void gpSaveCanvasToJPG(java.lang.String name, java.awt.Rectangle r)
          Saves a region of the Paintlet canvas as a JPEG file.
 void gpSaveImageToFile(java.io.File f, java.awt.image.BufferedImage img)
          Saves a BufferedImage as a JPEG file.
 void gpSaveImageToFile(java.io.File f, java.awt.image.BufferedImage img, float saveQuality)
          Saves a BufferedImage as a JPEG file with the specified quality-compression setting.
 void gpSaveScaledCanvas(java.lang.String name, int width, int height)
          Saves a scaled version of the Paintlet canvas as a JPEG file.
 void gpSetAntiAlias(boolean b)
          Sets rendering to be done with antialiasing when value of parameter b is true.
 void gpSetBrushDensity(int i)
          Sets the density of the paint brush for the spray operation.
 void gpSetBrushWidth(int x)
          Sets the width of the paint brush for rendering operations.
 void gpSetColor(java.awt.Color c)
          Sets the current color to the specified color.
 void gpSetFillShape(boolean b)
          Deprecated. Replaced by gpSetShapeFill
 void gpSetFont(java.awt.Font f)
          Sets the font for text rendering.
 void gpSetFont(java.lang.String name, int type, int size)
          Sets the font for text rendering to the Font with the specified name, style and face.
 void gpSetFontHiLite(boolean b)
          Text will be drawn with a hilite when the parameter is true.
 void gpSetFontHiLite(boolean b, int size, java.awt.Color c)
          Text will be drawn with a hilite in the specified size and color when the parameter b is true.
 void gpSetFontShear(double d)
          Deprecated. No replacement
 void gpSetGradient(boolean b)
          Sets the paint rendering mode to a color gradient when the value of the parameter b is true.
 void gpSetGradient(boolean b, java.awt.Color c1, java.awt.Color c2)
          Sets the paint rendering mode to a gradient of two specified colors when the value of the parameter b is true.
 void gpSetGradient(boolean b, java.awt.Color c1, java.awt.Color c2, boolean cyclic)
          Sets the paint rendering mode to a cyclic, two-color gradient when the value of the parameters b and cyclic are true.
 void gpSetImageBrush(int i)
          Sets the current image brush to the specified image.
 void gpSetShapeFill(boolean b)
          Sets the rendering of shapes to filled when parameter b is true, and drawn when false.
 void gpSetText(java.lang.String text, int x, int y)
          Draws the text specified by the String parameter using the current font and paint color.
 void gpSetTips(java.awt.Image img)
          Registers the image to be displayed as a tip.
 void gpSetTips(java.lang.String text)
          Registers the text to be displayed as a tip.
 void gpSetTransparent(boolean b)
          Sets the paint rendering mode to transparent when the value of the parameter b is true.
 void gpSetTransparent(boolean b, float f)
          Sets the paint rendering mode to a specified transparency when the value of the parameter b is true.
 void gpSpray(int x, int y)
          Applies a paint spray to the canvas.
 void gpTextBackground(java.lang.String text, java.lang.String fontName, int fontType, int fontSize, java.awt.Color c)
          Tiles the Paintlet canvas with the specified text in the given font.
abstract  void initComponent()
          An implementation of this abstract method must be provided when developing a gpad component.
 void newBackground(java.awt.Color c)
          Deprecated. Replaced by gpFillBackground
abstract  void runComponent()
          Invoked when the component is run by the user.
 void setTipsEnabled(boolean b)
          Deprecated. No replacement
 void showTips()
          Displays the tip that is registered on this component.
 boolean showTipsEnabled()
          Deprecated. No replacement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameters

public boolean parameters
Flag indicating whether component has parameters.

gparm

public GpadParm gparm
Container for parameter values. Also defines parameter types.
See Also:
GpadParm
Constructor Detail

GpadComponent

public GpadComponent()
Class constructor.
Method Detail

initComponent

public abstract void initComponent()
An implementation of this abstract method must be provided when developing a gpad component. Normally, this method initializes the component by adding zero or more parameters. Also performs other initialization normally found in a constructor. Gpad components should not define a constructor.

runComponent

public abstract void runComponent()
Invoked when the component is run by the user. An implementation of this abstract method must be provided when developing a gpad component. This method retrieves parameter values, if any, and executes operations on the Paintlet canvas using methods of this class.

addParameter

public final void addParameter(java.lang.String parmName,
                               int parmType)
Adds a parameter to the component of the specified name and type. Parameter types are defined in GpadParm.
Parameters:
parmName - the string that is to be this parameter's name
parmType - the type of this parameter
See Also:
GpadParm

getGpadParm

public final GpadParm getGpadParm()
Retrieves the GpadParm object associated with this gpad component. Parameters can be retrieved with this object. return GpadParm a GpadParm object with this component's parameters
See Also:
GpadParm.getParmValue(String)

getVariableChoice

public java.awt.Choice getVariableChoice(java.lang.String paramName)
Invoked when a variable parameter type is selected on this component. This method should be overridden by components with variable parameters. The Choice object returned contains a list of one or more Strings. Returns a Choice object with the String null by default.

The argument String is the name of this parameter. If more than one variable parameter is added to this component, the argument String is used to determine which Choice object should be returned.

The returned Choice object is displayed in the Gpad GUI when the user selects the variable type parameter.

Parameters:
paramName - the name of the variable type parameter
Returns:
Choice the Choice object containing variable parameter values
See Also:
Choice

gpSetTips

public final void gpSetTips(java.lang.String text)
Registers the text to be displayed as a tip. The text is displayed when the showTips method is invoked.
Parameters:
text - the string to display

gpSetTips

public final void gpSetTips(java.awt.Image img)
Registers the image to be displayed as a tip. The image is displayed when the showTips method is invoked. Either String or Image tips may be registered on a component, but not both.
Parameters:
img - the Image to display

showTips

public final void showTips()
Displays the tip that is registered on this component. The tip is shown in the body of a JOptionPane message.
See Also:
gpSetTips(String), gpSetTips(Image)

showTipsEnabled

public final boolean showTipsEnabled()
Deprecated. No replacement


setTipsEnabled

public final void setTipsEnabled(boolean b)
Deprecated. No replacement


gpRestoreDefaults

public final void gpRestoreDefaults()
Sets Paintlet's rendering variables to their default values. The color gradient, transparent paint, solid shapes and antialiasing variables are false by default. The brushWidth and text hilite sizes are 1. The text hilite color is black and the transparency value is 0.5.

gpSetColor

public final void gpSetColor(java.awt.Color c)
Sets the current color to the specified color. All subsequent graphics operations will use this specified color.
Parameters:
c - the new color
See Also:
Color

gpSetGradient

public final void gpSetGradient(boolean b)
Sets the paint rendering mode to a color gradient when the value of the parameter b is true. The color gradient will use the last two colors selected with the gpSetColor method.
Parameters:
b - when true paints in two-color gradient
See Also:
gpSetColor(Color), gpSetGradient(boolean,Color,Color), gpSetGradient(boolean,Color,Color,boolean)

gpSetGradient

public final void gpSetGradient(boolean b,
                                java.awt.Color c1,
                                java.awt.Color c2)
Sets the paint rendering mode to a gradient of two specified colors when the value of the parameter b is true. The color gradient will use the parameter colors c1 and c2.
Parameters:
b - when true paints in two-color gradient
c1 - the first color of the color gradient
c2 - the second color of the color gradient
See Also:
gpSetGradient(boolean), gpSetGradient(boolean,Color,Color,boolean)

gpSetGradient

public final void gpSetGradient(boolean b,
                                java.awt.Color c1,
                                java.awt.Color c2,
                                boolean cyclic)
Sets the paint rendering mode to a cyclic, two-color gradient when the value of the parameters b and cyclic are true. The color gradient will use the parameter colors c1 and c2.
Parameters:
b - when true paints in two-color gradient
c1 - the first color of the color gradient
c2 - the second color of the color gradient
cyclic - when true paints in a cyclic gradient
See Also:
gpSetGradient(boolean), gpSetGradient(boolean,Color,Color)

gpSetTransparent

public final void gpSetTransparent(boolean b)
Sets the paint rendering mode to transparent when the value of the parameter b is true.
Parameters:
b - when true paint rendering is transparent
See Also:
gpSetTransparent(boolean,float)

gpSetTransparent

public final void gpSetTransparent(boolean b,
                                   float f)
Sets the paint rendering mode to a specified transparency when the value of the parameter b is true. The paint will be fully transparent when the value of the parameter f is 0.0, its minimum value, and fully opaque at 1.0, its maximum value.
Parameters:
b - when true paint rendering is transparent
f - the value specifying the transparency of the paint
See Also:
gpSetTransparent(boolean)

gpSetAntiAlias

public final void gpSetAntiAlias(boolean b)
Sets rendering to be done with antialiasing when value of parameter b is true.
Parameters:
b - when true rendering is done with antialiasing

gpSetFillShape

public final void gpSetFillShape(boolean b)
Deprecated. Replaced by gpSetShapeFill

See Also:
gpSetShapeFill(boolean)

gpSetShapeFill

public final void gpSetShapeFill(boolean b)
Sets the rendering of shapes to filled when parameter b is true, and drawn when false. This is the same as solid and hollow respectively.
Parameters:
b - when true shape rendering is filled or solid

gpSetBrushWidth

public final void gpSetBrushWidth(int x)
Sets the width of the paint brush for rendering operations. Minimum value for the parameter x is 1 and maximum value is 25.
Parameters:
x - the width of the paint brush

gpSetBrushDensity

public final void gpSetBrushDensity(int i)
Sets the density of the paint brush for the spray operation. Minimum density value for parameter i is 25 and maximum value is 100. The parameter value i corresponds to the number of random points sprayed per call to gpSpray.
Parameters:
i - the number of points to spray when gpSpray is invoked
See Also:
gpSpray(int,int)

newBackground

public final void newBackground(java.awt.Color c)
Deprecated. Replaced by gpFillBackground

See Also:
gpFillBackground(Color)

gpFillBackground

public final void gpFillBackground(java.awt.Color c)
Fills the Paintlet canvas with the specified color.
Parameters:
c - the background color

gpTextBackground

public final void gpTextBackground(java.lang.String text,
                                   java.lang.String fontName,
                                   int fontType,
                                   int fontSize,
                                   java.awt.Color c)
Tiles the Paintlet canvas with the specified text in the given font. The text is rendered in black on a background filled with a color gradient of Color c and white. The gradient is from the top of the canvas to the bottom.
Parameters:
text - the text tiled on the canvas
fontName - the name of the font to render text
fontType - the type of font to render text
fontSize - the size of the font to render text
c - the top color of the background color gradient

gpLine

public final void gpLine(int x,
                         int y,
                         int x1,
                         int y1)
Draws a line between the points (x,y) and (x1,y1).
Parameters:
x - the x coordinate of the first point
y - the y coordinate of the first point
x1 - the x coordinate of the second point
y1 - the y coordinate of the second point

gpCircle

public final void gpCircle(int x,
                           int y,
                           int w,
                           int h)
Deprecated. Replaced by gpOval

See Also:
gpOval(int,int,int,int)

gpOval

public final void gpOval(int x,
                         int y,
                         int w,
                         int h)
Draws an oval. The result is a circle or ellipse that fits into the rectangle defined by the x,y,w and h arguments.
Parameters:
x - the x coordinate of the upper left corner of the oval
y - the y coordinate of the upper left corner of the oval
w - the width of the oval to be drawn
h - the height of the oval to be drawn

gpRectangle

public final void gpRectangle(int x,
                              int y,
                              int w,
                              int h)
Draws a rectangle. The left and right edges of the rectangle are at x and x + w. The top and bottom are at y and y + h.
Parameters:
x - the x coordinate of the upper left corner of the rectangle
y - the y coordinate of the upper left corner of the rectangle
w - the width of the rectangle to be drawn
h - the height of the rectangle to be drawn

gpQuadCurve

public final void gpQuadCurve(int x1,
                              int y1,
                              int x2,
                              int y2,
                              int x3,
                              int y3)
Draws a quadradic curve from the start point (x1,y1) to the end point (x3,y3) where (x2,y2) is the control point.
Parameters:
x1 - the x coordinate of the start point
y1 - the y coordinate of the start point
x2 - the x coordinate of the control point
y2 - the y coordinate of the control point
x3 - the x coordinate of the end point
y3 - the y coordinate of the end point

gpDrawShape

public final void gpDrawShape(java.awt.Shape s)
Draws the Shape specified by parameter s.
Parameters:
s - the Shape to draw
See Also:
Shape

gpSpray

public final void gpSpray(int x,
                          int y)
Applies a paint spray to the canvas. The upper left corner of the spray is at the point (x,y).
Parameters:
x - the x coordinate of the spray anchor point
y - the y coordinate of the spray anchor point
See Also:
gpSetBrushDensity(int)

gpBlend

public final void gpBlend(int x,
                          int y)
Applies a semi-transparent swatch of paint at the point (x,y).
Parameters:
x - the x coordinate of the blend point
y - the y coordinate of the blend point
See Also:
gpSetBrushWidth(int)

gpSetText

public final void gpSetText(java.lang.String text,
                            int x,
                            int y)
Draws the text specified by the String parameter using the current font and paint color. The baseline of the first character is at point (x,y).
Parameters:
text - the text to draw
x - the x coordinate of the text anchor point
y - the y coordinate of the text anchor point
See Also:
gpDrawLineMeasuredText(AttributedString,Point,float), gpSetFont(Font), gpBlendText(String,int,int,int,boolean), gpImageText(String,int,int)

gpDrawLineMeasuredText

public final java.awt.Point gpDrawLineMeasuredText(java.text.AttributedString as,
                                                   java.awt.Point p,
                                                   float wrapWidth,
                                                   boolean b)
Deprecated. No replacement


gpDrawLineMeasuredText

public final void gpDrawLineMeasuredText(java.text.AttributedString as,
                                         java.awt.Point p,
                                         float wrapWidth)
Draws the AttributedString parameter as a paragraph of text with a specified wrapping width. Anchor point for the string is parameter p. The line-breaking policy is found in LineBreakMeasurer.
Parameters:
as - the AttributedString to be drawn
p - the anchor point for the text
wrapWidth - the width that each text line fits to
See Also:
AttributedString, LineBreakMeasurer, TextLayout

gpDrawStringCentered

public final void gpDrawStringCentered(java.lang.String s,
                                       java.awt.Rectangle r)
Draws the text given by the specified string centered in the parameter rectangle.
Parameters:
s - the text to draw
r - the rectangular area to center the text within
See Also:
gpDrawStringUpperRight(String,Rectangle), gpDrawStringLowerRight(String,Rectangle), gpDrawStringUpperLeft(String,Rectangle), gpDrawStringLowerLeft(String,Rectangle)

gpDrawStringUpperRight

public final void gpDrawStringUpperRight(java.lang.String s,
                                         java.awt.Rectangle r)
Draws the text given by the specified string at the upper right region of the parameter rectangle.
Parameters:
s - the text to draw
r - the rectangular area to draw the text within
See Also:
gpDrawStringCentered(String,Rectangle), gpDrawStringLowerRight(String,Rectangle), gpDrawStringUpperLeft(String,Rectangle), gpDrawStringLowerLeft(String,Rectangle)

gpDrawStringLowerRight

public final void gpDrawStringLowerRight(java.lang.String s,
                                         java.awt.Rectangle r)
Draws the text given by the specified string at the lower right region of the parameter rectangle.
Parameters:
s - the text to draw
r - the rectangular area to draw the text within
See Also:
gpDrawStringCentered(String,Rectangle), gpDrawStringUpperRight(String,Rectangle), gpDrawStringUpperLeft(String,Rectangle), gpDrawStringLowerLeft(String,Rectangle)

gpDrawStringLowerLeft

public final void gpDrawStringLowerLeft(java.lang.String s,
                                        java.awt.Rectangle r)
Draws the text given by the specified string at the lower left region of the parameter rectangle.
Parameters:
s - the text to draw
r - the rectangular area to draw the text within
See Also:
gpDrawStringCentered(String,Rectangle), gpDrawStringUpperRight(String,Rectangle), gpDrawStringLowerRight(String,Rectangle), gpDrawStringUpperLeft(String,Rectangle)

gpDrawStringUpperLeft

public final void gpDrawStringUpperLeft(java.lang.String s,
                                        java.awt.Rectangle r)
Draws the text given by the specified string at the upper left region of the parameter rectangle.
Parameters:
s - the text to draw
r - the rectangular area to draw the text within
See Also:
gpDrawStringCentered(String,Rectangle), gpDrawStringUpperRight(String,Rectangle), gpDrawStringLowerRight(String,Rectangle), gpDrawStringLowerLeft(String,Rectangle)

gpSetFont

public final void gpSetFont(java.awt.Font f)
Sets the font for text rendering. All subsequent text operations will use this font.
Parameters:
f - the font object
See Also:
gpSetFont(String,int,int), Font

gpSetFont

public final void gpSetFont(java.lang.String name,
                            int type,
                            int size)
Sets the font for text rendering to the Font with the specified name, style and face. All subsequent text operations will use this font.
Parameters:
name - the font face name
type - the font style constant from the Font class
size - the font size
See Also:
gpSetFont(java.awt.Font), Font

gpSetFontHiLite

public final void gpSetFontHiLite(boolean b)
Text will be drawn with a hilite when the parameter is true. The default hilite color is black and default hilite size is 1 pixel. Hilites will not be drawn if the gradient mode is enabled.
Parameters:
b - When true, a text hilite will be drawn.
See Also:
gpSetText(String,int,int)

gpSetFontHiLite

public final void gpSetFontHiLite(boolean b,
                                  int size,
                                  java.awt.Color c)
Text will be drawn with a hilite in the specified size and color when the parameter b is true. Hilites will not be drawn if the gradient mode is enabled.
Parameters:
b - When true, a text hilite will be drawn.
size - the size of the text hilite
c - the color of the text hilite
See Also:
gpSetFontHiLite(boolean), gpSetText(String,int,int)

gpSetFontShear

public final void gpSetFontShear(double d)
Deprecated. No replacement


gpGetStringWidth

public final int gpGetStringWidth(java.lang.String s)
Returns the width of the specified string.
Parameters:
s - the string
Returns:
the width of the string
See Also:
gpGetStringWidth(String,Font), gpGetStringHeight(String)

gpGetStringHeight

public final int gpGetStringHeight(java.lang.String s)
Returns the height of the specified string.
Parameters:
s - the string
Returns:
the height of the string
See Also:
gpGetStringHeight(String,Font), gpGetStringWidth(String)

gpGetStringWidth

public final int gpGetStringWidth(java.lang.String s,
                                  java.awt.Font f)
Returns the width of the string when drawn in the specified font.
Parameters:
s - the string
f - the font
Returns:
the width of the string
See Also:
gpGetStringWidth(String), gpGetStringHeight(String,Font)

gpGetStringHeight

public final int gpGetStringHeight(java.lang.String s,
                                   java.awt.Font f)
Returns the height of the string when drawn in the specified font.
Parameters:
s - the string
f - the font
Returns:
the height of the string
See Also:
gpGetStringHeight(String), gpGetStringWidth(String,Font)

gpGetStringBounds

public final java.awt.geom.Rectangle2D gpGetStringBounds(java.lang.String s)
Returns the bounding rectangle of the specified string.
Parameters:
s - the bounded string
Returns:
the bounding rectangle
See Also:
Rectangle2D

gpDrawImage

public final void gpDrawImage(java.awt.Image img,
                              int x,
                              int y)
Draws the specified image with the top-left corner at the point (x,y). As much of the image as is currently available will be drawn.
Parameters:
img - the image to be drawn
x - the x coordinate of the anchor point
y - the y coordinate of the anchor point
See Also:
Image, gpDrawImage(Image,int,int,int,int), gpDrawImage(Image,int,int,int,int,int,int,int,int)

gpDrawImage

public final void gpDrawImage(java.awt.Image img,
                              int x,
                              int y,
                              int w,
                              int h)
Draws the specified image, scaled, with the top-left corner at the point (x,y). The image will be scaled to fit within the rectangle specified by the width and height parameters. As much of the image as is currently available will be drawn.
Parameters:
img - the image to be drawn
x - the x coordinate of the anchor point
y - the y coordinate of the anchor point
w - the width of the scaled image
h - the height of the scaled image
See Also:
Image, gpDrawImage(Image,int,int), gpDrawImage(Image,int,int,int,int,int,int,int,int)

gpDrawImage

public final void gpDrawImage(java.awt.Image img,
                              int dx1,
                              int dy1,
                              int dx2,
                              int dy2,
                              int sx1,
                              int sy1,
                              int sx2,
                              int sy2)
Draws the specified image, scaled, with as much of the image as is currently available. This method will not use a cached image. The image will be scaled on the fly such that coordinates of the source rectangle are mapped to coordinates of the destination rectangle.
Parameters:
img - the image to be drawn
dx1 - the x coordinate of the first corner of the destination rectangle
dy1 - the y coordinate of the first corner of the destination rectangle
dx2 - the x coordinate of the second corner of the destination rectangle
dy2 - the y coordinate of the second corner of the destination rectangle
sx1 - the x coordinate of the first corner of the source rectangle
sy1 - the y coordinate of the first corner of the source rectangle
sx2 - the x coordinate of the second corner of the source rectangle
sy2 - the y coordinate of the second corner of the source rectangle
See Also:
Image, gpDrawImage(Image,int,int), gpDrawImage(Image,int,int,int,int)

gpGetImageWidth

public final int gpGetImageWidth(java.awt.Image img)
Returns the width of the specified image.
Parameters:
img - the image to measure
Returns:
the width of the image
See Also:
Image

gpGetImageHeight

public final int gpGetImageHeight(java.awt.Image img)
Returns the height of the specified image.
Parameters:
img - the image to measure
Returns:
the height of the image
See Also:
Image

gpGetImageBrushWidth

public final int gpGetImageBrushWidth()
Returns the width of the current image brush.
Returns:
the width of the image brush
See Also:
gpGetImageBrush(), gpSetImageBrush(int)

gpGetImageBrushHeight

public final int gpGetImageBrushHeight()
Returns the height of the current image brush.
Returns:
the height of the image brush
See Also:
gpGetImageBrush(), gpSetImageBrush(int)

gpGetImageBrush

public final java.awt.Image gpGetImageBrush()
Returns the currently selected image brush.
Returns:
the current image brush
See Also:
gpSetImageBrush(int), Image

gpSetImageBrush

public final void gpSetImageBrush(int i)
Sets the current image brush to the specified image. Images are numbered from 0 to 149, where the first 90 images are included in the Paintlet program and the remainder are user-supplied. The images correspond to the image palette and are numbered left to right. The first row images are 0, 1 and 2.
Parameters:
i - the image number
See Also:
gpGetImageBrush()

gpDrawImageBrush

public final void gpDrawImageBrush(java.util.Vector v,
                                   int startPtX,
                                   int startPtY)
Draws the current image brush at the coordinates specified by the collection of points in the vector. The parameter Vector must contain Point objects that will be drawn relative to the starting point (startPtX, startPtY).
Parameters:
v - the vector that contains relative drawing points
startPtX - the x coordinate of the anchor point
startPtY - the y coordinate of the anchor point
See Also:
Vector

gpPaintImgCircle

public final void gpPaintImgCircle(java.awt.Point startPt,
                                   java.awt.Point endPt)
Draws a circle using the current image brush. The startPt and endPt define a radius for the circle, where the endPt is the center of the circle.
Parameters:
startPt - the point on the circle
endPt - the center point of the circle
See Also:
Point, gpSetImageBrush(int)

gpPaintImgLine

public final void gpPaintImgLine(int x1,
                                 int y1,
                                 int x2,
                                 int y2)
Draws a line using the current image brush. The starting point (x1,y1) and ending point (x2,y2) define the line. As the line becomes more vertical, the number of images used to draw the line decreases.
Parameters:
x1 - the x coordinate of the first line point
y1 - the y coordinate of the first line point
x2 - the x coordinate of the second line point
y2 - the y coordinate of the second line point
See Also:
gpSetImageBrush(int)

gpImageText

public final void gpImageText(java.lang.String s,
                              int x,
                              int y)
Draws the specified string with the current image brush. The point (x,y) is the anchor point for the text. The font size is 70.
Parameters:
s - the text
x - the x coordinate of the anchor point
y - the y coordinate of the anchor point
See Also:
gpSetImageBrush(int)

gpBlendText

public final void gpBlendText(java.lang.String s,
                              int x,
                              int y,
                              int w,
                              boolean jagged)
Draws the specified string with the gpBlend method. The point (x,y) is the anchor point for the text. The font size is 70. The string is drawn in an irregular fashion when jagged is true.
Parameters:
s - the text
x - the x coordinate of the anchor point
y - the y coordinate of the anchor point
jagged - when true, text is drawn irregularly
See Also:
gpBlend(int,int)

gpImageBack

public final void gpImageBack()
Tiles the canvas with the current image brush. The image is drawn every 2 pixels horizontally and 10 pixels vertically. Tiling pattern is left to right, left to right.
See Also:
gpSetImageBrush(int), gpImageBack(boolean,int,int)

gpImageBack

public final void gpImageBack(boolean b,
                              int horz,
                              int vert)
Tiles the canvas with the current image brush at specified horizontal and vertical intervals. When the boolean parameter is true, the image is tiled in serpentine fashion, otherwise left to right, left to right.
Parameters:
b - when true, tiles in serpentine fashion
horz - the horizontal tiling interval
vert - the vertical tiling interval
See Also:
gpSetImageBrush(int), gpImageBack()

gpGetImage

public final java.awt.Image gpGetImage(java.io.File f)
Returns the specified File parameter as an Image. The file must be in JPEG or GIF format.
Parameters:
f - the image file to open
Returns:
the specified File as an Image
See Also:
gpCreateImage(MemoryImageSource), File

gpCreateImage

public final java.awt.Image gpCreateImage(java.awt.image.MemoryImageSource mis)
Returns an Image created from the specified MemoryImageSource.
Parameters:
mis - the MemoryImageSource
Returns:
the specified MemoryImageSource as an Image
See Also:
gpGetImage(File), MemoryImageSource, Image

gpSaveCanvas

public final void gpSaveCanvas(java.lang.String name,
                               java.awt.Rectangle r)
Deprecated. Replaced by gpSaveCanvasToJPG

See Also:
gpSaveCanvasToJPG(String,Rectangle)

gpSaveCanvasToJPG

public final void gpSaveCanvasToJPG(java.lang.String name,
                                    java.awt.Rectangle r)
Saves a region of the Paintlet canvas as a JPEG file. The region defined by the parameter r will be saved with the specified name. If the name parameter does not end with .jpg it will be appended to the file name.
Parameters:
name - the file name
r - the rectangular region to save

gpSaveScaledCanvas

public final void gpSaveScaledCanvas(java.lang.String name,
                                     int width,
                                     int height)
Saves a scaled version of the Paintlet canvas as a JPEG file. The saved image will have a width and height as specified by the parameters. If the name parameter does not end with .jpg it will be appended to the file name.
Parameters:
name - the file name
w - the width of the scaled image
h - the height of the scaled image
See Also:
gpSaveCanvasToJPG(String,Rectangle)

gpSaveImageToFile

public void gpSaveImageToFile(java.io.File f,
                              java.awt.image.BufferedImage img)
Saves a BufferedImage as a JPEG file. The image defined by the parameter img will be saved with the name specified. in the File object. If the name parameter does not end with .jpg it will be appended to the file name.
Parameters:
f - the File
img - the BufferedImage to save
See Also:
gpSaveImageToFile(File,BufferedImage,float), File, Image, BufferedImage

gpSaveImageToFile

public void gpSaveImageToFile(java.io.File f,
                              java.awt.image.BufferedImage img,
                              float saveQuality)
Saves a BufferedImage as a JPEG file with the specified quality-compression setting. The image defined by the parameter img will be saved with the name specified in the File object. If the name parameter does not end with .jpg it will be appended to the file name. The saveQuality values can range from 0.0 to 1.0 with the high value representing the highest quality and lowest compression.
Parameters:
f - the File
img - the BufferedImage to save
saveQuality - the compression-quality setting
See Also:
gpSaveImageToFile(File,BufferedImage), File, Image, BufferedImage

gpApplyFilter

public final void gpApplyFilter(GpadFilter gpf)
Applies the filter operation specified by the GpadFilter parameter. The filter operation can be applied to a specified region of the canvas through the GpadFilter parameter. Similarly, the filter type and strength can also be set.
Parameters:
gpf - the GpadFilter
See Also:
GpadFilter

gpApplyCurve

public final void gpApplyCurve(GpadCurve gpc)
Applies the curve generation specified by the GpadCurve parameter to the canvas. Curve type and properties are specified in the GpadCurve object.
Parameters:
gpc - the GpadCurve
See Also:
GpadCurve

gpAnimate

public final void gpAnimate(GpadAnimation gpa)
Runs an animation sequence specified by the GpadAnimation parameter. Developers implement the animate method of the GpadAnimation abstract class. The method contains the timed sequence of drawing operations on the canvas.
Parameters:
gpa - the GpadAnimation
See Also:
GpadAnimation, Thread

gpRepaint

public final void gpRepaint()
Repaints the entire canvas. This method should be normally be called after all painting operations have executed. This ensures that the canvas is updated.
See Also:
gpRepaint(int,int,int,int)

gpRepaint

public final void gpRepaint(int x,
                            int y,
                            int w,
                            int h)
Repaints a region of the canvas. The rectangular region is anchored by the upper-left point (x,y) and has a width w and height h. This method should be normally be called after all painting operations have executed. This ensures that the canvas is updated.
Parameters:
x - the x coordinate of the anchor point
y - the y coordinate of the anchor point
w - the width of the rectangular repaint region
h - the height of the rectangular repaint region
See Also:
gpRepaint()

gpGetCanvasImage

public java.awt.Image gpGetCanvasImage()
Returns the canvas Image. This gives direct access to the graphics context of the canvas.
Returns:
the canvas Image