Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.fx   Previous This
Package
Next

 


Class FxPen

public class FxPen extends FxFill
{
  // Constructors
  public FxPen();
  public FxPen(int width, int rgb);
  public FxPen(int width, int r, int g, int b);
  public FxPen(int width, FxColor c);
  public FxPen(int width, Color c);

  // Methods
  public boolean drawLineCallback(FxGraphics g, int x1, int y1, int
        x2, int y2);
  public boolean drawOvalCallback(FxGraphics g, int x, int y,
        int w, int h);
  public boolean drawPolygonCallback(FxGraphics g, int xPoints[],
        int yPoints[], int nPoints);
  public boolean drawRectCallback(FxGraphics g, int x, int y,
        int width, int height);
  public boolean drawRoundRectCallback(FxGraphics g, int x, int y,
        int width, int height, int arcWidth, int arcHeight);
  public boolean drawScanLinesCallback(FxGraphics g,
        boolean xChanging, int points[], int offset, int nPoints);
  public boolean fillRectCallback(FxGraphics g, int x, int y,
        int width, int height);
  public int getWidth();
  public void setWidth(int w);
}

This class supplies a general drawing pen object whose color and line width can be specified. The FxPen object is a wide pen (that is, used for lines more than a pixel wide. Lines and curves that are one pixel wide may be drawn without using a pen object.)

Be aware that the line drawing calculations for lines are done in this class. For other curves, however, the calculations are done in the ShapeX derived routines. The following example shows how to construct and use an FxPen object.

// Create an FxPen with the default base color (0, 0, 0).
// Use the setWidth method to set or modify a pen's
// width (measured in pixels) after construction.
FxPen fxp1 = new FxPen();
fxp1.setWidth(5);

// Create an red FxPen object that is 5 pixels wide.
FxPen fxp2 = new FxPen(5, 255, 0, 0);

// You can also use Color objects to construct an FxPen.
FxPen fxp3 = new FxPen(5, Color.red);

Note FxPen objects perform all their operations through callback methods that are called when an FxGraphics object is called to perform a drawing operation, and the graphics color is an FxPen object. FxPen objects can perform any of the basic operations that you would expect of a variable-width pen. If a drawChars or drawString operation is called, however, the appropriate callback method in FxFill will be called and return false. For more information about the use of callback methods in the com.ms.fx package, see the overview information at the beginning of this package.

BaseColor
  |
  +--FxColor
    |
    +--FxFill
      |
      +--FxPen

Constructors

FxPen

public FxPen();

Creates a pen with a default base color and a width of one pixel.

FxPen

public FxPen(int width, int rgb);

Creates a pen with a specified base color (RGB) and width.

ParameterDescription
width The width of the pen (in pixels).
rgb The base color to use.

FxPen

public FxPen(int width, int r, int g, int b);

Creates a pen with a specified base color and width.

ParameterDescription
width The width of the pen (in pixels).
r The red component of the color.
g The green component of the color.
b The blue component of the color.

FxPen

public FxPen(int width, FxColor c);

Creates a pen with a specified base color and width.This constructor is included for JDK 1.0.2 compatibility.

ParameterDescription
width The width of the pen (in pixels).
c The base Color. This parameter may also be one of the extended FxColor types, including FxColor, FxFill, and FxTexture.

FxPen

public FxPen(int width, Color c);

Creates a pen with a specified base color and width.

ParameterDescription
width The width of the pen (in pixels).
c The base Color. This parameter may also be one of the extended FxColor types, including FxColor, FxFill, and FxTexture.

Methods

drawLineCallback

public boolean drawLineCallback(FxGraphics g, int x1, int y1, int x2,
        int y2);

Draws a wide line when called by an FxGraphics object.

Note This method is called by FxGraphics if drawLine is called and an FxPen object is the selected color. The callback methods are used internally and are not intended to be called by applications. They are made public so that derived classes can extend the callback functionality.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object.
x1 The x coordinate of the starting point of the line.
y1 The y coordinate of the starting point of the line.
x2 The x coordinate of the ending point of the line.
y2 The y coordinate of the ending point of the line.

Overrides:

drawLineCallback(FxGraphics,int,int,int,int) in FxFill.

See Also: java.awt.Graphics.drawLine, com.ms.fx.FxFill.drawLineCallback

drawOvalCallback

public boolean drawOvalCallback(FxGraphics g, int x, int y, int w, int h);

Draws an oval when called by an FxGraphics object.

Note This method is called by FxGraphics if drawOval is called and an FxPen object is the selected color. The callback methods are used internally and are not intended to be called by applications. They are made public so that derived classes can extend the callback functionality.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object.
x The upper-left x coordinate of the oval's bounding rectangle.
y The upper-left y coordinate of the oval's bounding rectangle.
w The width of the oval's bounding rectangle (in pixels).
h The height of the oval's bounding rectangle (in pixels).

Overrides:

drawOvalCallback(FxGraphics,int,int,int,int) in FxFill.

See Also: java.awt.Graphics.drawOval, com.ms.fx.FxFill.drawOvalCallback

drawPolygonCallback

public boolean drawPolygonCallback(FxGraphics g, int xPoints[],
        int yPoints[], int nPoints);

Draws an polygon when called by an FxGraphics object.

Note This method is called by FxGraphics if drawPolygon is called and an FxPen object is the selected color. The callback methods are used internally and are not intended to be called by applications. They are made public so that derived classes can extend the callback functionality.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object.
xPoints An array containing the polygon's x coordinates.
yPoints An array containing the polygon's y coordinates.
nPoints The number of points in the polygon.

Overrides:

drawPolygonCallback(FxGraphics,int[],int[],int) in FxFill.

See Also: java.awt.Graphics.drawPolygon, com.ms.fx.FxFill.drawPolygonCallback

drawRectCallback

public boolean drawRectCallback(FxGraphics g, int x, int y, int width,
        int height);

Draws an rectangle when called by an FxGraphics object.

Note This method is called by FxGraphics if drawRect is called and an FxPen object is the selected color. The callback methods are used internally and are not intended to be called by applications. They are made public so that derived classes can extend the callback functionality.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object.
x The upper-left x coordinate of the rectangle.
y The upper-left y coordinate of the rectangle.
width The width of the rectangle (in pixels).
height The height of the rectangle (in pixels).

Overrides:

drawRectCallback(FxGraphics,int,int,int,int) in FxFill.

See Also: java.awt.Graphics.drawRect, com.ms.fx.FxFill.drawRectCallback

drawRoundRectCallback

public boolean drawRoundRectCallback(FxGraphics g, int x, int y, int width,
        int height, int arcWidth, int arcHeight);

Draws an rectangle with rounded edges when called by an FxGraphics object.

Note This method is called by FxGraphics if drawRoundRect is called and an FxPen object is the selected color. The callback methods are used internally and are not intended to be called by applications. They are made public so that derived classes can extend the callback functionality.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object.
x The upper-left x coordinate of the rectangle.
y The upper-left y coordinate of the rectangle.
width The width of the rectangle (in pixels).
height The height of the rectangle (in pixels).
arcWidth The arc width of the rectangle's rounded edges.
arcHeight the arc height of the rectangle's rounded edges.

Overrides:

drawRoundRectCallback(FxGraphics,int,int,int,int,int,int) in FxFill.

See Also: java.awt.Graphics.drawRoundRect, com.ms.fx.FxFill.drawRoundRectCallback

drawScanLinesCallback

public boolean drawScanLinesCallback(FxGraphics g, boolean xChanging,
        int points[], int offset, int nPoints);

Draws scan lines when called by an FxGraphics object.

Note This method is called by FxGraphics if drawScanLines is called and an FxPen object is the selected color. The callback methods are used internally and are not intended to be called by applications. They are made public so that derived classes can extend the callback functionality.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object.
xChanging The direction the line should be drawn, either horizontally or vertically.
points An array of points.
offset The offset to use.
nPoints The number of points in the array.

Overrides:

drawScanLinesCallback(FxGraphics,boolean,int[],int,int) in FxFill.

See Also: com.ms.fx.FxGraphics.drawScanLines, com.ms.fx.FxFill.drawScanLinesCallback

fillRectCallback

public boolean fillRectCallback(FxGraphics g, int x, int y, int width,
        int height);

Draws a filled rectangle with rounded edges when called by an FxGraphics object.

Note This method is called by FxGraphics if fillRoundRect is called and an FxPen object is the selected color. The callback methods are used internally and are not intended to be called by applications. They are made public so that derived classes can extend the callback functionality.

Return Value:

Returns true if successful; returns false if a fill color has not been specified.

ParameterDescription
g The graphics object.
x The upper-left x coordinate of the rectangle.
y The upper-left y coordinate of the rectangle.
width The width of the rectangle (in pixels).
height The height of the rectangle (in pixels).

Overrides:

fillRectCallback(FxGraphics,int,int,int,int) in FxFill.

See Also: java.awt.Graphics.fillRect, com.ms.fx.FxFill.fillRectCallback

getWidth

public int getWidth();

Retrieves the pen's width.

Return Value:

Returns the pen's width (in pixels).

See Also: setWidth

setWidth

public void setWidth(int w);

Sets the pen's width.

ParameterDescription
w The pen's width (in pixels).

Remarks:

The width of the pen may be changed only after the pen has been created.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.