Methods Summary |
---|
public void | addDialListener(DialListener listener)
if ( dialListeners == null )
dialListeners = new Vector();
dialListeners.addElement( listener );
|
private void | draw3DCircle(java.awt.Graphics g, int x, int y, int radius, boolean raised)
g.setColor( raised ? Color.white : Color.black );
g.drawArc( x, y, radius*2, radius*2, 45, 180);
g.setColor( raised ? Color.black : Color.white);
g.drawArc( x, y, radius*2, radius*2, 225, 180);
|
private void | fireEvent()
if ( dialListeners == null )
return;
DialEvent event = new DialEvent(this, value);
for (Enumeration e = dialListeners.elements(); e.hasMoreElements(); )
((DialListener)e.nextElement()).dialAdjusted( event );
|
public int | getMaximum() return maxValue;
|
public int | getMinimum() return minValue;
|
public java.awt.Dimension | getPreferredSize()
return new Dimension( 100, 100 );
|
public int | getValue() return value;
|
public void | paint(java.awt.Graphics g)
int tick = 10;
radius = getSize().width/2 - tick;
g.drawLine(radius*2+tick/2, radius, radius*2+tick, radius); // the tick
draw3DCircle( g, 0, 0, radius, true );
draw3DCircle( g, 1, 1, radius-1, true );
int knobRadius = radius/7;
double th = value*(2*Math.PI)/(maxValue-minValue);
int x = (int)(Math.cos(th)*(radius-knobRadius*3)),
y = (int)(Math.sin(th)*(radius-knobRadius*3));
draw3DCircle( g, x+radius-knobRadius, y+radius-knobRadius, knobRadius, false );
|
public void | processEvent(java.awt.AWTEvent e)
if ( e.getID() == MouseEvent.MOUSE_DRAGGED ) {
int y=((MouseEvent)e).getY();
int x=((MouseEvent)e).getX();
double th = Math.atan( (1.0*y-radius)/(x-radius) );
int value = ( (int)(th/(2*Math.PI) * (maxValue-minValue)) );
if ( x < radius )
setValue( value + maxValue/2 );
else if ( y < radius )
setValue( value + maxValue );
else
setValue( value );
fireEvent();
}
super.processEvent( e );
|
public void | removeDialListener(DialListener listener)
if ( dialListeners != null )
dialListeners.removeElement( listener );
|
public void | setMaximum(int maxValue) this.maxValue = maxValue;
|
public void | setMinimum(int minValue) this.minValue = this.minValue;
|
public void | setValue(int value)
this.value = value;
repaint();
|