j3d.org Code

org.j3d.renderer.java3d.overlay
Class ScribbleOverlay

java.lang.Object
  extended byorg.j3d.renderer.java3d.overlay.OverlayBase
      extended byorg.j3d.renderer.java3d.overlay.InteractiveOverlayBase
          extended byorg.j3d.renderer.java3d.overlay.MouseOverlay
              extended byorg.j3d.renderer.java3d.overlay.ScribbleOverlay
All Implemented Interfaces:
java.awt.event.ComponentListener, java.util.EventListener, InteractiveOverlay, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, Overlay, ScreenComponent, UpdatableEntity

public class ScribbleOverlay
extends MouseOverlay

An overlay allows the user to scribble on the screen, over the top of the 3D display.

Version:
$Revision: 1.1 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.renderer.java3d.overlay.OverlayBase
activeBuffer, backgroundColor, backgroundMode, bottomInset, canvas, componentSize, consoleBG, consoleTG, DEFAULT_INSET, DIRTY_ACTIVE_BUFFER, DIRTY_POSITION, DIRTY_SIZE, DIRTY_VISIBLE, fieldOfView, fixedSize, leftInset, overlayBounds, overlayTexGrp, rightInset, subOverlay, topInset
 
Fields inherited from interface org.j3d.renderer.java3d.overlay.Overlay
BACKGROUND_COPY, BACKGROUND_NONE
 
Constructor Summary
ScribbleOverlay(javax.media.j3d.Canvas3D canvas, java.awt.Dimension size)
          Create a new scribble overlay that bases its size on the canvas it overlays.
ScribbleOverlay(javax.media.j3d.Canvas3D canvas, java.awt.Dimension size, java.awt.Color lineColor)
          Create a new scribble overlay using the given line color.
 
Method Summary
 void clear()
          Clear the current screen.
 void initialize()
          Initialise the overlay to build mouse input support
 void mouseDragged(java.awt.event.MouseEvent evt)
          Process a mouse drag event.
 void mousePressed(java.awt.event.MouseEvent evt)
          Process a mouse press event to start a new line in the given color.
 void mouseReleased(java.awt.event.MouseEvent evt)
          Process a mouse release event.
 void paint(java.awt.Graphics2D g)
          Paint the overlay with the given graphics context.
 void setLineColor(java.awt.Color color)
          Set the line colour that any new lines will be drawn in.
 
Methods inherited from class org.j3d.renderer.java3d.overlay.MouseOverlay
mouseClicked, mouseEntered, mouseExited, mouseMoved
 
Methods inherited from class org.j3d.renderer.java3d.overlay.InteractiveOverlayBase
addKeyListener, addMouseListener, addMouseMotionListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, requestFocus, setInputRequester
 
Methods inherited from class org.j3d.renderer.java3d.overlay.OverlayBase
componentHidden, componentMoved, componentResized, componentShown, contains, dirty, getBackgroundImage, getBounds, getGraphics, getRoot, getUpdateManager, isAntialiased, isVisible, repaint, setActiveBuffer, setAntialiased, setBackgroundColor, setBackgroundImage, setBackgroundMode, setComponentDetails, setInsets, setInsets, setLocation, setSize, setUpdateManager, setVisible, update, updateBuffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.renderer.java3d.overlay.Overlay
contains, getBounds, getRoot, getUpdateManager, isAntialiased, isVisible, setAntialiased, setComponentDetails, setLocation, setSize, setUpdateManager, setVisible
 
Methods inherited from interface org.j3d.renderer.java3d.overlay.UpdatableEntity
update
 

Constructor Detail

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
Method Detail

initialize

public void initialize()
Initialise the overlay to build mouse input support

Specified by:
initialize in interface Overlay
Overrides:
initialize in class OverlayBase

paint

public void paint(java.awt.Graphics2D g)
Paint the overlay with the given graphics context. All lines are drawn in their alloted colors.

Overrides:
paint in class OverlayBase
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.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class MouseOverlay
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.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class MouseOverlay
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.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class MouseOverlay
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.


j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org