WebCab JGraph v2.0

com.webcab.beans.newchart
Class Chart

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--com.webcab.beans.newchart.Chart
All Implemented Interfaces:
Accessible, ActionListener, ComponentListener, EventListener, ImageObserver, MenuContainer, MouseListener, MouseMotionListener, Serializable

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

This class can be used to represent discrete data sets as bar charts. The data set is read from a database. A JDBC driver is required to connect to the database. The charts 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
Chart()
          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 antialiasing is used while drawing.
 Color getBackground()
          Gets the background color.
 int getBackgroundFillDirection()
          Gets the current filling direction.
 boolean getBaseColor()
          Returns true is the base is filled with a solid color.
 int getBorderSpace()
          Gets the current border in pixels.
 Color getChartBackground()
          Gets the chart's backgound color.
 boolean getChartOutline()
          Returns true if the rectangle bounding the chart is visible.
 boolean getChartShadow()
          Returns true if the chart has shadow.
 boolean getDashedGrid()
          Returns true if a dashed line is used while drawing the grid.
 boolean getDisplayGrid()
          Returns true if a grid is displayed.
 boolean getDisplayImage()
          Returns true if an image is used as background.
 boolean getDisplayValues()
          Returns true is values are displayed.
 boolean getFillBottom()
          Returns true if the bottom base is filled with a solid color.
 int getFirstColumn()
          Gets the index of the first selected column within the dataset.
 Font getFont()
          Gets the current font.
 Color getForeground()
          Gets the current foreground color.
 Color getGridColor()
          Gets the grid color.
 float getGridThickness()
          Gets the space between the grid lines.
 String getImageUrl()
          Gets the string representation of the URL where to find the background image.
 boolean getInteractive()
          Returns true if the program responds to mouse clicks.
 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 getLastColumn()
          Gets the index of the last selected column within the dataset.
 int getLegendPosition()
          Returns the current legend alignment.
 boolean getLight()
          Returns true if a light effect is used.
 Dimension getMinimumSize()
           
 String getName()
          Gets the name of the chart.
 boolean getShadow()
          Returns true if shadows are used.
 Color getShadowColor()
          Gets the shadow color.
 int getSpace()
          Gets the space in pixels between sets of multiple series charts.
 int getTransparencyLevel()
          Returns the transparency level.
 int getTypeOfChart()
          Gets the type of chart displayed on the screen.
 int getTypeOfImage()
          Gets the type of image alignament.
 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 antialiasing is used while drawing.
 void setBackground(Color color)
          Sets the background color.
 void setBackgroundFillDirection(int value)
          Sets the filling direction for the background of the chart.
 void setBaseColor(boolean value)
          Sets whether the base of the chart is filled with a solid color.
 void setBorderSpace(int value)
          Sets the border in pixels of the chart.
 void setChartBackground(Color color)
          Sets the chart's background color.
 void setChartOutline(boolean value)
          Sets whether the rectangle bounding the chart is visible.
 void setChartShadow(boolean value)
          Sets whether the whole chart has shadow.
 void setDashedGrid(boolean value)
          Sets whether a dased line is used while drawing the grid.
 void setDisplayGrid(boolean value)
          Sets whether a grid should be displayed.
 void setDisplayImage(boolean value)
          Sets whether an image should be used as background.
 void setDisplayValues(boolean value)
          Sets whether values should be displayed on the edge of the grid.
 void setFillBottom(boolean value)
          Sets whether the bottom base of the chart is filled with a solid color.
 void setFirstColumn(int value)
          Sets the index of the first selected column within the dataset.
 void setFont(Font font)
          Sets the current font.
 void setForeground(Color color)
          Sets the foreground color.
 void setGridColor(Color color)
          Sets the grid color.
 void setGridThickness(float value)
          Sets the space between the grid lines.
 void setImageUrl(String url)
          Sets the string representation of the URL where the program should find an valid image to use as background.
 void setInteractive(boolean value)
          Sets whether the program should respond to users's mouse clicks or not.
 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 setLastColumn(int value)
          Sets the index of the last selected column within the dataset.
 void setLegendPosition(int value)
          Sets the legend alignment.
 void setLight(boolean value)
          Sets whether a light effect is used when drawing the charts that uses 3D perspective.
 void setName(String value)
          Sets the name of the chart.
 void setShadow(boolean value)
          Sets whether shadows should be used while drawing the chart.
 void setShadowColor(Color color)
          Sets the shadow color.
 void setSpace(int value)
          Sets the space in pixels between sets of multiple series charts.
 void setTransparencyLevel(int value)
          Sets the transparency level from 0 (opaque) to 100.
 void setTypeOfChart(int value)
          Sets the type of chart that should be displayed.
 void setTypeOfImage(int type)
          Sets the type of alignament for the image used as background.
 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, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, 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, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, 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

Chart

public Chart()
This is the non-zero constructor required by the java.beans.Bean class in order to instantiate the bean.
Method Detail

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:
Parameters:
type - the type of alignament.

getTypeOfImage

public int getTypeOfImage()
Gets the type of image alignament.

setAntialias

public void setAntialias(boolean value)
Sets whether antialiasing is used while drawing.
Parameters:
value - true if antialiasing is used; false othwerwise.

getAntialias

public boolean getAntialias()
Returns true if antialiasing is used while drawing.

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 image types are: JPEG, GIF, PNG.
Parameters:
url - the string representation of URL where to download the image used as background.

getImageUrl

public String getImageUrl()
Gets the string representation of the URL where to find the background image.

setFirstColumn

public void setFirstColumn(int value)
Sets the index of the first selected column within the dataset.
Parameters:
value - the index of the first selected column.

getFirstColumn

public int getFirstColumn()
Gets the index of the first selected column within the dataset.

setLastColumn

public void setLastColumn(int value)
Sets the index of the last selected column within the dataset.
Parameters:
value - the index of the last selected column.

getLastColumn

public int getLastColumn()
Gets the index of the last selected column within the dataset.

setName

public void setName(String value)
Sets the name of the chart. The name of the chart can be dragged with the mouse to any position. To disable the name of the chart set it to a blank string.
Overrides:
setName in class Component
Parameters:
value - the string to use as name of the chart.

getName

public String getName()
Gets the name of the chart.
Overrides:
getName in class Component

setLight

public void setLight(boolean value)
Sets whether a light effect is used when drawing the charts that uses 3D perspective.
Parameters:
value - true if a light effect is used; false otherwise.

getLight

public boolean getLight()
Returns true if a light effect is used.

setBaseColor

public void setBaseColor(boolean value)
Sets whether the base of the chart is filled with a solid color.
Parameters:
value - true is the base is filled; false otherwise.

getBaseColor

public boolean getBaseColor()
Returns true is the base is filled with a solid color.

setDashedGrid

public void setDashedGrid(boolean value)
Sets whether a dased line is used while drawing the grid.
Parameters:
value - true is a dashed line is used; false otherwise.

getDashedGrid

public boolean getDashedGrid()
Returns true if a dashed line is used while drawing the grid.

setBackgroundFillDirection

public void setBackgroundFillDirection(int value)
Sets the filling direction for the background of the chart. Valid values are from 0 to 6.
Parameters:
value - the direction to be used.

getBackgroundFillDirection

public int getBackgroundFillDirection()
Gets the current filling direction.

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.

setShadow

public void setShadow(boolean value)
Sets whether shadows should be used while drawing the chart.
Parameters:
value - true is shadows are used; false otherwise.

getShadow

public boolean getShadow()
Returns true if shadows are used.

setDisplayValues

public void setDisplayValues(boolean value)
Sets whether values should be displayed on the edge of the grid.
Parameters:
value - true if the values are displayed; false otherwise.

getDisplayValues

public boolean getDisplayValues()
Returns true is values are displayed.

setChartShadow

public void setChartShadow(boolean value)
Sets whether the whole chart has shadow.
Parameters:
value - true if the chart has shadow; false otherwise.

getChartShadow

public boolean getChartShadow()
Returns true if the chart has shadow.

setChartOutline

public void setChartOutline(boolean value)
Sets whether the rectangle bounding the chart is visible.
Parameters:
value - true if the rectangle is visible; false otherwise.

getChartOutline

public boolean getChartOutline()
Returns true if the rectangle bounding the chart is visible.

setTransparencyLevel

public void setTransparencyLevel(int value)
Sets the transparency level from 0 (opaque) to 100.
Parameters:
value - the transparency level.

getTransparencyLevel

public int getTransparencyLevel()
Returns the transparency level.

setTypeOfChart

public void setTypeOfChart(int value)
Sets the type of chart that should be displayed. Predefined constants can be used to select the type or the following values:
Parameters:
type - the type of chart.

getTypeOfChart

public int getTypeOfChart()
Gets the type of chart displayed on the screen.

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.

setSpace

public void setSpace(int value)
Sets the space in pixels between sets of multiple series charts.
Parameters:
value - the space in pixels.

getSpace

public int getSpace()
Gets the space in pixels between sets of multiple series charts.

setBorderSpace

public void setBorderSpace(int value)
Sets the border in pixels of the chart.
Parameters:
value - the border in pixels.

getBorderSpace

public int getBorderSpace()
Gets the current border in pixels.

setInteractive

public void setInteractive(boolean value)
Sets whether the program should respond to users's mouse clicks or not. This is usefull to protect a certain layout of the elements of the chart.
Parameters:
value - true if the program will respond to mouse clicks; false otherwise.

getInteractive

public boolean getInteractive()
Returns true if the program responds to mouse clicks.

setBackground

public void setBackground(Color color)
Sets the background color.
Overrides:
setBackground in class Component

getBackground

public Color getBackground()
Gets the background color.
Overrides:
getBackground in class Component

setShadowColor

public void setShadowColor(Color color)
Sets the shadow color.

getShadowColor

public Color getShadowColor()
Gets the shadow color.

setChartBackground

public void setChartBackground(Color color)
Sets the chart's background color.

getChartBackground

public Color getChartBackground()
Gets the chart's backgound color.

setFont

public void setFont(Font font)
Sets the current font.
Overrides:
setFont in class Component
Parameters:
font - the font to be used.

getFont

public Font getFont()
Gets the current font.
Overrides:
getFont in class Component

setForeground

public void setForeground(Color color)
Sets the foreground color.
Overrides:
setForeground in class Component
Parameters:
color - the color to be used.

getForeground

public Color getForeground()
Gets the current foreground color.
Overrides:
getForeground in class Component

setGridColor

public void setGridColor(Color color)
Sets the grid color.
Parameters:
color - the color to be used.

getGridColor

public Color getGridColor()
Gets the grid color.

setGridThickness

public void setGridThickness(float value)
Sets the space between the grid lines.
Parameters:
value - the space between the grid lines.

getGridThickness

public float getGridThickness()
Gets the space between the grid lines.

setDisplayGrid

public void setDisplayGrid(boolean value)
Sets whether a grid should be displayed.
Parameters:
true - if a grid is displayed; false otherwise.

getDisplayGrid

public boolean getDisplayGrid()
Returns true if a grid is displayed.

setFillBottom

public void setFillBottom(boolean value)
Sets whether the bottom base of the chart is filled with a solid color.
Parameters:
value - true if the base is filled; false otherwise.

getFillBottom

public boolean getFillBottom()
Returns true if the bottom base is filled with a solid color.

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

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