Frames | No Frames |
1: /* =========================================================== 2: * JFreeChart : a free chart library for the Java(tm) platform 3: * =========================================================== 4: * 5: * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jfreechart/index.html 8: * 9: * This library is free software; you can redistribute it and/or modify it 10: * under the terms of the GNU Lesser General Public License as published by 11: * the Free Software Foundation; either version 2.1 of the License, or 12: * (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but 15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17: * License for more details. 18: * 19: * You should have received a copy of the GNU Lesser General Public 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * --------------- 28: * WindNeedle.java 29: * --------------- 30: * (C) Copyright 2002-2007, by the Australian Antarctic Division and 31: * Contributors. 32: * 33: * Original Author: Bryan Scott (for the Australian Antarctic Division); 34: * Contributor(s): David Gilbert (for Object Refinery Limited); 35: * 36: * Changes: 37: * -------- 38: * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); 39: * 09-Sep-2003 : Added equals() method (DG); 40: * 41: */ 42: 43: package org.jfree.chart.needle; 44: 45: import java.awt.Graphics2D; 46: import java.awt.geom.Point2D; 47: import java.awt.geom.Rectangle2D; 48: import java.io.Serializable; 49: 50: /** 51: * A needle that indicates wind direction, for use with the 52: * {@link org.jfree.chart.plot.CompassPlot} class. 53: */ 54: public class WindNeedle extends ArrowNeedle 55: implements Cloneable, Serializable { 56: 57: /** For serialization. */ 58: private static final long serialVersionUID = -2861061368907167834L; 59: 60: /** 61: * Default constructor. 62: */ 63: public WindNeedle() { 64: super(false); // isArrowAtTop 65: } 66: 67: /** 68: * Draws the needle. 69: * 70: * @param g2 the graphics device. 71: * @param plotArea the plot area. 72: * @param rotate the rotation point. 73: * @param angle the angle. 74: */ 75: protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, 76: Point2D rotate, double angle) { 77: 78: super.drawNeedle(g2, plotArea, rotate, angle); 79: if ((rotate != null) && (plotArea != null)) { 80: 81: int spacing = getSize() * 3; 82: Rectangle2D newArea = new Rectangle2D.Double(); 83: 84: Point2D newRotate = rotate; 85: newArea.setRect(plotArea.getMinX() - spacing, plotArea.getMinY(), 86: plotArea.getWidth(), plotArea.getHeight()); 87: super.drawNeedle(g2, newArea, newRotate, angle); 88: 89: newArea.setRect(plotArea.getMinX() + spacing, 90: plotArea.getMinY(), plotArea.getWidth(), 91: plotArea.getHeight()); 92: super.drawNeedle(g2, newArea, newRotate, angle); 93: 94: } 95: } 96: 97: /** 98: * Tests another object for equality with this object. 99: * 100: * @param object the object to test. 101: * 102: * @return A boolean. 103: */ 104: public boolean equals(Object object) { 105: if (object == null) { 106: return false; 107: } 108: if (object == this) { 109: return true; 110: } 111: if (super.equals(object) && object instanceof WindNeedle) { 112: return true; 113: } 114: return false; 115: } 116: 117: } 118: