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
-
cx
- current coordinate, 0 to 255
-
cy
- current coordinate, 0 to 255
-
image
- dithered image
-
listener
- current listener
-
SIZE
- dither panel size.
-
type
- type of the dither panel.
-
TYPE_RB
- red-blue type.
-
TYPE_RG
- red-green type.
-
DitherPlane(int, int, int, DitherPanelListener)
- Constructs a dither plane and initializes it.
-
drawCurrent(Graphics)
- Draws a marker indicating current position.
-
minimumSize()
- Overrides the default minimumSize() method.
-
mouseDown(Event, int, int)
- Processes mouse down event, updates current position and
invokes the listener.
-
mouseDrag(Event, int, int)
- Processes mouse drag event, updates current position and
invokes the listener.
-
paint(Graphics)
- paint method.
-
preferredSize()
- Overrides the default preferredSize() method.
-
setCurrent(int, int)
- Sets current coordinates.
-
setCurrentXY(int, int)
- Sets current coordinates.
-
setCxCy(int, int)
- Clips input coordinates to 0 to 255 range.
-
update(Graphics)
- Overrides the default update(Graphics) method
in order not to clear screen to avoid flicker.
SIZE
public static final int SIZE
- dither panel size.
TYPE_RG
public static final int TYPE_RG
- red-green type.
TYPE_RB
public static final int TYPE_RB
- red-blue type.
type
int type
- type of the dither panel.
image
Image image
- dithered image
cx
int cx
- current coordinate, 0 to 255
cy
int cy
- current coordinate, 0 to 255
listener
DitherPanelListener listener
- current listener
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.
drawCurrent
void drawCurrent(Graphics g)
- Draws a marker indicating current position.
minimumSize
public Dimension minimumSize()
- Overrides the default minimumSize() method.
- Returns:
- new Dimension
- Overrides:
- minimumSize in class Component
preferredSize
public Dimension preferredSize()
- Overrides the default preferredSize() method.
- Returns:
- new Dimension
- Overrides:
- preferredSize in class Component
paint
public void paint(Graphics g)
- paint method.
- Overrides:
- paint in class Canvas
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
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
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.
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.
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
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