|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.cosylab.gui.components.Gauger
public class Gauger
Gauger is a visual component that displays a value on a scale between minimum and maximum. Shape and visual layout of the component will change to best fit into the available space. Behaviour of the scale can be adjusted to fixed (lower and upper bound cannot change), constant span (scale will always span fixed ammount) or rescaling (lower and upper bound will adjust to accomodate current value). Supported scales are linear and logarithmic.
For accurate readouts, the currently set value is also displayed in custom formatted label.
Gauger is aimed to provide fastest possible response to value changes.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
CONSTANT_SPAN
Deprecated. replaced by ShiftValuePolicy |
static int |
FIXED_SCALE
Deprecated. replaced by TrimValuePolicy |
protected Needle |
needle
|
static int |
STRETCH_SCALE
Deprecated. replaced by RescalingValuePolicy |
protected RangedValueController |
userRangedValue
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
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 | |
---|---|
Gauger()
Creates a new gauger and sets the default parameters. |
Method Summary | |
---|---|
java.lang.String |
formatNumber(double x)
Formats the input value to a specific print format. |
java.awt.Color |
getAlarmColor()
Returns the color which indicates the alarm status. |
AbstractCustomizerPanel |
getCustomizer()
Returns the Customizer intance for this displayer. |
java.lang.String |
getFormat()
Returns format of value label. |
double |
getHighAlarmLimit()
Returns the high alarm limit. |
double |
getHighWarningLimit()
Returns the high warning limit. |
double |
getLowAlarmLimit()
Returns the low alarm limit. |
double |
getLowWarningLimit()
Returns the low warning limit. |
double |
getMaximum()
Returns the current maximum value of the scale. |
double |
getMinimum()
Returns the current minimum value of the scale. |
protected Needle |
getNeedle()
Returns needle renderer. |
java.awt.Color |
getNeedleColor()
Returns the color of the needle. |
java.awt.Color |
getOutOfBoundsColor()
Returns the color which indicates out of bounds status. |
PopupManager |
getPopupManager()
Returns popup manager for adding popup actions. |
RangedValueController |
getRangedValue()
Returns RangedValueController . |
java.awt.Color |
getScaleColor()
Returns color of scale background. |
int |
getScaleMode()
Deprecated. use getValuePolicy() |
State |
getState()
Will be called by the StateKeeper in the process of the
application state saving. |
Tick[] |
getTicks()
Returns the information about the scale ticks. |
java.awt.Font |
getTickTextFont()
Returns font used to display tick labels. |
protected java.lang.String |
getTitle()
Returns the title of this widget. |
protected int |
getTitleMaximumFontSize()
Returns the maximum allowed font size of the title. |
protected int |
getTitleMinimumFontSize()
Returns the minimum allowed font size of the title. |
ScaleTransform |
getTransform()
Returns current transform used to render the scale. |
java.lang.String |
getUnits()
Returns units string of value label. |
double |
getValue()
Returns the current value of the scale. |
protected ValueLabel |
getValueLabel()
Gets the instance of the value label used to display current value. |
java.awt.Font |
getValueLabelFont()
Returns font for value label. |
RangedValuePolicy |
getValuePolicy()
Returns the RangedValuePolicy. |
java.awt.Color |
getWarningColor()
Returns the color which indicates warning status. |
boolean |
isLinearScale()
Returns whether the scale is linear. |
boolean |
isLogarithmicScale()
Returns whether the scale is logarithmic. |
boolean |
isPopupEnabled()
Return true if the popup menu is enabled or false otherwise. |
protected boolean |
isResizable()
|
protected boolean |
isTitleVisible()
Returns true is title is visible. |
boolean |
isUnitsVisible()
Returns unitsVisible of value label. |
static void |
main(java.lang.String[] args)
Simple test method for gauger. |
int |
measureTick(double position,
java.lang.String text)
Returns size of tick label when renderer. |
protected void |
paintComponent(java.awt.Graphics g)
Paints the component. |
void |
setAlarmColor(java.awt.Color alarmColor)
Sets the color which indicates the alarm status. |
void |
setFormat(java.lang.String format)
Sets format string of value label. |
void |
setHighAlarmLimit(double v)
Sets the high alarm limit. |
void |
setHighWarningLimit(double v)
Sets the high warning limit. |
void |
setLinearScale()
Sets scale to linear. |
void |
setLogarithmicScale()
Sets scale to logarithmic. |
void |
setLowAlarmLimit(double v)
Sets the low alarm limit. |
void |
setLowWarningLimit(double v)
Sets the low warning limit. |
void |
setMaximum(double newMax)
Sets the upper limit for the display. |
void |
setMinimum(double newMin)
Sets the lower limit for the display. |
void |
setNeedleColor(java.awt.Color newNeedleColor)
Sets the color of the needle. |
void |
setOutOfBoundsColor(java.awt.Color outOfBoundsColor)
Sets the color which indicates out of bounds status. |
void |
setPopupEnabled(boolean enabled)
Enables or disables the popup menu. |
protected void |
setResizable(boolean resizable)
|
void |
setScaleColor(java.awt.Color newScaleColor)
Sets color of scale background. |
void |
setScaleMode(int mode)
Deprecated. use setValuePolicy(RangedValuePolicy) |
void |
setState(State state)
Will be called by the StateKeepr when it reads
State object which belongs to this component. |
void |
setTickTextFont(java.awt.Font tickText)
Sets the font used to display tick labels. |
protected void |
setTitle(java.lang.String title)
Sets the title of this widget. |
protected void |
setTitleMaximumFontSize(int titleMaximumFontSize)
Sets the maximum allowed font size of the title. |
protected void |
setTitleMinimumFontSize(int titleMinimumFontSize)
Sets the minimum allowed font size of the title. |
protected void |
setTitleVisible(boolean titleVisible)
Sets the title visible/invisible. |
void |
setUnits(java.lang.String units)
Sets units of value label. |
void |
setUnitsVisible(boolean b)
Sets units visible of value label. |
void |
setValue(double newValue)
Sets the new value to be displayed on this scale. |
void |
setValue(double newMin,
double newMax,
double newVal)
Sets the value and limits for the displayer. |
void |
setValueLabelFont(java.awt.Font value)
Sets font for value label. |
void |
setValueLabelPosition(java.awt.Point p)
Sets position of value label. |
void |
setValuePolicy(RangedValuePolicy policy)
Sets the RangedValuePolicy. |
void |
setWarningColor(java.awt.Color warningColor)
Sets the color which indicates the warning status. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, 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 |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
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, 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, hide, 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, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int FIXED_SCALE
TrimValuePolicy
setScaleMode(int)
,
Constant Field Valuespublic static final int CONSTANT_SPAN
ShiftValuePolicy
setScaleMode(int)
,
Constant Field Valuespublic static final int STRETCH_SCALE
RescalingValuePolicy
setScaleMode(int)
,
Constant Field Valuesprotected RangedValueController userRangedValue
protected Needle needle
Constructor Detail |
---|
public Gauger()
Method Detail |
---|
public void setScaleMode(int mode)
setValuePolicy(RangedValuePolicy)
FIXED_SCALE will fix the limits to any value regardless of the actual value displayed by needle. If value displayed is outside limits, it will be limited to either bound.
CONSTANT_SPAN will automatically move the scale based on needle movement. If needle moves outside current limits, they will move in the same direction, but span (maximum-minimum) of the scale will remain unchanged.
STRETCH_SCALE will change only one limit at the time whenever needle moves outside current limits. Scale will not shrink back when needle is within old bounds.
mode
- New mode to set.public void setValuePolicy(RangedValuePolicy policy)
policy
- setScaleMode(int)
public RangedValuePolicy getValuePolicy()
getScaleMode()
public int getScaleMode()
getValuePolicy()
Gauger.FIXED_SCALE
, Gauger.CONSTANT_SPAN
or
Gauger.STRETCH_SCALE
.
setScaleMode(int)
public double getMaximum()
public double getMinimum()
protected Needle getNeedle()
public RangedValueController getRangedValue()
RangedValueController
. This method can be used
to gain access to more advanced aspects of RangedValueController
Instance returned is not replacable.
RangedValue
public double getValue()
protected ValueLabel getValueLabel()
public void setFormat(java.lang.String format)
format
- C-Style format of value label.public java.lang.String getFormat()
public void setUnits(java.lang.String units)
units
- String to be appended to value label. Can be null.public java.lang.String getUnits()
public void setUnitsVisible(boolean b)
b
- whether units should be displayed.public boolean isUnitsVisible()
public void setValue(double newValue)
newValue
- doublepublic Tick[] getTicks()
public ScaleTransform getTransform()
public void setMinimum(double newMin)
newMin
- public void setMaximum(double newMax)
newMax
- public void setValue(double newMin, double newMax, double newVal)
newMin
- New minimum.newMax
- New maximum.newVal
- New value.public void setValueLabelPosition(java.awt.Point p)
p
- Center point of value label.protected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- Context to paint to.public void setLogarithmicScale()
public void setLinearScale()
public boolean isLogarithmicScale()
public boolean isLinearScale()
public int measureTick(double position, java.lang.String text)
measureTick
in interface TickParameters
position
- relative position of the tick on 0..1.text
- label to display, may be empty string or null.
com.cosylab.gui.components.range.TickCallback#measureTick(double,
String)
public PopupManager getPopupManager()
getPopupManager
in interface PopupManageable
PopupManageable.getPopupManager()
public boolean isPopupEnabled()
public void setPopupEnabled(boolean enabled)
enabled
- true if enable or false if disabledspublic AbstractCustomizerPanel getCustomizer()
public State getState()
StateOriginator
StateKeeper
in the process of the
application state saving. The component which implements this interface
will tipycally use StateFactory
to create a
State
object and fill it with needed values. For example a
component can use this snippet.
public State getState() {
State s = StateFactory.createState();
s.putDouble("Min", getMinimum());
s.putDouble("Max", getMaximum());
s.putString("Format", getFormat());
s.putString("Units", getUnits());
return s;
}
getState
in interface StateOriginator
public void setState(State state)
StateOriginator
StateKeepr
when it reads
State
object which belongs to this component.
setState
in interface StateOriginator
state
- object previously created by this componentpublic void setTickTextFont(java.awt.Font tickText)
tickText
- Font for tick labels.public java.awt.Font getTickTextFont()
public java.awt.Color getScaleColor()
public void setScaleColor(java.awt.Color newScaleColor)
newScaleColor
- Color of scale background.public java.awt.Color getNeedleColor()
public void setNeedleColor(java.awt.Color newNeedleColor)
newNeedleColor
- New color of needle.public java.awt.Font getValueLabelFont()
public void setValueLabelFont(java.awt.Font value)
value
- New font for value label.public void setLowWarningLimit(double v)
v
- new low warning limitpublic double getLowWarningLimit()
public void setLowAlarmLimit(double v)
v
- new low alarm limit.public double getLowAlarmLimit()
public void setHighWarningLimit(double v)
v
- new high warning limitpublic double getHighWarningLimit()
public void setHighAlarmLimit(double v)
v
- new high alarm limitpublic double getHighAlarmLimit()
public java.awt.Color getAlarmColor()
public void setAlarmColor(java.awt.Color alarmColor)
alarmColor
- new alarm colorpublic java.awt.Color getOutOfBoundsColor()
public void setOutOfBoundsColor(java.awt.Color outOfBoundsColor)
outOfBoundsColor
- new out of bounds colorpublic java.awt.Color getWarningColor()
public void setWarningColor(java.awt.Color warningColor)
warningColor
- new warning colorprotected java.lang.String getTitle()
protected void setTitle(java.lang.String title)
title
- protected boolean isTitleVisible()
protected void setTitleVisible(boolean titleVisible)
titleVisible
- protected boolean isResizable()
protected void setResizable(boolean resizable)
protected int getTitleMaximumFontSize()
protected void setTitleMaximumFontSize(int titleMaximumFontSize)
titleMaximumFontSize
- new maximum font sizeprotected int getTitleMinimumFontSize()
protected void setTitleMinimumFontSize(int titleMinimumFontSize)
titleMinimumFontSize
- new minimum font sizepublic java.lang.String formatNumber(double x)
TickParameters
formatNumber
in interface TickParameters
x
- double to be formatted
public static void main(java.lang.String[] args)
args
- String[]
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |