1 23 24 package de.progra.charting.swing; 25 26 import javax.swing.JPanel ; 27 import de.progra.charting.render.AbstractChartRenderer; 28 import de.progra.charting.event.*; 29 import de.progra.charting.Chart; 30 import de.progra.charting.Legend; 31 import de.progra.charting.Title; 32 import de.progra.charting.CoordSystem; 33 import de.progra.charting.DefaultChart; 34 import java.awt.geom.Rectangle2D ; 35 import java.awt.Rectangle ; 36 import java.awt.Graphics ; 37 import java.awt.Graphics2D ; 38 import java.awt.Dimension ; 39 import java.util.Map ; 40 import de.progra.charting.model.ChartDataModel; 41 42 50 public class ChartPanel extends JPanel implements Chart { 51 52 53 DefaultChart chart; 54 55 56 private ChartPanel() { 57 } 58 59 64 public ChartPanel(ChartDataModel model, String title) { 65 this(); 66 chart = new DefaultChart(model, title); 67 } 68 69 75 public ChartPanel(ChartDataModel model, String title, int coord) { 76 this(); 77 chart = new DefaultChart(model, title, coord); 78 } 79 80 82 private void initComponents() { 84 setLayout(new java.awt.BorderLayout ()); 85 86 } 88 92 public void addChartRenderer(AbstractChartRenderer renderer, int z) { 93 chart.addChartRenderer(renderer, z); 94 } 95 96 99 public Rectangle getBounds() { 100 return chart.getBounds(); 101 } 102 103 106 public ChartDataModel getChartDataModel() { 107 return chart.getChartDataModel(); 108 } 109 110 113 public Map getChartRenderer() { 114 return chart.getChartRenderer(); 115 } 116 117 121 public AbstractChartRenderer getChartRenderer(int z) { 122 return chart.getChartRenderer(z); 123 } 124 125 128 public CoordSystem getCoordSystem() { 129 return chart.getCoordSystem(); 130 } 131 132 135 public Legend getLegend() { 136 return chart.getLegend(); 137 } 138 139 142 public Title getTitle() { 143 return chart.getTitle(); 144 } 145 146 149 public void setBounds(Rectangle r) { 150 chart.setBounds(r); 151 } 152 153 156 public void setChartDataModel(ChartDataModel model) { 157 chart.setChartDataModel(model); 158 } 159 160 164 public void setChartRenderer(Map renderer) { 165 chart.setChartRenderer(renderer); 166 } 167 168 174 public void setCoordSystem(CoordSystem c) { 175 chart.setCoordSystem(c); 176 } 177 178 181 public void setLegend(Legend l) { 182 chart.setLegend(l); 183 } 184 185 188 public void setTitle(Title t) { 189 chart.setTitle(t); 190 } 191 192 195 public Dimension getPreferredSize() { 196 return new java.awt.Dimension (Integer.MAX_VALUE, Integer.MAX_VALUE); 197 } 198 199 202 public void paint(Graphics graphics) { 203 chart.setBounds(new Rectangle (this.getWidth(), this.getHeight())); 204 chart.render((Graphics2D )graphics); 205 } 206 207 212 public void render(Graphics2D g) { 213 paint(g); 214 } 215 216 219 220 } 221 | Popular Tags |