public class PointGraphics extends Object implements AlignmentConstants, IPath
Modifier and Type | Field and Description |
---|---|
boolean |
dontFreeGraphics
If this is set true then a free() on this PointGraphics will not
free the underlying Graphics.
|
static int |
TRANSFORM_NONE |
static int |
TRANSFORM_ROTATE_180 |
static int |
TRANSFORM_ROTATE_270 |
static int |
TRANSFORM_ROTATE_90 |
static int |
TRANSFORM_ROTATE_NONE |
static int |
TRANSFORM_ROTATE_NOT_RIGHT |
protected double |
xdpi |
protected double |
xscale |
protected double |
ydpi |
protected double |
yscale |
BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, LEFT, NORTH, NORTHEAST, NORTHWEST, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, STRETCH, TAG_BACKGROUND_IMAGE, TAG_BORDER, TAG_FIXEDSIZE, TAG_INSETS, TAG_MAXIMUMSIZE, TAG_MINIMUMSIZE, TAG_PREFERREDSIZE, TAG_RECT, TAG_SPAN, TAG_TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
Modifier | Constructor and Description |
---|---|
protected |
PointGraphics()
If this default constructor is used, you must, at a minimum,
call setDPI() before doing any drawing.
|
|
PointGraphics(Graphics g,
int graphicsWidth,
int graphicsHeight,
double xDPI,
double yDPI)
Create a PointGraphics from a Graphics object, specifying the number of pixels
that the Graphics covers horizontally and vertically and specifying the x and y DPI
values that you attribute to the Graphics.
|
|
PointGraphics(Image im,
double dpi)
Create a PointGraphics to draw on an image using a specific DPI value.
|
|
PointGraphics(Image im,
double pointWidth,
double pointHeight)
Create a PointGraphics to draw on an image where the x and y dpi are
chosen such that the specified point width and height fit the image
exactly.
|
|
PointGraphics(IPointCanvas canvas) |
Modifier and Type | Method and Description |
---|---|
void |
addToPath(double x,
double y)
Add a straight line segment to the path.
|
void |
addToPath(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Add a Cubic Bezier curve segment from the current point to (x3,y3) using
(x1, y1) and (x2, y2) as the control points.
|
static void |
anchor(PointRect subArea,
PointRect largeArea,
int anchor)
Modify subArea so that it is anchored appropriately in largeArea.
|
boolean |
canConvertToPixels()
Return if the underlying surface can convert from points to pixels.
|
void |
closePath()
Close the path by making a straight line segment back to the original point.
|
void |
drawArc(double x,
double y,
double width,
double height,
float startAngle,
float angle)
Draw an open arc section of an ellipse using the current pen.
|
void |
drawImageData(ImageData src,
double x,
double y,
double width,
double height,
int scaleOptions)
Draw a full ImageData object scaled to a particular size.
|
void |
drawImageData(ImageData src,
double x,
double y,
double width,
double height,
PointRect destArea,
int options)
Scale and draw an ImageData to the PointGraphics, specifying the destination area
that is to be drawn on the PointGraphics - all other sections of the image will
be clipped.
|
void |
drawLine(double x1,
double y1,
double x2,
double y2)
Draw a single line segment.
|
void |
drawLines(double[] x,
double[] y,
int xoffset,
int yoffset,
int count)
Draw a set of lines joined to the next forming a single unbroken path.
|
void |
drawLines(double[] x,
double[] y,
int xoffset,
int yoffset,
int count,
boolean separateLines)
Draw a set of lines either by joining one to the next forming a single unbroken path,
or by drawing sets of separate lines.
|
void |
drawText(char[] data,
int offset,
int length,
double x,
double y)
Draw text in the PointGraphics.
|
void |
drawText(String text,
double x,
double y)
Draw text at a particular location.
|
void |
drawText(StringList lines,
double x,
double y,
double width,
double height,
int alignment,
int anchor)
Draw text in a certain area, aligned and anchored appropriately.
|
void |
drawText(StringList lines,
PointRect where,
int alignment,
int anchor,
int startLine,
int count)
Draw text in a certain area, aligned and anchored appropriately.
|
void |
free()
Free all resources associated with this PointGraphics.
|
PointFontMetrics |
getFontMetrics(PointFont f)
Get a PointFontMetrics for a PointFont on the current PointGraphics.
|
IPointCanvas |
getPointCanvas()
If this PointGraphics is implemented on a PointCanvas then return it,
otherwise this will return null.
|
IPointDocument |
getPointDocument()
If this PointGraphics is implemented on a PointCanvas then return the
IPointDocument it is associated with if any.
|
void |
getScreenUpdateRect(int px,
int py,
int pwidth,
int pheight,
PointRect dest,
int screenAreaPixelOffsetX,
int screenAreaPixelOffsetY)
This method is used when an object being drawn on a PointGraphics
is being mapped to some area on the screen (or some other pixel oriented device)
where each pixel represents a dot.
|
AffineTransform |
getTransform()
Don't use this directly.
|
AffineTransform |
getTransform(AffineTransform dest)
Don't use this directly.
|
TransformState |
getTransformState()
Get a TransformState for this PointGraphics to manipulate
the transformations.
|
TransformState |
getTransformState(TransformState dest)
Get a TransformState for this PointGraphics to manipulate
the transformations.
|
double |
getXdpi()
Get the X dpi, but if this is based on an IPointCanvas, this will be zero.
|
double |
getYdpi()
Get the X dpi, but if this is based on an IPointCanvas, this will be zero.
|
void |
paintClosedArc(double x,
double y,
double width,
double height,
float startAngle,
float angle,
boolean useBrush,
boolean usePen)
Paint a closed arc section of an ellipse.
|
void |
paintEllipse(double x,
double y,
double width,
double height,
boolean useBrush,
boolean usePen)
Paint a complete ellipse contained in the x, y, width and height
values specified.
|
void |
paintPath(boolean useBrush,
boolean usePen) |
void |
paintPie(double x,
double y,
double width,
double height,
float startAngle,
float angle,
boolean useBrush,
boolean usePen)
Paint a closed pie section of an ellipse.
|
void |
paintPolygon(double[] x,
double[] y,
int xoffset,
int yoffset,
int count,
boolean useBrush,
boolean usePen)
Paint a closed polygon.
|
void |
paintRect(double x,
double y,
double width,
double height,
boolean useBrush,
boolean usePen)
Paint a complete Rectangle contained in the x, y, width and height
values specified.
|
void |
paintRoundRect(double x,
double y,
double width,
double height,
double radius,
boolean useBrush,
boolean usePen)
Paint a complete Rectangle with rounded corners contained in the x, y, width and height
values specified.
|
double |
pixelHeight()
Get the height of an individual pixel in points, but if this
PointGraphics is based on an IPointCanvas, this will return 0.
|
double |
pixelWidth()
Get the width of an individual pixel in points, but if this
PointGraphics is based on an IPointCanvas, this will return 0.
|
void |
reset()
Reset the PointGraphics and underlying Graphics to the original state.
|
int |
scaleHeight(double height)
Given a heidhg in points, calculate the height in pixels for the PointGraphics,
but this will only work if canConvertToPixels() returns true.
|
Rect |
scaleToPixels(PointRect pr,
Rect dest)
Given a PointRect convert to the corresponding pixel Rect,
but this will only work if canConvertToPixels() returns true.
|
int |
scaleWidth(double width)
Given a width in points, calculate the width in pixels for the PointGraphics,
but this will only work if canConvertToPixels() returns true.
|
void |
setBackground(Color c)
Set the background color of the Graphics.
|
void |
setBrush(Color c,
int style)
Set the current Brush (used in filling).
|
void |
setBrush(Color c,
int style,
int rule) |
void |
setColor(Color c)
Set the Pen to be a solid pen of point width 1 and the brush to be a solid brush,
both with the specified color.
|
protected void |
setDPI(double xDPI,
double yDPI) |
void |
setFont(PointFont f)
Set the current font for text operations for the PointGraphics.
|
void |
setPen(Color c,
int style,
double thickness)
Set the current Pen for the PointGraphics.
|
void |
setPen(Color c,
int style,
double xWidth,
double yWidth,
float miterLimit)
Set the current Pen for the PointGraphics.
|
AffineTransform |
setTransform(AffineTransform at)
Don't use this directly.
|
AffineTransform |
setTransform(AffineTransform at,
AffineTransform old)
Don't use this directly.
|
void |
startPath(double x,
double y)
Start a new sub path at x and y.
|
void |
startScreenUpdate(int screenAreaPixelOffsetX,
int screenAreaPixelOffsetY)
This method is used when an object being drawn on a PointGraphics
is being mapped to some area on the screen (or some other pixel oriented device)
where each pixel represents a dot.
|
protected boolean |
surfaceCanTransform() |
protected Object |
surfaceSetTransform(double[] buffer) |
protected double xscale
protected double yscale
protected double xdpi
protected double ydpi
public boolean dontFreeGraphics
public static final int TRANSFORM_ROTATE_90
public static final int TRANSFORM_ROTATE_180
public static final int TRANSFORM_ROTATE_270
public static final int TRANSFORM_NONE
public static final int TRANSFORM_ROTATE_NONE
public static final int TRANSFORM_ROTATE_NOT_RIGHT
protected PointGraphics()
public PointGraphics(IPointCanvas canvas)
public PointGraphics(Image im, double dpi)
im
- the Image to draw on.dpi
- the DPI to use for the PointGraphics.public PointGraphics(Image im, double pointWidth, double pointHeight)
im
- the image.pointWidth
- the width in points represented by the width of the image.pointHeight
- the height in points represented by the height of the image.public PointGraphics(Graphics g, int graphicsWidth, int graphicsHeight, double xDPI, double yDPI)
g
- The target Graphics object.graphicsWidth
- the number of horizontal pixels covered by the Graphics object.graphicsHeight
- the number of vertical pixels covered by the Graphics object.xDPI
- the horizontal DPI being attributed to the Graphics.yDPI
- the vertical DPI being attributed to the Graphics.public void setFont(PointFont f)
f
- the PointFont for the PointGraphics.public PointFontMetrics getFontMetrics(PointFont f)
f
- the PointFont.public void setBackground(Color c)
c
- the new background color.public double pixelWidth()
public double pixelHeight()
public double getXdpi()
public double getYdpi()
public void reset()
public void free()
protected boolean surfaceCanTransform()
protected Object surfaceSetTransform(double[] buffer)
protected void setDPI(double xDPI, double yDPI)
public void setPen(Color c, int style, double xWidth, double yWidth, float miterLimit)
c
- the Color of the Pen.style
- the style of the Pen which should be one of the eve.fx.Pen style values.xWidth
- the horizontal width of the Pen in points.yWidth
- the vertical width of the Pen in points.miterLimit
- the miter limit for the Pen. A miter limit of less than 1 is illegal
and will cause the miter limit to default to the default miter limit of 10.public void setBrush(Color c, int style)
c
- the Color of the Brush.style
- the style of the Brush, which should be one of the eve.fx.Brush
style values.public void setBrush(Color c, int style, int rule)
public void setColor(Color c)
c
- the Color for the current pen and brush.public void startScreenUpdate(int screenAreaPixelOffsetX, int screenAreaPixelOffsetY)
The area on the screen will usually cover some area within the object being drawn and therefore its upper left corner is usually offset a certain number of pixels horizontally or vertically.
When you are about to redraw the object or part of the object to the screen call this method first to set the correct translation in points. Then you can call getScreenUpdateRect() any number of times to get a PointRect which indicates the area on the object (in points) which needs to be drawn to this PointGraphics.
screenAreaPixelOffsetX
- the X-offset of the screen area into the
drawn object.screenAreaPixelOffsetY
- the Y-offset of the screen area into the
drawn object.public void getScreenUpdateRect(int px, int py, int pwidth, int pheight, PointRect dest, int screenAreaPixelOffsetX, int screenAreaPixelOffsetY)
The area on the screen will usually cover some area within the object being drawn and therefore its upper left corner is usually offset a certain number of pixels horizontally or vertically.
When you are about to redraw the object or part of the object to the screen call the startScreenUpdate() method first to set the correct translation in points. Then you can call getScreenUpdateRect() any number of times to get a PointRect which indicates the area on the object (in points) which needs to be drawn to this PointGraphics.
px
- the x-coordinate (in pixels) of the screen area being updated
relative to its own origin, not relative to the drawn object.py
- the y-coordinate (in pixels) of the screen area being updated
relative to its own origin, not relative to the drawn object.pwidth
- the width in pixels of the screen area being updated.pheight
- the height in pixels of the screen area being updated.dest
- a non-null PointRect to hold the area that should be re-drawn
in points in the drawn object.screenAreaPixelOffsetX
- the X-offset of the screen area into the
drawn object.screenAreaPixelOffsetY
- the Y-offset of the screen area into the
drawn object.public void paintPie(double x, double y, double width, double height, float startAngle, float angle, boolean useBrush, boolean usePen)
x
- the x co-ordinate of the bounding box of the complete ellipse.y
- the y co-ordinate of the bounding box of the complete ellipse.width
- the width of the bounding box of the complete ellipse.height
- the height of the bounding box of the complete ellipse.startAngle
- the start angle of the pie section, measured in degrees anti-clockwise where
0 degrees is the 3 O'clock position.angle
- the number of degrees in the pie section.useBrush
- if this is true the pie section will be filled in the current brush before the
outline is drawn. If it is false the pie section is not filled.usePen
- if this is true then the outline of the section will be drawn in the current pen after
any filling is done (if any). if this is false then the outline is not drawn.public void paintClosedArc(double x, double y, double width, double height, float startAngle, float angle, boolean useBrush, boolean usePen)
x
- the x co-ordinate of the bounding box of the complete ellipse.y
- the y co-ordinate of the bounding box of the complete ellipse.width
- the width of the bounding box of the complete ellipse.height
- the height of the bounding box of the complete ellipse.startAngle
- the start angle of the arc section, measured in degrees anti-clockwise where
0 degrees is the 3 O'clock position.angle
- the number of degrees in the arc section.useBrush
- if this is true the arc section will be filled in the current brush before the
outline is drawn. If it is false the arc section is not filled.usePen
- if this is true then the outline of the section will be drawn in the current pen after
any filling is done (if any). if this is false then the outline is not drawn.public void drawArc(double x, double y, double width, double height, float startAngle, float angle)
x
- the x co-ordinate of the bounding box of the complete ellipse.y
- the y co-ordinate of the bounding box of the complete ellipse.width
- the width of the bounding box of the complete ellipse.height
- the height of the bounding box of the complete ellipse.startAngle
- the start angle of the arc section, measured in degrees anti-clockwise where
0 degrees is the 3 O'clock position.angle
- the number of degrees in the arc section.public void paintEllipse(double x, double y, double width, double height, boolean useBrush, boolean usePen)
x
- the x co-ordinate of the bounding box of the complete ellipse.y
- the y co-ordinate of the bounding box of the complete ellipse.width
- the width of the bounding box of the complete ellipse.height
- the height of the bounding box of the complete ellipse.useBrush
- if this is true the ellipse will be filled in the current brush before the
outline is drawn. If it is false the ellipse is not filled.usePen
- if this is true then the outline of the ellipse will be drawn in the current pen after
any filling is done (if any). if this is false then the outline is not drawn.public void paintRect(double x, double y, double width, double height, boolean useBrush, boolean usePen)
x
- the x co-ordinate of the rectangle.y
- the y co-ordinate of the rectangle.width
- the width of the rectangle.height
- the height of the rectangle.useBrush
- if this is true the rectangle will be filled in the current brush before the
outline is drawn. If it is false the rectangle is not filled.usePen
- if this is true then the outline of the rectangle will be drawn in the current pen after
any filling is done (if any). if this is false then the outline is not drawn.public void paintPolygon(double[] x, double[] y, int xoffset, int yoffset, int count, boolean useBrush, boolean usePen)
x
- an array holding the x co-ordinates for the corners of the polygon.y
- an array holding the y co-ordinates for the corners of the polygon.xoffset
- the start location in the x array for the co-ordinates.yoffset
- the start location in the y array for the co-ordinates.count
- the number of corners in the polygon, which should be a minimum of three.useBrush
- if this is true the polygon will be filled in the current brush before the
outline is drawn. If it is false the polygon is not filled.usePen
- if this is true then the outline of the polygon will be drawn in the current pen after
any filling is done (if any). if this is false then the outline is not drawn.public void paintRoundRect(double x, double y, double width, double height, double radius, boolean useBrush, boolean usePen)
x
- the x co-ordinate of the rectangle.y
- the y co-ordinate of the rectangle.width
- the width of the rectangle.height
- the height of the rectangle.radius
- the radius of the ellipse segment used for drawing the corners.useBrush
- if this is true the rectangle will be filled in the current brush before the
outline is drawn. If it is false the rectangle is not filled.usePen
- if this is true then the outline of the rectangle will be drawn in the current pen after
any filling is done (if any). if this is false then the outline is not drawn.public void drawLines(double[] x, double[] y, int xoffset, int yoffset, int count)
x
- the array holding the X co-ordinate points. If y is null then this
also holds the Y co-ordinate points,
either in a separate area or interleaved with the x values.y
- the Y co-ordinate points or null if the Y co-ordinates are in the
x array.xoffset
- the offset into the x array containing the first X point.yoffset
- the offset into the y array containing the first Y point.
If the y array is null then the y points are in the x array. If the yoffset
is equal to xoffset or to xoffset+1, it is assumed that the x and y
co-ordinates are interleaved (first x, then y, then x, then y),
otherwise it is assumed that the x and y co-ordinates
are in non-overlapping contiguous sections within the array.count
- the number of points in the array.public void drawLines(double[] x, double[] y, int xoffset, int yoffset, int count, boolean separateLines)
x
- the array holding the X co-ordinate points. If y is null then this
also holds the Y co-ordinate points,
either in a separate area or interleaved with the x values.y
- the Y co-ordinate points or null if the Y co-ordinates are in the
x array.xoffset
- the offset into the x array containing the first X point.yoffset
- the offset into the y array containing the first Y point.
If the y array is null then the y points are in the x array. If the yoffset
is equal to xoffset or to xoffset+1, it is assumed that the x and y
co-ordinates are interleaved (first x, then y, then x, then y),
otherwise it is assumed that the x and y co-ordinates
are in non-overlapping contiguous sections within the array.count
- the number of points in the array.separateLines
- true to draw as separate lines (i.e from x0,y0 to x1,y1 and then x2,y2 to x3,y3)
false to draw as a single path (i.e. from x0,y0 to x1,y1 to x2,y2 to x3,y3).public void drawLine(double x1, double y1, double x2, double y2)
x1
- the start x co-ordinate.y1
- the start y co-ordinate.x2
- the end x co-ordinate.y2
- the end y co-ordinate.public IPointCanvas getPointCanvas()
public IPointDocument getPointDocument()
public void drawImageData(ImageData src, double x, double y, double width, double height, PointRect destArea, int options)
src
- the source ImageDatax
- the x location where the top left corner of the ImageData would be
if the entire image was drawn.y
- the y location where the top left corner of the ImageData would be
if the entire image was drawn.width
- the full width of the scaled image.height
- the full heigh of the scaled image.destArea
- the destination area being updated on the PointGraphics.
If this is null then the full x, y, width and height values are used.options
- scale options, none of which are currently defined.public void drawText(char[] data, int offset, int length, double x, double y)
data
- the characters to draw.offset
- the offset into character array for the first character.length
- the number of characters to draw.x
- the x co-ordinate of the left side of the first character.y
- the y co-ordinate of the top of first character. The text base line
will be lower than this value equal to the ascent of the font.public boolean canConvertToPixels()
public int scaleWidth(double width)
width
- a width in points.public int scaleHeight(double height)
height
- a height in points.public Rect scaleToPixels(PointRect pr, Rect dest)
pr
- the area in points.dest
- an optional destination Rect.public void setPen(Color c, int style, double thickness)
c
- the Color of the Pen.style
- the style of the Pen which should be one of the eve.fx.Pen style values.thickness
- the horizontal and vertical width of the pen in points.public void drawImageData(ImageData src, double x, double y, double width, double height, int scaleOptions)
src
- the source ImageData.x
- the x co-ordinate for the top left corner of the image.y
- the y co-ordinate for the top left corner of the image.width
- the scaled full width of the image.height
- the scaled full height of the image.scaleOptions
- scale options - none are currently defined.public void drawText(String text, double x, double y)
x
- the x co-ordinate of the left side of the first character.y
- the y co-ordinate of the top of first character. The text base line
will be lower than this value equal to the ascent of the font.public static void anchor(PointRect subArea, PointRect largeArea, int anchor)
public void drawText(StringList lines, PointRect where, int alignment, int anchor, int startLine, int count)
lines
- the text to draw.where
- the bounding rectangle of the text.alignment
- the alignment of the text relative to each other. This
should be LEFT, RIGHT, CENTERanchor
- the anchor of the text within the rectangle. This should be NORTH, SOUTH, etc.startLine
- the first line to draw.count
- the number of lines to draw.public void drawText(StringList lines, double x, double y, double width, double height, int alignment, int anchor)
lines
- the text to draw.x
- the x co-ordinate of the bounding rectangle.y
- the y co-ordinate of the bounding rectangle.width
- the width of the bounding rectangle.height
- the height of the bounding rectangle.alignment
- the alignment of the text relative to each other. This
should be LEFT, RIGHT, CENTERanchor
- the anchor of the text within the rectangle. This should be NORTH, SOUTH, etc.public AffineTransform getTransform(AffineTransform dest)
public AffineTransform getTransform()
public AffineTransform setTransform(AffineTransform at, AffineTransform old)
public AffineTransform setTransform(AffineTransform at)
public TransformState getTransformState(TransformState dest)
public TransformState getTransformState()
public void addToPath(double x, double y)
IPath
public void addToPath(double x1, double y1, double x2, double y2, double x3, double y3)
IPath
public void closePath()
IPath
public void startPath(double x, double y)
IPath
public void paintPath(boolean useBrush, boolean usePen)