com.softsynth.tools.view
Class RotaryKnob

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by com.softsynth.tools.view.RotaryKnob
All Implemented Interfaces:
ValueController, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class RotaryKnob
extends java.awt.Canvas
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, ValueController

RotaryKnob like on a synthesizer. You control this knob by clicking on it and dragging up or down. If you move the mouse to the left of the knob then you will have coarse control. If you move the mouse to the right of the knob then you will have fine control.

You can set the taper of the knob to LINEAR or EXPONENTIAL. EXPONENTIAL taper is useful for controlling frequency or amplitude which is perceived exponentially.

Clients of RotaryKnob should implement ValueListener.

Version:
14.2
Author:
(C) 2000 Phil Burk, SoftSynth.com, All Rights Reserved
See Also:
ValueListener, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
static int EXPONENTIAL
           
static int LINEAR
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RotaryKnob(double val, double min, double max)
          Constructor with initial value, min value, max value.
 
Method Summary
 void addValueListener(ValueListener listener)
          Add a listener to receive value change events.
 double getDoubleValue()
          This odd method is required for ValueController interface.
 double getMaximum()
          Get maximum value.
 double getMinimum()
          Get minimum value.
 int getTaper()
           
 double getUnitIncrement()
           
 double getValue()
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
           
 void removeValueListener(ValueListener listener)
           
 void setMaximum(double maximum)
          Set maximum for value.
 void setMinimum(double minimum)
          Set minimum for value.
 void setTaper(int taper)
          Set taper to LINEAR or EXPONENTIAL.
 void setUnitIncrement(double v)
          Set nominal increment value as a fraction from 0.0 to 1.0.
 void setValue(double v)
           
 void setValues(double val, double min, double max)
          Convenience routine to set all three at once.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LINEAR

public static final int LINEAR
See Also:
Constant Field Values

EXPONENTIAL

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

RotaryKnob

public RotaryKnob(double val,
                  double min,
                  double max)
Constructor with initial value, min value, max value.

Method Detail

addValueListener

public void addValueListener(ValueListener listener)
Add a listener to receive value change events.

Specified by:
addValueListener in interface ValueController

removeValueListener

public void removeValueListener(ValueListener listener)
Specified by:
removeValueListener in interface ValueController

setTaper

public void setTaper(int taper)
Set taper to LINEAR or EXPONENTIAL. When using EXPONENTIAL taper, do not use a minimum of 0.0 because log(0.0) is undefined.


getTaper

public int getTaper()

setValue

public void setValue(double v)
Specified by:
setValue in interface ValueController

getValue

public double getValue()
Returns:
current value

getDoubleValue

public double getDoubleValue()
This odd method is required for ValueController interface. This is because some controllers have an underlying integer value.

Specified by:
getDoubleValue in interface ValueController
Returns:
current value

setValues

public void setValues(double val,
                      double min,
                      double max)
Convenience routine to set all three at once.


setMaximum

public void setMaximum(double maximum)
Set maximum for value.

Specified by:
setMaximum in interface ValueController

getMaximum

public double getMaximum()
Get maximum value.

Specified by:
getMaximum in interface ValueController

setMinimum

public void setMinimum(double minimum)
Set minimum for value.

Specified by:
setMinimum in interface ValueController

getMinimum

public double getMinimum()
Get minimum value.

Specified by:
getMinimum in interface ValueController

setUnitIncrement

public void setUnitIncrement(double v)
Set nominal increment value as a fraction from 0.0 to 1.0. Higher values cause knob to spin faster.


getUnitIncrement

public double getUnitIncrement()

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Canvas

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener