1 44 45 package org.jfree.chart.needle; 46 47 import java.awt.Graphics2D ; 48 import java.awt.geom.Arc2D ; 49 import java.awt.geom.Area ; 50 import java.awt.geom.Point2D ; 51 import java.awt.geom.Rectangle2D ; 52 import java.io.Serializable ; 53 54 59 public class PlumNeedle extends MeterNeedle implements Serializable { 60 61 62 private static final long serialVersionUID = -3082660488660600718L; 63 64 72 protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 73 Point2D rotate, double angle) { 74 75 Arc2D shape = new Arc2D.Double (Arc2D.PIE); 76 double radius = plotArea.getHeight(); 77 double halfX = plotArea.getWidth() / 2; 78 double diameter = 2 * radius; 79 80 shape.setFrame(plotArea.getMinX() + halfX - radius , 81 plotArea.getMinY() - radius, 82 diameter, diameter); 83 radius = Math.toDegrees(Math.asin(halfX / radius)); 84 shape.setAngleStart(270 - radius); 85 shape.setAngleExtent(2 * radius); 86 87 Area s = new Area (shape); 88 89 if ((rotate != null) && (angle != 0)) { 90 getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); 92 s.transform(getTransform()); 93 } 94 95 defaultDisplay(g2, s); 96 } 97 98 105 public boolean equals(Object object) { 106 if (object == null) { 107 return false; 108 } 109 if (object == this) { 110 return true; 111 } 112 if (super.equals(object) && object instanceof PlumNeedle) { 113 return true; 114 } 115 return false; 116 } 117 118 } 119 | Popular Tags |