WebCab JGraph v2.0

## com.webcab.beans.newchart
Class Graph

    java.lang.Object
      |
      +--java.awt.Component
            |
            +--java.awt.Canvas
                  |
                  +--com.webcab.beans.newchart.Graph

All Implemented Interfaces:
  Accessible, ActionListener, ComponentListener, EventListener, ImageObserver, MenuContainer, MouseListener, MouseMotionListener, Serializable

public class Graph
extends Canvas
implements Serializable, MouseMotionListener, MouseListener, ActionListener, ComponentListener

This class can be used to represent discrete data sets as graphs using several interpolation methods. Multiple series are supported. The data set is read from a database. A JDBC driver is required to connect to the database. The graphs are fully customizable, the component offering options for almost every visual detail.

Author:
  WebCab Components
See Also:
  Serialized Form

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
`Graph()` This is the non-zero constructor required by the java.beans.Bean class in order to instantiate the bean.

Method Summary
`void` `actionPerformed(ActionEvent e)`
`void` `componentHidden(ComponentEvent e)`
`void` `componentMoved(ComponentEvent e)`
`void` `componentResized(ComponentEvent e)`
`void` `componentShown(ComponentEvent e)`
`boolean` `getAntialias()` Returns true if antilaias is used while drawing.
`double` `getCenterX()` Gets the x center value.
`double` `getCenterY()` Gets the y center value.
`Color[]` `getColors()`
`boolean` `getDisplayAxis()` Returns true if the axis are displayed.
`boolean` `getDisplayGrid()` Returns true if the gird is displayed.
`boolean` `getDisplayImage()` Returns true if an image is used as background.
`boolean` `getDisplayPoints()` Returns true if the interpolation points are displayed.
`boolean` `getDraggGraphEnabled()` Returns true if the graph can be dragged.
`boolean` `getDraggPointsEnabled()` Returns true if the interpolation points can be dragged.
`int` `getDraggTolerance()` Gets the current tolerance.
`int` `getFirstDerivative()` Gets the value of the first deivative for the first interpolation point.
`Color` `getGridColor()` Gets the grid color.
`double` `getGridY()` Gets the grid y value.
`String` `getImageUrl()` Gets the string representation of the URL where to find the background image.
`String` `getJDBCDriver()` Gets the current JDBC driver.
`String` `getJDBCPassword()` Gets the current JDBC password.
`String` `getJDBCQuery()` Gets the current JDBC query.
`String` `getJDBCUrl()` Gets the current JDBC URL.
`String` `getJDBCUser()` Gets the current JDBC user.
`int` `getLastDerivative()` Gets the value of the first deivative for the last interpolation point.
`int` `getLegendPosition()` Returns the current legend alignment.
`float` `getLineWidth()` Gets the current line width.
`Dimension` `getMinimumSize()`
`String` `getName()` Gets the name of the graph.
`int` `getPointsWidth()` Gets the width for the interpolation points.
`boolean` `getRoundPoints()` Returns true if the points are represented as cirlces.
`double` `getScaleX()` Gets the scale x value.
`double` `getScaleY()` Gets the scale y value.
`boolean` `getSnapToGrid()` Returns true is snap to grid is used.
`Color` `getTipBackground()` Gets the background color for tips.
`int` `getTipDelayMillis()` Gets the delay in milliseconds before displaying the tip.
`Color` `getTipForeground()` Gets the foregound color for tips.
`int` `getType()` Gets the current interpolation method.
`int` `getTypeOfImage()` Gets the type of image alignament.
`boolean` `getUseToolTip()` Returns true if a tooltip is used.
`Color` `getXAxColor()` Gets the x ax color.
`String` `getXLabel()` Gets the x ax label.
`Color` `getXLabelColor()` Gets the x ax label color.
`int` `getXValuesAngle()` Gets the angles in degrees of the x ax values.
`Color` `getYAxColor()` Gets the y ax color.
`String` `getYLabel()` Gets the y ax label.
`Color` `getYLabelColor()` Gets the y ax label color.
`int` `getYValuesAngle()` Gets the angle in degrees of the y ax values.
`double` `getZoom()` Gets the zoom value in percentages.
`void` `mouseClicked(MouseEvent e)`
`void` `mouseDragged(MouseEvent e)`
`void` `mouseEntered(MouseEvent e)`
`void` `mouseExited(MouseEvent e)`
`void` `mouseMoved(MouseEvent e)`
`void` `mousePressed(MouseEvent e)`
`void` `mouseReleased(MouseEvent e)`
`void` `paint(Graphics g)`
`void` `setAntialias(boolean value)` Sets whether antialias is used while drawing.
`void` `setCenterX(double value)` Sets the x center value.
`void` `setCenterY(double value)` Sets the y center value.
`void` `setColors(Color[] col)`
`void` `setDisplayAxis(boolean value)` Sets whether axis are displayed.
`void` `setDisplayGrid(boolean value)` Sets whether the gird is displayed.
`void` `setDisplayImage(boolean value)` Sets whether an image should be used as background.
`void` `setDisplayPoints(boolean value)` Sets whether the interpolation points are displayed.
`void` `setDraggGraphEnabled(boolean value)` Sets whether the whole graph can be dragged.
`void` `setDraggPointsEnabled(boolean value)` Sets whether the interpolation points can be dragged.
`void` `setDraggTolerance(int value)` Sets the tolerance in pixels, when dragging interpolation points.
`void` `setFirstDerivative(int value)` Sets the value of the first deivative for the first interpolation point.
`void` `setGridColor(Color value)` Sets the grid color.
`void` `setGridX(double value)` Sets the grid x value.
`void` `setGridY(double value)` Sets the grid y value.
`void` `setImageUrl(String url)` Sets the string representation of the URL where the program should find an valid image to use as background.
`void` `setJDBCDriver(String driver)` This method only sends a new driver to the JavaBeans component.
`void` `setJDBCPassword(String value)` This method only registers this password as the next password to use when sending the next query.
`void` `setJDBCQuery(String query)` This method tries to send the specified query to the JDBC server (as previously registered with the `setJDBCDriver` and the `setJDBCUrl` methods.
`void` `setJDBCUrl(String url)` This method only registers this url as the next url to use when sending the next query.
`void` `setJDBCUser(String value)` This method only registers this user as the next user to use when sending the next query.
`void` `setLastDerivative(int value)` Sets the value of the first deivative for the last interpolation point.
`void` `setLegendPosition(int value)` Sets the legend alignment.
`void` `setLineWidth(float value)` Sets the line width in pixels.
`void` `setName(String value)` Sets the name of the Graph.
`void` `setPointsWidth(int value)` Sets the width for the interpolation points.
`void` `setRoundPoints(boolean value)` Sets whether the interpolation points should be represented as circles instead of sqaures.
`void` `setScaleX(double value)` Sets the scale x value.
`void` `setScaleY(double value)` Sets the scale y value.
`void` `setSnapToGrid(boolean value)` Sets whether the points will be snapped to grid when drawing.
`void` `setTipBackground(Color value)` Sets the background color for tips.
`void` `setTipDelayMillis(int value)` Sets the delay in milliseconds before displaying the tip.
`void` `setTipForeground(Color value)` Sets the foreground color for tips.
`void` `setType(int value)` Gets the grid x value.
`void` `setTypeOfImage(int type)` Sets the type of alignament for the image used as background.
`void` `setUseToolTip(boolean value)` Sets whether a tooltip is used.
`void` `setXAxColor(Color value)` Sets the x ax color.
`void` `setXLabel(String value)` Sets the x ax label.
`void` `setXLabelColor(Color value)` Sets the x ax label color.
`void` `setXValuesAngle(int value)` Sets the angle in degrees of the x ax values.
`void` `setYAxColor(Color value)` Sets the y ax color.
`void` `setYLabel(String value)` Sets the y ax label.
`void` `setYLabelColor(Color value)` Sets the y ax label color.
`void` `setYValuesAngle(int value)` Sets the angle in degrees of the y ax values.
`void` `setZoom(double value)` Sets the zoom value in percentages.
`void` `update(Graphics g)`

Methods inherited from class java.awt.Canvas
`addNotify, getAccessibleContext`

Methods inherited from class java.awt.Component

`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Graph

    public Graph()

  This is the non-zero constructor required by the java.beans.Bean class in order to instantiate the bean.

Method Detail

### setDraggPointsEnabled

    public void setDraggPointsEnabled(boolean value)

  Sets whether the interpolation points can be dragged.
  Parameters:
    `value` - true if the points can be dragged; false otherwise.

### getDraggPointsEnabled

    public boolean getDraggPointsEnabled()

  Returns true if the interpolation points can be dragged.

### setDraggGraphEnabled

    public void setDraggGraphEnabled(boolean value)

  Sets whether the whole graph can be dragged.
  Parameters:
    `value` - true if the graph can be dragged.

### getDraggGraphEnabled

    public boolean getDraggGraphEnabled()

  Returns true if the graph can be dragged.

### setSnapToGrid

    public void setSnapToGrid(boolean value)

  Sets whether the points will be snapped to grid when drawing.
  Parameters:
    `value` - true if snap to grid is used; false otherwise.

### getSnapToGrid

    public boolean getSnapToGrid()

  Returns true is snap to grid is used.

### setDraggTolerance

    public void setDraggTolerance(int value)

  Sets the tolerance in pixels, when dragging interpolation points.
  Parameters:
    `value` - the tolerance in pixels.

### getDraggTolerance

    public int getDraggTolerance()

  Gets the current tolerance.

### setDisplayImage

    public void setDisplayImage(boolean value)

  Sets whether an image should be used as background.
  Parameters:
    `value` - true if an image is used as background; false otherwise.

### getDisplayImage

    public boolean getDisplayImage()

  Returns true if an image is used as background.

### setTypeOfImage

    public void setTypeOfImage(int type)

  Sets the type of alignament for the image used as background. Predefined constants can be used to select the type or the following values:
  - 0 - Top left
  - 1 - Top center
  - 2 - Top right
  - 3 - Midle left
  - 4 - Midle center
  - 5 - Midle right
  - 6 - Bottom left
  - 7 - Bottom center
  - 8 - Bottom right
  - 9 - Tiled
  - 10 - Streched
  Parameters:
    `type` - the type of alignament.

### getTypeOfImage

    public int getTypeOfImage()

  Gets the type of image alignament.

### setImageUrl

    public void setImageUrl(String url)

  Sets the string representation of the URL where the program should find an valid image to use as background. Valid images are JPEG, GIF and PNG.
  Parameters:
    `url` - the string representation of the url.

### getImageUrl

    public String getImageUrl()

  Gets the string representation of the URL where to find the background image.

### setLineWidth

    public void setLineWidth(float value)

  Sets the line width in pixels.
  Parameters:
    `value` - the line width.

### getLineWidth

    public float getLineWidth()

  Gets the current line width.

### setRoundPoints

    public void setRoundPoints(boolean value)

  Sets whether the interpolation points should be represented as circles instead of sqaures.
  Parameters:
    `value` - true if the points are represented as circles; false otherwise.

### getRoundPoints

    public boolean getRoundPoints()

  Returns true if the points are represented as cirlces.

### setYValuesAngle

    public void setYValuesAngle(int value)

  Sets the angle in degrees of the y ax values.
  Parameters:
    `value` - the angle in degrees.

### getYValuesAngle

    public int getYValuesAngle()

  Gets the angle in degrees of the y ax values.

### setXValuesAngle

    public void setXValuesAngle(int value)

  Sets the angle in degrees of the x ax values.
  Parameters:
    `value` - the angle in degrees.

### getXValuesAngle

    public int getXValuesAngle()

  Gets the angles in degrees of the x ax values.

### setPointsWidth

    public void setPointsWidth(int value)

  Sets the width for the interpolation points. This width will be added to the line width values.
  Parameters:
    `value` - the width to be used.

### getPointsWidth

    public int getPointsWidth()

  Gets the width for the interpolation points.

### setLastDerivative

    public void setLastDerivative(int value)

  Sets the value of the first deivative for the last interpolation point.
  Parameters:
    `value` - the value of the first derivative.

### getLastDerivative

    public int getLastDerivative()

  Gets the value of the first deivative for the last interpolation point.

### setFirstDerivative

    public void setFirstDerivative(int value)

  Sets the value of the first deivative for the first interpolation point.
  Parameters:
    `value` - the value of the first derivative.

### getFirstDerivative

    public int getFirstDerivative()

  Gets the value of the first deivative for the first interpolation point.
  Parameters:
    `value` - the value of the first derivative.

### setTipForeground

    public void setTipForeground(Color value)

  Sets the foreground color for tips.
  Parameters:
    `the` - color to be used.

### getTipForeground

    public Color getTipForeground()

  Gets the foregound color for tips.

### setTipBackground

    public void setTipBackground(Color value)

  Sets the background color for tips.
  Parameters:
    `the` - color to be used.

### getTipBackground

    public Color getTipBackground()

  Gets the background color for tips.

### setTipDelayMillis

    public void setTipDelayMillis(int value)

  Sets the delay in milliseconds before displaying the tip.
  Parameters:
    `value` - the delay in milliseconds.

### getTipDelayMillis

    public int getTipDelayMillis()

  Gets the delay in milliseconds before displaying the tip.

### setUseToolTip

    public void setUseToolTip(boolean value)

  Sets whether a tooltip is used.
  Parameters:
    `true` - if tooltip is used; false otherwise.

### getUseToolTip

    public boolean getUseToolTip()

  Returns true if a tooltip is used.

### setGridColor

    public void setGridColor(Color value)

  Sets the grid color.
  Parameters:
    `value` - the color to be used.

### getGridColor

    public Color getGridColor()

  Gets the grid color.

### setXAxColor

    public void setXAxColor(Color value)

  Sets the x ax color.
  Parameters:
    `value` - the color to be used.

### getXAxColor

    public Color getXAxColor()

  Gets the x ax color.

### setYAxColor

    public void setYAxColor(Color value)

  Sets the y ax color.
  Parameters:
    `value` - the color to be used.

### getYAxColor

    public Color getYAxColor()

  Gets the y ax color.

### setDisplayAxis

    public void setDisplayAxis(boolean value)

  Sets whether axis are displayed.
  Parameters:
    `value` - true if axis are displayed; false otherwise.

### getDisplayAxis

    public boolean getDisplayAxis()

  Returns true if the axis are displayed.

### setName

    public void setName(String value)

  Sets the name of the Graph.
  Overrides:
    `setName` in class `Component`
  Parameters:
    `value` - the name of the Graph.

### getName

    public String getName()

  Gets the name of the graph.
  Overrides:
    `getName` in class `Component`

### setDisplayPoints

    public void setDisplayPoints(boolean value)

  Sets whether the interpolation points are displayed.
  Parameters:
    `value` - true if the interpolation points are displayed; false otherwise.

### getDisplayPoints

    public boolean getDisplayPoints()

  Returns true if the interpolation points are displayed.

### setDisplayGrid

    public void setDisplayGrid(boolean value)

  Sets whether the gird is displayed.
  Parameters:
    `value` - true if the grid is displayed; false otherwise.

### getDisplayGrid

    public boolean getDisplayGrid()

  Returns true if the gird is displayed.

### setAntialias

    public void setAntialias(boolean value)

  Sets whether antialias is used while drawing.
  Parameters:
    `value` - true if antialias is used; false othwerwise.

### getAntialias

    public boolean getAntialias()

  Returns true if antilaias is used while drawing.

### setLegendPosition

    public void setLegendPosition(int value)

  Sets the legend alignment. Valid values are from 0 to 3.
  Parameters:
    `value` - the legend alignment.

### getLegendPosition

    public int getLegendPosition()

  Returns the current legend alignment.

### setXLabel

    public void setXLabel(String value)

  Sets the x ax label.
  Parameters:
    `the` - x ax label.

### getXLabel

    public String getXLabel()

  Gets the x ax label.

### setYLabel

    public void setYLabel(String value)

  Sets the y ax label.
  Parameters:
    `the` - y ax label.

### getYLabel

    public String getYLabel()

  Gets the y ax label.

### setXLabelColor

    public void setXLabelColor(Color value)

  Sets the x ax label color.
  Parameters:
    `value` - the color to be used.

### getXLabelColor

    public Color getXLabelColor()

  Gets the x ax label color.

### setYLabelColor

    public void setYLabelColor(Color value)

  Sets the y ax label color.
  Parameters:
    `value` - the color to be used.

### getYLabelColor

    public Color getYLabelColor()

  Gets the y ax label color.

### setScaleX

    public void setScaleX(double value)

  Sets the scale x value.
  Parameters:
    `value` - the scale x value.

### getScaleX

    public double getScaleX()

  Gets the scale x value.

### setCenterX

    public void setCenterX(double value)

  Sets the x center value.
  Parameters:
    `value` - the value to be used

### getCenterX

    public double getCenterX()

  Gets the x center value.

### setCenterY

    public void setCenterY(double value)

  Sets the y center value.
  Parameters:
    `value` - the value to be used

### getCenterY

    public double getCenterY()

  Gets the y center value.

### setZoom

    public void setZoom(double value)

  Sets the zoom value in percentages.
  Parameters:
    `the` - zoom value.

### getZoom

    public double getZoom()

  Gets the zoom value in percentages.

### setScaleY

    public void setScaleY(double value)

  Sets the scale y value.
  Parameters:
    `value` - the scale x value.

### getScaleY

    public double getScaleY()

  Gets the scale y value.

### setGridX

    public void setGridX(double value)

  Sets the grid x value.
  Parameters:
    `value` - the grid value.

### setType

    public void setType(int value)

  Gets the grid x value. / public double getGridX(){ return gridx; } //----------------------------------------------------------------------------------------- /** Sets the type of interpolation that should be used. Predefined constants can be used to select the type or the following values:
  - 0 - Cubic Splines Interpolation
  - 1 - Polynomial Interpolation 1
  - 2 - Polynomial Interpolation 2
  - 3 - Polynomial Interpolation 3
  - 4 - Rational Interpolation
  - 5 - No Interpolation
  Parameters:
    `value` - the index of the interpolation.

### getType

    public int getType()

  Gets the current interpolation method.

### setGridY

    public void setGridY(double value)

  Sets the grid y value.
  Parameters:
    `value` - the grid value.

### getGridY

    public double getGridY()

  Gets the grid y value.

### setJDBCDriver

    public void setJDBCDriver(String driver)

  This method only sends a new driver to the JavaBeans component. It will not take effect until a new query is sent to the JDBC server.

### setJDBCUrl

    public void setJDBCUrl(String url)

  This method only registers this url as the next url to use when sending the next query. It will not take effect until the `setJDBCQuery` method is actually run.

### setJDBCQuery

    public void setJDBCQuery(String query)

  This method tries to send the specified query to the JDBC server (as previously registered with the `setJDBCDriver` and the `setJDBCUrl` methods. It requires that the query return a ResultSet containing such: 1. double (the x coordinate) 2. double (the y coordinate)

  The method will not throw an exception, instead it will print its stack-trace. Please send a request if you wish it to be in any other way.

### getJDBCDriver

    public String getJDBCDriver()

  Gets the current JDBC driver.

### getJDBCUrl

    public String getJDBCUrl()

  Gets the current JDBC URL.

### getJDBCQuery

    public String getJDBCQuery()

  Gets the current JDBC query.

### setJDBCUser

    public void setJDBCUser(String value)

  This method only registers this user as the next user to use when sending the next query. It will not take effect until the `setJDBCQuery` method is actually run.

### getJDBCUser

    public String getJDBCUser()

  Gets the current JDBC user.

### setJDBCPassword

    public void setJDBCPassword(String value)

  This method only registers this password as the next password to use when sending the next query. It will not take effect until the `setJDBCQuery` method is actually run.

### getJDBCPassword

    public String getJDBCPassword()

  Gets the current JDBC password.

### getMinimumSize

    public Dimension getMinimumSize()

  Overrides:
    `getMinimumSize` in class `Component`

### componentResized

    public void componentResized(ComponentEvent e)

  Specified by:
    `componentResized` in interface `ComponentListener`

### componentMoved

    public void componentMoved(ComponentEvent e)

  Specified by:
    `componentMoved` in interface `ComponentListener`

### componentHidden

    public void componentHidden(ComponentEvent e)

  Specified by:
    `componentHidden` in interface `ComponentListener`

### componentShown

    public void componentShown(ComponentEvent e)

  Specified by:
    `componentShown` in interface `ComponentListener`

### actionPerformed

    public void actionPerformed(ActionEvent e)

  Specified by:
    `actionPerformed` in interface `ActionListener`

### mouseDragged

    public void mouseDragged(MouseEvent e)

  Specified by:
    `mouseDragged` in interface `MouseMotionListener`

### mouseMoved

    public void mouseMoved(MouseEvent e)

  Specified by:
    `mouseMoved` in interface `MouseMotionListener`

### mousePressed

    public void mousePressed(MouseEvent e)

  Specified by:
    `mousePressed` in interface `MouseListener`

### mouseClicked

    public void mouseClicked(MouseEvent e)

  Specified by:
    `mouseClicked` in interface `MouseListener`

### mouseReleased

    public void mouseReleased(MouseEvent e)

  Specified by:
    `mouseReleased` in interface `MouseListener`

### mouseEntered

    public void mouseEntered(MouseEvent e)

  Specified by:
    `mouseEntered` in interface `MouseListener`

### mouseExited

    public void mouseExited(MouseEvent e)

  Specified by:
    `mouseExited` in interface `MouseListener`

### setColors

    public void setColors(Color[] col)

### getColors

    public Color[] getColors()

### paint

    public void paint(Graphics g)

  Overrides:
    `paint` in class `Canvas`

### update

    public void update(Graphics g)

  Overrides:
    `update` in class `Component`

WebCab JGraph v2.0