moka.x
Class Canvas

java.lang.Object
  |
  +--moka.lang.Object
        |
        +--moka.event.EventListener
              |
              +--moka.x.Component
                    |
                    +--moka.x.Image
                          |
                          +--moka.x.Canvas

public class Canvas
extends Image

Canvas class is a drawing component.

Since:
MDK1.0a

Field Summary
 short color
          The color of the pen use to draw in this Canvas.
 
Fields inherited from class moka.x.Image
bmp
 
Fields inherited from class moka.x.Component
enabled, height, listen, mnemonic, next, parent, prev, visible, width, x, y
 
Constructor Summary
Canvas()
           
Canvas(moka.x.BITMAP_p bmp)
           
Canvas(java.lang.String file)
           
 
Method Summary
 void drawPix(short dx, short dy)
          Draws a pixel in the canvas.
 void erase()
          Erases the the canvas.
 boolean getPix(short dx, short dy)
          Gets the status of a pixel on the canvas.
 void save()
          Saves the area of the canvas.
 void saveToFile(java.lang.String file)
          Saves the bitmap displayed in the canvas to a PIC file.
 void use()
          This method is invoked by the GEM when the user interacts with the Canvas.
 
Methods inherited from class moka.x.Image
finalize, paint, setBmp, setBmp
 
Methods inherited from class moka.x.Component
bottom, center, checkMnemonic, clean, eventTriggered, isCursorOver, left, move, onPaint, right, setBounds, setEnabled, setHeight, setMnemonic, setVisible, setWidth, setX, setY, toFront, top
 
Methods inherited from class moka.event.EventListener
eventTriggered
 
Methods inherited from class moka.lang.Object
equals, getClassName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

color

public short color
The color of the pen use to draw in this Canvas. Can be either Color.BLACK_COLOR, Color.WHITE_COLOR or Color.INVERT_COLOR.

Constructor Detail

Canvas

public Canvas()

Canvas

public Canvas(moka.x.BITMAP_p bmp)

Canvas

public Canvas(java.lang.String file)
Method Detail

drawPix

public void drawPix(short dx,
                    short dy)
Draws a pixel in the canvas.


getPix

public boolean getPix(short dx,
                      short dy)
Gets the status of a pixel on the canvas.

Returns:
true if the pixel is on, false otherwize

save

public void save()
Saves the area of the canvas.


erase

public void erase()
Erases the the canvas.


saveToFile

public void saveToFile(java.lang.String file)
Saves the bitmap displayed in the canvas to a PIC file. If the file string object risk to be used later, use a copy of the string object instead of the original, the string being finalized before the method returns.

Parameters:
file - The PIC file name

use

public void use()
This method is invoked by the GEM when the user interacts with the Canvas.

Overrides:
use in class Component