danger.ui
Class Pen

java.lang.Object
  extended by danger.ui.Pen
Direct Known Subclasses:
RecordingPen, ScaledPen


public abstract class Pen
extends Object

Basic drawing primitives. This class implements the basic drawing primitives that would normally be found in the abstract windowing toolbox.


Field Summary
static int HINT_DEFAULT
          Default rendering.
static int HINT_FAST_ALPHA_GLYPHS
          Signal that we are displaying fonts on a plain black or white background, and may be able to use a faster glyph rendering function.
static int HINT_FONT_ANTIALIAS_OFF
          Turn off font anti-aliasing.
static int HORIZONTAL
          Specify that a gradient should be horizontal.
static int ROUND_END
          Specify that the ending corners (bottom for vertical gradients and right for horizontal gradients) should be round instead of square.
static int ROUND_START
          Specify that the starting corners (top for vertical gradients and left for horizontal gradients) should be round instead of square.
static int VERTICAL
          Specify that a gradient should be vertical.
 
Constructor Summary
Pen()
           
 
Method Summary
abstract  Pen clonePen()
          Clone the current pen.
protected abstract  void copy(Pen from)
           
abstract  void drawArc(int left, int top, int right, int bottom, int startAngle, int arcAngle)
           
 void drawArc(Rect bounds, int startAngle, int arcAngle)
           
abstract  void drawBitmap(int x, int y, Bitmap bm)
          Draw a bitmap.
abstract  void drawBitmap(int x, int y, Bitmap inBitmap, boolean inInverted)
          Draw a bitmap that may be inverted.
 void drawBitmap(int x, int y, Bitmap inBitmap, int weight)
          Translucently draw a Bitmap.
 void drawBitmap(int x, int y, Bitmap bm1, int w1, Bitmap bm2, int w2)
          Draw a blend of two Bitmaps.
abstract  void drawBitmap(int x, int y, Bitmap bm, int left, int top, int right, int bottom)
          Draw a portion of a bitmap.
 void drawBitmap(int x, int y, Bitmap bm, Rect r)
           
abstract  int drawChar(int x, int y, char c)
          Draw a character.
abstract  void drawLine(int x1, int y1, int x2, int y2)
          Draw a line.
abstract  void drawOval(int left, int top, int right, int bottom)
          Draw an oval.
 void drawOval(Rect r)
          Draw an oval.
abstract  void drawPoint(int x, int y)
          Draw a point.
 void drawPoint(Point p)
          Draw a point.
abstract  void drawPoly(int[] x, int[] y)
          Draw a polygon.
abstract  void drawRect(int left, int top, int right, int bottom)
          Draw a rectangle.
 void drawRect(Rect r)
          Draw a rectangle.
abstract  void drawRoundRect(int left, int top, int right, int bottom, int arcWidth, int arcHeight)
          Draw a round-cornered rectangle.
 void drawRoundRect(Rect r, int arcWidth, int arcHeight)
          Draw a round-cornered rectangle.
 int drawText(int x, int y, byte[] data, int offset, int length)
          Draw a string.
 int drawText(int x, int y, char[] data, int offset, int length)
          Draw a string.
 int drawText(int x, int y, CharSequence str)
           
 int drawText(int x, int y, CharSequence cs, int offset, int len)
           
abstract  int drawText(int x, int y, String str)
          Draw a string.
 int drawText(int x, int y, String s, int offset, int len)
           
abstract  void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
          Draw a triangle.
abstract  void fillArc(int left, int top, int right, int bottom, int startAngle, int arcAngle)
           
 void fillArc(Rect bounds, int startAngle, int arcAngle)
           
 void fillGradientRect(Rect rect, int orientation, int startColor, int endColor)
          Draw a simple gradient inside the rectangle.
 void fillGradientRoundRect(Rect rect, int orientation, int arcSize, int startColor, int endColor)
          Draw a simple gradient with rounded corners inside the rectangle.
abstract  void fillOval(int left, int top, int right, int bottom)
          Fill an oval.
 void fillOval(Rect r)
          Fill an oval.
abstract  void fillPoly(int[] x, int[] y)
          Fill a polygon.
abstract  void fillRect(int left, int top, int right, int bottom)
          Fill a rectangle.
 void fillRect(Rect r)
          Fill a rectangle.
abstract  void fillRoundRect(int left, int top, int right, int bottom, int arcWidth, int arcHeight)
          Fill a round-cornered rectangle.
 void fillRoundRect(Rect r, int arcWidth, int arcHeight)
          Fill a round-cornered rectangle.
 void fillSplitGradientRect(Rect rect, int orientation, int cornerOptions, int arcSize, int[] colorsAndPositions)
          Draw a gradient split in multiple parts inside the rectangle.
 void fillSplitGradientRect(Rect rect, int orientation, int cornerOptions, int arcSize, int[] colors, int[] positionPcts)
          Draw a gradient split in multiple parts inside the rectangle.
abstract  void fillTexturedPoly(Bitmap sourceMap, int[] x, int[] y, int[] u, int[] v)
          Fill a polygon with a Textured bitmap Fill a polygon from a list of coordinates passed in using a bitmap as a texture.
abstract  void fillTexturedPoly(Bitmap sourceMap, int[] x, int[] y, int[] u, int[] v, int vertexOffset, int numVertexes)
          Fill a polygon with a Textured bitmap Fill a polygon from a list of coordinates passed in using a bitmap as a texture.
abstract  void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
          Fill a triangle.
 Rect getClip()
          Get the clipping rectangle in local coordinates.
abstract  Rect getClip(Rect rect)
          Get the clipping rectangle in local coordinates.
 Rect getClipGlobal()
          Get the clipping rectangle in global coordinates.
abstract  Rect getClipGlobal(Rect rect)
          Get the clipping rectangle in global coordinates.
abstract  int getColor()
           
abstract  Font getFont()
          Get the current font.
abstract  int getLeft()
          Get the horizontal offset of the pen.
abstract  int getRenderHints()
          Get this Pen's rendering hints.
abstract  int getTextOutlineColor()
           
abstract  int getTextShadowColor()
          Get the current shadow color used when rendering a font with F_SHADOW.
abstract  int getTextureColor()
          Get the current texture color used when rendering with fillTexturedPoly().
abstract  int getTop()
          Get the vertical offset of the pen.
abstract  int getVisibleBottom()
          return the last visible line (in local coordinates)
abstract  void getVisibleRect(Rect r)
          return a rectangle that encloses all the visible points (in local coordinates)
abstract  int getVisibleTop()
          return the first visible line (in local coordinates)
 boolean isClipEmpty()
          returns true if *nothing* will be drawn with this pen
abstract  boolean isDashed()
          Query the state of dashed-style drawing.
 int maxStack()
           
abstract  void offset(int dx, int dy)
          Offset coordinate space.
 void pop()
          Restores the last copy of this pen saved on the statestack.
 void popAll()
          Pops all saved state off the statestack
 void push()
          Saves a copy of this pen on the statestack.
 void setClip(int l, int t, int r, int b)
          Adjust the clip-rect of the Pen using local coordinates.
abstract  void setClipGlobal(int l, int t, int r, int b)
          Adjust the clip-rect of the Pen using global coordinates.
 void setColor(Color c)
           
 void setColor(int color)
           
 void setColor(int r, int g, int b)
           
 void setColor(int r, int g, int b, int a)
           
abstract  void setColorAlpha(int color)
          Set the pen drawing color.
 void setColorAlpha(int color, int alpha)
           
abstract  void setDashed(boolean dashed)
          enable/disable dashed-style drawing
abstract  void setFont(Font f)
          Set the current font.
abstract  void setRenderHints(int hints)
          Set this Pen's rendering hints.
abstract  void setSize(int inWidth, int inHeight)
          Set the current pen size.
 void setTextOutlineColor(Color c)
           
abstract  void setTextOutlineColor(int color)
          Set the current outline text color.
 void setTextOutlineColor(int r, int g, int b)
           
abstract  void setTextShadowColor(int packedColor)
          Set the current shadow color used when rendering a font with F_SHADOW.
 void setTextShadowColor(int r, int g, int b)
          Set the current shadow color used when rendering a font with F_SHADOW.
abstract  void setTextureColor(int packedColor)
          Set the current texture color used when rendering with fillTexturedPoly().
 void setTextureColor(int r, int g, int b)
          Set the current texture color used when rendering with fillTexturedPoly().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HINT_DEFAULT

public static final int HINT_DEFAULT
Default rendering. Used with setRenderHints(int)

Since:
4.0
See Also:
Constant Field Values

HINT_FONT_ANTIALIAS_OFF

public static final int HINT_FONT_ANTIALIAS_OFF
Turn off font anti-aliasing. Used with setRenderHints(int)

Since:
4.0
See Also:
Constant Field Values

HINT_FAST_ALPHA_GLYPHS

public static final int HINT_FAST_ALPHA_GLYPHS
Signal that we are displaying fonts on a plain black or white background, and may be able to use a faster glyph rendering function. Used with setRenderHints(int)

Since:
4.5
See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Specify that a gradient should be vertical. Used in calls to fillGradientRect(danger.ui.Rect, int, int, int), fillGradientRoundRect(danger.ui.Rect, int, int, int, int), and fillSplitGradientRect(danger.ui.Rect, int, int, int, int[]).

Since:
4.0
See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
Specify that a gradient should be horizontal. Used in calls to fillGradientRect(danger.ui.Rect, int, int, int), fillGradientRoundRect(danger.ui.Rect, int, int, int, int), and fillSplitGradientRect(danger.ui.Rect, int, int, int, int[]).

Since:
4.0
See Also:
Constant Field Values

ROUND_START

public static final int ROUND_START
Specify that the starting corners (top for vertical gradients and left for horizontal gradients) should be round instead of square.

Since:
4.0
See Also:
Constant Field Values

ROUND_END

public static final int ROUND_END
Specify that the ending corners (bottom for vertical gradients and right for horizontal gradients) should be round instead of square.

Since:
4.0
See Also:
Constant Field Values
Constructor Detail

Pen

public Pen()
Method Detail

drawPoint

public abstract void drawPoint(int x,
                               int y)
Draw a point. Draws a single point/pixel using current pen color.


drawLine

public abstract void drawLine(int x1,
                              int y1,
                              int x2,
                              int y2)
Draw a line. Draws a line using the current pen color. If x1 equals x2 and y1 equals y2, then a single point will be drawn.

Parameters:
x1 - An integer specifying the beginning x location in pixels.
x2 - An integer specifying the ending x location in pixels.
y1 - An integer specifying the beginning y location in pixels.
y2 - An integer specifying the ending y location in pixels.

drawRect

public abstract void drawRect(int left,
                              int top,
                              int right,
                              int bottom)
Draw a rectangle. Draw a rectangle using the current pen color. If left equals right or top equals bottom, a 2 pixel-wide line will be drawn. If left equals right and top equals bottom a single pixel will be drawn.

Parameters:
left - An integer specifying the left coordinate of the rectangle.
top - An integer specifying the top coordinate of the rectangle.
right - An integer specifying the right coordinate of the rectangle.
bottom - An integer specifying the bottom coordinate of the rectangle.

fillRect

public abstract void fillRect(int left,
                              int top,
                              int right,
                              int bottom)
Fill a rectangle. Fill a rectangle using the current pen color. Note that this method fills a rectangle that fits inside of the rectangle framed by DrawRect. If left equals right or top equals bottom, nothing is drawn.

Parameters:
left - An integer specifying the left coordinate of the rectangle.
top - An integer specifying the top coordinate of the rectangle.
right - An integer specifying the right coordinate of the rectangle.
bottom - An integer specifying the bottom coordinate of the rectangle.

fillGradientRect

public void fillGradientRect(Rect rect,
                             int orientation,
                             int startColor,
                             int endColor)
Draw a simple gradient inside the rectangle. If rect.left == rect.right or rect.top == rect.bottom, nothing is drawn. orientation should be VERTICAL or HORIZONTAL. If the gradient is vertical, then startColor is the color of the leftmost line, and endColor is the color of the rightmost line. If the gradient is horizontal, then startColor is the color of the topmost line, and endColor is the color of the bottommost line.

Since:
4.0

fillGradientRoundRect

public void fillGradientRoundRect(Rect rect,
                                  int orientation,
                                  int arcSize,
                                  int startColor,
                                  int endColor)
Draw a simple gradient with rounded corners inside the rectangle. If rect.left == rect.right or rect.top == rect.bottom, nothing is drawn. orientation should be VERTICAL or HORIZONTAL. If the gradient is vertical, then startColor is the color of the leftmost line, and endColor is the color of the rightmost line. If the gradient is horizontal, then startColor is the color of the topmost line, and endColor is the color of the bottommost line.

Since:
4.0

fillSplitGradientRect

public void fillSplitGradientRect(Rect rect,
                                  int orientation,
                                  int cornerOptions,
                                  int arcSize,
                                  int[] colorsAndPositions)
Draw a gradient split in multiple parts inside the rectangle. If rect.left == rect.right or rect.top == rect.bottom, nothing is drawn. See fillGradientRoundRect(danger.ui.Rect, int, int, int, int) for an explanation of the first four parameters.

colorsAndPositions defines the colors and inflection points. colorsAndPositions[0] defines the starting color. colorsAndPositions[1] defines the placement of the first inflection point, as a percentage of distance between the start and end points. colorsAndPositions[2] defines the color of the first inflection point. The last value in the array defines the color at the end point. The length of the array must be even. cornerOptions can include ROUND_START and ROUND_END. If not otherwise specified, corners are square. This method is basically the same as fillSplitGradientRect(Rect,int,int,int,int[],int[]); it simply provides a convenient way to pass in the colors and positions as one array instead of two.

Since:
4.0

fillSplitGradientRect

public void fillSplitGradientRect(Rect rect,
                                  int orientation,
                                  int cornerOptions,
                                  int arcSize,
                                  int[] colors,
                                  int[] positionPcts)
Draw a gradient split in multiple parts inside the rectangle. If rect.left == rect.right or rect.top == rect.bottom, nothing is drawn. See fillGradientRoundRect(danger.ui.Rect, int, int, int, int) for an explanation of the first four parameters.

colors[0] defines the starting color. The other colors in the array define the colors at the inflection points and the end color.

positionPcts[0] defines the placement of the first inflection point, as a percentage of distance between the start and end points. The size of positionPcts should be 2 less than the size of colors.

cornerOptions can include ROUND_START and ROUND_END. If not otherwise specified, corners are square.

Since:
4.0

drawOval

public abstract void drawOval(int left,
                              int top,
                              int right,
                              int bottom)
Draw an oval. Draw an oval using the current pen color.

Parameters:
left - An integer specifying the left coordinate of the oval.
top - An integer specifying the top coordinate of the oval.
right - An integer specifying the right coordinate of the oval.
bottom - An integer specifying the bottom coordinate of the oval.

drawArc

public abstract void drawArc(int left,
                             int top,
                             int right,
                             int bottom,
                             int startAngle,
                             int arcAngle)

drawArc

public void drawArc(Rect bounds,
                    int startAngle,
                    int arcAngle)

fillArc

public abstract void fillArc(int left,
                             int top,
                             int right,
                             int bottom,
                             int startAngle,
                             int arcAngle)

fillArc

public void fillArc(Rect bounds,
                    int startAngle,
                    int arcAngle)

fillOval

public abstract void fillOval(int left,
                              int top,
                              int right,
                              int bottom)
Fill an oval. Fill an oval using the current pen color. Note that this method fills an oval that fits inside of the oval framed by DrawOval.

Parameters:
left - An integer specifying the left coordinate of the oval.
top - An integer specifying the top coordinate of the oval.
right - An integer specifying the right coordinate of the oval.
bottom - An integer specifying the bottom coordinate of the oval.

drawChar

public abstract int drawChar(int x,
                             int y,
                             char c)
Draw a character. Draw the character specified by c at the location specified by x and y.

Parameters:
x - An integer specifying the x location for the character in pixels.
y - An integer specifying the y location for the character in pixels.
c - A char specifying the Unicode character to be drawn.

drawText

public abstract int drawText(int x,
                             int y,
                             String str)
Draw a string. Draw the string specified by str at the location specified by x and y.

Parameters:
x - An integer specifying the x location for the string in pixels.
y - An integer specifying the y location for the string in pixels.
str - A String specifying the Unicode character string to be drawn.

drawText

public int drawText(int x,
                    int y,
                    CharSequence str)

drawText

public int drawText(int x,
                    int y,
                    String s,
                    int offset,
                    int len)

drawText

public int drawText(int x,
                    int y,
                    CharSequence cs,
                    int offset,
                    int len)

drawText

public int drawText(int x,
                    int y,
                    byte[] data,
                    int offset,
                    int length)
Draw a string. Draw the string specified by str at the location specified by x and y.

Parameters:
x - An integer specifying the x location for the string in pixels.
y - An integer specifying the y location for the string in pixels.
data - Array of UTF-8 encoded Unicode chars to draw
offset - Offset into chars array
length - Number of chars in chars array to draw

drawText

public int drawText(int x,
                    int y,
                    char[] data,
                    int offset,
                    int length)
Draw a string. Draw the string specified by str at the location specified by x and y.

Parameters:
x - An integer specifying the x location for the string in pixels.
y - An integer specifying the y location for the string in pixels.
data - Array of Unicode chars to draw
offset - Offset into chars array
length - Number of chars in chars array to draw

drawBitmap

public abstract void drawBitmap(int x,
                                int y,
                                Bitmap bm)
Draw a bitmap. Draw the bitmap specified by bm at the location specified by x and y.

Parameters:
x - An integer specifying the x location for the bitmap in pixels.
y - An integer specifying the y location for the bitmap in pixels.
bm - A Bitmap specifying the bitmap to be drawn.

drawBitmap

public abstract void drawBitmap(int x,
                                int y,
                                Bitmap bm,
                                int left,
                                int top,
                                int right,
                                int bottom)
Draw a portion of a bitmap. Draw only the portion of the bitmap specified in the rectangle.

Parameters:
x - An integer specifying the x location for the bitmap in pixels.
y - An integer specifying the y location for the bitmap in pixels.
bm - A Bitmap specifying the bitmap to be drawn.
left - An integer specifying the left coordinate of the source rectangle.
top - An integer specifying the top coordinate of the source rectangle.
right - An integer specifying the right coordinate of the source rectangle.
bottom - An integer specifying the bottom coordinate of the source rectangle.

drawBitmap

public void drawBitmap(int x,
                       int y,
                       Bitmap bm,
                       Rect r)

drawBitmap

public abstract void drawBitmap(int x,
                                int y,
                                Bitmap inBitmap,
                                boolean inInverted)
Draw a bitmap that may be inverted. Draw the bitmap specified by bm at the location specified by x and y. If inInverted is true, the bitmap will be inverted exclusive or'ing the pixels. Note that pixels that are the same color as the transparent color are not inverted.

Parameters:
x - An integer specifying the x location for the bitmap in pixels.
y - An integer specifying the y location for the bitmap in pixels.
inBitmap - A Bitmap specifying the bitmap to be drawn.
inInverted - A boolean specifying whether or not to invert the bitmap.

drawBitmap

public void drawBitmap(int x,
                       int y,
                       Bitmap inBitmap,
                       int weight)
Translucently draw a Bitmap. Draw the bitmap specified by bm at the location specified by x and y with the specified weight. Weight is multiplied against the existing alpha channel per pixel before compositing with the destination. If the Bitmap's colorspace does not include an alpha channel, the specified weight is used as a uniform alpha channel for all pixels. The weight will be clipped to a minimum of 0 and a maximum of 255.

Parameters:
x - An integer specifying the x location for the bitmap in pixels.
y - An integer specifying the y location for the bitmap in pixels.
inBitmap - A Bitmap specifying the bitmap to be drawn.
weight - The alpha value for the Bitmap. A value of 0 results in no drawing. A value of 255 is equivalent to an opaque draw.
Since:
3.0

drawBitmap

public void drawBitmap(int x,
                       int y,
                       Bitmap bm1,
                       int w1,
                       Bitmap bm2,
                       int w2)
Draw a blend of two Bitmaps. Begin by drawing the bitmap specified by bm1 at the location specified by x and y. Then, draw the bitmap specified by bm2 at the same location with weight w2. Weights w1 and w2 will be clipped to a minimum of 0 and a maximum of 255. The clipped values must sum to 255. The two bitmaps must be of equal size.

Parameters:
x - An integer specifying the x location for the bitmaps in pixels.
y - An integer specifying the y location for the bitmaps in pixels.
bm1 - The first Bitmap to draw.
w1 - The weight for the first Bitmap. Note that the Bitmap is not actually drawn with this weight. The value of this parameter is merely checked to see if, when added to w2, the sum is 255.
bm2 - The second Bitmap to draw.
w2 - The weight for the second Bitmap.

drawRoundRect

public abstract void drawRoundRect(int left,
                                   int top,
                                   int right,
                                   int bottom,
                                   int arcWidth,
                                   int arcHeight)
Draw a round-cornered rectangle. Draw a round-cornered rectangle using the current pen color. The roundness of the corners is specified by the arcWidth and arcHeight parameters. Except for the rounding of the corners, this method behaves exactly the same as the DrawRect method.

Parameters:
left - An integer specifying the left coordinate of the rectangle.
top - An integer specifying the top coordinate of the rectangle.
right - An integer specifying the right coordinate of the rectangle.
bottom - An integer specifying the bottom coordinate of the rectangle.
arcWidth - An integer specifying the width of the arc to be used for the corners.
arcHeight - An integer specifying the height of the arc to be used for the corners.

fillRoundRect

public abstract void fillRoundRect(int left,
                                   int top,
                                   int right,
                                   int bottom,
                                   int arcWidth,
                                   int arcHeight)
Fill a round-cornered rectangle. Fill a round-cornered rectangle using the current pen color. The roundness of the corners is specified by the arcWidth and arcHeight parameters. Except for the rounding of the corners, this method behaves exactly the same as the FillRect method.

Parameters:
left - An integer specifying the left coordinate of the rectangle.
top - An integer specifying the top coordinate of the rectangle.
right - An integer specifying the right coordinate of the rectangle.
bottom - An integer specifying the bottom coordinate of the rectangle.
arcWidth - An integer specifying the width of the arc to be used for the corners.
arcHeight - An integer specifying the height of the arc to be used for the corners.

drawRect

public void drawRect(Rect r)
Draw a rectangle. Draw a rectangle using the current pen color. If r.left equals r.right or r.top equals r.bottom, a 2 pixel-wide line will be drawn. If r.left equals r.right and r.top equals r.bottom a single pixel will be drawn.

Parameters:
r - A Rect specifying the coordinates of the rectangle.

drawPoint

public void drawPoint(Point p)
Draw a point. Draws a single point/pixel using current pen color.


fillRect

public void fillRect(Rect r)
Fill a rectangle. Fill a rectangle using the current pen color. Note that this method fills a rectangle that fits inside of the rectangle framed by DrawRect. If r.left equals r.right or r.top equals r.bottom, nothing is drawn.

Parameters:
r - A Rect specifying the coordinates of the rectangle.

drawOval

public void drawOval(Rect r)
Draw an oval. Draw an oval using the current pen color.

Parameters:
r - A Rect specifying the coordinates of the rectangle.

fillOval

public void fillOval(Rect r)
Fill an oval. Fill an oval using the current pen color.

Parameters:
r - A Rect specifying the coordinates of the rectangle.

drawRoundRect

public void drawRoundRect(Rect r,
                          int arcWidth,
                          int arcHeight)
Draw a round-cornered rectangle. Draw a round-cornered rectangle using the current pen color. The roundness of the corners is specified by the arcWidth and arcHeight parameters. Except for the rounding of the corners, this method behaves exactly the same as the DrawRect method.

Parameters:
r - A Rect specifying the coordinates of the rectangle.
arcWidth - An integer specifying the width of the arc to be used for the corners.
arcHeight - An integer specifying the height of the arc to be used for the corners.

fillRoundRect

public void fillRoundRect(Rect r,
                          int arcWidth,
                          int arcHeight)
Fill a round-cornered rectangle. Fill a round-cornered rectangle using the current pen color. The roundness of the corners is specified by the arcWidth and arcHeight parameters. Except for the rounding of the corners, this method behaves exactly the same as the FillRect method.

Parameters:
r - A Rect specifying the coordinates of the rectangle.
arcWidth - An integer specifying the width of the arc to be used for the corners.
arcHeight - An integer specifying the height of the arc to be used for the corners.

drawTriangle

public abstract void drawTriangle(int x1,
                                  int y1,
                                  int x2,
                                  int y2,
                                  int x3,
                                  int y3)
Draw a triangle. Draw a triangle formed from a loop of the coordinates passed in using the current pen color. This method is more efficient than drawPoly.

Parameters:
x1 - the x coordinate of the first vertex
y1 - the y coordinate of the first vertex
x2 - the x coordinate of the second vertex
y2 - the y coordinate of the second vertex
x3 - the x coordinate of the third vertex
y3 - the y coordinate of the third vertex

fillTriangle

public abstract void fillTriangle(int x1,
                                  int y1,
                                  int x2,
                                  int y2,
                                  int x3,
                                  int y3)
Fill a triangle. Fill a triangle formed from a loop of the coordinates passed in using the current pen color. This method is more efficient than fillPoly.

Parameters:
x1 - the x coordinate of the first vertex
y1 - the y coordinate of the first vertex
x2 - the x coordinate of the second vertex
y2 - the y coordinate of the second vertex
x3 - the x coordinate of the third vertex
y3 - the y coordinate of the third vertex

drawPoly

public abstract void drawPoly(int[] x,
                              int[] y)
Draw a polygon. Draw a polygon formed from a loop of the coordinates passed in using the current pen color.

Parameters:
x - An integer array of x coordinates.
y - An integer array of y coordinates.

fillPoly

public abstract void fillPoly(int[] x,
                              int[] y)
Fill a polygon. Fill a polygon formed from a loop of the coordinates passed in using the current pen color. Self-intersecting polygons are rendered using the even-odd rule, also known as the alternating rule.

Parameters:
x - An integer array of x coordinates.
y - An integer array of y coordinates.

fillTexturedPoly

public abstract void fillTexturedPoly(Bitmap sourceMap,
                                      int[] x,
                                      int[] y,
                                      int[] u,
                                      int[] v)
Fill a polygon with a Textured bitmap Fill a polygon from a list of coordinates passed in using a bitmap as a texture. Clips against current clip rect.

Parameters:
sourceMap - An Bitmap.
x - An integer array of x coordinates that mark the polygon.
y - An integer array of y coordinates that mark the polygon.
u - An integer array of x coordinates in the source Bitmap's coordinates space.
v - An integer array of y coordinates in the source Bitmap's coordinates space. x/y vertices must run in a clockwise direction

This is a tweaked port of Michael Abrash's DDA from chapter 56 of the _Graphics Programming Black Book (Special Edition)_ Also Dr Dobbs Journal September 1992.

Since:
3.0

fillTexturedPoly

public abstract void fillTexturedPoly(Bitmap sourceMap,
                                      int[] x,
                                      int[] y,
                                      int[] u,
                                      int[] v,
                                      int vertexOffset,
                                      int numVertexes)
Fill a polygon with a Textured bitmap Fill a polygon from a list of coordinates passed in using a bitmap as a texture. Clips against current clip rect.

Parameters:
sourceMap - An Bitmap.
x - An integer array of x coordinates that mark the polygon.
y - An integer array of y coordinates that mark the polygon.
u - An integer array of x coordinates in the source Bitmap's coordinates space.
v - An integer array of y coordinates in the source Bitmap's coordinates space.
vertexOffset - An integer that is the starting index when reading from the []x, []y, []u, and []v arrays.
numVertexes - An integer for how many vertexes to read. Example for vertexOffset and numVertexes would be 0 and length of all arrays, which is the same as calling fillTexturedPoly() without these last two parameters. x/y vertices must run in a clockwise direction

This is a tweaked port of Michael Abrash's DDA from chapter 56 of the _Graphics Programming Black Book (Special Edition)_ Also Dr Dobbs Journal September 1992.

Since:
3.0

offset

public abstract void offset(int dx,
                            int dy)
Offset coordinate space. Offset the coordinate space by the amount specified by dx and dy. This offset is applied to the coordinates passed to all drawing routines of the Pen class. For example, after calling Offset(10, 10), a call to DrawPoint(0, 0) will cause a point to be drawn at (10,10).

Parameters:
dx - An integer specifying the delta for the x origin.
dy - An integer specifying the delta for the y origin.

getClipGlobal

public Rect getClipGlobal()
Get the clipping rectangle in global coordinates. Returns the current clipping rectangle in global coordinates. These coordinates are not affected by the size of the view or the current offset of the coordinate system.

Returns:
A Rect specifying the clipping rectangle.

getClip

public Rect getClip()
Get the clipping rectangle in local coordinates. Returns the current clipping rectangle in local coordinates. These coordinates are relative to the size of the view and the current offset.

Returns:
A Rect specifying the clipping rectangle.

getClipGlobal

public abstract Rect getClipGlobal(Rect rect)
Get the clipping rectangle in global coordinates. Returns the current clipping rectangle in global coordinates. These coordinates are not affected by the size of the view or the current offset of the coordinate system.

Parameters:
rect - the Rect whose values will be set to the clip region
Returns:
rect

getClip

public abstract Rect getClip(Rect rect)
Get the clipping rectangle in local coordinates. Returns the current clipping rectangle in local coordinates. These coordinates are relative to the size of the view and the current offset.

Parameters:
rect - the Rect whose values will be set to the clip region
Returns:
rect

setColorAlpha

public abstract void setColorAlpha(int color)
Set the pen drawing color. This color is used to draw all graphic objects until a subsequent call to SetColor is made. For 16 bit color devices, the color components are shifted from 24 to 16 bit colorspace. For 4 bit grayscale devices, the 0-15 intensity of the pixel is computed as follows: i = [ (R + 2*G + B) / 4 ] * [ 16 / 256 ] 0x000000 is black 0xffffff is white.

Parameters:
color - A packed RGB integer specifying the color.

setColor

public void setColor(int color)

setColor

public void setColor(int r,
                     int g,
                     int b)

setColor

public void setColor(int r,
                     int g,
                     int b,
                     int a)

setColorAlpha

public void setColorAlpha(int color,
                          int alpha)
Since:
4.0

setColor

public void setColor(Color c)

getColor

public abstract int getColor()

setTextureColor

public abstract void setTextureColor(int packedColor)
Set the current texture color used when rendering with fillTexturedPoly(). Default is Color.WHITE.

Parameters:
packedColor - RGB packed color. Use setTextureColor(int,int,int) to set with red, green, blue values.
Since:
4.0

getTextureColor

public abstract int getTextureColor()
Get the current texture color used when rendering with fillTexturedPoly(). Default is Color.WHITE.

Since:
4.0

setTextureColor

public void setTextureColor(int r,
                            int g,
                            int b)
Set the current texture color used when rendering with fillTexturedPoly(). Default is Color.WHITE.

Parameters:
r - red component of color
g - green component of color
b - blue component of color
Since:
4.0

setTextOutlineColor

public abstract void setTextOutlineColor(int color)
Set the current outline text color.


setTextOutlineColor

public void setTextOutlineColor(int r,
                                int g,
                                int b)

setTextOutlineColor

public void setTextOutlineColor(Color c)

getTextOutlineColor

public abstract int getTextOutlineColor()

setTextShadowColor

public abstract void setTextShadowColor(int packedColor)
Set the current shadow color used when rendering a font with F_SHADOW. Default is Color.BLACK.

Parameters:
packedColor - RGB packed color. Use setTextShadowColor(int,int,int) to set with red, green, blue values.
Since:
4.0

getTextShadowColor

public abstract int getTextShadowColor()
Get the current shadow color used when rendering a font with F_SHADOW. Default is Color.BLACK.

Since:
4.0

setTextShadowColor

public void setTextShadowColor(int r,
                               int g,
                               int b)
Set the current shadow color used when rendering a font with F_SHADOW. Default is Color.BLACK.

Parameters:
r - red component of color
g - green component of color
b - blue component of color
Since:
4.0

setRenderHints

public abstract void setRenderHints(int hints)
Set this Pen's rendering hints. These are used to change how specific things are drawn.

Parameters:
hints - bitwise or'd bits, or HINT_DEFAULT for defaults
Since:
4.0

getRenderHints

public abstract int getRenderHints()
Get this Pen's rendering hints.

Returns:
int bitwise bits, or HINT_DEFAULT for default
Since:
4.0

setFont

public abstract void setFont(Font f)
Set the current font. Set the current font to be the font specified by f. All text will be drawn in this font until the next call to SetFont.

Parameters:
f - A Font specifying the font to be used.

getFont

public abstract Font getFont()
Get the current font. Returns the font specified by the last call to SetFont. Returns null if no previous call to SetFont has been made.

Returns:
A Font containing the current font.

setSize

public abstract void setSize(int inWidth,
                             int inHeight)
Set the current pen size. Sets the current pen size used by all but the text drawing methods. inWidth and inHeight specify the width and height of the pen respectively.

Parameters:
inWidth - An int specifying the width for the pen.
inHeight - An int specifying the height for the pen.

setClipGlobal

public abstract void setClipGlobal(int l,
                                   int t,
                                   int r,
                                   int b)
Adjust the clip-rect of the Pen using global coordinates. The clip-rect can never be made *larger* than it currently is.


isClipEmpty

public boolean isClipEmpty()
returns true if *nothing* will be drawn with this pen


setClip

public void setClip(int l,
                    int t,
                    int r,
                    int b)
Adjust the clip-rect of the Pen using local coordinates. The clip-rect can never be made *larger* than it currently is.


getTop

public abstract int getTop()
Get the vertical offset of the pen.


getLeft

public abstract int getLeft()
Get the horizontal offset of the pen.


clonePen

public abstract Pen clonePen()
Clone the current pen. Returns a new Pen object that is an exact clone of the current Pen.

Returns:
A Pen that is a duplicate of the current pen.

getVisibleRect

public abstract void getVisibleRect(Rect r)
return a rectangle that encloses all the visible points (in local coordinates)


getVisibleTop

public abstract int getVisibleTop()
return the first visible line (in local coordinates)


getVisibleBottom

public abstract int getVisibleBottom()
return the last visible line (in local coordinates)


setDashed

public abstract void setDashed(boolean dashed)
enable/disable dashed-style drawing


isDashed

public abstract boolean isDashed()
Query the state of dashed-style drawing.

Returns:
true iff line drawing happens in a "dashed" style

copy

protected abstract void copy(Pen from)

push

public void push()
Saves a copy of this pen on the statestack.


pop

public void pop()
Restores the last copy of this pen saved on the statestack. Throws a UIException if the stack is empty


maxStack

public int maxStack()

popAll

public void popAll()
Pops all saved state off the statestack