public class Joggle extends JComponent
JoggleModel
.
The following image shows a joggle UI with HORIZONTAL
orientation.
Any joggle has a certain number of grooves. The visible groove count relies
on the apex angle. The apex angle must be a value between pi/9 (20
degrees) and pi (180 degrees). For example, if the apex angle is pi
then approximately the half of all grooves will be visible. You can set the
number of grooves with the method setGrooveCount(int)
and the apex angle with setApexAngle(double)
.
The rotation angle describes the current position of the joggle. You can
get it by the method getRotationAngle()
but you can also explicitly
set it by setRotationAngle(double)
. Note that the rotation angles of
0 (0 degrees), 2*pi (360 degrees),
4*pi (720 degrees), 6*pi (1080 degrees), etc., corresponds to
the same position. You can get these position by the method
getPositionAngle()
.
If you are not using the constructor expecting the arguments for grooveCount, initApexAngle and initRotationAngle, the following default values will be set:
You can "jog" (drag) this Joggle
BACKWARD
,
FORWARD
or to both directions
.
FORWARD
means that you can drag this Joggle
to the right (HORIZONTAL
orientation) or to the bottom
(VERTICAL
orientation). BACKWARD
means
that you can drag it to the left (HORIZONTAL
orientation) or to
the top (VERTICAL
orientation).
The default jogDirection is BIDIRECTIONAL
, that means
dragging this Joggle
into both directions is possible. You
can specify the jogDirection with setJogDirection(int)
or with a
certain constructor.
If you want the joggle to move constantly and permanently, you only have to "jog" it. This meens, you have to release the mouse button while you are still dragging. The speed of the joggle's rotation depends on the speed you drag it in the moment of mouse releasing.
There are three colors to set for a joggle.
highlight angle
.
The default highlight angle is 0 - in this
case the light color is the color on the very top of the joggle. The light
color can be set by setJoggleLightColor(Color)
.setJoggleShadowColor(Color)
.setMarkedGrooveColor(Color)
.updateUI()
will call
UIManager.getColor
("ScrollBar.thumbShadow")
and
UIManager.getColor("ScrollBar.thumbHighlight")
.red
.
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
BACKWARD
Direction a
Joggle is able to be dragged. |
static int |
BIDIRECTIONAL
Direction a
Joggle is able to be dragged. |
static int |
FORWARD
Direction a
Joggle is able to be dragged. |
static int |
HORIZONTAL
For horizontal orientation of this
Joggle . |
static int |
TIMER_DELAY |
static int |
VERTICAL
For vertical orientation of this
Joggle . |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
Joggle()
Creates a new
Joggle with a new DefaultJoggleModel . |
Joggle(int orientation)
Creates a new
Joggle with a new DefaultJoggleModel
and the specified orientation. |
Joggle(JoggleModel joggleModel)
Creates a new
Joggle with the specified JoggleModel . |
Joggle(JoggleModel joggleModel,
int orientation)
Creates a new
Joggle with the specified JoggleModel
and orientation. |
Joggle(JoggleModel joggleModel,
int orientation,
int grooveCount,
double initApexAngle,
int initJogDirection)
Creates a new
Joggle with the specified JoggleModel
and orientation. |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
Adds a listener to the list that is notified each time a change to the
model occurs.
|
void |
doLayout() |
protected void |
fireStateChanged()
Sends a ChangeEvent, whose source is this Joggle, to each listener which was
added to this Joggle.
|
boolean |
getAntialiasing()
Returns true if the Java2D rendering mode is set to antialias this
Joggle , false otherwise. |
double |
getApexAngle()
Returns the current apex angle describing the visible part of this
Joggle . |
int |
getGrooveCount()
Returns the current count of grooves of this
Joggle . |
double |
getHighlightAngle()
Returns the angle (in radian) to the lightpoint shining on this
Joggle . |
int |
getJogDirection()
Returns the currently set direction this
Joggle is able to be dragged. |
Color |
getJoggleLightColor()
Returns the current light color of this
Joggle . |
Color |
getJoggleShadowColor()
Returns the current shadow color of this
Joggle . |
Color |
getMarkedGrooveColor()
Returns the color of the marked groove.
|
JoggleModel |
getModel()
Returns this
Joggle's data model. |
double |
getPositionAngle()
Returns the angle (in radian) in relation to the current rotation angle
but ignoring the count of rotations.
|
double |
getRotationAngle()
Returns the current rotation angle (in radian).
|
SharableTimer |
getTimer()
Returns the SharableTimer this Joggle is using.
|
double |
getValue()
Returns the value this
Joggle is currently representing. |
void |
paintComponent(Graphics g) |
void |
removeChangeListener(ChangeListener l)
Removes a ChangeListener from this Joggle.
|
void |
setAntialiasing(boolean b)
Specifies the Java2D rendering mode.
|
void |
setApexAngle(double d)
Sets a new apex angle (in radian) for this
Joggle . |
void |
setGrooveCount(int i)
Sets the total (visible and invisible) count of grooves of this
Joggle . |
void |
setHighlightAngle(double d)
Sets the angle (in radian) to the lightpoint shining on this
Joggle . |
void |
setJogDirection(int direction)
Sets the direction this
Joggle should be able to be dragged. |
void |
setJoggleLightColor(Color c)
Sets this
Joggle's color at the highlight angle. |
void |
setJoggleShadowColor(Color c)
Sets this
Joggle's shadow color. |
void |
setMarkedGrooveColor(Color c)
Sets the color of this
Joggle's marked groove. |
void |
setModel(JoggleModel model)
Sets a new data model for this
Joggle . |
void |
setRotationAngle(double d)
Sets the current rotation angle (in radian) of this
Joggle . |
void |
setTimer(SharableTimer timer)
Sets a new SharableTimer for this Joggle.
|
void |
setValue(double value)
Sets a new (transmissioned) value to the model.
|
void |
updateUI()
Sets shadow and light color to new LookAndFeel colors of a scrollbar only
if they were not set manually by the user.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int BACKWARD
Joggle
is able to be dragged.public static final int BIDIRECTIONAL
Joggle
is able to be dragged.public static final int FORWARD
Joggle
is able to be dragged.public static final int HORIZONTAL
Joggle
.public static final int TIMER_DELAY
public static final int VERTICAL
Joggle
.public Joggle()
Joggle
with a new DefaultJoggleModel
.
Other initial values are:HORIZONTAL
BIDIRECTIONAL
public Joggle(int orientation)
Joggle
with a new DefaultJoggleModel
and the specified orientation. The orientation can be HORIZONTAL
or
VERTICAL
. Other initial values are:BIDIRECTIONAL
orientation
- HORIZONTAL
or VERTICAL
.public Joggle(JoggleModel joggleModel)
Joggle
with the specified JoggleModel
.
Other initial values are:HORIZONTAL
joggleModel.
getValue()
/
joggleModel.
getTransmissionRatio()
BIDIRECTIONAL
joggleModel
- A data model for this Joggle
.public Joggle(JoggleModel joggleModel, int orientation)
Joggle
with the specified JoggleModel
and orientation. The orientation can be HORIZONTAL
or
VERTICAL
. Other initial values are:joggleModel.
getValue()
/
joggleModel.
getTransmissionRatio()
BIDIRECTIONAL
joggleModel
- A data model for this Joggle
.orientation
- HORIZONTAL
or VERTICAL
.public Joggle(JoggleModel joggleModel, int orientation, int grooveCount, double initApexAngle, int initJogDirection)
Joggle
with the specified JoggleModel
and orientation. The orientation can be HORIZONTAL
or
VERTICAL
. Further more, init values for grooveCount, apexAngle
and jogDirection have to be specified. See class
documentation for details.
The current position of this
Joggle
- its rotationAngle - will be calculated by
joggleModel.
getValue()
/
joggleModel.
getTransmissionRatio()
.
joggleModel
- A data model for this Joggle
.orientation
- HORIZONTAL
or VERTICAL
.grooveCount
- total number of grooves this Joggle
has.initApexAngle
- the angle describing the visible part of this
Joggle
.initJogDirection
- FORWARD
, BACKWARD
or
BIDIRECTIONAL
.IllegalArgumentException
- if the initApexAngle is no value
between pi and pi/9.IllegalArgumentException
- if the orientation is not
HORIZONTAL
or VERTICAL
.IllegalArgumentException
- if the jogDirection is not
FORWARD
, BACKWARD
or
BIDIRECTIONAL
.public void addChangeListener(ChangeListener l)
l
- the ChangeListener to addsetValue(double value)
protected void fireStateChanged()
addChangeListener(ChangeListener l)
public boolean getAntialiasing()
Joggle
, false otherwise.Joggle
, false otherwise.public double getApexAngle()
Joggle
.Joggle
.setApexAngle(double)
public int getGrooveCount()
Joggle
.
Note that the really visible groove count depends on the apex angle
and is the half of the set groove count at the maximum apex angle of
pi (180 degrees).getApexAngle()
public double getHighlightAngle()
Joggle
.Joggle
.public int getJogDirection()
Joggle
is able to be dragged.FORWARD
, BACKWARD
or BIDIRECTIONAL
public Color getJoggleLightColor()
Joggle
.
The light color is the color at the joggle's highlight angle.Joggle
.getHighlightAngle()
public Color getJoggleShadowColor()
Joggle
.
The shadow color is visible at 90 degrees or more from the highlight angle.Joggle
.getJoggleLightColor()
,
getHighlightAngle()
public Color getMarkedGrooveColor()
Joggle
.public JoggleModel getModel()
Joggle's
data model.Joggle's
data model.JoggleModel
public double getPositionAngle()
public double getRotationAngle()
Joggle
depending on the count of
rotations.
If you want the angle in relation to one rotation, you have to
call getPositionAngle()
.getPositionAngle()
public SharableTimer getTimer()
public double getValue()
Joggle
is currently representing.
Note: The returned value comes from the model and is almost never equal to the rotationAngle. It rather depends on the rotationAngle by multiplying it with a transmissionRatio. This ratio is defined in the model, too.
Joggle
is currently representing.JoggleModel.getValue()
,
JoggleModel.getTransmissionRatio()
public void paintComponent(Graphics g)
paintComponent
in class JComponent
public void removeChangeListener(ChangeListener l)
l
- the listener to remove.public void setAntialiasing(boolean b)
Joggle
will be drawn antialiased, otherwise not.
The default is true.b
- public void setApexAngle(double d)
Joggle
.
The angle describes the visible part of this Joggle
.d
- the new apex angle.IllegalArgumentException
- if d>pi or d<pi/9public void setGrooveCount(int i)
Joggle
.
Note that the really visible number of grooves depends on the
currently set apex angle.i
- the new count of grooves.setApexAngle(double)
public void setHighlightAngle(double d)
Joggle
.
If d=0 then the lightpoint stands in the zenith to this
Joggle
.
Other values around zero move
the lightpoint to the left and right (HORIZONTAL
orientation)
or top and bottom (VERTICAL
orientation). d should be a radian
value between -pi and pi.d
- a radian value describing the highlight angle.public void setJogDirection(int direction)
Joggle
should be able to be dragged.direction
- FORWARD
, BACKWARD
or
BIDIRECTIONAL
public void setJoggleLightColor(Color c)
Joggle's
color at the highlight angle.c
- the new light color.getHighlightAngle()
public void setJoggleShadowColor(Color c)
Joggle's
shadow color.c
- the new shadow color.public void setMarkedGrooveColor(Color c)
Joggle's
marked groove.c
- the new color for the marked groove.public void setModel(JoggleModel model)
Joggle
.model
- the new data model.JoggleModel
public void setRotationAngle(double d)
Joggle
.
The rotation angle describes its absolut position depending on the count
of rotations the Joggle
has already complete.d
- the new rotation angle.public void setTimer(SharableTimer timer)
timer
- the new timer.public void setValue(double value)
value
- the new value this Joggle
has to represent.getValue()
,
JoggleModel.setValue(double)
,
JoggleModel.getTransmissionRatio()
public void updateUI()
SwingUtilities.updateComponentTreeUI(Component)
was called.updateUI
in class JComponent