1 43 package org.jfree.chart.renderer; 44 45 import java.awt.geom.Point2D ; 46 import java.util.ArrayList ; 47 import java.util.Iterator ; 48 import java.util.List ; 49 50 66 public class OutlierList { 67 68 69 private List outliers; 70 71 72 private Outlier averagedOutlier; 73 74 78 private boolean multiple = false; 79 80 85 public OutlierList(Outlier outlier) { 86 this.outliers = new ArrayList (); 87 setAveragedOutlier(outlier); 88 } 89 90 97 public boolean add(Outlier outlier) { 98 return this.outliers.add(outlier); 99 } 100 101 106 public int getItemCount() { 107 return this.outliers.size(); 108 } 109 110 115 public Outlier getAveragedOutlier() { 116 return this.averagedOutlier; 117 } 118 119 124 public void setAveragedOutlier(Outlier averagedOutlier) { 125 this.averagedOutlier = averagedOutlier; 126 } 127 128 134 public boolean isMultiple() { 135 return this.multiple; 136 } 137 138 144 public void setMultiple(boolean multiple) { 145 this.multiple = multiple; 146 } 147 148 156 public boolean isOverlapped(Outlier other) { 157 158 if (other == null) { 159 return false; 160 } 161 162 boolean result = other.overlaps(getAveragedOutlier()); 163 return result; 164 165 } 166 167 171 public void updateAveragedOutlier() { 172 double totalXCoords = 0.0; 173 double totalYCoords = 0.0; 174 int size = getItemCount(); 175 for (Iterator iterator = this.outliers.iterator(); 176 iterator.hasNext();) { 177 Outlier o = (Outlier) iterator.next(); 178 totalXCoords += o.getX(); 179 totalYCoords += o.getY(); 180 } 181 getAveragedOutlier().getPoint().setLocation( 182 new Point2D.Double (totalXCoords / size, totalYCoords / size) 183 ); 184 } 185 186 } 187 | Popular Tags |