1 10 11 12 package org.krysalis.jcharts.designer; 13 14 15 16 import org.krysalis.jcharts.Chart; 17 import org.krysalis.jcharts.properties.PropertyException; 18 import org.krysalis.jcharts.chartData.ChartDataException; 19 20 import javax.swing.*; 21 import java.awt.*; 22 23 24 public class ChartPanel extends JPanel { 25 26 private Designer designer; 27 private Chart chart; 28 29 30 34 public ChartPanel( Designer designer ) { 35 super(); 36 37 super.setMinimumSize( new Dimension( 400, 400 ) ); 38 super.setVisible( true ); 39 40 this.designer = designer; 41 } 42 43 44 50 public void setChart( Chart chart, int width, int height ) { 51 this.chart = chart; 52 super.setSize( width, height ); 53 } 55 56 57 61 public void paint( Graphics graphics ) { 62 super.paint( graphics ); 63 64 if( this.chart != null ) { 65 try { 66 this.chart.setGraphics2D( (Graphics2D) graphics ); 67 this.chart.render(); 68 } 69 catch( ChartDataException chartDataException ) { 70 chartDataException.printStackTrace(); 71 } 72 catch( PropertyException propertyException ) { 73 propertyException.printStackTrace(); 74 } 75 } 76 } 77 78 79 } 80 | Popular Tags |