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