com.adventnet.snmp.ui
Class Graph

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.adventnet.snmp.ui.Graph

public class Graph
extends javax.swing.JPanel
implements java.io.Serializable

Class Graph is the base class for all the graph beans(BarGraph,LineGraph,FilledGraph,MultiLineGraph and MultiBarGraph.) Graph beans are useful to represent the values that are polled from one or more variables of a remote agent. It can be used with bean builders and other applications.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent, javax.swing.JComponent.IntVector, javax.swing.JComponent.KeyboardBinding, javax.swing.JComponent.KeyboardState
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.util.Vector[] bardata
           
protected  int boxheight
           
protected  int boxwidth
           
protected  int boxX
           
protected  int boxY
           
protected  int count3
           
protected  java.util.Vector[] data
          The data to be graphed, i.e.
protected  java.util.Date date
           
protected  java.util.Date date1
           
protected  java.awt.Image dbuf
           
protected  java.awt.Image dbuf1
           
protected  int dotRad
          marker length, and radius of graph point.
protected  java.util.Vector[] filledgraphdata
           
protected  java.awt.Graphics g
           
protected  java.awt.Graphics g1
           
protected  java.awt.Graphics glegend
           
protected  java.awt.Graphics graph
           
protected  java.awt.Graphics graph1
           
protected  int halfWid
           
protected  int height
           
 boolean isGraphResized
          To know whether graph is resized or not .
 boolean isScrollBarEnabled
          To know whether scroll bar is enabled or not .
 boolean isXRangeChanged
          To know whether XRange is changed or not .
protected  int markLen
          marker length, and radius of graph point.
 int maxX
          The maximum value on the X scale.
protected  int maxX1
           
 int minX
          The minimum value on the X scale.
 int noOfPages
           
protected  int prevht
           
protected  int prevwid
          Height and Width of the Panel.
protected  java.lang.String s
           
protected  java.awt.Font scaleFont
          The labels font name, e.g.
protected  java.util.Vector[] tempvector
           
protected  java.util.Date[] timearray
          To find the polling interval
protected  int width
          Height and Width of the Panel.
protected  int x
           
protected  int[] XGrids
           
protected  int[] xMarks
           
 int xRange
          Difference between x minimum and x maximum.
protected  long xval
           
protected  int y
           
protected  int[] YGrids
           
protected  int[] yMarks
           
protected  int yValueForDisplay
           
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
component, containerListener, layoutMgr, ncomponents
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
Graph()
          This constructor adds mouse and mouse motion listeners for the graph.
 
Method Summary
(package private)  boolean addBarGraphPoint(int barnum, double[] nextpoint)
          Add a point for bar graph without repainting the entire bar and multi bar graph.
(package private)  boolean addFilledGraphPoint(int barnum, double[] nextpoint)
          Add a point for filled graph without repainting the entire graph.
(package private)  boolean addPoint(int linenum, double[] nextpoint)
          Add a point without repainting the entire line and multi line graph.
 void barGraphSetUp()
          This is needed to setup the time at which bean has been instantiated.
 void calculatePoints()
          calculate the points on the graph
protected  long computeX(int x)
          To compute X value(for corresponding x point).
protected  int computeXPoint(double xval)
          To compute X point (for corresponding x value(time))
protected  long computeY(int y)
          To compute Y value(for corresponding y point).
protected  int computeYPoint(double yval)
          To compute y point (for corresponding y value).
protected  void drawGraph()
           
 void drawLegend(java.awt.Graphics glegend)
          To draw a box to show value and time .
 void drawSkeletenGraph()
          To draw the graph .
 void filledGraphSetUp()
          This is needed to setup the time at which bean has been instantiated.
 java.awt.Color getBarColor()
          To get bar color .
 java.awt.Color[] getBarColors()
          To get bar colors.
 java.awt.Color getBgcolor()
          To get background color .
 java.awt.Color getFgcolor()
          To get foreground color.
 java.awt.Color getLinecolor()
          To get line color.
 java.awt.Color[] getLineColors()
          To get line colors.
 long getMaxY()
          To get maximum value in y axis.
 long getMinY()
          To get minimum value in y axis.
 int getNoOfBars()
          To get number of bars.
 int getNoOfLines()
          To get number of lines.
 int getNoOfValues()
          To get no of polled values to be displayed in the graph .
 java.awt.Dimension getPreferredSize()
          To get the preferred size for the graph .
 java.awt.Font getScaleFont()
          To get scale font.
 int getTime()
           
 java.lang.String getTitle()
          To get title of graph.
 java.awt.Font getTitleFont()
          To get font of the title.
 int getXGrids()
          To get number of vertical grids.
 java.lang.String getXLabel()
          To get label on the X axis.
 int getXRange()
          To get difference between x minimum and x maximum.
 int getXScalePoints()
          To get number of marks on x axis.
 int getYGrids()
          To get number of horizontal grids.
 java.lang.String getYLabel()
          To get label on the Y axis.
 int getYScalePoints()
          To get number of marks on y axis.
 void graphData()
          To graph the data
 boolean isAbsoluteTime()
          To know whether the graph is using absolute time or not.
 boolean isShowTitle()
          To know whether it can show the title or not.
 boolean isShowxLabel()
          To know whether it can show the x label or not.
 boolean isShowyLabel()
          To know whether it can show the y label or not.
 boolean isTimeAverage()
          To know whether time average the polled value or not.
 void lineGraphSetUp()
          This is needed to setup the time at which bean has been instantiated.
 void paintComponent(java.awt.Graphics g)
           
 double[] results(long diff)
          To change the maximum x and y values corresponding to time and polled value.
 java.lang.String roundUp(java.lang.String ss)
          To round-up the Scale points .
 void setAbsoluteTime(boolean b)
          To set whether the graph can use absolute time or not.
 void setBarColor(java.awt.Color c)
          To set line color.
 void setBarColors(java.awt.Color[] c)
          To set bar colors.
 void setBarGraphResult(long diff)
          This updates the bar graph with the new value
 void setBgcolor(java.awt.Color c)
          To set background color.
 void setFgcolor(java.awt.Color c)
          To set foreground color.
 void setFilledGraphResult(long diff)
          This updates the filled graph with the new value
 void setLinecolor(java.awt.Color c)
          To set line color.
 void setLineColors(java.awt.Color[] c)
          To set line colors.
 void setMaxY(long l)
          To set maximum value in y axis.
 void setMinY(long l)
          To set minimum value in y axis.
 void setMultiBarGraphResult(int barNumber, long diff)
          This updates the multi bar graph with the new value
 void setNoOfBars(int i)
          To set no of bars.
 void setNoOfLines(int i)
          To set no of lines.
 void setNoOfValues(int i)
          To set no of polled values to be displayed in the graph .
 void setResult(int lineNumber, long diff)
          This updates the line graph with the new value
 void setResult(long diff)
          This updates the line graph with the new value
 void setScaleFont(java.awt.Font f)
          To set scale font.
 void setShowTitle(boolean b)
          To set whether it can show the title or not.
 void setShowxLabel(boolean b)
          To set whether it can show the x label or not.
 void setShowyLabel(boolean b)
          To set whether it can show the y label or not.
 void setTimeAverage(boolean b)
          To set whether time average the polled value or not.
 void setTitle(java.lang.String s)
          To set name of graph.
 void setTitleFont(java.awt.Font f)
          To set font of the title.
 void setXGrids(int i)
          To set number of vertical grids.
 void setXLabel(java.lang.String s)
          To set label on the X axis.
 void setXRange(int i)
          To set difference between x minimum and x maximum.
 void setXScalePoints(int i)
          To set number of marks on x axis.
 void setYGrids(int i)
          To set number of horizontal grids.
 void setYLabel(java.lang.String s)
          To set label on the Y axis.
 void setYScalePoints(int i)
          To set number of marks on y axis.
 
Methods inherited from class javax.swing.JPanel
, getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, bindingForKeyStroke, checkIfChildObscuredBySibling, computeVisibleRect, computeVisibleRect, contains, createToolTip, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, rectangleIsObscuredBySibling, registerKeyboardAction, registerKeyboardAction, registerWithKeyboardManager, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, unregisterWithKeyboardManager, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getLayout, getMouseEventTarget, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setCursor, setFocusOwner, setLayout, transferFocus, updateCursor, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, constructComponentName, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isEnabledImpl, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

width

protected int width
Height and Width of the Panel.

prevwid

protected int prevwid
Height and Width of the Panel.

height

protected int height

prevht

protected int prevht

noOfPages

public int noOfPages

isScrollBarEnabled

public boolean isScrollBarEnabled
To know whether scroll bar is enabled or not .

isGraphResized

public boolean isGraphResized
To know whether graph is resized or not .

isXRangeChanged

public boolean isXRangeChanged
To know whether XRange is changed or not .

maxX1

protected int maxX1

yValueForDisplay

protected int yValueForDisplay

g

protected transient java.awt.Graphics g

graph

protected transient java.awt.Graphics graph

g1

protected transient java.awt.Graphics g1

graph1

protected transient java.awt.Graphics graph1

glegend

protected transient java.awt.Graphics glegend

dbuf

protected transient java.awt.Image dbuf

dbuf1

protected transient java.awt.Image dbuf1

scaleFont

protected java.awt.Font scaleFont
The labels font name, e.g. Helvetica.

minX

public int minX
The minimum value on the X scale.

maxX

public int maxX
The maximum value on the X scale.

xRange

public int xRange
Difference between x minimum and x maximum.

XGrids

protected int[] XGrids

YGrids

protected int[] YGrids

xMarks

protected int[] xMarks

yMarks

protected int[] yMarks

markLen

protected int markLen
marker length, and radius of graph point.

dotRad

protected int dotRad
marker length, and radius of graph point.

data

protected java.util.Vector[] data
The data to be graphed, i.e. each line is Vector of points (x,y)

bardata

protected java.util.Vector[] bardata

filledgraphdata

protected java.util.Vector[] filledgraphdata

tempvector

protected java.util.Vector[] tempvector

halfWid

protected int halfWid

date

protected java.util.Date date

date1

protected java.util.Date date1

timearray

protected java.util.Date[] timearray
To find the polling interval

count3

protected int count3

x

protected int x

y

protected int y

boxX

protected int boxX

boxY

protected int boxY

boxwidth

protected int boxwidth

boxheight

protected int boxheight

xval

protected long xval

s

protected java.lang.String s
Constructor Detail

Graph

public Graph()
This constructor adds mouse and mouse motion listeners for the graph.
Method Detail

drawLegend

public void drawLegend(java.awt.Graphics glegend)
To draw a box to show value and time .

getPreferredSize

public java.awt.Dimension getPreferredSize()
To get the preferred size for the graph .
Overrides:
getPreferredSize in class javax.swing.JComponent

lineGraphSetUp

public void lineGraphSetUp()
This is needed to setup the time at which bean has been instantiated.

barGraphSetUp

public void barGraphSetUp()
This is needed to setup the time at which bean has been instantiated.

filledGraphSetUp

public void filledGraphSetUp()
This is needed to setup the time at which bean has been instantiated.

setResult

public void setResult(long diff)
This updates the line graph with the new value

setResult

public void setResult(int lineNumber,
                      long diff)
This updates the line graph with the new value

setBarGraphResult

public void setBarGraphResult(long diff)
This updates the bar graph with the new value

setMultiBarGraphResult

public void setMultiBarGraphResult(int barNumber,
                                   long diff)
This updates the multi bar graph with the new value

setFilledGraphResult

public void setFilledGraphResult(long diff)
This updates the filled graph with the new value

results

public double[] results(long diff)
To change the maximum x and y values corresponding to time and polled value. It calculates the polled value if time avrage is true.

paintComponent

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

drawGraph

protected void drawGraph()

getTime

public int getTime()

computeX

protected long computeX(int x)
To compute X value(for corresponding x point).

computeY

protected long computeY(int y)
To compute Y value(for corresponding y point).

computeXPoint

protected int computeXPoint(double xval)
To compute X point (for corresponding x value(time))

computeYPoint

protected int computeYPoint(double yval)
To compute y point (for corresponding y value).

calculatePoints

public void calculatePoints()
calculate the points on the graph

drawSkeletenGraph

public void drawSkeletenGraph()
To draw the graph .

graphData

public void graphData()
To graph the data

addPoint

boolean addPoint(int linenum,
                 double[] nextpoint)
Add a point without repainting the entire line and multi line graph.

addBarGraphPoint

boolean addBarGraphPoint(int barnum,
                         double[] nextpoint)
Add a point for bar graph without repainting the entire bar and multi bar graph.

addFilledGraphPoint

boolean addFilledGraphPoint(int barnum,
                            double[] nextpoint)
Add a point for filled graph without repainting the entire graph.

roundUp

public java.lang.String roundUp(java.lang.String ss)
To round-up the Scale points .

getTitle

public java.lang.String getTitle()
To get title of graph.

setTitle

public void setTitle(java.lang.String s)
To set name of graph.

isShowTitle

public boolean isShowTitle()
To know whether it can show the title or not.

setShowTitle

public void setShowTitle(boolean b)
To set whether it can show the title or not.

getTitleFont

public java.awt.Font getTitleFont()
To get font of the title.

setTitleFont

public void setTitleFont(java.awt.Font f)
To set font of the title.

getBgcolor

public java.awt.Color getBgcolor()
To get background color .

setBgcolor

public void setBgcolor(java.awt.Color c)
To set background color.

getFgcolor

public java.awt.Color getFgcolor()
To get foreground color.

setFgcolor

public void setFgcolor(java.awt.Color c)
To set foreground color.

getLinecolor

public java.awt.Color getLinecolor()
To get line color.

setLinecolor

public void setLinecolor(java.awt.Color c)
To set line color.

getBarColor

public java.awt.Color getBarColor()
To get bar color .

setBarColor

public void setBarColor(java.awt.Color c)
To set line color.

getXLabel

public java.lang.String getXLabel()
To get label on the X axis.

setXLabel

public void setXLabel(java.lang.String s)
To set label on the X axis.

isShowxLabel

public boolean isShowxLabel()
To know whether it can show the x label or not.

setShowxLabel

public void setShowxLabel(boolean b)
To set whether it can show the x label or not.

getYLabel

public java.lang.String getYLabel()
To get label on the Y axis.

setYLabel

public void setYLabel(java.lang.String s)
To set label on the Y axis.

isShowyLabel

public boolean isShowyLabel()
To know whether it can show the y label or not.

setShowyLabel

public void setShowyLabel(boolean b)
To set whether it can show the y label or not.

isTimeAverage

public boolean isTimeAverage()
To know whether time average the polled value or not.

setTimeAverage

public void setTimeAverage(boolean b)
To set whether time average the polled value or not.

getScaleFont

public java.awt.Font getScaleFont()
To get scale font.

setScaleFont

public void setScaleFont(java.awt.Font f)
To set scale font.

getXRange

public int getXRange()
To get difference between x minimum and x maximum.

setXRange

public void setXRange(int i)
To set difference between x minimum and x maximum.

getMinY

public long getMinY()
To get minimum value in y axis.

setMinY

public void setMinY(long l)
To set minimum value in y axis.

getMaxY

public long getMaxY()
To get maximum value in y axis.

setMaxY

public void setMaxY(long l)
To set maximum value in y axis.

getXGrids

public int getXGrids()
To get number of vertical grids.

setXGrids

public void setXGrids(int i)
To set number of vertical grids.

getYGrids

public int getYGrids()
To get number of horizontal grids.

setYGrids

public void setYGrids(int i)
To set number of horizontal grids.

getXScalePoints

public int getXScalePoints()
To get number of marks on x axis.

setXScalePoints

public void setXScalePoints(int i)
To set number of marks on x axis.

getYScalePoints

public int getYScalePoints()
To get number of marks on y axis.

setYScalePoints

public void setYScalePoints(int i)
To set number of marks on y axis.

getNoOfLines

public int getNoOfLines()
To get number of lines.

setNoOfLines

public void setNoOfLines(int i)
To set no of lines.

getNoOfBars

public int getNoOfBars()
To get number of bars.

setNoOfBars

public void setNoOfBars(int i)
To set no of bars.

getLineColors

public java.awt.Color[] getLineColors()
To get line colors.

setLineColors

public void setLineColors(java.awt.Color[] c)
To set line colors.

getBarColors

public java.awt.Color[] getBarColors()
To get bar colors.

setBarColors

public void setBarColors(java.awt.Color[] c)
To set bar colors.

getNoOfValues

public int getNoOfValues()
To get no of polled values to be displayed in the graph .

setNoOfValues

public void setNoOfValues(int i)
To set no of polled values to be displayed in the graph .

isAbsoluteTime

public boolean isAbsoluteTime()
To know whether the graph is using absolute time or not.

setAbsoluteTime

public void setAbsoluteTime(boolean b)
To set whether the graph can use absolute time or not.