com.java4less.rchart.swt
Class ChartViewer

java.lang.Object
  |
  +--Composite
        |
        +--com.java4less.rchart.swt.ChartViewer

public class ChartViewer
extends Composite

This class is a SWT control which can be added to any SWT Control or window. The viewer implements the following features: 
- It displays the chart you set with the setChart() method.
- It implements scroll bars and zoom in/out buttons. 
- It can automatically change the cursor when the pointer moves over a value in the chart.
 
The following is a very simple SWT java program which uses the chart viewer:

Display display = new Display();
// set Rchart SWT mode
GraphicsProvider.setMode(GraphicsProvider.MODE_SWT); 
SwtGraphicsProvider.setDefaultDisplay(display);


Shell shell = new Shell(display);
shell.setSize(300,300);
shell.setBounds(100,100,400,400);

// create chart
ChartLoader cloader=new ChartLoader();
cloader.loadFromFile("areaChart.txt",false); // load chart parameters from file
Chart chart=cloader.build(false,false);

// create chart viewer and set the chart
ChartViewer chartViewer=new ChartViewer(shell,SWT.NONE);
chartViewer.setBounds(0,0,400,400); 
chartViewer.setChart(chart);

shell.open();


while(!shell.isDisposed())
if(!display.readAndDispatch())
display.sleep();
display.dispose();
chart.dispose();

See Also:
Serialized Form

Field Summary
 boolean allowZoom
          if TRUE the +/- zoom buttons will be made visible.
 boolean changePointer
          change mouse pointer when we are over a point
 int currentZoom
          current value of zoom (initial value is 100)
 int maxZoom
          maximum zoom in %.
 int minZoom
          minimum zoom in %.
 int zoomIncrement
          zoom increment in % for the +/- buttons.
 
Constructor Summary
ChartViewer(Composite parent, int style)
           
 
Method Summary
 void dispose()
          dispose control
 Chart getChart()
          get chart to display
 void redrawChart()
          force the chart to be repainted
 void setChart(Chart c)
          set chart to display
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allowZoom

public boolean allowZoom
if TRUE the +/- zoom buttons will be made visible.


maxZoom

public int maxZoom
maximum zoom in %. The default is 300.


minZoom

public int minZoom
minimum zoom in %. The default is 50.


currentZoom

public int currentZoom
current value of zoom (initial value is 100)


zoomIncrement

public int zoomIncrement
zoom increment in % for the +/- buttons. The default is 25.


changePointer

public boolean changePointer
change mouse pointer when we are over a point

Constructor Detail

ChartViewer

public ChartViewer(Composite parent,
                   int style)
Method Detail

getChart

public Chart getChart()
get chart to display

Returns:

setChart

public void setChart(Chart c)
set chart to display

Parameters:
c -

dispose

public void dispose()
dispose control


redrawChart

public void redrawChart()
force the chart to be repainted