Class DitherPlane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----DitherPlane

public class DitherPlane
extends Canvas
This class produces a component that displays dithered R-G or R-B "planes", each containing a round marker, representing current position. It is hooked up to the mouse for input.

See Also:
DitherPanelListener

Variable Index

 o cx
current coordinate, 0 to 255
 o cy
current coordinate, 0 to 255
 o image
dithered image
 o listener
current listener
 o SIZE
dither panel size.
 o type
type of the dither panel.
 o TYPE_RB
red-blue type.
 o TYPE_RG
red-green type.

Constructor Index

 o DitherPlane(int, int, int, DitherPanelListener)
Constructs a dither plane and initializes it.

Method Index

 o drawCurrent(Graphics)
Draws a marker indicating current position.
 o minimumSize()
Overrides the default minimumSize() method.
 o mouseDown(Event, int, int)
Processes mouse down event, updates current position and invokes the listener.
 o mouseDrag(Event, int, int)
Processes mouse drag event, updates current position and invokes the listener.
 o paint(Graphics)
paint method.
 o preferredSize()
Overrides the default preferredSize() method.
 o setCurrent(int, int)
Sets current coordinates.
 o setCurrentXY(int, int)
Sets current coordinates.
 o setCxCy(int, int)
Clips input coordinates to 0 to 255 range.
 o update(Graphics)
Overrides the default update(Graphics) method in order not to clear screen to avoid flicker.

Variables

 o SIZE
 public static final int SIZE
dither panel size.

 o TYPE_RG
 public static final int TYPE_RG
red-green type.

 o TYPE_RB
 public static final int TYPE_RB
red-blue type.

 o type
 int type
type of the dither panel.

 o image
 Image image
dithered image

 o cx
 int cx
current coordinate, 0 to 255

 o cy
 int cy
current coordinate, 0 to 255

 o listener
 DitherPanelListener listener
current listener

Constructors

 o DitherPlane
 public DitherPlane(int type,
                    int cx,
                    int cy,
                    DitherPanelListener listener)
Constructs a dither plane and initializes it.

Parameters:
type - red-green or red-blue.
cx - current x coordinate, 0 to 255.
cy - current y coordinate, 0 to 255.
listener - listener to process input from this plane.

Methods

 o drawCurrent
 void drawCurrent(Graphics g)
Draws a marker indicating current position.

 o minimumSize
 public Dimension minimumSize()
Overrides the default minimumSize() method.

Returns:
new Dimension
Overrides:
minimumSize in class Component
 o preferredSize
 public Dimension preferredSize()
Overrides the default preferredSize() method.

Returns:
new Dimension
Overrides:
preferredSize in class Component
 o paint
 public void paint(Graphics g)
paint method.

Overrides:
paint in class Canvas
 o update
 public void update(Graphics g)
Overrides the default update(Graphics) method in order not to clear screen to avoid flicker.

Overrides:
update in class Component
 o setCxCy
 final void setCxCy(int c_x,
                    int c_y)
Clips input coordinates to 0 to 255 range.

Parameters:
c_x - x coordinate
c_y - y coordinate
 o setCurrent
 public void setCurrent(int cx,
                        int cy)
Sets current coordinates.

Parameters:
cx - new x coordinate, 0 to 255.
cy - new y coordinate, 0 to 255.
 o setCurrentXY
 void setCurrentXY(int x,
                   int y)
Sets current coordinates.

Parameters:
x - new x coordinate, 0 to SIZE.
y - new y coordinate, 0 to SIZE.
 o mouseDrag
 public boolean mouseDrag(Event e,
                          int x,
                          int y)
Processes mouse drag event, updates current position and invokes the listener.

Overrides:
mouseDrag in class Component
 o mouseDown
 public boolean mouseDown(Event e,
                          int x,
                          int y)
Processes mouse down event, updates current position and invokes the listener.

Overrides:
mouseDown in class Component