|
From: <nat...@us...> - 2003-08-14 00:34:17
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/demo/swing
In directory sc8-pr-cvs1:/tmp/cvs-serv14177
Modified Files:
SwingDemo.java
Log Message:
made so repaints chart when component resizes
Index: SwingDemo.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/demo/swing/SwingDemo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SwingDemo.java 15 Jun 2003 14:29:07 -0000 1.1
--- SwingDemo.java 14 Aug 2003 00:26:21 -0000 1.2
***************
*** 59,62 ****
--- 59,66 ----
private JPanel panel;
+ private PieChart2DProperties pieChart2DProperties;
+ private LegendProperties legendProperties;
+ private ChartProperties chartProperties;
+
/*******************************************************************************
***************
*** 72,76 ****
*
********************************************************************************/
! private void initComponents() throws ChartDataException, PropertyException
{
this.setSize( 500, 500 );
--- 76,80 ----
*
********************************************************************************/
! private void initComponents()
{
this.setSize( 500, 500 );
***************
*** 78,94 ****
this.panel.setSize( 500, 500 );
this.getContentPane().add( this.panel );
- this.setVisible( true );
-
- String[] labels = {"BMW", "Audi", "Lexus"};
- String title = "Cars that Own";
- Paint[] paints = {Color.blue, Color.gray, Color.red};
- double[] data = {50d, 30d, 20d};
! PieChart2DProperties pieChart2DProperties = new PieChart2DProperties();
! PieChartDataSet pieChartDataSet = new PieChartDataSet( title, data, labels, paints, pieChart2DProperties );
! PieChart2D pieChart2D = new PieChart2D( pieChartDataSet, new LegendProperties(), new ChartProperties(), 450, 450 );
! pieChart2D.setGraphics2D( (Graphics2D) this.panel.getGraphics() );
! pieChart2D.render();
addWindowListener( new java.awt.event.WindowAdapter()
--- 82,91 ----
this.panel.setSize( 500, 500 );
this.getContentPane().add( this.panel );
! this.pieChart2DProperties = new PieChart2DProperties();
! this.legendProperties= new LegendProperties();
! this.chartProperties= new ChartProperties();
! this.setVisible( true );
addWindowListener( new java.awt.event.WindowAdapter()
***************
*** 104,111 ****
/*********************************************************************************
* Exit the Application
*
* @param windowEvent
! ***********************************************************************************/
private void exitForm( WindowEvent windowEvent )
{
--- 101,143 ----
/*********************************************************************************
+ *
+ * @param graphics
+ ********************************************************************************/
+ public void paint( Graphics graphics )
+ {
+ try {
+ String[] labels = {"BMW", "Audi", "Lexus"};
+ String title = "Cars that Own";
+ Paint[] paints = {Color.blue, Color.gray, Color.red};
+ double[] data = {50d, 30d, 20d};
+ PieChartDataSet pieChartDataSet = new PieChartDataSet( title,
+ data,
+ labels,
+ paints,
+ this.pieChart2DProperties );
+
+ Dimension dimension= this.panel.getSize();
+ PieChart2D pieChart2D = new PieChart2D( pieChartDataSet,
+ this.legendProperties,
+ this.chartProperties,
+ (int) dimension.getWidth(),
+ (int) dimension.getHeight() );
+ pieChart2D.setGraphics2D( (Graphics2D) this.panel.getGraphics() );
+ pieChart2D.render();
+ }
+ catch( ChartDataException chartDataException ) {
+ chartDataException.printStackTrace();
+ }
+ catch( PropertyException propertyException ) {
+ propertyException.printStackTrace();
+ }
+ }
+
+
+ /*******************************************************************************
* Exit the Application
*
* @param windowEvent
! ******************************************************************************/
private void exitForm( WindowEvent windowEvent )
{
***************
*** 114,120 ****
! /*********************************************************************************
*
! ***********************************************************************************/
public static void main( String args[] ) throws ChartDataException, PropertyException
{
--- 146,152 ----
! /******************************************************************************
*
! ******************************************************************************/
public static void main( String args[] ) throws ChartDataException, PropertyException
{
|