JSci.swing
Class JPointer

java.lang.Object
  extended byJSci.swing.JPointer

public class JPointer
extends java.lang.Object

A pointer for the JRoundDial or JArcDial


Field Summary
protected  javax.swing.event.EventListenerList listenerList
          The list of ChangeListeners for this model.
static int POINTER_SIMPLE_QUADRANGLE
           
static int POINTER_SIMPLE_STOP
           
static int POINTER_SIMPLE_TRIANGLE
           
static int SLIDER_SIMPLE_QUADRANGLE
           
static int SLIDER_SIMPLE_STOP
           
static int SLIDER_SIMPLE_TRIANGLE
           
 
Constructor Summary
JPointer(int t)
           
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to the model's listener list.
 boolean contains(java.awt.Point p)
          check if a point is inside the pointer image
protected  void fireStateChanged()
          Run each ChangeListeners stateChanged() method.
 javax.swing.event.ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added to this JPointer with addChangeListener().
 java.util.EventListener[] getListeners(java.lang.Class listenerType)
          Return an array of all the listeners of the given type that were added to this model.
 double getValue()
          get the value of the pointer
protected  void paintOnDial(java.awt.Graphics2D g, double radius, double one, double zero, double x0, double y0)
          draw the pointer on the dial.
protected  void paintOnSlider(java.awt.Graphics2D g, double start, double end, double width, double heigth)
          draw the slider on the dial.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from the model's listener list.
 void setAdjusting(boolean b)
          If you are adjusting the value, the changes should not be fired (dispatched) to the listeners.
 void setColor(java.awt.Color col)
          set the color of the pointer
 void setEnabled(boolean b)
          enable or disable the motion by the mouse
 void setValue(double v)
          set the value of the pointer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected javax.swing.event.EventListenerList listenerList
The list of ChangeListeners for this model. Subclasses may store their own listeners here.


POINTER_SIMPLE_TRIANGLE

public static final int POINTER_SIMPLE_TRIANGLE
See Also:
Constant Field Values

POINTER_SIMPLE_QUADRANGLE

public static final int POINTER_SIMPLE_QUADRANGLE
See Also:
Constant Field Values

POINTER_SIMPLE_STOP

public static final int POINTER_SIMPLE_STOP
See Also:
Constant Field Values

SLIDER_SIMPLE_TRIANGLE

public static final int SLIDER_SIMPLE_TRIANGLE
See Also:
Constant Field Values

SLIDER_SIMPLE_QUADRANGLE

public static final int SLIDER_SIMPLE_QUADRANGLE
See Also:
Constant Field Values

SLIDER_SIMPLE_STOP

public static final int SLIDER_SIMPLE_STOP
See Also:
Constant Field Values
Constructor Detail

JPointer

public JPointer(int t)
Parameters:
t - the type of the pointer
Method Detail

getValue

public double getValue()
get the value of the pointer

Returns:
the value

setValue

public void setValue(double v)
set the value of the pointer

Parameters:
v - the value

setEnabled

public void setEnabled(boolean b)
enable or disable the motion by the mouse

Parameters:
b - should the mouse move the pointer?

setAdjusting

public void setAdjusting(boolean b)
If you are adjusting the value, the changes should not be fired (dispatched) to the listeners. Typically, when the movement is done by the mouse, only releasing the button actually fires the change. If appropriate, this fires the state changed.

Parameters:
b - are the following movements adjustments?

setColor

public void setColor(java.awt.Color col)
set the color of the pointer

Parameters:
col - the desired color

contains

public boolean contains(java.awt.Point p)
check if a point is inside the pointer image

Parameters:
p - the point
Returns:
is p inside the pointer image

paintOnDial

protected void paintOnDial(java.awt.Graphics2D g,
                           double radius,
                           double one,
                           double zero,
                           double x0,
                           double y0)
draw the pointer on the dial. Called by the dials.

Parameters:
g - the graphics on which to draw
radius - the radius of the dial
one - the value of one turn
zero - the angle (clockwise, starting from the top) at which the zero should be placed
x0 - horizontal coordinate of the center of the dial
y0 - vertical coordinate of the center of the dial

paintOnSlider

protected void paintOnSlider(java.awt.Graphics2D g,
                             double start,
                             double end,
                             double width,
                             double heigth)
draw the slider on the dial. Called by the dials.

Parameters:
g - the graphics on which to draw
start - the value on the bottom of the JSliderPlus
end - the value on the top of the JSliderPlus
width - the width of the component
heigth - the heigth of the component

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the model's listener list. The ChangeListeners must be notified when the models value changes.

Parameters:
l - the ChangeListener to add
See Also:
removeChangeListener(javax.swing.event.ChangeListener)

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the model's listener list.

Parameters:
l - the ChangeListener to remove
See Also:
addChangeListener(javax.swing.event.ChangeListener)

getChangeListeners

public javax.swing.event.ChangeListener[] getChangeListeners()
Returns an array of all the ChangeListeners added to this JPointer with addChangeListener().

Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

protected void fireStateChanged()
Run each ChangeListeners stateChanged() method.

See Also:
setValue(double), EventListenerList

getListeners

public java.util.EventListener[] getListeners(java.lang.Class listenerType)
Return an array of all the listeners of the given type that were added to this model. For example to find all of the ChangeListeners added to this model:
 myJPointer.getListeners(ChangeListener.class);
 

Parameters:
listenerType - the type of listeners to return, e.g. ChangeListener.class
Returns:
all of the objects receiving listenerType notifications from this model