com.swfm.mica.widgets
Class MiGauge

java.lang.Object
  extended bycom.swfm.mica.core.MiPart
      extended bycom.swfm.mica.core.MiContainer
          extended bycom.swfm.mica.layouts.MiLayout
              extended bycom.swfm.mica.core.MiVisibleContainer
                  extended bycom.swfm.mica.widgets.MiWidget
                      extended bycom.swfm.mica.widgets.MiAdjuster
                          extended bycom.swfm.mica.widgets.MiSlider
                              extended bycom.swfm.mica.widgets.MiGauge
All Implemented Interfaces:
MiiActionTypes, MiiAdjuster, MiiAttributeTypes, MiiCopyable, MiiDragAndDropParticipant, MiiDraggable, MiiEventTypes, MiiLayout, MiiNames, MiiPropertyTypes, MiiTypes

public class MiGauge
extends MiSlider

A MiGauge is a vertical or horizontally oriented thermometer-like widget that is usually used to display a percentage of some quantity.

The 'fluid' filling the gauge can either be solid or seperate 'LED' like rectangles. The spacing between LEDs is controlled by the alley spacing (see MiLayout#setAlleySpacing);

The size of the LED rectangles when there are multiple LEDs is determined by the length of this gauge, the number of LEDs, and the alley spacing.

Version:
%I% %G%
Author:
Michael L. Davis

Field Summary
static java.lang.String Mi_GAUGE_PROTOTYPE_CLASS_NAME
           
                     
Constructor Summary
MiGauge()
          Constructs a new MiGauge.
MiGauge(int orientation)
          Constructs a new MiGauge with the given orientation.
 
Method Summary
static MiWidget create()
          Creates a new widget from the prototype.
 int drag(MiEvent event)
          Handles the user 'dragging' on the gauge when changing the value.
 MiPart getLabel()
          Gets the label.
 MiPart getLED()
          Gets the MiPart that is used to draw the 'LEDs' (i.e.
 int getNumberOfLEDs()
          Gets the number of 'LEDs' along the length of this gauge.
 boolean getPartialLEDsAreOK()
          Gets whether partial LEDs can be drawn or just full size LEDs.
static MiWidget getPrototype()
          Gets the prototype that is to be copied when the #create method is called and to have it's attributes and handlers copied whenever any widget of this type is created.
 boolean isPercentage()
          Gets whether the label, if any, displays the percentage or current values.
 void setIsPercentage(boolean flag)
          Sets whether the label, if any, displays the percentage or current values.
 void setLabel(MiPart label)
          Sets the label.
 void setLED(MiPart part)
          Sets the MiPart that is used to draw the 'LEDs' (i.e.
 void setNormalizedValue(double value)
          Sets the value of this MiGauge.
 void setNumberOfLEDs(int number)
          Sets the number of 'LEDs' along the length of this gauge.
 void setPartialLEDsAreOK(boolean flag)
          Sets whether partial LEDs can be drawn or just full size LEDs.
static void setPrototype(MiGauge p)
          Sets the prototype that is to be copied when the #create method is called and to have it's attributes and handlers copied whenever any widget of this type is created.
 
Methods inherited from class com.swfm.mica.widgets.MiSlider
adjustValueFromVector, calcMinimumSize, calcPreferredSize, getNormalizedLengthOfThumb, getOrientation, getSlotWidth, getThumb, getThumbWidth, getValue, layoutParts, moveOneChunkTowardsLocation, refreshLookAndFeel, setNormalizedLengthOfThumb, setNormalizedPositionOfThumb, setOrientation, setPrototype, setSlotWidth, setThumb, setThumbWidth, setValue, setValueFromLocation
 
Methods inherited from class com.swfm.mica.widgets.MiAdjuster
decreaseOneChunk, decreaseOnePage, decreaseOneUnit, decreaseToMinimum, drop, getChunkIncrement, getCurrentValue, getGenerateAbsolutePositionsOnly, getMaximumValue, getMinimumValue, getNormalizedValue, getObserver, getOrientationOfGeneratedMessages, getPageIncrement, getUnitIncrement, increaseOneChunk, increaseOnePage, increaseOneUnit, increaseToMaximum, moveOneChunkTowardsValue, pickup, setChunkIncrement, setCurrentValue, setGenerateAbsolutePositionsOnly, setMaximumValue, setMinimumValue, setObserver, setOrientationOfGeneratedMessages, setPageIncrement, setScrollable, setUnitIncrement
 
Methods inherited from class com.swfm.mica.widgets.MiWidget
copy, doExport, getContents, getEnterKeyFocusAttributes, getEnterKeyFocusBackgroundColor, getEnterKeyFocusBorderLook, getEnterKeyFocusColor, getEnterKeyFocusStatusHelp, getInSensitiveAttributes, getInSensitiveBackgroundColor, getInSensitiveBorderLook, getInSensitiveColor, getInSensitiveStatusHelp, getKeyboardFocusAttributes, getKeyboardFocusBackgroundColor, getKeyboardFocusBorderLook, getKeyboardFocusColor, getKeyboardFocusStatusHelp, getMouseFocusAttributes, getMouseFocusBackgroundColor, getMouseFocusBorderLook, getMouseFocusColor, getMouseFocusStatusHelp, getNormalAttributes, getNormalBackgroundColor, getNormalBorderLook, getNormalColor, getNormalStatusHelp, getPropertyDescriptions, getPropertyValue, getRadioStateEnforcer, getSelectedAttributes, getSelectedBackgroundColor, getSelectedBorderLook, getSelectedColor, getSelectedStatusHelp, getToolkit, getWidgetAttributes, isAutoAttributesEnabled, isDesignTime, select, setAttributes, setAutoAttributesEnabled, setContents, setCurrentBackgroundColor, setCurrentColor, setEnterKeyFocus, setEnterKeyFocusAttributes, setEnterKeyFocusBackgroundColor, setEnterKeyFocusBorderLook, setEnterKeyFocusColor, setEnterKeyFocusStatusHelpMessage, setInSensitiveAttributes, setInSensitiveBackgroundColor, setInSensitiveBorderLook, setInSensitiveColor, setInSensitiveStatusHelpMessage, setKeyboardFocus, setKeyboardFocusAttributes, setKeyboardFocusBackgroundColor, setKeyboardFocusBorderLook, setKeyboardFocusColor, setKeyboardFocusStatusHelpMessage, setMouseFocus, setMouseFocusAttributes, setMouseFocusBackgroundColor, setMouseFocusBorderLook, setMouseFocusColor, setMouseFocusStatusHelpMessage, setNormalAttributes, setNormalBackgroundColor, setNormalBorderLook, setNormalColor, setNormalStatusHelpMessage, setPropertyValue, setPropertyValues, setRadioStateEnforcer, setSelectedAttributes, setSelectedBackgroundColor, setSelectedBorderLook, setSelectedColor, setSelectedStatusHelpMessage, setSensitive, setWidgetAttributes, setWidgetAttributes
 
Methods inherited from class com.swfm.mica.core.MiVisibleContainer
getContainerLayoutSpec, getDisplaysFocusBorder, getInnerBounds, getIntersectionWithLine, getOKToDrawOutsideInnerBounds, getShadowShape, getShape, getTotalMargins, getVisibleContainerAutomaticLayoutEnabled, invalidateArea, isShapeShrinkToFitEnabled, pick, setContainerLayoutSpec, setDisplaysFocusBorder, setMargins, setOKToDrawOutsideInnerBounds, setShape, setShape, setShapeShrinkToFitEnabled, setVisibleContainerAutomaticLayoutEnabled
 
Methods inherited from class com.swfm.mica.layouts.MiLayout
determinesPreferredAndMinimumSizes, getAlleyHSpacing, getAlleyMargins, getAlleyVSpacing, getCellMargins, getCellMargins, getElementHJustification, getElementHSizing, getElementVJustification, getElementVSizing, getInsetMargins, getInsetMargins, getLastElementJustification, getTarget, getUniqueElementIndex, getUniqueElementSizing, isEnabled, isIndependantOfTargetPosition, isScalingOfPartsWhenBoundsChangesHandledDuringLayout, makeCopy, setAlleyHSpacing, setAlleySpacing, setAlleyVSpacing, setCellMargins, setCellMargins, setElementHJustification, setElementHSizing, setElementJustification, setElementSizing, setElementVJustification, setElementVSizing, setEnabled, setInsetMargins, setInsetMargins, setLastElementJustification, setScalingOfPartsWhenBoundsChangesHandledDuringLayout, setTarget, setUniqueElementIndex, setUniqueElementSizing, toString
 
Methods inherited from class com.swfm.mica.core.MiContainer
appendPart, containsPart, deepCopy, doImport, getIndexOfPart, getKeepConnectionsBelowNodes, getNumberOfParts, getPart, getPart, getSupportedImportFormats, hasEventHandlers, hasValidCachedEventHandlerInfo, insertPart, invalidateCachedEventHandlerInfo, isContainerOf, isContainerOf, isContainerOfWithAttachments, pickDeepListContents, pickObject, removeAllParts, removePart, removePart, setKeepConnectionsBelowNodes, setPart, translate
 
Methods inherited from class com.swfm.mica.core.MiPart
_reCalcBounds, _render, _replaceBounds, _setContainer, _setDrawManager, _setValidatingLayout, appendActionHandler, appendActionHandler, appendActionHandler, appendActionHandler, appendActionHandler, appendAttachment, appendAttachment, appendCommandHandler, appendCommandHandler, appendCommandHandler, appendConnection, appendContainer, appendEventHandler, appendItem, appendPoint, appendPoint, applyCustomLookAndFeel, containsItem, containsOpaqueRectangles, copy, deleteAllConnections, deleteAllParts, deleteSelf, dispatchAction, dispatchAction, dispatchAction, dispatchActionRequest, dispatchActionRequest, dispatchActionRequest, dispatchEvent, draw, drawNow, drawNow, flip, flip, freeAccessLock, get1DShapeStrokeBackgroundColor, get1DShapeStrokesFilled, getAccessLock, getActionHandler, getActionsGenerated, getActionsLocallyGenerated, getActionsRequestedFromParts, getAfterRenderer, getAlphaCompositeRenderMode, getAnnotationPointManager, getAssociatedParts, getAttachment, getAttachment, getAttachmentMargins, getAttachments, getAttributeLockMask, getAttributePublicMask, getAttributes, getAttributeValue, getBackgroundColor, getBackgroundImage, getBackgroundRenderer, getBackgroundTile, getBalloonHelp, getBeforeRenderer, getBlackColor, getBorderHiliteColor, getBorderHiliteWidth, getBorderLook, getBorderRenderer, getBounds, getBounds, getCenter, getCenter, getCenterOfRotation, getCenterX, getCenterY, getColor, getConnection, getConnectionPointManager, getContainer, getContainerRequestedActions, getContainingEditor, getContainingWindow, getContextCursor, getContextMenu, getContextMenu, getControlPointManager, getCustomLookAndFeels, getCustomLookAndFeels, getDarkColor, getDeepConnection, getDeepConnection, getDeepConnections, getDeeplyInvalidateAreas, getDefaultAttributes, getDialogHelp, getDoubleBuffer, getDragAndDropBehavior, getDrawBounds, getDrawManager, getEventHandler, getEventHandler, getEventHandlerWithClass, getEventHandlingDisabledByContainer, getEventHandlingEnabled, getFlipped, getFont, getFontHorizontalJustification, getFontPointSize, getFontVerticalJustification, getHasBorderHilite, getHasShadow, getHeight, getID, getIncomingInvalidLayoutNotificationsEnabled, getIndexOfItem, getInnerBounds, getInvalidAreaNotificationsEnabled, getInvalidLayoutNotificationsEnabled, getItem, getItem, getKeyFocusTraversalGroup, getLayout, getLayoutManipulator, getLightColor, getLineEndSize, getLineEndsRenderer, getLineEndsSizeFnOfLineWidth, getLineEndStyle, getLineStartSize, getLineStartStyle, getLineStyle, getLineWidth, getLocallyRequestedEventTypes, getManipulator, getMargins, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumPickAreaSize, getMinimumSize, getMinimumWidth, getName, getNumberOfActionHandlers, getNumberOfAttachments, getNumberOfConnections, getNumberOfContainers, getNumberOfDeepConnections, getNumberOfEventHandlers, getNumberOfItems, getNumberOfPoints, getNumberOfResources, getOutgoingInvalidLayoutNotificationsEnabled, getPoint, getPoint, getPointEntryAngle, getPointExitAngle, getPointX, getPointY, getPreferredSize, getPrototypeManipulator, getRelativeLocation, getResource, getResourceName, getRootWindow, getRotation, getSelectionGraphics, getShadowColor, getShadowDirection, getShadowLength, getShadowRenderer, getShadowStyle, getSize, getSnapPointManager, getStatusHelp, getSupportedExportFormats, getThisOrPartHasInvalidArea, getToolHintHelp, getTotalNumberOfPartsCreated, getTransform, getTransparency, getValidatingLayout, getVisibilityAnimator, getWhiteColor, getWidth, getWriteMode, getXmax, getXmin, getXorColor, getYmax, getYmin, hasAttachment, hasAttribute, hasEnterKeyFocus, hasEventHandler, hasFixedAspectRatio, hasFixedHeight, hasFixedWidth, hasKeyboardFocus, hasMouseFocus, hasOverriddenMinimumSize, hasOverriddenPreferredSize, hasProperty, hasTotallyInvalidArea, hasValidLayout, insertActionHandler, insertActionHandler, insertActionHandler, insertConnection, insertContainer, insertEventHandler, insertItem, insertPoint, insertPoint, invalidateArea, invalidateLayout, isAcceptingEnterKeyFocus, isAcceptingKeyboardFocus, isAcceptingMouseFocus, isAcceptingTabKeys, isActionDispatchingEnabled, isConnectable, isConnectedTo, isCopyable, isCopyableAsPartOfCopyable, isDeletable, isDoubleBuffered, isDragAndDropSource, isDragAndDropTarget, isFilled, isFontBold, isFontItalic, isFontUnderlined, isHidden, isMovable, isOpaqueRectangle, isPickable, isPickableWhenTransparent, isPrintable, isSavable, isSelectable, isSelected, isSensitive, isShowing, isSnappable, isUngroupable, isValidConnectionDestination, isValidConnectionSource, isVisible, makeImageFromArea, makeLayoutManipulator, makeManipulator, optimizedInvalidateArea, optimizedInvalidateDrawBoundsArea, overrideAttributes, overrideEventHandlingDisabledByContainer, packLayout, pickDeepList, preRenderToDoubleBuffer, refreshBounds, refreshLookAndFeel, removeActionHandler, removeActionHandler, removeActionHandlers, removeAllActionHandlers, removeAllAttachments, removeAllConnections, removeAllEventHandlers, removeAllItems, removeAllManipulators, removeAttachment, removeAttachment, removeCommandHandler, removeCommandHandler, removeConnection, removeConnection, removeContainer, removeContainer, removeEventHandler, removeFromAllContainers, removeItem, removeItem, removePoint, removeResource, removeSelf, replaceDrawBounds, replaceSelf, requestEnterKeyFocus, requestKeyboardFocus, rotate, rotate, rotateTo, scale, scale, scale, set1DShapeStrokeBackgroundColor, set1DShapeStrokesFilled, setAcceptingEnterKeyFocus, setAcceptingKeyboardFocus, setAcceptingMouseFocus, setAcceptingTabKeys, setActionDispatchingEnabled, setAfterRenderer, setAlphaCompositeRenderMode, setAnnotationPointManager, setAttachmentDrawnAfter, setAttachmentMargins, setAttachmentsVisibility, setAttributeLockMask, setAttributePublicMask, setAttributeValue, setAttributeValue, setAttributeValue, setAttributeValue, setAttributeValue, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundRenderer, setBackgroundTile, setBalloonHelp, setBalloonHelpMessage, setBeforeRenderer, setBlackColor, setBorderHiliteColor, setBorderHiliteWidth, setBorderLook, setBorderRenderer, setBounds, setBounds, setCenter, setCenter, setCenterX, setCenterY, setColor, setColor, setConnectable, setConnectionPointManager, setContextCursor, setContextMenu, setControlPointManager, setCopyable, setCopyableAsPartOfCopyable, setCustomLookAndFeels, setCustomLookAndFeels, setDarkColor, setDeeplyInvalidateAreas, setDefaultAttributes, setDeletable, setDialogHelp, setDialogHelpMessage, setDoubleBuffer, setDoubleBuffered, setDragAndDropBehavior, setEventHandlingEnabled, setFilled, setFixedAspectRatio, setFixedHeight, setFixedWidth, setFont, setFontBold, setFontHorizontalJustification, setFontItalic, setFontPointSize, setFontUnderlined, setFontVerticalJustification, setHasBorderHilite, setHasShadow, setHeight, setHidden, setIncomingInvalidLayoutNotificationsEnabled, setInvalidAreaNotificationsEnabled, setInvalidLayoutNotificationsEnabled, setIsDragAndDropSource, setIsDragAndDropTarget, setIsOpaqueRectangle, setItem, setKeyFocusTraversalGroup, setLayout, setLightColor, setLineEndSize, setLineEndSizeFnOfLineWidth, setLineEndsRenderer, setLineEndStyle, setLineStartSize, setLineStartStyle, setLineStyle, setLineWidth, setMaximumHeight, setMaximumWidth, setMinimumHeight, setMinimumPickAreaSize, setMinimumSize, setMinimumWidth, setMovable, setName, setNumberOfPoints, setOutgoingInvalidLayoutNotificationsEnabled, setPickable, setPickableWhenTransparent, setPoint, setPoint, setPreferredSize, setPrintable, setPrototypeManipulator, setResource, setSavable, setSelectable, setSelectionGraphics, setShadowColor, setShadowDirection, setShadowLength, setShadowRenderer, setShadowStyle, setSize, setSize, setSnappable, setSnapPointManager, setStatusHelp, setStatusHelpMessage, setSupportedImportFormats, setToolHintHelp, setToolHintMessage, setTransparency, setTransparency, setUngroupable, setVisibilityAnimator, setVisible, setWhiteColor, setWidth, setWriteMode, setXmax, setXmin, setXorColor, setYmax, setYmin, supportsImportOfSpecificInstance, translate, translate, translatePoint, validateLayout, validatePropertyValue, waitUntilRedrawn
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.swfm.mica.layouts.MiiLayout
getMinimumSize, getPreferredSize, invalidateLayout
 

Field Detail

Mi_GAUGE_PROTOTYPE_CLASS_NAME

public static final java.lang.String Mi_GAUGE_PROTOTYPE_CLASS_NAME
See Also:
Constant Field Values
Constructor Detail

MiGauge

public MiGauge()
Constructs a new MiGauge.


MiGauge

public MiGauge(int orientation)
Constructs a new MiGauge with the given orientation.

Parameters:
orientation - Mi_HORIZONTAL or Mi_VERTICAL
Method Detail

create

public static MiWidget create()
Creates a new widget from the prototype. This is the factory pattern implementation for this widget. If the prototype is null, then the default contructor is used.

Returns:
the new widget
See Also:
setPrototype(com.swfm.mica.widgets.MiGauge)

setLabel

public void setLabel(MiPart label)
Sets the label. If the label is textual or a widget it's value is always automatically updated to display the current percentage value ,if isPercentage() is true, else the current value.

See Also:
setIsPercentage(boolean), MiAdjuster.setMinimumValue(double), MiAdjuster.setMaximumValue(double)

getLabel

public MiPart getLabel()
Gets the label.

Returns:
the label.

setNumberOfLEDs

public void setNumberOfLEDs(int number)
Sets the number of 'LEDs' along the length of this gauge. The default is equal to 1, which is a solid bar.

Parameters:
number - the number of LEDS (must be >= 1).
Throws:
java.lang.IllegalArgumentException - if number < 1

getNumberOfLEDs

public int getNumberOfLEDs()
Gets the number of 'LEDs' along the length of this gauge. The default is equal to 1, which is a solid bar.

Returns:
the number of LEDS

setIsPercentage

public void setIsPercentage(boolean flag)
Sets whether the label, if any, displays the percentage or current values.

Parameters:
flag - true if to display the percentage

isPercentage

public boolean isPercentage()
Gets whether the label, if any, displays the percentage or current values.

Returns:
true if to display the percentage

getLED

public MiPart getLED()
Gets the MiPart that is used to draw the 'LEDs' (i.e. the mercury filler).

Returns:
the LED

setLED

public void setLED(MiPart part)
Sets the MiPart that is used to draw the 'LEDs' (i.e. mercury filler).

Parameters:
part - the LED

setPartialLEDsAreOK

public void setPartialLEDsAreOK(boolean flag)
Sets whether partial LEDs can be drawn or just full size LEDs. This is for the case where there are multiple LEDs and the current normalized value is not a multiple of 1/numberOfLEDs. This is not used unless the number of LEDs is greater than 1.

Parameters:
flag - true if partially drawn LEDs are OK

getPartialLEDsAreOK

public boolean getPartialLEDsAreOK()
Gets whether partial LEDs can be drawn or just full size LEDs.

Returns:
true if partially drawn LEDs are OK

setPrototype

public static void setPrototype(MiGauge p)
Sets the prototype that is to be copied when the #create method is called and to have it's attributes and handlers copied whenever any widget of this type is created.

Parameters:
p - the new prototype
See Also:
getPrototype(), create(), MiPart.copy()

getPrototype

public static MiWidget getPrototype()
Gets the prototype that is to be copied when the #create method is called and to have it's attributes and handlers copied whenever any widget of this type is created.

Returns:
the prototype
See Also:
setPrototype(com.swfm.mica.widgets.MiGauge), create(), MiPart.copy()

setNormalizedValue

public void setNormalizedValue(double value)
Sets the value of this MiGauge. Note: assure the value specified is not NaN or the LED will render incorrectly.

Specified by:
setNormalizedValue in interface MiiAdjuster
Overrides:
setNormalizedValue in class MiSlider
Parameters:
value - the value (between 0.0 and 1.0)
See Also:
MiAdjuster.setCurrentValue(double)

drag

public int drag(MiEvent event)
Handles the user 'dragging' on the gauge when changing the value.

Specified by:
drag in interface MiiDraggable
Overrides:
drag in class MiSlider
Parameters:
event - the drag event
Returns:
consumes the event