1 23 24 package de.progra.charting.render; 25 26 import java.awt.Rectangle ; 27 import de.progra.charting.CoordSystem; 28 import java.awt.geom.AffineTransform ; 29 import java.awt.Shape ; 30 import de.progra.charting.PointToPixelTranslator; 31 import java.awt.Graphics2D ; 32 import java.awt.Dimension ; 33 import de.progra.charting.model.ChartDataModel; 34 35 40 public abstract class AbstractChartRenderer implements Renderer { 41 42 protected Rectangle bounds; 43 44 protected CoordSystem coord; 45 46 protected PointToPixelTranslator p; 47 48 protected ChartDataModel model; 49 50 protected RowColorModel rcm; 51 52 55 protected AbstractChartRenderer(ChartDataModel model) { 56 this.model = model; 57 } 58 59 68 public AbstractChartRenderer(PointToPixelTranslator p, ChartDataModel model) { 69 this(model); 70 this.p = p; 71 } 72 73 79 public AbstractChartRenderer(CoordSystem cs, 80 ChartDataModel model) { 81 this(model); 82 this.coord = cs; 83 } 84 85 90 public Rectangle getBounds() { 91 return bounds; 92 } 93 94 97 public Dimension getPreferredSize() { 98 return new Dimension (Integer.MIN_VALUE, Integer.MIN_VALUE); 99 } 100 101 107 public void render(Graphics2D g) { 108 Rectangle bounds = getBounds(); 109 Shape clip = g.getClip(); 110 g.setClip((int)bounds.getX(), (int)bounds.getY(), (int)bounds.getWidth(), (int)bounds.getHeight()); 111 renderChart(g); 112 g.setClip(clip); 113 } 114 115 116 public abstract void renderChart(Graphics2D g); 117 118 123 public void setBounds(Rectangle bounds) { 124 this.bounds = bounds; 125 } 126 127 130 public void setChartDataModel(ChartDataModel model) { 131 this.model = model; 132 } 133 134 137 public ChartDataModel getChartDataModel() { 138 return model; 139 } 140 141 145 public void setPointToPixelTranslator(PointToPixelTranslator p) { 146 this.p = p; 147 } 148 149 153 public PointToPixelTranslator getPointToPixelTranslator() { 154 return p; 155 } 156 157 158 public CoordSystem getCoordSystem() { 159 return coord; 160 } 161 162 166 public void setCoordSystem(CoordSystem cs) { 167 coord = cs; 168 } 169 170 173 public AffineTransform getTransform(int axis) { 174 return getCoordSystem().getTransform(axis); 175 } 176 177 180 public void setRowColorModel(RowColorModel rcm) { 181 this.rcm = rcm; 182 } 183 184 187 public RowColorModel getRowColorModel() { 188 return rcm; 189 } 190 } 191 | Popular Tags |