Gephi Toolkit Javadoc

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

java.lang.Object
  extended by org.gephi.data.attributes.type.DynamicType<T>
Type Parameters:
T - type of data
Direct Known Subclasses:
DynamicBigDecimal, DynamicBigInteger, DynamicBoolean, DynamicByte, DynamicCharacter, DynamicDouble, DynamicFloat, DynamicInteger, DynamicLong, DynamicShort, DynamicString, TimeInterval

public abstract class DynamicType<T>
extends java.lang.Object

A special type which provides methods of getting/setting values of any time interval. It is internally implemented using Interval Tree for efficiency.

Author:
Cezary Bartosiak

Field Summary
protected  IntervalTree<T> intervalTree
           
 
Constructor Summary
DynamicType()
          Constructs a new DynamicType instance with no intervals.
DynamicType(DynamicType<T> source)
          Constructs a deep copy of source.
DynamicType(DynamicType<T> source, Interval<T> in)
          Constructs a deep copy of source that contains a given Interval<T> in.
DynamicType(DynamicType<T> source, Interval<T> in, Interval<T> out)
          Constructs a deep copy of source that contains a given Interval<T> in.
DynamicType(DynamicType<T> source, java.util.List<Interval<T>> in)
          Constructs a deep copy of source with additional intervals given by List<Interval<T>> in.
DynamicType(DynamicType<T> source, java.util.List<Interval<T>> in, java.util.List<Interval<T>> out)
          Constructs a deep copy of source with additional intervals given by List<Interval<T>> in.
DynamicType(Interval<T> in)
          Constructs a new DynamicType instance that contains a given Interval<T> in.
DynamicType(java.util.List<Interval<T>> in)
          Constructs a new DynamicType instance with intervals given by List<Interval<T>> in.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares this instance with the specified object for equality.
 double getHigh()
          Returns the rightmost point or Double.POSITIVE_INFINITY in case of no intervals.
 java.util.List<Interval<T>> getIntervals()
          Returns a list of all intervals.
 java.util.List<Interval<T>> getIntervals(double low, double high)
          Returns a list of intervals which overlap with a [low, high] time interval.
 java.util.List<Interval<T>> getIntervals(Interval interval)
          Returns a list of intervals which overlap with a given time interval.
 double getLow()
          Returns the leftmost point or Double.NEGATIVE_INFINITY in case of no intervals.
abstract  java.lang.Class getUnderlyingType()
          Returns the underlying type T.
 T getValue()
          Returns the estimated value of a set of values whose time intervals overlap with a [-inf, inf] time interval.
 T getValue(double low, double high)
          Returns the estimated value of a set of values whose time intervals overlap with a [low, high] time interval.
 T getValue(double low, double high, Estimator estimator)
          Returns the estimated value of a set of values whose time intervals overlap with a [low, high] time interval.
 T getValue(Estimator estimator)
          Returns the estimated value of a set of values whose time intervals overlap with a [-inf, inf] time interval.
 T getValue(Interval interval)
          Returns the estimated value of a set of values whose time intervals overlap with a given time interval.
abstract  T getValue(Interval interval, Estimator estimator)
          Returns the estimated value of a set of values whose time intervals overlap with a given time interval.
 java.util.List<T> getValues()
          Returns a list of all values stored in this instance.
 java.util.List<T> getValues(double low, double high)
          Returns a list of values whose time intervals overlap with a [low, high] time interval.
 java.util.List<T> getValues(Interval interval)
          Returns a list of values whose time intervals overlap with a given time interval.
 int hashCode()
          Returns a hashcode of this instance.
 boolean isHighExcluded()
          Indicates if the rightmost point is excluded.
 boolean isInRange(double low, double high)
          Indicates if [low, high] interval overlaps with any interval of this instance.
 boolean isInRange(Interval interval)
          Indicates if a given time interval overlaps with any interval of this instance.
 boolean isLowExcluded()
          Indicates if the leftmost point is excluded.
 java.lang.String toString()
          Returns a string representation of this instance in a format <[low, high, value], ..., [low, high, value]>.
 java.lang.String toString(boolean timesAsDoubles)
          Creates a string representation of all the intervals with their values.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

intervalTree

protected IntervalTree<T> intervalTree
Constructor Detail

DynamicType

public DynamicType()
Constructs a new DynamicType instance with no intervals.


DynamicType

public DynamicType(Interval<T> in)
Constructs a new DynamicType instance that contains a given Interval<T> in.

Parameters:
in - interval to add (could be null)

DynamicType

public DynamicType(java.util.List<Interval<T>> in)
Constructs a new DynamicType instance with intervals given by List<Interval<T>> in.

Parameters:
in - intervals to add (could be null)

DynamicType

public DynamicType(DynamicType<T> source)
Constructs a deep copy of source.

Parameters:
source - an object to copy from (could be null, then completely new instance is created)

DynamicType

public DynamicType(DynamicType<T> source,
                   Interval<T> in)
Constructs a deep copy of source that contains a given Interval<T> in.

Parameters:
source - an object to copy from (could be null, then completely new instance is created)
in - interval to add (could be null)

DynamicType

public DynamicType(DynamicType<T> source,
                   Interval<T> in,
                   Interval<T> out)
Constructs a deep copy of source that contains a given Interval<T> in. Before add it removes from the newly created object all intervals that overlap with a given Interval<T> out.

Parameters:
source - an object to copy from (could be null, then completely new instance is created)
in - interval to add (could be null)
out - interval to remove (could be null)

DynamicType

public DynamicType(DynamicType<T> source,
                   java.util.List<Interval<T>> in)
Constructs a deep copy of source with additional intervals given by List<Interval<T>> in.

Parameters:
source - an object to copy from (could be null, then completely new instance is created)
in - intervals to add (could be null)

DynamicType

public DynamicType(DynamicType<T> source,
                   java.util.List<Interval<T>> in,
                   java.util.List<Interval<T>> out)
Constructs a deep copy of source with additional intervals given by List<Interval<T>> in. Before add it removes from the newly created object all intervals that overlap with intervals given by List<Interval<T>> out.

Parameters:
source - an object to copy from (could be null, then completely new instance is created)
in - intervals to add (could be null)
out - intervals to remove (could be null)
Method Detail

getLow

public double getLow()
Returns the leftmost point or Double.NEGATIVE_INFINITY in case of no intervals.

Returns:
the leftmost point.

getHigh

public double getHigh()
Returns the rightmost point or Double.POSITIVE_INFINITY in case of no intervals.

Returns:
the rightmost point.

isLowExcluded

public boolean isLowExcluded()
Indicates if the leftmost point is excluded.

Returns:
true if the leftmost point is excluded, false otherwise.

isHighExcluded

public boolean isHighExcluded()
Indicates if the rightmost point is excluded.

Returns:
true if the rightmost point is excluded, false otherwise.

isInRange

public boolean isInRange(Interval interval)
Indicates if a given time interval overlaps with any interval of this instance.

Parameters:
interval - a given time interval
Returns:
true a given time interval overlaps with any interval of this instance, otherwise false.

isInRange

public boolean isInRange(double low,
                         double high)
Indicates if [low, high] interval overlaps with any interval of this instance.

Parameters:
low - the left endpoint
high - the right endpoint
Returns:
true a given time interval overlaps with any interval of this instance, otherwise false.
Throws:
java.lang.IllegalArgumentException - if low > high.

getValue

public T getValue()
Returns the estimated value of a set of values whose time intervals overlap with a [-inf, inf] time interval. Estimator.FIRST is used.

Returns:
the estimated value of a set of values whose time intervals overlap with a [-inf, inf] time interval or null if there are no intervals.
See Also:
Estimator

getValue

public T getValue(Interval interval)
Returns the estimated value of a set of values whose time intervals overlap with a given time interval. Estimator.FIRST is used.

Parameters:
interval - a given time interval
Returns:
the estimated value of a set of values whose time intervals overlap with a given time interval or null if there are no intervals.
See Also:
Estimator

getValue

public T getValue(double low,
                  double high)
Returns the estimated value of a set of values whose time intervals overlap with a [low, high] time interval. Estimator.FIRST is used.

Parameters:
low - the left endpoint
high - the right endpoint
Returns:
the estimated value of a set of values whose time intervals overlap with a [low, high] time interval or null if there are no intervals.
Throws:
java.lang.IllegalArgumentException - if low > high.
See Also:
Estimator

getValue

public T getValue(Estimator estimator)
Returns the estimated value of a set of values whose time intervals overlap with a [-inf, inf] time interval.

Parameters:
estimator - used to estimate the result
Returns:
the estimated value of a set of values whose time intervals overlap with a [-inf, inf] time interval or null if there are no intervals.
Throws:
java.lang.UnsupportedOperationException - if type T doesn't support the given estimator.
See Also:
Estimator

getValue

public abstract T getValue(Interval interval,
                           Estimator estimator)
Returns the estimated value of a set of values whose time intervals overlap with a given time interval.

Parameters:
interval - a given time interval
estimator - used to estimate the result
Returns:
the estimated value of a set of values whose time intervals overlap with a given time interval or null if there are no intervals.
Throws:
java.lang.UnsupportedOperationException - if type T doesn't support the given estimator.
See Also:
Estimator

getValue

public T getValue(double low,
                  double high,
                  Estimator estimator)
Returns the estimated value of a set of values whose time intervals overlap with a [low, high] time interval.

Parameters:
low - the left endpoint
high - the right endpoint
estimator - used to estimate the result
Returns:
the estimated value of a set of values whose time intervals overlap with a [low, high] time interval or null if there are no intervals.
Throws:
java.lang.IllegalArgumentException - if low > high.
java.lang.UnsupportedOperationException - if type T doesn't support the given estimator.
See Also:
Estimator

getValues

public java.util.List<T> getValues()
Returns a list of all values stored in this instance.

Returns:
a list of all values stored in this instance.

getValues

public java.util.List<T> getValues(double low,
                                   double high)
Returns a list of values whose time intervals overlap with a [low, high] time interval.

Parameters:
low - the left endpoint
high - the right endpoint
Returns:
a list of values whose time intervals overlap with a [low, high] time interval.
Throws:
java.lang.IllegalArgumentException - if low > high.

getValues

public java.util.List<T> getValues(Interval interval)
Returns a list of values whose time intervals overlap with a given time interval.

Parameters:
interval - a given time interval
Returns:
a list of values whose time intervals overlap with a given time interval.

getIntervals

public java.util.List<Interval<T>> getIntervals()
Returns a list of all intervals.

Returns:
a list of intervals which overlap with a given time interval.

getIntervals

public java.util.List<Interval<T>> getIntervals(Interval interval)
Returns a list of intervals which overlap with a given time interval.

Parameters:
interval - a given time interval
Returns:
a list of intervals which overlap with a given time interval.

getIntervals

public java.util.List<Interval<T>> getIntervals(double low,
                                                double high)
Returns a list of intervals which overlap with a [low, high] time interval.

Parameters:
low - the left endpoint
high - the right endpoint
Returns:
a list of intervals which overlap with a [low, high] time interval.
Throws:
java.lang.IllegalArgumentException - if low > high.

getUnderlyingType

public abstract java.lang.Class getUnderlyingType()
Returns the underlying type T.

Returns:
the underlying type T.

equals

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

Note that two DynamicType instances are equal if they have got the same type T and their interval trees are equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to which this instance is to be compared
Returns:
true if and only if the specified Object is a DynamicType which has the same type T and an equal interval tree.
See Also:
hashCode()

hashCode

public int hashCode()
Returns a hashcode of this instance.

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode of this instance.

toString

public java.lang.String toString(boolean timesAsDoubles)
Creates a string representation of all the intervals with their values.

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 instance in a format <[low, high, value], ..., [low, high, value]>. Intervals are ordered by its left endpoint.

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

Gephi Toolkit Javadoc