Source for org.jfree.chart.plot.ValueMarker

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2005, 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:  * ValueMarker.java
  29:  * ----------------
  30:  * (C) Copyright 2004, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: ValueMarker.java,v 1.3.2.1 2005/10/25 20:52:07 mungady Exp $
  36:  *
  37:  * Changes
  38:  * -------
  39:  * 09-Feb-2004 : Version 1 (DG);
  40:  * 16-Feb-2005 : Added new constructor (DG);
  41:  */
  42: 
  43: package org.jfree.chart.plot;
  44: 
  45: import java.awt.Paint;
  46: import java.awt.Stroke;
  47: 
  48: /**
  49:  * A marker that represents a single fixed value.
  50:  */
  51: public class ValueMarker extends Marker {
  52:     
  53:     /** The constant value. */
  54:     private double value;
  55: 
  56:     /**
  57:      * Creates a new marker.
  58:      * 
  59:      * @param value  the value.
  60:      */
  61:     public ValueMarker(double value) {
  62:         super();
  63:         this.value = value;
  64:     }
  65:     
  66:     /**
  67:      * Creates a new marker.
  68:      * 
  69:      * @param value  the value.
  70:      * @param paint  the paint (<code>null</code> not permitted).
  71:      * @param stroke  the stroke (<code>null</code> not permitted).
  72:      */
  73:     public ValueMarker(double value, Paint paint, Stroke stroke) {
  74:         this(value, paint, stroke, paint, stroke, 1.0f);
  75:     }
  76:     
  77:     /**
  78:      * Creates a new value marker.
  79:      * 
  80:      * @param value  the value.
  81:      * @param paint  the paint (<code>null</code> not permitted).
  82:      * @param stroke  the stroke (<code>null</code> not permitted).
  83:      * @param outlinePaint  the outline paint (<code>null</code> permitted).
  84:      * @param outlineStroke  the outline stroke (<code>null</code> permitted).
  85:      * @param alpha  the alpha transparency.
  86:      */
  87:     public ValueMarker(double value, Paint paint, Stroke stroke, 
  88:                        Paint outlinePaint, Stroke outlineStroke, float alpha) {
  89:         super(paint, stroke, paint, stroke, alpha);
  90:         this.value = value;
  91:     }
  92:     
  93:     /**
  94:      * Returns the value.
  95:      *
  96:      * @return The value.
  97:      */
  98:     public double getValue() {
  99:         return this.value;
 100:     }
 101: 
 102:     /**
 103:      * Compares this marker against an arbitrary object.
 104:      * 
 105:      * @param obj  the object (<code>null</code> permitted).
 106:      * 
 107:      * @return A boolean.
 108:      */
 109:     public boolean equals(Object obj) {
 110:         if (obj == this) {
 111:             return true;
 112:         }
 113:         if (!super.equals(obj)) {
 114:             return false;
 115:         }
 116:         if (!(obj instanceof ValueMarker)) {
 117:             return false;
 118:         }
 119:         ValueMarker that = (ValueMarker) obj;
 120:         if (this.value != that.value) {
 121:             return false;
 122:         }
 123:         return true;
 124:     }
 125: }