net.java.swingfx.rubberband.rubberbands
Class AbstractRubberBand

java.lang.Object
  extended by javax.swing.event.MouseInputAdapter
      extended by net.java.swingfx.rubberband.rubberbands.AbstractRubberBand
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, MouseInputListener, RubberBand
Direct Known Subclasses:
RectangularRubberBand

public abstract class AbstractRubberBand
extends MouseInputAdapter
implements RubberBand

An abstract implementation of RubberBand which handles the basic drawing/setup of the rubber band.

Since:
1.0 $Revision: 1.1 $
Author:
rwickesser

Field Summary
protected  RubberBandCanvas canvas
          the canvas where the rubber band will be drawn onto
protected  Rectangle rubberband
          maintains the size and location of the rubber band
 
Constructor Summary
AbstractRubberBand(RubberBandCanvas canvas)
          Creates a new RubberBand and sets the canvas
 
Method Summary
 void addMouseListeners()
          Enforces that the mouse listeners are added to the canvas
 Rectangle getBounds()
          Returns an integer Rectangle which contains the size and location of this rubber band
protected  boolean isHideOnRelease()
          Returns whether or not the rubber band should disappear after the mouse is released
 void mouseDragged(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void setCanvas(RubberBandCanvas canvas)
          Sets the canvas which the rubber band will be drawn onto
protected  void setHideOnRelease(boolean hideOnRelease)
          Sets whether the rubber band should disappear when the mouse is released or not
 
Methods inherited from class javax.swing.event.MouseInputAdapter
mouseClicked, mouseEntered, mouseExited, mouseMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.java.swingfx.rubberband.rubberbands.RubberBand
draw, startRubberBand, stopRubberBand, update, updateRubberBand
 

Field Detail

canvas

protected RubberBandCanvas canvas
the canvas where the rubber band will be drawn onto


rubberband

protected Rectangle rubberband
maintains the size and location of the rubber band

Constructor Detail

AbstractRubberBand

public AbstractRubberBand(RubberBandCanvas canvas)
Creates a new RubberBand and sets the canvas

Parameters:
canvas - the RubberBandCanvas on which the rubber band will be drawn
See Also:
setCanvas(RubberBandCanvas)
Method Detail

addMouseListeners

public void addMouseListeners()
Description copied from interface: RubberBand
Enforces that the mouse listeners are added to the canvas

Specified by:
addMouseListeners in interface RubberBand

getBounds

public Rectangle getBounds()
Description copied from interface: RubberBand
Returns an integer Rectangle which contains the size and location of this rubber band

Specified by:
getBounds in interface RubberBand
Returns:
an integer Rectangle which contains the size and location of this rubber band

setCanvas

public void setCanvas(RubberBandCanvas canvas)
Description copied from interface: RubberBand
Sets the canvas which the rubber band will be drawn onto

Specified by:
setCanvas in interface RubberBand
Parameters:
canvas - the canvas which the rubber band will be drawn onto

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class MouseInputAdapter

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseInputAdapter

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseInputAdapter

setHideOnRelease

protected void setHideOnRelease(boolean hideOnRelease)
Sets whether the rubber band should disappear when the mouse is released or not

Parameters:
hideOnRelease - if true the rubber band will disappear when the mouse is released, if false the rubber band will remain visible until a new rubber band is created

isHideOnRelease

protected boolean isHideOnRelease()
Returns whether or not the rubber band should disappear after the mouse is released

Returns:
true if the rubber band should disappear when the mouse is released, else if false the rubber band should remain visible until a new rubber band is created