net.comrom.chart
Class Chart

java.lang.Object
  extended bynet.comrom.chart.Chart

public class Chart
extends java.lang.Object

Main class . The Chart class calculates the position and size of all the components and calls the draw method of them as required. Example of use: // data double[] d1={1,2,3,4,5,4,2}; BarDataSerie data1= new BarDataSerie(d1,new FillStyle(GraphicsProvider.getColor(ChartColor.CYAN))); data1.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL); //data1.borderType=BarDataSerie.BORDER_RAISED; data1.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL); data1.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10); double[] d2={-2,3,4,4.2,6.4,4.5,6.1}; BarDataSerie data2= new BarDataSerie(d2,new FillStyle(GraphicsProvider.getColor(ChartColor.GREEN))); data2.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10); data2.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL); data2.negativeStyle=new FillStyle(GraphicsProvider.getColor(ChartColor.RED)); Legend l=new Legend(); l.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL); l.addItem("Company A",new FillStyle(GraphicsProvider.getColor(ChartColor.CYAN))); l.addItem("Company B",new FillStyle(GraphicsProvider.getColor(ChartColor.GREEN))); // create title Title title=new Title("Benefits companies A & B"); // create axis Axis XAxis=new Axis(Axis.HORIZONTAL,new Scale()); Axis YAxis=new Axis(Axis.VERTICAL,new Scale()); XAxis.tickAtBase=true; // draw also first tick XAxis.scale.min=-3; XAxis.scale.max=7; YAxis.scale.min=0; YAxis.scale.max=7; YAxis.IntegerScale=true; YAxis.scaleTickInterval=1; XAxis.scaleTickInterval=1; XAxis.gridStyle=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_DOTS); YAxis.gridStyle=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_DOTS); String[] lbls={"1998","1999","2000","2001","2002","2003","2004","2005"}; YAxis.tickLabels=lbls; HAxisLabel XLabel= new HAxisLabel("million $",GraphicsProvider.getColor(ChartColor.BLACK),GraphicsProvider.getFont("Arial",ChartFont.BOLD,12)); VAxisLabel YLabel= new VAxisLabel("Year",GraphicsProvider.getColor(ChartColor.BLACK),GraphicsProvider.getFont("Arial",ChartFont.BOLD,12)); // plotter BarPlotter plot=new BarPlotter(); plot.verticalBars=false; plot.interBarSpace=0; // create chart Chart chart=new Chart(title,plot,XAxis,YAxis); chart.XLabel=XLabel; chart.YLabel=YLabel; chart.legend=l; chart.addSerie(data2); chart.addSerie(data1); chart.back=new FillStyle(GraphicsProvider.getColor(ChartColor.LIGHTGRAY)); chart.saveToFile("chart.gif","GIF");


Field Summary
 boolean activateSelection
          if true the selectedSerie and selectedSeriePoint will get a value of the point, bar or item the cursor is on
 boolean autoRebuild
           
 boolean autoSize
          if true (default) the position and size of the components will be calculated automatically
 double axisMargin
           
 FillStyle back
          background of the chart.
 ChartImage backImage
           
 LineStyle border
          border of the chart.
 double bottomMargin
          area reserved for the x axis.
 double currentValueX
          position of the cursor.
 double currentValueY
          position of the cursor.
 double currentValueY2
          position of the cursor.
 int currentX
          position of the cursor.
 int currentY
          position of the cursor.
static int dnum
           
 boolean doubleBuffering
          use double buffering for creating the chart?
 boolean fullXAxis
           
 java.lang.String htmlLinkTarget
          target of the html links when creating a html image map
 int layout
          position of the legend in the chart.
static int LAYOUT_LEGEND_BOTTOM
           
static int LAYOUT_LEGEND_RIGHT
           
static int LAYOUT_LEGEND_TOP
           
 double leftMargin
          area reserved for the y axis.
 Legend legend
          legend of the chart
 double legendMargin
          area reserved for the legend.
 ChartLoader loader
           
 long msecs
           
static java.lang.String numberLocale
          locale used for decimal number formatting
 int offsetX
          used by th chart viewer only for scroll functions
 int offsetY
          used by th chart viewer only for scroll functions
 Plotter[] plotters
          array of plotter
 java.lang.String reloadFrom
          url where the chart should be reloaded from
 boolean repaintAll
          force the paint to be repainted
 boolean repaintAlways
           
 double rightMargin
          empty area to the right side of the chrta if the legend is on the top or the bottom
 double secondYAxisMargin
           
 ChartLabel selectedLabel
          holds the selected chartlabel
 DataSerie selectedSerie
          holds the DataSerie of the selected point
 int selectedSeriePoint
           
 boolean showPosition
          show position of cursor (only if used inside an applet)
 boolean showTips
          show tips
 Title title
          title of the chart
 double topMargin
          area reserved for the title.
 int virtualHeight
          height of the chart (in pixels).
 int virtualWidth
          Width of the chart (in pixels).
 boolean withScroll
           
 Axis XAxis
          X axis of the chart
 HAxisLabel XLabel
          X axis of the chart
 Axis Y2Axis
           
 VAxisLabel Y2Label
           
 Axis YAxis
           
 VAxisLabel YLabel
           
 
Constructor Summary
Chart(Title t, Plotter p, Axis X, Axis Y)
           
 
Method Summary
 void addChartListener(ChartListener cl)
           
 void addNote(java.lang.String note)
           
 void addPlotter(Plotter p)
           
 void addSerie(DataSerie s)
           
 void addTargetZone(TargetZone zone)
           
 void dispose()
           
 int getHeight()
           
 java.lang.String getHTMLImageMap(java.lang.String name)
           
 TargetZone[] getTargetZones()
           
 int getWidth()
           
 void mouseClick()
           
 void mouseMoved(int eX, int eY)
           
 void paint(ChartGraphics pg)
           
 void removeAllChartListener()
           
 void removeChartListener(ChartListener cl)
           
 void removeNotes()
           
 void removePlotters()
           
 void removeTargetZones()
           
 void saveToFile(java.io.OutputStream os, java.lang.String psFormat)
           
 void saveToFile(java.lang.String psFile, java.lang.String psFormat)
           
 void setHeight(int h)
           
 void setMinimumSize(int w, int h)
           
 void setSize(int w, int h)
           
 void setWidth(int w)
           
 void setY2Scale(Axis a)
           
 void startUpdater()
           
 void stopUpdater()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT_LEGEND_RIGHT

public static final int LAYOUT_LEGEND_RIGHT
See Also:
Constant Field Values

LAYOUT_LEGEND_TOP

public static final int LAYOUT_LEGEND_TOP
See Also:
Constant Field Values

LAYOUT_LEGEND_BOTTOM

public static final int LAYOUT_LEGEND_BOTTOM
See Also:
Constant Field Values

dnum

public static final int dnum
See Also:
Constant Field Values

numberLocale

public static java.lang.String numberLocale
locale used for decimal number formatting


YLabel

public VAxisLabel YLabel

Y2Label

public VAxisLabel Y2Label

XLabel

public HAxisLabel XLabel
X axis of the chart


legend

public Legend legend
legend of the chart


XAxis

public Axis XAxis
X axis of the chart


YAxis

public Axis YAxis

Y2Axis

public Axis Y2Axis

title

public Title title
title of the chart


bottomMargin

public double bottomMargin
area reserved for the x axis.


topMargin

public double topMargin
area reserved for the title.


secondYAxisMargin

public double secondYAxisMargin

leftMargin

public double leftMargin
area reserved for the y axis.


rightMargin

public double rightMargin
empty area to the right side of the chrta if the legend is on the top or the bottom


legendMargin

public double legendMargin
area reserved for the legend.


axisMargin

public double axisMargin

autoSize

public boolean autoSize
if true (default) the position and size of the components will be calculated automatically


plotters

public Plotter[] plotters
array of plotter


layout

public int layout
position of the legend in the chart.


back

public FillStyle back
background of the chart.


border

public LineStyle border
border of the chart.


offsetX

public int offsetX
used by th chart viewer only for scroll functions


offsetY

public int offsetY
used by th chart viewer only for scroll functions


backImage

public ChartImage backImage

doubleBuffering

public boolean doubleBuffering
use double buffering for creating the chart?


virtualWidth

public int virtualWidth
Width of the chart (in pixels).


virtualHeight

public int virtualHeight
height of the chart (in pixels).


withScroll

public boolean withScroll

repaintAll

public boolean repaintAll
force the paint to be repainted


repaintAlways

public boolean repaintAlways

fullXAxis

public boolean fullXAxis

selectedLabel

public ChartLabel selectedLabel
holds the selected chartlabel


selectedSerie

public DataSerie selectedSerie
holds the DataSerie of the selected point


selectedSeriePoint

public int selectedSeriePoint

activateSelection

public boolean activateSelection
if true the selectedSerie and selectedSeriePoint will get a value of the point, bar or item the cursor is on


currentX

public int currentX
position of the cursor.


currentY

public int currentY
position of the cursor.


currentValueX

public double currentValueX
position of the cursor.


currentValueY

public double currentValueY
position of the cursor.


currentValueY2

public double currentValueY2
position of the cursor.


htmlLinkTarget

public java.lang.String htmlLinkTarget
target of the html links when creating a html image map


showTips

public boolean showTips
show tips


showPosition

public boolean showPosition
show position of cursor (only if used inside an applet)


loader

public ChartLoader loader

msecs

public long msecs

reloadFrom

public java.lang.String reloadFrom
url where the chart should be reloaded from


autoRebuild

public boolean autoRebuild
Constructor Detail

Chart

public Chart(Title t,
             Plotter p,
             Axis X,
             Axis Y)
Parameters:
t -
p -
X -
Y -
creates a chart for the specified components.
Method Detail

getWidth

public int getWidth()

getHeight

public int getHeight()

setMinimumSize

public void setMinimumSize(int w,
                           int h)

setSize

public void setSize(int w,
                    int h)

addTargetZone

public void addTargetZone(TargetZone zone)

removeTargetZones

public void removeTargetZones()

addNote

public void addNote(java.lang.String note)

removeNotes

public void removeNotes()

getTargetZones

public TargetZone[] getTargetZones()

setWidth

public void setWidth(int w)

setHeight

public void setHeight(int h)

addChartListener

public void addChartListener(ChartListener cl)

removeChartListener

public void removeChartListener(ChartListener cl)

removeAllChartListener

public void removeAllChartListener()

addPlotter

public void addPlotter(Plotter p)

removePlotters

public void removePlotters()

setY2Scale

public void setY2Scale(Axis a)

paint

public void paint(ChartGraphics pg)

addSerie

public void addSerie(DataSerie s)
Parameters:
s -
adds a serie to the plotter (the one used in the constructor).

dispose

public void dispose()

saveToFile

public void saveToFile(java.io.OutputStream os,
                       java.lang.String psFormat)
                throws java.lang.Exception
Throws:
java.lang.Exception

saveToFile

public void saveToFile(java.lang.String psFile,
                       java.lang.String psFormat)
                throws java.lang.Exception
Throws:
java.lang.Exception

mouseClick

public void mouseClick()

mouseMoved

public void mouseMoved(int eX,
                       int eY)

startUpdater

public void startUpdater()

stopUpdater

public void stopUpdater()

getHTMLImageMap

public java.lang.String getHTMLImageMap(java.lang.String name)