1 43 44 package org.jfree.chart.renderer; 45 46 import java.awt.geom.Point2D ; 47 48 55 public class Outlier implements Comparable { 56 57 60 private Point2D point; 61 62 63 private double radius; 64 65 73 public Outlier(double xCoord, double yCoord, double radius) { 74 this.point = new Point2D.Double (xCoord - radius, yCoord - radius); 75 this.radius = radius; 76 } 77 78 84 public Point2D getPoint() { 85 return this.point; 86 } 87 88 94 public void setPoint(Point2D point) { 95 this.point = point; 96 } 97 98 104 public double getX() { 105 return getPoint().getX(); 106 } 107 108 114 public double getY() { 115 return getPoint().getY(); 116 } 117 118 123 public double getRadius() { 124 return this.radius; 125 } 126 127 132 public void setRadius(double radius) { 133 this.radius = radius; 134 } 135 136 145 public int compareTo(Object o) { 146 Outlier outlier = (Outlier) o; 147 Point2D p1 = getPoint(); 148 Point2D p2 = outlier.getPoint(); 149 if (p1.equals(p2)) { 150 return 0; 151 } 152 else if ((p1.getX() < p2.getX()) || (p1.getY() < p2.getY())) { 153 return -1; 154 } 155 else { 156 return 1; 157 } 158 } 159 160 170 public boolean overlaps(Outlier other) { 171 return ((other.getX() >= getX() - (this.radius * 1.1)) 172 && (other.getX() <= getX() + (this.radius * 1.1)) 173 && (other.getY() >= getY() - (this.radius * 1.1)) 174 && (other.getY() <= getY() + (this.radius * 1.1))); 175 } 176 177 182 public String toString() { 183 return "{" + getX() + "," + getY() + "}"; 184 } 185 186 } 187 | Popular Tags |