1 43 44 package org.jfree.chart.plot; 45 46 import java.awt.geom.Point2D ; 47 import java.awt.geom.Rectangle2D ; 48 import java.io.IOException ; 49 import java.io.ObjectInputStream ; 50 import java.io.ObjectOutputStream ; 51 import java.io.Serializable ; 52 import java.util.List ; 53 54 import org.jfree.chart.ChartRenderingInfo; 55 import org.jfree.io.SerialUtilities; 56 import org.jfree.util.ObjectUtilities; 57 58 61 public class PlotRenderingInfo implements Cloneable , Serializable { 62 63 64 private static final long serialVersionUID = 8446720134379617220L; 65 66 67 private transient ChartRenderingInfo owner; 68 69 70 private transient Rectangle2D plotArea; 71 72 73 private transient Rectangle2D dataArea; 74 75 78 private List subplotInfo; 79 80 85 public PlotRenderingInfo(ChartRenderingInfo owner) { 86 this.owner = owner; 87 this.dataArea = new Rectangle2D.Double (); 88 this.subplotInfo = new java.util.ArrayList (); 89 } 90 91 96 public ChartRenderingInfo getOwner() { 97 return this.owner; 98 } 99 100 105 public Rectangle2D getPlotArea() { 106 return this.plotArea; 107 } 108 109 114 public void setPlotArea(Rectangle2D area) { 115 this.plotArea = area; 116 } 117 118 123 public Rectangle2D getDataArea() { 124 return this.dataArea; 125 } 126 127 132 public void setDataArea(Rectangle2D area) { 133 this.dataArea = area; 134 } 135 136 141 public int getSubplotCount() { 142 return this.subplotInfo.size(); 143 } 144 145 150 public void addSubplotInfo(PlotRenderingInfo info) { 151 this.subplotInfo.add(info); 152 } 153 154 161 public PlotRenderingInfo getSubplotInfo(int index) { 162 return (PlotRenderingInfo) this.subplotInfo.get(index); 163 } 164 165 176 public int getSubplotIndex(Point2D source) { 177 int subplotCount = getSubplotCount(); 178 for (int i = 0; i < subplotCount; i++) { 179 PlotRenderingInfo info = getSubplotInfo(i); 180 Rectangle2D area = info.getDataArea(); 181 if (area.contains(source)) { 182 return i; 183 } 184 } 185 return -1; 186 } 187 188 195 public boolean equals(Object obj) { 196 if (this == obj) { 197 return true; 198 } 199 if (!(obj instanceof PlotRenderingInfo)) { 200 return false; 201 } 202 PlotRenderingInfo that = (PlotRenderingInfo) obj; 203 if (!ObjectUtilities.equal(this.dataArea, that.dataArea)) { 204 return false; 205 } 206 if (!ObjectUtilities.equal(this.plotArea, that.plotArea)) { 207 return false; 208 } 209 if (!ObjectUtilities.equal(this.subplotInfo, that.subplotInfo)) { 210 return false; 211 } 212 return true; 213 } 214 215 222 public Object clone() throws CloneNotSupportedException { 223 return super.clone(); 224 } 225 226 233 private void writeObject(ObjectOutputStream stream) throws IOException { 234 stream.defaultWriteObject(); 235 SerialUtilities.writeShape(this.dataArea, stream); 236 SerialUtilities.writeShape(this.plotArea, stream); 237 } 238 239 247 private void readObject(ObjectInputStream stream) 248 throws IOException , ClassNotFoundException { 249 stream.defaultReadObject(); 250 this.dataArea = (Rectangle2D ) SerialUtilities.readShape(stream); 251 this.plotArea = (Rectangle2D ) SerialUtilities.readShape(stream); 252 } 253 254 } 255 | Popular Tags |