public class Canvas extends Widget
SCROLL_DIR_ALL, SCROLL_DIR_BOTTOM, SCROLL_DIR_HORIZONTAL, SCROLL_DIR_LEFT, SCROLL_DIR_NONE, SCROLL_DIR_RIGHT, SCROLL_DIR_TOP, SCROLL_DIR_VERTICAL, SCROLLBAR_MODE_ACTIVE, SCROLLBAR_MODE_AUTO, SCROLLBAR_MODE_OFF, SCROLLBAR_MODE_ON, STATE_CHECKED, STATE_DEFAULT, STATE_DISABLED, STATE_SCROLLED
ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_TOP, objImpl, SIDE_BOTTOM, SIDE_FULL, SIDE_LEFT, SIDE_RIGHT, SIDE_TOP, SIZE_CONTENT, TEXT_DECOR_NONE, TEXT_DECOR_STRIKETHROUGH, TEXT_DECOR_UNDERLINE
Constructor and Description |
---|
Canvas(int width,
int height)
Constructs a canvas with the given size
|
Modifier and Type | Method and Description |
---|---|
void |
drawArc(int x,
int y,
int radius,
int startAngle,
int endAngle)
Draws an arc on the canvas
|
void |
drawImage(byte[] data,
int offset,
int length,
int x,
int y)
Draws an image on the canvas
|
void |
drawImage(String source,
int x,
int y)
Draws an image on the canvas
|
void |
drawLine(int x,
int y,
int x2,
int y2)
Draws a simple line which from (x,y) to (x2, y2) on the canvas
|
void |
drawLine(PointGroup group)
Draws a line on the canvas.
|
void |
drawPolygon(PointGroup group)
Draws a polygon on the canvas
|
void |
drawRect(int x,
int y,
int w,
int h)
Draws a rectangle on the canvas
|
void |
drawText(String text,
int x,
int y)
Draws a text on the canvas
|
void |
drawText(String text,
int x,
int y,
int maxWidth)
Draws a text on the canvas
|
void |
fill(Color color)
Fills the canvas with color
|
Image |
getImage()
Creates an image from the canvas.
|
void |
resetPropertyValuesOfDraw()
Resets all draw properties to default value
|
void |
setBackgroundColorOfDraw(Color color)
Sets draw property
background color of the canvas |
void |
setImageAngleOfDraw(int angle)
Sets draw property
image angle of the canvas |
void |
setImagePivotOfDraw(int pivotX,
int pivotY)
Sets draw property
image pivot of the canvas |
void |
setImageRecolorOfDraw(Color color)
Sets draw property
image recolor of the canvas |
void |
setImageZoomOfDraw(double factor)
Sets draw property
image zoom of the canvas |
void |
setLineColorOfDraw(Color color)
Sets draw property
line color of the canvas |
void |
setLineDashGapOfDraw(int gap)
Sets draw property
line dash gap of the canvas |
void |
setLineDashWidthOfDraw(int width)
Sets draw property
line dash width of the canvas |
void |
setLineWidthOfDraw(int width)
Sets draw property
line width of the canvas |
void |
setPixel(int x,
int y,
Color color)
Sets the color of a pixel on the canvas
|
void |
setPixel(Point point,
Color color)
Sets the color of a pixel on the canvas
|
void |
setRectRadiusOfDraw(int radius)
Sets draw property
rect radius of the canvas |
void |
setShadowColorOfDraw(Color color)
Sets draw property
shadow color of the canvas |
void |
setShadowOffsetXOfDraw(int offsetX)
Sets draw property
shadow offsetX of the canvas |
void |
setShadowOffsetYOfDraw(int offsetY)
Sets draw property
shadow offsetY of the canvas |
void |
setShawdowWidthOfDraw(int width)
Sets draw property
shadow width of the canvas |
void |
setTextColorOfDraw(Color color)
Sets draw property
text color of the canvas |
void |
setTextDecorOfDraw(int decor)
Sets draw property
text decor of the canvas |
void |
setTextFontOfDraw(Font font)
Sets draw property
text font of the canvas |
void |
setTextLetterSpaceOfDraw(int space)
Sets draw property
text letter space of the canvas |
void |
setTextLineSpaceOfDraw(int space)
Sets draw property
text line space of the canvas |
getContainer
getObjectOfState, getScrollbar, getScrollbarMode, getScrollbarOfState, getScrollBottom, getScrollDirection, getScrollLeft, getScrollRight, getScrollTop, getScrollX, getScrollY, isChecked, isClickable, isDisabled, isFloating, isHidden, isIgnoreLayout, isScrollable, isScrolled, resetAllListeners, scrollToView, scrollToView, scrollToX, scrollToX, scrollToY, scrollToY, setCancelListener, setChecked, setClickable, setClickedListener, setDisabled, setFloating, setHidden, setIgnoreLayout, setReadyListener, setScrollable, setScrollbarMode, setScrollDirection, setScrollListener, setValueChangedListener
enableClipCorner, forceNewTrack, getBackgroundColor, getBorderColor, getBorderWidth, getColumnPadding, getCoordinates, getFlexGrow, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getName, getPadding, getParent, getPropertyBooleanValue, getPropertyIntValue, getRadius, getRowPadding, getShadowColor, getShadowOffsetX, getShadowOffsetY, getShadowWidth, getTextColor, getTextLetterSpace, getTextLineSpace, getTranslateX, getTranslateY, getUserData, getWidth, getX, getY, isClipCornerEnabled, setAlign, setBackgroundColor, setBorderColor, setBorderWidth, setColumnPadding, setFlexGrow, setHeight, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setName, setPadding, setPadding, setParent, setPos, setPropertyValue, setPropertyValue, setPropertyValue, setPropertyValue, setRadius, setRecolor, setRowPadding, setShadowColor, setShadowOffsetX, setShadowOffsetY, setShadowWidth, setSize, setTextAlign, setTextColor, setTextDecor, setTextFont, setTextLetterSpace, setTextLineSpace, setTranslateX, setTranslateY, setUserData, setWidth, setX, setY
public Canvas(int width, int height)
width
- width of the canvasheight
- height of the canvaspublic void fill(Color color)
color
- the background colorpublic void setPixel(Point point, Color color)
point
- the point to setcolor
- color of the pixelpublic void setPixel(int x, int y, Color color)
x
- x coordinate of the point to sety
- x coordinate of the point to setcolor
- color of the pixelpublic void drawLine(int x, int y, int x2, int y2)
x
- x coordinate of start pointy
- y coordinate of start pointx2
- x coordinate of end pointy2
- y coordinate of end pointpublic void drawLine(PointGroup group)
group
- a set of pointspublic void drawPolygon(PointGroup group)
group
- a set of points of the polygonpublic void drawRect(int x, int y, int w, int h)
x
- left coordinate of the rectangley
- top coordinate of the rectanglew
- width of the rectangleh
- height of the rectanglepublic void drawArc(int x, int y, int radius, int startAngle, int endAngle)
x
- origo x of the arcy
- origo y of the arcradius
- radius of the arcstartAngle
- start angle in degreesendAngle
- end angle in degreespublic void drawText(String text, int x, int y)
text
- text to displayx
- left coordinate of the texty
- top coordinate of the textpublic void drawText(String text, int x, int y, int maxWidth)
text
- text to displayx
- left coordinate of the texty
- top coordinate of the textmaxWidth
- max width of the text. The text will be wrapped to fit into
this sizepublic void drawImage(String source, int x, int y) throws IOException
source
- file path in jar of the imagex
- left coordinate of the imagey
- top coordinate of the imageIOException
public void drawImage(byte[] data, int offset, int length, int x, int y)
data
- byte array contains the data of the imageoffset
- the start offset in the data
length
- the number of bytes of the imagex
- left coordinate of the imagey
- top coordinate of the imagepublic Image getImage()
public void setBackgroundColorOfDraw(Color color)
background color
of the canvascolor
- background colorpublic void setLineColorOfDraw(Color color)
line color
of the canvascolor
- line colorpublic void setLineWidthOfDraw(int width)
line width
of the canvaswidth
- in pixelspublic void setRectRadiusOfDraw(int radius)
rect radius
of the canvasradius
- in pixelspublic void setShadowColorOfDraw(Color color)
shadow color
of the canvascolor
- shadow colorpublic void setShawdowWidthOfDraw(int width)
shadow width
of the canvaswidth
- in pixelspublic void setShadowOffsetXOfDraw(int offsetX)
shadow offsetX
of the canvasoffsetX
- in pixelspublic void setShadowOffsetYOfDraw(int offsetY)
shadow offsetY
of the canvasoffsetY
- in pixelspublic void setLineDashWidthOfDraw(int width)
line dash width
of the canvas
Note that dash may works only on horizontal and vertical lineswidth
- in pixelspublic void setLineDashGapOfDraw(int gap)
line dash gap
of the canvas
Note that dash may works only on horizontal and vertical linesgap
- gap between dashes in pixelspublic void setTextColorOfDraw(Color color)
text color
of the canvascolor
- text colorpublic void setTextFontOfDraw(Font font)
text font
of the canvasfont
- text fontpublic void setTextDecorOfDraw(int decor)
text decor
of the canvasdecor
- a combination of UIObject.TEXT_DECOR_NONE
,
UIObject.TEXT_DECOR_UNDERLINE
and
UIObject.TEXT_DECOR_STRIKETHROUGH
public void setTextLetterSpaceOfDraw(int space)
text letter space
of the canvasspace
- in pixelspublic void setTextLineSpaceOfDraw(int space)
text line space
of the canvasspace
- in pixelspublic void setImageZoomOfDraw(double factor)
image zoom
of the canvasfactor
- zoom factorpublic void setImageAngleOfDraw(int angle)
image angle
of the canvasangle
- the rotation angle of the image in degree with 0.1 degree
resolutionpublic void setImagePivotOfDraw(int pivotX, int pivotY)
image pivot
of the canvaspivotX
- rotation center x of the imagepivotY
- rotation center y of the imagepublic void setImageRecolorOfDraw(Color color)
image recolor
of the canvascolor
- the color to mix to imagepublic void resetPropertyValuesOfDraw()