Gephi Toolkit Javadoc

org.gephi.data.attributes.type
Class Interval<T>

java.lang.Object
  extended by org.gephi.data.attributes.type.Interval<T>
Type Parameters:
T - type of data
All Implemented Interfaces:
java.lang.Comparable<Interval>

public final class Interval<T>
extends java.lang.Object
implements java.lang.Comparable<Interval>

This class represents an interval with some value.

Author:
Cezary Bartosiak

Constructor Summary
Interval(double low, double high)
          Constructs a new interval instance with no value and left and right endpoints included by default.
Interval(double low, double high, boolean lopen, boolean ropen)
          Constructs a new interval instance with no value.
Interval(double low, double high, boolean lopen, boolean ropen, T value)
          Constructs a new interval instance.
Interval(double low, double high, T value)
          Constructs a new interval instance with left and right endpoints included by default.
Interval(Interval interval, T value)
          Constructs a new interval instance
 
Method Summary
 int compareTo(Interval interval)
          Compares this interval with the specified interval for order.
 boolean equals(java.lang.Object obj)
          Compares this interval with the specified object for equality.
 double getHigh()
          Returns the right endpoint.
 double getLow()
          Returns the left endpoint.
 T getValue()
          Returns the value stored in this interval.
 int hashCode()
           
 boolean isHighExcluded()
          Indicates if the right endpoint is excluded.
 boolean isLowExcluded()
          Indicates if the left endpoint is excluded.
 java.lang.String toString()
          Returns a string representation of this interval in one of the formats: [low, high, value] (low, high, value] [low, high, value) (low, high, value)
 java.lang.String toString(boolean timesAsDoubles)
          Creates a string representation of the interval with its value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Interval

public Interval(Interval interval,
                T value)
Constructs a new interval instance

Note that value cannot be null if you want use this interval as a value storage. If it is null some estimators could not work and generate exceptions.

Parameters:
interval - the interval to copy the values from
value - the value stored in this interval
Throws:
java.lang.IllegalArgumentException - if low > high.

Interval

public Interval(double low,
                double high,
                boolean lopen,
                boolean ropen,
                T value)
Constructs a new interval instance.

Note that value cannot be null if you want use this interval as a value storage. If it is null some estimators could not work and generate exceptions.

Parameters:
low - the left endpoint
high - the right endpoint
lopen - indicates if the left endpoint is excluded (true in this case)
ropen - indicates if the right endpoint is excluded (true in this case)
value - the value stored in this interval
Throws:
java.lang.IllegalArgumentException - if low > high.

Interval

public Interval(double low,
                double high,
                boolean lopen,
                boolean ropen)
Constructs a new interval instance with no value.

Parameters:
low - the left endpoint
high - the right endpoint
lopen - indicates if the left endpoint is excluded (true in this case)
ropen - indicates if the right endpoint is excluded (true in this case)
Throws:
java.lang.IllegalArgumentException - if low > high.

Interval

public Interval(double low,
                double high,
                T value)
Constructs a new interval instance with left and right endpoints included by default.

Note that value cannot be null if you want use this interval as a value storage. If it is null some estimators could not work and generate exceptions.

Parameters:
low - the left endpoint
high - the right endpoint
value - the value stored in this interval
Throws:
java.lang.IllegalArgumentException - if low > high.

Interval

public Interval(double low,
                double high)
Constructs a new interval instance with no value and left and right endpoints included by default.

Parameters:
low - the left endpoint
high - the right endpoint
Throws:
java.lang.IllegalArgumentException - if low > high.
Method Detail

compareTo

public int compareTo(Interval interval)
Compares this interval with the specified interval for order.

Any two intervals i and i' satisfy the interval trichotomy; that is, exactly one of the following three properties holds:

  1. i and i' overlap;
  2. i is to the left of i' (i.high < i'.low);
  3. i is to the right of i' (i'.high < i.low).

Note that if two intervals are equal (i.low = i'.low and i.high = i'.high), they overlap as well. But if they simply overlap (for instance i.low < i'.low and i.high > i'.high) they aren't equal. Remember that if two intervals are equal, they have got the same bounds excluded or included.

Specified by:
compareTo in interface java.lang.Comparable<Interval>
Parameters:
interval - the interval to be compared
Returns:
a negative integer, zero, or a positive integer as this interval is to the left of, overlaps with, or is to the right of the specified interval.
Throws:
java.lang.NullPointerException - if interval is null.

getLow

public double getLow()
Returns the left endpoint.

Returns:
the left endpoint.

getHigh

public double getHigh()
Returns the right endpoint.

Returns:
the right endpoint.

isLowExcluded

public boolean isLowExcluded()
Indicates if the left endpoint is excluded.

Returns:
true if the left endpoint is excluded, false otherwise.

isHighExcluded

public boolean isHighExcluded()
Indicates if the right endpoint is excluded.

Returns:
true if the right endpoint is excluded, false otherwise.

getValue

public T getValue()
Returns the value stored in this interval.

Returns:
the value stored in this interval.

equals

public boolean equals(java.lang.Object obj)
Compares this interval with the specified object for equality.

Note that two intervals are equal if i.low = i'.low and i.high = i'.high and they have got the bounds excluded/included.

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to which this interval is to be compared
Returns:
true if and only if the specified Object is a Interval whose low and high are equal to this Interval's.
See Also:
compareTo(org.gephi.data.attributes.type.Interval), hashCode()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString(boolean timesAsDoubles)
Creates a string representation of the interval with its value.

Parameters:
timesAsDoubles - indicates if times should be shown as doubles or dates
Returns:
a string representation with times as doubles or dates.

toString

public java.lang.String toString()
Returns a string representation of this interval in one of the formats:
  1. [low, high, value]
  2. (low, high, value]
  3. [low, high, value)
  4. (low, high, value)

Times are always shown as doubles

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this interval.

Gephi Toolkit Javadoc