org.j3d.geom.overlay
Class ScribbleOverlay
- public class ScribbleOverlay
- extends org.j3d.geom.overlay.MouseOverlay
- An overlay allows the user to scribble on the screen, over the top of the 3D display.
- Version:
- $Revision: 1.6 $
- Author:
- Justin Couch
lineList
private java.util.ArrayList lineList
- A mapping of the color value to lines drawn in that color. Each element of the list is an instance of LineDetails. The line is in drawing order so that we may have a set of LineDetails with the same color more than once in the list.
currentColor
private java.awt.Color currentColor
- The current colour that we are drawing new lines in
currentLine
private org.j3d.geom.overlay.LineData currentLine
- The current line that we are adding points to
currentLineDetails
private org.j3d.geom.overlay.LineDetails currentLineDetails
- The current set of lines that match the current color
worldPoint
private java.awt.Point worldPoint
- Working variable to prevent garbage generation
ScribbleOverlay
public ScribbleOverlay(javax.media.j3d.Canvas3D canvas,
java.awt.Dimension size)
- Create a new scribble overlay that bases its size on the canvas it overlays. The default line colour is white. If the bounds are null, the overlay works for the entire canvas.
- Parameters:
canvas
- The canvas that is scribbled on
size
- The size of the overlay in pixels
ScribbleOverlay
public ScribbleOverlay(javax.media.j3d.Canvas3D canvas,
java.awt.Dimension size,
java.awt.Color lineColor)
- Create a new scribble overlay using the given line color. If the bounds are null, the overlay works for the entire canvas.
- Parameters:
canvas
- The canvas that is scribbled on
size
- The size of the overlay in pixels
lineColor
- The colour to start the first line with
initialize
public void initialize()
- Initialise the overlay to build mouse input support
paint
public void paint(java.awt.Graphics2D g)
- Paint the overlay with the given graphics context. All lines are drawn in their alloted colors.
- Parameters:
g
- The graphics context to paint with
mousePressed
public void mousePressed(java.awt.event.MouseEvent evt)
- Process a mouse press event to start a new line in the given color.
- Parameters:
evt
- The event that caused this method to be called
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent evt)
- Process a mouse release event.
- Parameters:
evt
- The event that caused this method to be called
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent evt)
- Process a mouse drag event. Adds another segment to the line.
- Parameters:
evt
- The event that caused this method to be called
setLineColor
public void setLineColor(java.awt.Color color)
- Set the line colour that any new lines will be drawn in. All currently held lines will maintain their alloted color. A value of null will throw an exception.
- Parameters:
color
- The new color to use
clear
public void clear()
- Clear the current screen. This removes all of the current lines from the active drawn list.