1 44 45 package org.jfree.chart.needle; 46 47 import java.awt.Graphics2D ; 48 import java.awt.geom.Area ; 49 import java.awt.geom.Ellipse2D ; 50 import java.awt.geom.GeneralPath ; 51 import java.awt.geom.Point2D ; 52 import java.awt.geom.Rectangle2D ; 53 import java.io.Serializable ; 54 55 60 public class PinNeedle extends MeterNeedle implements Serializable { 61 62 63 private static final long serialVersionUID = -3787089953079863373L; 64 65 73 protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 74 Point2D rotate, double angle) { 75 76 Area shape; 77 GeneralPath pointer = new GeneralPath (); 78 79 int minY = (int) (plotArea.getMinY()); 80 int maxY = (int) (plotArea.getMaxY()); 82 int midX = (int) (plotArea.getMinX() + (plotArea.getWidth() / 2)); 83 int lenX = (int) (plotArea.getWidth() / 10); 85 if (lenX < 2) { 86 lenX = 2; 87 } 88 89 pointer.moveTo(midX - lenX, maxY - lenX); 90 pointer.lineTo(midX + lenX, maxY - lenX); 91 pointer.lineTo(midX, minY + lenX); 92 pointer.closePath(); 93 94 lenX = 4 * lenX; 95 Ellipse2D circle = new Ellipse2D.Double ( 96 midX - lenX / 2, plotArea.getMaxY() - lenX, lenX, lenX 97 ); 98 99 shape = new Area (circle); 100 shape.add(new Area (pointer)); 101 if ((rotate != null) && (angle != 0)) { 102 getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); 104 shape.transform(getTransform()); 105 } 106 107 defaultDisplay(g2, shape); 108 109 } 110 111 118 public boolean equals(Object object) { 119 if (object == null) { 120 return false; 121 } 122 if (object == this) { 123 return true; 124 } 125 if (super.equals(object) && object instanceof PinNeedle) { 126 return true; 127 } 128 return false; 129 } 130 131 } 132 | Popular Tags |