Class FxStyledPen
public class FxStyledPen extends FxPen
{
// Fields
public final static int DASH;
public final static int DOT;
public final static int PLAIN;
// Constructors
public FxStyledPen(int style, int width);
public FxStyledPen(int style, int width, Color c);
public FxStyledPen(int style, int width, FxColor c);
public FxStyledPen(int style, int width, int r, int g, int b);
public FxStyledPen(int style, int width, int rgb);
// Methods
public boolean drawLineCallback(FxGraphics g, int x1, int y1, int
x2, int y2);
public boolean drawPolygonCallback(FxGraphics g, int xPoints[],
int yPoints[], int nPoints);
public boolean drawRectCallback(FxGraphics g, int x, int y,
int width, int height);
}
This class provides a drawing pen object with specifiable style. Although variable line width is also specifiable, it is not supported for the Microsoft SDK for Java version 3.0 pre-release 2. The FxStyledPen is used for dotted and dashed lines, and basic shapes.
An FxStyledPen is selected into a graphics context the same way that a Color object is selected, and performs all its operations internally using callback methods. For more information on the use of callback methods in the com.ms.fx package, see the com.ms.fx package overview information.
The following example shows how to create and use an FxStyledPen object.
// Create an FxStyledPen object that draws dotted lines.
FxStyledPen fxsp1 = new FxStyledPen(FxStyledPen.DOT, 1);
// Set the color of an extended graphics object
// to use the styled pen.
fxgraf.setColor(fxsp1);
// You can draw dotted lines and rectangles
// using standard drawing API calls.
fxgraf.drawLine(0, 0, 100, 100);
// or
fxgraf.drawRect(1, 1, 50, 50);
BaseColor
|
+--FxColor
|
+--FxFill
|
+--FxPen
|
+--FxStyledPen
public FxStyledPen(int style, int width);
Creates an FxStyledPen object with the specified style and width, and a default color.
Parameter | Description |
style
| The style of the pen. This parameter may be one of the following three pen styles.
The PLAIN style draws the same effect as an FxPen object.
|
width
| The width of the pen (in pixels). Currently, FxStyledPen only supports lines one pixel wide.
|
public FxStyledPen(int style, int width, Color c);
Creates an FxStyledPen object with the specified style, width, and color.
Parameter | Description |
style
| The style of the pen. This parameter may be one of the following three pen styles.
The PLAIN style draws the same effect as an FxPen object.
|
width
| The width of the pen (in pixels). Currently, FxStyledPen only supports lines one pixel wide.
|
c
| The Color of the pen.
|
public FxStyledPen(int style, int width, FxColor c);
Creates an FxStyledPen object with the specified style, width, and color.
Parameter | Description |
style
| The style of the pen. This parameter may be one of the following three pen styles.
The PLAIN style draws the same effect as an FxPen object.
|
width
| The width of the pen (in pixels). Currently, FxStyledPen only supports lines one pixel wide.
|
c
| The FxColor of the pen.
|
public FxStyledPen(int style, int width, int r, int g, int b);
Creates an FxStyledPen object with the specified style, width, and color.
Parameter | Description |
style
| The style of the pen. This parameter may be one of the following three pen styles.
The PLAIN style draws the same effect as an FxPen object.
|
width
| The width of the pen (in pixels). Currently, FxStyledPen only supports lines one pixel wide.
|
r
| The red component of the color of the pen.
|
g
| The green component of the color of the pen.
|
b
| The blue component of the color of the pen.
|
public FxStyledPen(int style, int width, int rgb);
Creates an FxStyledPen object with the specified style, width, and color.
Parameter | Description |
style
| The style of the pen. This parameter may be one of the following three pen styles.
The PLAIN style draws the same effect as an FxPen object.
|
width
| The width of the pen (in pixels). Currently, FxStyledPen only supports lines one pixel wide.
|
rgb
| The RGB value for the color of the pen.
|
public boolean drawLineCallback(FxGraphics g, int x1, int y1, int x2,
int y2);
Draws a plain, dotted, or dashed line when called by an FxGraphics object.
Note This method is called by FxGraphics if drawLine is called and an FxStyledPen 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.
Parameter | Description |
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 FxPen.
See Also: java.awt.Graphics.drawLine, com.ms.fx.FxFill.drawLineCallback
public boolean drawPolygonCallback(FxGraphics g, int xPoints[],
int yPoints[], int nPoints);
Draws a plain, dotted, or dashed polygon when called by an FxGraphics object.
Note Currently, this callback is not implemented. It is called by FxGraphics if drawPolygon is called and an FxStyledPen 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.
Parameter | Description |
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 FxPen.
See Also: java.awt.Graphics.drawPolygon, com.ms.fx.FxFill.drawPolygonCallback
public boolean drawRectCallback(FxGraphics g, int x, int y, int width,
int height);
Draws an plain, dotted, or dashed rectangle when called by an FxGraphics object.
Note This method is called by FxGraphics if drawRect is called and an FxStyledPen 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.
Parameter | Description |
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 FxPen.
See Also: java.awt.Graphics.drawRect, com.ms.fx.FxFill.drawRectCallback
- DASH
- A pen style that indicates the pen draws a dashed line.
- DOT
- A pen style that indicates the pen draws a dotted line.
- PLAIN
- A pen style that indicates the pen draws a solid line (effectively, is an FxPen).