mit.ai.techniques
Class BinaryDrawingCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--mit.ai.techniques.BinaryDrawingCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class BinaryDrawingCanvas
extends java.awt.Canvas

This canvas allows the user to draw big, blocky, binary images with the mouse. It can export its data in the form of a binary array.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
private  boolean currentDrawSetting
          True -> drawing black pixels, false -> drawing white pixels.
private static int PIX_MULT
          Pixel size.
private  boolean[][] pixels
          Pixel state storage.
 
Fields inherited from class java.awt.Canvas
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dbg, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BinaryDrawingCanvas()
          Construct a canvas, default size is 15 x 15 big, blocky pixels.
BinaryDrawingCanvas(boolean[][] initPixels)
          Constrct a canvas that displays the values in initPixels (true -> black, false -> white).
 
Method Summary
 void clearCanvas()
          Clear the canvas (and associated data structures).
 void drawPixel(int x, int y, boolean start)
          Accepts real-screen pixels, and adds their big, blocky superset pixels to the screen and internal data structure.
 int getBigPixelHeight()
          Return canvas height in big pixels.
 int getBigPixelWidth()
          Return canvas width in big pixels.
 boolean[][] getBinaryData()
          Get the binary data.
 int getHeight()
          Return canvas height.
 int getWidth()
          Return canvas width.
 void paint(java.awt.Graphics g)
          Paint the screen with the big, blocky pixels demanded by the current set of pixels we have drawn over.
 void randomize(double blackPercentage)
          Randomize the canvas value to produce a given percentage of black pixels.
 void setSize(int xPixels, int yPixels)
          Set the size in big, blocky pixels.
 void update(java.awt.Graphics g)
          Usual lazy update routine.
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, getAccessibleContext, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkGD, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createChildHierarchyEvents, createHierarchyEvents, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPaint, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, numListening, paintAll, paintHeavyweightComponents, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, toString, transferFocus, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

PIX_MULT

private static final int PIX_MULT
Pixel size.

pixels

private boolean[][] pixels
Pixel state storage.

currentDrawSetting

private boolean currentDrawSetting
True -> drawing black pixels, false -> drawing white pixels.
Constructor Detail

BinaryDrawingCanvas

public BinaryDrawingCanvas()
Construct a canvas, default size is 15 x 15 big, blocky pixels.

BinaryDrawingCanvas

public BinaryDrawingCanvas(boolean[][] initPixels)
Constrct a canvas that displays the values in initPixels (true -> black, false -> white).
Method Detail

getBigPixelWidth

public int getBigPixelWidth()
Return canvas width in big pixels.

getBigPixelHeight

public int getBigPixelHeight()
Return canvas height in big pixels.

getWidth

public int getWidth()
Return canvas width.
Overrides:
getWidth in class java.awt.Component

getHeight

public int getHeight()
Return canvas height.
Overrides:
getHeight in class java.awt.Component

clearCanvas

public void clearCanvas()
Clear the canvas (and associated data structures).

randomize

public void randomize(double blackPercentage)
Randomize the canvas value to produce a given percentage of black pixels.

getBinaryData

public boolean[][] getBinaryData()
Get the binary data. Note that it is indexed in (x,y) order, so we need to transpose so the user (me) won't be too confused.

setSize

public void setSize(int xPixels,
                    int yPixels)
Set the size in big, blocky pixels.
Overrides:
setSize in class java.awt.Component

update

public void update(java.awt.Graphics g)
Usual lazy update routine.
Overrides:
update in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Paint the screen with the big, blocky pixels demanded by the current set of pixels we have drawn over.
Overrides:
paint in class java.awt.Canvas

drawPixel

public void drawPixel(int x,
                      int y,
                      boolean start)
Accepts real-screen pixels, and adds their big, blocky superset pixels to the screen and internal data structure.