SmartFrog 3.10.000

org.smartfrog.examples.dynamicwebserver.gui.graphpanel
Class GraphPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.smartfrog.examples.dynamicwebserver.gui.graphpanel.GraphPanel
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
Direct Known Subclasses:
ThresholdPanel

public class GraphPanel
extends javax.swing.JPanel
implements java.awt.event.ComponentListener, java.awt.event.KeyListener

A panel to display a graph. It uses two arrays, one for x axis, a second one for the y axis.

See Also:
Serialized Form

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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 boolean adjustable
           
 java.awt.Color axisColor
           
 float axisPencilWidth
           
 float axisWidth
           
 java.awt.Color backgroundColor
           
protected  java.awt.Image backgroundImage
           
protected  java.awt.Image bottomBar
           
protected  boolean dirty
           
 boolean drawGrid
           
 java.awt.Color graphColor
           
 float graphPencilWidth
           
 float graphWidth
           
 java.awt.Color gridColor
           
 int gridStepX
           
 int gridStepY
           
 boolean keysAllowed
           
protected  java.awt.Image middleBar
           
 int sampleNumber
           
 java.awt.Color textColor
           
protected  java.awt.Image topBar
           
static int xAxis
           
protected  int xAxisPixelLength
           
protected  int xBarOffset
           
 int[] xData
           
 int xMax
           
 int xMin
           
 int xOffset
           
 int xOffsetDefault
           
 int xStep
           
static int yAxis
           
protected  int yAxisPixelLength
           
protected  int yBarSize
           
 int[] yData
           
 int yMax
           
 int yMin
           
 int yOffset
           
 int yOffsetDefault
           
 
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
GraphPanel()
          Default constructor
GraphPanel(java.awt.Dimension size)
          The constructor to be used : Sets the size, the offsets, the pencils, adds the listeners
 
Method Summary
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
          Called when the component has been resized
 void componentShown(java.awt.event.ComponentEvent e)
           
 java.awt.Image createImage(java.lang.String SFURL)
           
protected  void drawAxis(java.awt.Graphics2D g2d)
          Draw the two main axis
protected  void drawData(java.awt.Graphics2D g2d)
          Draw the two data arrays.
protected  void drawGrid(java.awt.Graphics2D g2d)
          Draw a 2d grid in the background.
 void drawPanel(java.awt.Graphics2D g2d)
          Overwrite this method to draw the panel differently
 void initImages()
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void paintComponent(java.awt.Graphics g)
           
protected  int scaleX(int xData)
          Returns a scaled int between 0 and xAxisPixelLength If xData greater than xMax or xData less than xMin the return values are 0 and xAxisPixelLength respectively
protected  int scaleY(int yData)
          Returns a scaled int between 0 and yAxisPixelLength If yData greater than yMax or yData less than yMin the return values are 0 and yAxisPixelLength respectively
 void setAdjustable(boolean adjustable)
          Set the graph's adjustability.
 void setAxis(int axis, int min, int max, int step)
          Set data for one axis : max & min value represented the step is the distance between two samples.
 void setCompleteGraphPanel(CompleteGraphPanel cgp)
          Set the CompleteGraphPanel surrounding this one.
 void setDataDimensions(int xMin, int xMax, int xStep, int yMin, int yMax)
          Set the axis for both dimensions
 void setGraphWidth(float graphWidth)
           
 void setGridDimensions(int gridStepX, int gridStepY)
          Set grid dimensions
 void setOffset(int xOffset, int yOffset)
          Set border offsets.
 void setPencilColour(java.lang.String pencilColour)
          Set the pencil's colour
 void setPencils()
          Set the pencils size
 void setSampleNumber(int samples)
          Set the size of the data arrays
 void toggleDisplay()
          Toggle a different display for the graph.
 void toggleDisplay(boolean filled)
          Toggle a different display for the graph.
 void toggleGrid()
          Toggle the grid on the graph.
 void update(java.awt.Graphics g)
           
 
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, 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, 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
 
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

xAxis

public static final int xAxis
See Also:
Constant Field Values

yAxis

public static final int yAxis
See Also:
Constant Field Values

dirty

protected boolean dirty

xMin

public int xMin

xMax

public int xMax

xStep

public int xStep

gridStepX

public int gridStepX

yMin

public int yMin

yMax

public int yMax

gridStepY

public int gridStepY

sampleNumber

public int sampleNumber

xOffset

public int xOffset

xOffsetDefault

public int xOffsetDefault

yOffset

public int yOffset

yOffsetDefault

public int yOffsetDefault

xAxisPixelLength

protected int xAxisPixelLength

yAxisPixelLength

protected int yAxisPixelLength

backgroundColor

public java.awt.Color backgroundColor

gridColor

public java.awt.Color gridColor

axisColor

public java.awt.Color axisColor

textColor

public java.awt.Color textColor

graphColor

public java.awt.Color graphColor

axisWidth

public float axisWidth

graphWidth

public float graphWidth

axisPencilWidth

public float axisPencilWidth

graphPencilWidth

public float graphPencilWidth

drawGrid

public boolean drawGrid

keysAllowed

public boolean keysAllowed

adjustable

public boolean adjustable

xData

public int[] xData

yData

public int[] yData

topBar

protected java.awt.Image topBar

middleBar

protected java.awt.Image middleBar

bottomBar

protected java.awt.Image bottomBar

backgroundImage

protected java.awt.Image backgroundImage

xBarOffset

protected int xBarOffset

yBarSize

protected int yBarSize
Constructor Detail

GraphPanel

public GraphPanel()
Default constructor


GraphPanel

public GraphPanel(java.awt.Dimension size)
The constructor to be used : Sets the size, the offsets, the pencils, adds the listeners

Parameters:
size - DOCUMENT ME!
Method Detail

initImages

public void initImages()

createImage

public java.awt.Image createImage(java.lang.String SFURL)

setCompleteGraphPanel

public void setCompleteGraphPanel(CompleteGraphPanel cgp)
Set the CompleteGraphPanel surrounding this one. Will be used to update extra labels, correspond with buttons, etc.

Parameters:
cgp - DOCUMENT ME!

setSampleNumber

public void setSampleNumber(int samples)
Set the size of the data arrays

Parameters:
samples - DOCUMENT ME!

setGraphWidth

public void setGraphWidth(float graphWidth)

setPencils

public void setPencils()
Set the pencils size


setDataDimensions

public void setDataDimensions(int xMin,
                              int xMax,
                              int xStep,
                              int yMin,
                              int yMax)
Set the axis for both dimensions

Parameters:
xMin - DOCUMENT ME!
xMax - DOCUMENT ME!
xStep - DOCUMENT ME!
yMin - DOCUMENT ME!
yMax - DOCUMENT ME!

setGridDimensions

public void setGridDimensions(int gridStepX,
                              int gridStepY)
Set grid dimensions

Parameters:
gridStepX - DOCUMENT ME!
gridStepY - DOCUMENT ME!

setOffset

public void setOffset(int xOffset,
                      int yOffset)
Set border offsets. Also computes the length, in pixel, of both axis.

Parameters:
xOffset - DOCUMENT ME!
yOffset - DOCUMENT ME!

setAxis

public void setAxis(int axis,
                    int min,
                    int max,
                    int step)
Set data for one axis : max & min value represented the step is the distance between two samples. It should correspond to ((xMax - xMin) / sampleNumbers)

Parameters:
axis - DOCUMENT ME!
min - DOCUMENT ME!
max - DOCUMENT ME!
step - DOCUMENT ME!

toggleDisplay

public void toggleDisplay()
Toggle a different display for the graph.


toggleDisplay

public void toggleDisplay(boolean filled)
Toggle a different display for the graph.

Parameters:
filled - DOCUMENT ME!

toggleGrid

public void toggleGrid()
Toggle the grid on the graph.


setPencilColour

public void setPencilColour(java.lang.String pencilColour)
Set the pencil's colour

Parameters:
pencilColour - DOCUMENT ME!

setAdjustable

public void setAdjustable(boolean adjustable)
Set the graph's adjustability.

Parameters:
adjustable - DOCUMENT ME!

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

update

public void update(java.awt.Graphics g)
Overrides:
update in class javax.swing.JComponent

drawPanel

public void drawPanel(java.awt.Graphics2D g2d)
Overwrite this method to draw the panel differently

Parameters:
g2d - DOCUMENT ME!

drawGrid

protected void drawGrid(java.awt.Graphics2D g2d)
Draw a 2d grid in the background. "gridStepX" and "gridStepY" are the spaces between lines of the grid.

Parameters:
g2d -

drawAxis

protected void drawAxis(java.awt.Graphics2D g2d)
Draw the two main axis

Parameters:
g2d - DOCUMENT ME!

drawData

protected void drawData(java.awt.Graphics2D g2d)
Draw the two data arrays. We need to convert them both to fit to the axis' scales, and to offset them

Parameters:
g2d - DOCUMENT ME!

scaleX

protected int scaleX(int xData)
Returns a scaled int between 0 and xAxisPixelLength If xData greater than xMax or xData less than xMin the return values are 0 and xAxisPixelLength respectively

Parameters:
xData - DOCUMENT ME!
Returns:
DOCUMENT ME!

scaleY

protected int scaleY(int yData)
Returns a scaled int between 0 and yAxisPixelLength If yData greater than yMax or yData less than yMin the return values are 0 and yAxisPixelLength respectively

Parameters:
yData - DOCUMENT ME!
Returns:
DOCUMENT ME!

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Called when the component has been resized

Specified by:
componentResized in interface java.awt.event.ComponentListener
Parameters:
e - DOCUMENT ME!

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP