package org.csstudio.swt.xygraph.linearscale;

/**
 * A range.
 * @author Xihui Chen
 *
 */
public class Range {

    /** the lower value of range */
    private double lower;

    /** the upper value of range */
    private double upper;

    /**
     * Constructor.
     * 
     * @param start
     *            the start value of range
     * @param end
     *            the end value of range
     */
    public Range(double start, double end) {
    	//if(end == start)
    	//	end = start + 1;
        this.lower = (end > start) ? start : end;
        this.upper = (end > start) ? end : start;
    }

    /**
     * Constructor.
     * 
     * @param range
     *            the range
     */
    public Range(Range range) {
        lower = (range.upper > range.lower) ? lower : upper;
        upper = (range.upper > range.lower) ? upper : lower;
    }

    
    /**If a value in the range or not.
     * @param value
     * @param includeBoundary true if the boundary should be considered.
     * @return true if the value is in the range. Otherwise false.
     */
    public boolean inRange(double value, boolean includeBoundary){
    	if(includeBoundary)
    		return (value >= lower && value <= upper);
    	else
    		return (value > lower && value < upper);
    }
    
    /**If a value in the range or not. The boundary is included.
     * @param value
     * @return true if the value is in the range. Otherwise false.
     */
    public boolean inRange(double value){
    	return value >= lower && value <= upper;
    }
    /*
     * @see Object#toString()
     */
    @Override
    public String toString() {
        return "lower=" + lower + ", upper=" + upper;
    }

	/**
	 * @return the lower
	 */
	public double getLower() {
		return lower;
	}

	/**
	 * @return the upper
	 */
	public double getUpper() {
		return upper;
	}
}

@@ -1531,158 +1531,8 @@
    %7D
-%0A    /*%0A     * @see Object#toString()%0A     */%0A    @Override%0A    public String toString() %7B%0A        return %22lower=%22 + lower + %22, upper=%22 + upper;%0A    %7D
 %0A%0A%09/
@@ -1685,13 +1685,800 @@
  upper;%0A
-
 %09%7D
+%0A%0A%09/** %7B@inheritDoc%7D */%0A%09@Override%0A    public boolean equals(final Object obj)%0A    %7B   // See %22Effective Java%22 Item 7%0A%09    if (this == obj)%0A%09        return true;%0A%09    if (! (obj instanceof Range))%0A%09        return false;%0A%09    final Range other = (Range) obj;%0A%09    return other.lower == lower  &&  other.upper == upper;%0A    %7D%0A%0A    /** %7B@inheritDoc%7D */%0A    @Override%0A    public int hashCode()%0A    %7B%0A        // %22Effective Java%22 Item 8: When overriding equals(), also implement hashCode%0A        int result = (int) Double.doubleToLongBits(lower);%0A        result = 37*result + (int) Double.doubleToLongBits(upper);%0A        return result;%0A    %7D%0A%0A    /*%0A     * @see Object#toString()%0A     */%0A    @Override%0A    public String toString() %7B%0A        return %22lower=%22 + lower + %22, upper=%22 + upper;%0A    %7D
 %0A%7D%0A

equals, hashCode