|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Canvas
gpl.fredy.datadrill.Gauge
public class Gauge
"Gauge" is a simple control, used to display a range of values using a "meter" format.
Accessible Attributes:
MinimumValue Low end of the scale MaximumValue High end of the scale CurrentValue Current setting (where the Pointer points) CriticalThreshold Percentage of MaxValue at which we start drawing using the Critical color WarningThreshold Percentage of MaxValue at which we start drawing using the Warning color Legend What we're measuring (e.g., Speed) Units What units we're using (e.g., MPH)
Attributes not yet publically accessible (next version, perhaps):
MinimumAngle Angle at which Minimum Value will be drawn MaximumAngle Angle at which Maximum Value will be drawn Margin Distance between the Scale and the Component's bounds() rect Separation Distance between Gauge subobjects (e.g, between Pointer and Scale) CriticalColor Color used to draw the Critical Section of the Scale(e.g., Color.red) WarningColor Color used to draw the Warning Section of the Scale NormalColor Color used to draw the Normal Section of the Scale InternalColor Color used to draw the interior of the Scale PenRadius Used to determine thickness of Pointer and Scale Draw3D Should the background be drawn as a raised rectangle? TickSize How long (in pixels) is a BigTick? BigTick Interval starting at Minimum at which BigTicks will be drawn LittleTick Interval starting at Minimum at which LittleTicks will be drawn
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Canvas |
---|
java.awt.Canvas.AccessibleAWTCanvas |
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 |
---|
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 | |
---|---|
Gauge()
Constructs a Gauge object. |
|
Gauge(int min,
int max)
Constructs a Gauge object with specified Min and Max. |
|
Gauge(int min,
int max,
float warn,
float crit,
java.lang.String newLegend,
java.lang.String newUnits)
Constructs a Gauge with the specified Min, Max, Legend, and Units values. |
Method Summary | |
---|---|
void |
drawBackground(java.awt.Graphics g)
If Draw3d is set, draw the background as a filled 3D rect in the current Background Color. |
void |
drawPointer(java.awt.Graphics g)
drawPointer draws the Pivot and the Pointer |
void |
drawScale(java.awt.Graphics g)
drawScale draws the ScaleArc itself, and the tick-marks |
void |
drawStrings(java.awt.Graphics g)
drawStrings draws the Legend, Units, Min, and Max. |
void |
drawTick(java.awt.Graphics g,
int where,
int offset)
drawTick draws one tick-mark from center of scale-arc _INWARDS_ |
double |
getCriticalThreshold()
|
int |
getCurrent()
|
int |
getMaximum()
|
int |
getMinimum()
|
java.awt.Color |
getValColor(int val)
getValColor returns the color associated with the region into which the value falls. |
double |
getWarningThreshold()
|
protected void |
init()
init() sets Guage's attributes to a "sane" set of initial values. |
java.awt.Point |
mapValToPoint(int val)
mapValToPoint returns a Point on the Scale for the specified value |
java.awt.Point |
mapValToPoint(int val,
int radius)
mapValToPoint returns a Point "radius" units from the Pivit for the specified value |
java.awt.Dimension |
minimumSize()
A Gauge wants to be no smaller than (100,100) |
boolean |
mouseDown(java.awt.Event evt,
int x,
int y)
|
boolean |
mouseDrag(java.awt.Event evt,
int x,
int y)
|
boolean |
mouseUp(java.awt.Event evt,
int x,
int y)
|
void |
paint(java.awt.Graphics g)
paint() paints in this order: Background (includes Internal area) Scale (includes TickMarks) Strings (Legend, Units, Min, Max) Pointer (inlcudes Pivot) |
java.awt.Dimension |
preferredSize()
Gauges prefer their minSize. |
void |
repaint()
|
void |
repaint(int x,
int y,
int w,
int h)
|
void |
repaint(long when)
|
void |
repaint(long when,
int x,
int y,
int w,
int h)
|
void |
reshape(int x,
int y,
int w,
int h)
|
void |
setCriticalThreshold(float newCritPcnt)
Change the Gauge's Critical Threshold. |
void |
setCurrent(int newCurr)
Change the Gauge's Current Value (the value the pointer points at) |
void |
setLegend(java.lang.String newLegend)
Change the Gauge's Legend (what this Gauge is measuring; e.g., Speed or Swap Rate) |
void |
setMaximum(int max)
Change the Gauge's Maximum Value |
void |
setMinimum(int min)
Change the Gauge's Minimum Value |
void |
setSize(java.awt.Dimension dim)
|
void |
setSize(int w,
int h)
When resized, recalculate where everything lives. |
void |
setUnits(java.lang.String newUnits)
Change the Gauge's Units (what Value is measured in; e.g., KPH or PPM) |
void |
setWarningThreshold(float newWarnPcnt)
Change the Gauge's Warning Threshold. |
java.lang.String |
toString()
|
void |
update(java.awt.Graphics g)
At update(); draw into an off-screen image and put up the whole image. |
Methods inherited from class java.awt.Canvas |
---|
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
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, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, 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, mouseEnter, mouseExit, mouseMove, move, nextFocus, paintAll, paramString, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Gauge()
init()
public Gauge(int min, int max)
min
- Minimum Gauge valuemax
- Maximum Gauge Valueinit()
public Gauge(int min, int max, float warn, float crit, java.lang.String newLegend, java.lang.String newUnits)
min
- Minimum Valuemax
- Maximum Valuewarn
- Percentage of Max of start of Warning areacrit
- Percentage of Max of start of Critical areanewLegend
- Gauge LegendnewUnits
- Gauge UnitsMethod Detail |
---|
protected void init()
Defaults are:
Minimum = 0 Maximum = 200 Current = Minimum Legend = "Velocity" Units = "KPH" WarningThresh = 0.7 CriticalThresh = 0.9 CriticalColor = Color.red WarningColor = Color.yellow InternalColor = Color.black NormalColor = getForeground() ForegroundColor = Color.white BackgroundColor = Color.gray Font = "Courier", BOLD, 18
public void setLegend(java.lang.String newLegend)
newLegend
- Legend's new valuepublic void setUnits(java.lang.String newUnits)
newUnits
- Units's new valuepublic void setMinimum(int min)
min
- New Minimumpublic int getMinimum()
public void setMaximum(int max)
max
- New Maximumpublic int getMaximum()
public void setCurrent(int newCurr)
newCurr
- New Currentpublic int getCurrent()
public void setWarningThreshold(float newWarnPcnt)
newWarnPercnt
- New Warning Thresholdpublic double getWarningThreshold()
public void setCriticalThreshold(float newCritPcnt)
newCritPercnt
- New Critical Thresholdpublic double getCriticalThreshold()
public void update(java.awt.Graphics g)
update
in class java.awt.Canvas
public void drawBackground(java.awt.Graphics g)
public void drawTick(java.awt.Graphics g, int where, int offset)
where
- Value at which to draw the tick-markoffset
- How long to make the tick-markpublic void drawScale(java.awt.Graphics g)
public void drawStrings(java.awt.Graphics g)
public java.awt.Color getValColor(int val)
val
- value of interestpublic java.awt.Point mapValToPoint(int val)
public java.awt.Point mapValToPoint(int val, int radius)
public void drawPointer(java.awt.Graphics g)
public void setSize(int w, int h)
Rules for resizing a Gauge:
setSize
in class java.awt.Component
public void setSize(java.awt.Dimension dim)
setSize
in class java.awt.Component
Component.resize(int,int)
public void reshape(int x, int y, int w, int h)
reshape
in class java.awt.Component
Component.resize(int,int)
public java.awt.Dimension minimumSize()
minimumSize
in class java.awt.Component
public java.awt.Dimension preferredSize()
preferredSize
in class java.awt.Component
minimumSize()
public void paint(java.awt.Graphics g)
paint
in class java.awt.Canvas
public void repaint()
repaint
in class java.awt.Component
public void repaint(long when)
repaint
in class java.awt.Component
public void repaint(int x, int y, int w, int h)
repaint
in class java.awt.Component
public void repaint(long when, int x, int y, int w, int h)
repaint
in class java.awt.Component
public boolean mouseDown(java.awt.Event evt, int x, int y)
mouseDown
in class java.awt.Component
public boolean mouseDrag(java.awt.Event evt, int x, int y)
mouseDrag
in class java.awt.Component
public boolean mouseUp(java.awt.Event evt, int x, int y)
mouseUp
in class java.awt.Component
public java.lang.String toString()
toString
in class java.awt.Component
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |