|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.lcdui.Displayable javax.microedition.lcdui.Canvas ch.aplu.gidlet.Playground
public class Playground
Graphics window of full screen width and height (client drawing area),
exclusively used as canvas for the class Turtle.
A current graph position is used, that remembers the end position of the last
drawing process and where new drawings start.
A soft button 'Exit' is shown. Hitting the corresponding key will
call the Gidlet's doExit(). If you do not need this button,
invoke removeExitButton().
If you implement your own CommandListener and call setCommandListener(), the internal
CommandListener is disabled.
Turtle
Field Summary |
---|
Fields inherited from class javax.microedition.lcdui.Canvas |
---|
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP |
Constructor Summary | |
---|---|
protected |
Playground(Turtle turtle,
java.lang.String title,
double range,
int bgColor,
int turtleColor,
int penColor,
int titleColor,
boolean visible,
boolean isShown)
|
Method Summary | |
---|---|
protected void |
_draw(int x,
int y)
Draws a line into trace buffer from current graph position to given pixel coordinates and sets the graph position to the endpoint. |
protected void |
_fillRectangle(int ulx,
int uly,
int lrx,
int lry,
int color)
Draws a filled rectangle with given opposite corners in pixel coordinates into trace buffer using the given color. |
protected void |
_fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int color)
Draws a filled triangle with given corners in pixel coordintates into trace buffer using the given color. |
protected int |
_getPosX()
Returns pixel coordinate x of current graph position. |
protected int |
_getPosY()
Returns pixel coordinate y of current graph position. |
protected boolean |
_image(java.lang.String imageUrl,
int x,
int y)
Puts the PNG image into turtle buffer from given file url at given pixel coordinates (specifies upper left corner of image). |
protected int |
_imageHeight(java.lang.String imageUrl)
Returns the height (vertical size) of the PNG image from the given url (in pixel coordinates). |
protected int |
_imageWidth(java.lang.String imageUrl)
Returns the width (horizontal size) of the PNG image from the given url (in pixel coordinates). |
protected void |
_line(int x1,
int y1,
int x2,
int y2)
Draws a line with given pixel coordinates into trace buffer and sets the graph position to the endpoint. |
protected void |
_move(int x,
int y)
Sets the current graph position into trace buffer to given pixel coordinates (without drawing anything). |
protected void |
_rectangle(int ulx,
int uly,
int lrx,
int lry)
Draws a rectangle with given opposite corners in pixel coordinates into trace buffer. |
protected int |
_screenHeight()
Returns height of screen in pixel coordinates. |
protected int |
_screenWidth()
Returns width of screen in pixel coordinates. |
protected void |
_triangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
Draws a triangle with given corners in pixel coordintates. |
protected void |
addKeyListener(KeyListener keyListener)
Registers an KeyListener to get a notification when a button is clicked. |
protected void |
addLabel(java.lang.String text,
int x,
int y,
int index,
int color)
Shows the given text with given color left adjusted at given x, y pixel coordinate. |
void |
addOkButton()
Adds an OK soft button with label "OK". |
void |
addOkButton(java.lang.String label)
Adds an OK soft button with given label. |
protected void |
clear(boolean init)
Clears the graphics buffers (fully paint with background color) and draws a surrounding white rectangle. |
protected void |
draw(double x,
double y)
Draws a line into trace buffer from current graph position to given window coordinates and sets the graph position to the endpoint. |
protected void |
drawLabels()
|
protected void |
fillRectangle(double x1,
double y1,
double x2,
double y2,
int color)
Draws a filled rectangle with given opposite corners in window coordinates using the given color. |
protected void |
fillTriangle(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
int color)
Draws a filled triangle with given corners in window coordintates using the given color. |
protected double |
getAspectRatio()
Returns the ratio of canvas height to width. |
protected double |
getPosX()
Returns window coordinate x of current graph position. |
protected double |
getPosY()
Returns window coordinate y of current graph position. |
protected javax.microedition.lcdui.Graphics |
getTraceBuffer()
Returns the graphics turtle buffer. |
protected javax.microedition.lcdui.Image |
getTraceImage()
Returns the trace image. |
protected javax.microedition.lcdui.Graphics |
getTurtleBuffer()
Returns the graphics turtle buffer. |
protected javax.microedition.lcdui.Image |
getTurtleImage()
Returns the turtle image. |
protected boolean |
image(java.lang.String imageUrl,
double x,
double y)
Puts the PNG image into turtle buffer from given file url at given window coordinates (specifies upper left corner of image). |
protected double |
imageHeight(java.lang.String imageUrl)
Returns the height (vertical size) of the PNG image from the given url (in window coordinates). |
protected double |
imageWidth(java.lang.String imageUrl)
Returns the width (horizontal size) of the PNG image from the given url (in window coordinates). |
protected void |
init()
Initializes Playground. |
protected void |
keyPressed(int keyCode)
Used to get key events. |
protected void |
keyReleased(int keyCode)
Used to get key events. |
protected void |
keyRepeated(int keyCode)
Used to get key events. |
protected void |
line(double x1,
double y1,
double x2,
double y2)
Draws a line into trace buffer with given window coordinates into given buffer and sets the graph position to the endpoint. |
protected void |
move(double x,
double y)
Sets the current graph position in trace buffer to given window coordinates (without drawing anything). |
protected void |
paint(javax.microedition.lcdui.Graphics g)
Used for rendering canvas. |
protected void |
rectangle(double x1,
double y1,
double x2,
double y2)
Draws a rectangle with given opposite corners in window coordinates. |
void |
removeExitButton()
Removes Exit soft button. |
protected void |
removeKeyListener()
Removes a registered KeyListener. |
protected void |
removeLabel(int index)
Removes text with given index. |
void |
removeOkButton()
Removes OK soft button. |
protected double |
screenHeight()
Returns height of screen in window coordinates. |
protected int |
screenResolutionX()
Returns number of pixels in horizontal direction. |
protected int |
screenResolutionY()
Returns number of pixels in vertical direction. |
protected double |
screenWidth()
Returns width of screen in window coordinates. |
protected int |
setTracePenColor(int color)
Sets color of drawing pen in trace buffer. |
void |
show()
Shows the form display if it is not yet visible or it was previously hidden by another display. |
protected void |
show(boolean wait)
Shows the graphics display if it was previously hidden by another display or not yet displayed. |
protected int |
toPixelHeight(double windowHeight)
Converts window coordinates increment to pixel coordinates increment (vertical). |
protected int |
toPixelWidth(double windowWidth)
Converts window coordinates increment to pixel coordinates increment (horizontal). |
protected int |
toPixelX(double windowX)
Converts window coordinates to pixel coordinates (horizontal). |
protected int |
toPixelY(double windowY)
Converts window coordinates to pixel coordinates (vertical). |
protected double |
toWindowHeight(int pixelHeight)
Converts pixel coordinates increment to window coordinates increment (vertical). |
protected double |
toWindowWidth(int pixelWidth)
Converts pixel coordinates increment to window coordinates increment (horizontal). |
protected double |
toWindowX(int userX)
Converts pixel coordinates to window coordinates (horizontal). |
protected double |
toWindowY(int userY)
Converts pixel coordinates to window coordinates (vertical). |
protected void |
triangle(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Draws a triangle with given corners in window coordintates. |
protected void |
window(double xmin,
double xmax,
double ymin,
double ymax)
Sets window coordinates. |
Methods inherited from class javax.microedition.lcdui.Canvas |
---|
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setCommandListener, setFullScreenMode, showNotify, sizeChanged |
Methods inherited from class javax.microedition.lcdui.Displayable |
---|
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setTicker, setTitle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Playground(Turtle turtle, java.lang.String title, double range, int bgColor, int turtleColor, int penColor, int titleColor, boolean visible, boolean isShown)
Method Detail |
---|
protected void init()
public void show()
protected void show(boolean wait)
protected int setTracePenColor(int color)
protected void clear(boolean init)
protected void addLabel(java.lang.String text, int x, int y, int index, int color)
protected void drawLabels()
protected void removeLabel(int index)
protected void _line(int x1, int y1, int x2, int y2)
protected void line(double x1, double y1, double x2, double y2)
protected void _draw(int x, int y)
protected void draw(double x, double y)
protected void _move(int x, int y)
protected void move(double x, double y)
protected void _triangle(int x1, int y1, int x2, int y2, int x3, int y3)
protected void triangle(double x1, double y1, double x2, double y2, double x3, double y3)
protected void _fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int color)
protected void fillTriangle(double x1, double y1, double x2, double y2, double x3, double y3, int color)
protected void _rectangle(int ulx, int uly, int lrx, int lry)
protected void rectangle(double x1, double y1, double x2, double y2)
protected void _fillRectangle(int ulx, int uly, int lrx, int lry, int color)
protected void fillRectangle(double x1, double y1, double x2, double y2, int color)
protected void window(double xmin, double xmax, double ymin, double ymax)
protected int toPixelX(double windowX)
protected int toPixelY(double windowY)
protected int toPixelWidth(double windowWidth)
protected int toPixelHeight(double windowHeight)
protected double toWindowX(int userX)
protected double toWindowY(int userY)
protected double toWindowWidth(int pixelWidth)
protected double toWindowHeight(int pixelHeight)
protected double getAspectRatio()
protected int _getPosX()
protected double getPosX()
protected int _getPosY()
protected double getPosY()
protected javax.microedition.lcdui.Graphics getTurtleBuffer()
protected javax.microedition.lcdui.Graphics getTraceBuffer()
protected javax.microedition.lcdui.Image getTurtleImage()
protected javax.microedition.lcdui.Image getTraceImage()
protected void addKeyListener(KeyListener keyListener)
protected void removeKeyListener()
protected boolean _image(java.lang.String imageUrl, int x, int y)
protected boolean image(java.lang.String imageUrl, double x, double y)
protected int _imageWidth(java.lang.String imageUrl)
protected double imageWidth(java.lang.String imageUrl)
protected int _imageHeight(java.lang.String imageUrl)
protected double imageHeight(java.lang.String imageUrl)
protected int _screenWidth()
protected int screenResolutionX()
protected double screenWidth()
protected int _screenHeight()
protected int screenResolutionY()
protected double screenHeight()
protected void paint(javax.microedition.lcdui.Graphics g)
paint
in class javax.microedition.lcdui.Canvas
protected void keyPressed(int keyCode)
keyPressed
in class javax.microedition.lcdui.Canvas
protected void keyReleased(int keyCode)
keyReleased
in class javax.microedition.lcdui.Canvas
protected void keyRepeated(int keyCode)
keyRepeated
in class javax.microedition.lcdui.Canvas
public void addOkButton()
public void addOkButton(java.lang.String label)
public void removeExitButton()
public void removeOkButton()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |