|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.java4less.rchart.Chart
Main class of RChart. 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
rebuild the chart (using the ChartLoader) automatically when the chart is updated using the updater thread? |
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
loader using to create the chart and/or update it automatically |
long |
msecs
reload the chart every x secodns |
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 if the chart |
java.lang.String |
reloadFrom
url where the chart should be reloaded from |
boolean |
repaintAll
force the paint to be repainted |
boolean |
repaintAlways
replaint the chart each time the paint() method is called? |
double |
rightMargin
empty area to the right side of the chrta if the legend is on the top or the bottom |
double |
secondYAxisMargin
margin reserved for the right Y axis |
ChartLabel |
selectedLabel
holds the selected chartlabel |
DataSerie |
selectedSerie
holds the DataSerie of the selected point |
int |
selectedSeriePoint
returns which point/bar/item of the serie the cursor is on or -1. |
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
used by the chart viewers to enable scroll |
Axis |
XAxis
X axis of the chart |
HAxisLabel |
XLabel
Label to be displayed along the X axis. |
Axis |
Y2Axis
second Y axis of the chart |
VAxisLabel |
Y2Label
Label to be displayed along the second Y axis. |
Axis |
YAxis
Y axis of the chart |
VAxisLabel |
YLabel
Label to be displayed along the Y axis. |
Constructor Summary | |
Chart(Title t,
Plotter p,
Axis X,
Axis Y)
creates a chart for the specified components. |
Method Summary | |
void |
addChartListener(ChartListener cl)
add a chart listener |
void |
addNote(java.lang.String note)
add new note |
void |
addPlotter(Plotter p)
adds an additional plotter to the chart. |
void |
addSerie(DataSerie s)
adds a serie to the plotter (the one used in the constructor). |
void |
addTargetZone(TargetZone zone)
add new targe zone |
void |
dispose()
release resources used by the chart (only required for SWT) |
int |
getHeight()
height of the component |
java.lang.String |
getHTMLImageMap(java.lang.String name)
get HTML image map code. |
TargetZone[] |
getTargetZones()
get list of all target zones |
int |
getWidth()
width of the component |
void |
mouseClick()
let rchart know the mouse has been clicked (this is normally called by the chartviewer) |
void |
mouseMoved(int eX,
int eY)
mouse has moved above the chart, notify new position. |
void |
paint(ChartGraphics pg)
paint chart on the given graphic context |
void |
removeAllChartListener()
remove all listeners |
void |
removeChartListener(ChartListener cl)
remove a chart listener |
void |
removeNotes()
delete all notes |
void |
removePlotters()
remove all plotters |
void |
removeTargetZones()
delete all target zones |
void |
saveToFile(java.io.OutputStream os,
java.lang.String psFormat)
Saves the current chart to an output stream If you use AWT the format can be "GIF", "PNG" or "JPEG". |
void |
saveToFile(java.lang.String psFile,
java.lang.String psFormat)
Saves the current chart to a graphics file. |
void |
setHeight(int h)
height of the component |
void |
setMinimumSize(int w,
int h)
set minimum size of the chart |
void |
setSize(int w,
int h)
set size of the chart |
void |
setWidth(int w)
width of the component |
void |
setY2Scale(Axis a)
Sets the second Y axis of the chart. |
void |
startUpdater()
start realtime/automatic chart updates |
void |
stopUpdater()
stop realtime/automatic updating |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LAYOUT_LEGEND_RIGHT
public static final int LAYOUT_LEGEND_TOP
public static final int LAYOUT_LEGEND_BOTTOM
public static final int dnum
public static java.lang.String numberLocale
public VAxisLabel YLabel
public VAxisLabel Y2Label
public HAxisLabel XLabel
public Legend legend
public Axis XAxis
public Axis YAxis
public Axis Y2Axis
public Title title
public double bottomMargin
public double topMargin
public double secondYAxisMargin
public double leftMargin
public double rightMargin
public double legendMargin
public double axisMargin
public boolean autoSize
public Plotter[] plotters
public int layout
public FillStyle back
public LineStyle border
public int offsetX
public int offsetY
public ChartImage backImage
public boolean doubleBuffering
public int virtualWidth
public int virtualHeight
public boolean withScroll
public boolean repaintAll
public boolean repaintAlways
public boolean fullXAxis
public ChartLabel selectedLabel
public DataSerie selectedSerie
public int selectedSeriePoint
public boolean activateSelection
public int currentX
public int currentY
public double currentValueX
public double currentValueY
public double currentValueY2
public java.lang.String htmlLinkTarget
public boolean showTips
public boolean showPosition
public ChartLoader loader
public long msecs
public java.lang.String reloadFrom
public boolean autoRebuild
Constructor Detail |
public Chart(Title t, Plotter p, Axis X, Axis Y)
t
- titlep
- plotterX
- axisY
- axisMethod Detail |
public int getWidth()
public int getHeight()
public void setMinimumSize(int w, int h)
w
- widthh
- heightpublic void setSize(int w, int h)
w
- widthh
- heightpublic void addTargetZone(TargetZone zone)
zone
- public void removeTargetZones()
public void addNote(java.lang.String note)
note
- public void removeNotes()
public TargetZone[] getTargetZones()
public void setWidth(int w)
public void setHeight(int h)
public void addChartListener(ChartListener cl)
cl
- public void removeChartListener(ChartListener cl)
cl
- public void removeAllChartListener()
public void addPlotter(Plotter p)
p
- plotterpublic void removePlotters()
public void setY2Scale(Axis a)
public void paint(ChartGraphics pg)
pg
- graphic contextpublic void addSerie(DataSerie s)
s
- seriespublic void dispose()
public void saveToFile(java.io.OutputStream os, java.lang.String psFormat) throws java.lang.Exception
os
- output streampsFormat
- file format
java.lang.Exception
public void saveToFile(java.lang.String psFile, java.lang.String psFormat) throws java.lang.Exception
psFile
- output filepsFormat
- file format
java.lang.Exception
public void mouseClick()
public void mouseMoved(int eX, int eY)
eX
- new x positioneY
- new Y positionpublic void startUpdater()
public void stopUpdater()
public java.lang.String getHTMLImageMap(java.lang.String name)
name
- name of the image map
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |