APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.java2d

public Class Spans

extends Object
Class Inheritance
Imports
java.util.Comparator, .Collections, .Iterator, .List, .Vector

Maintains a list of half-open intervals, called Spans. A Span can be tested against the list of Spans for intersection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
Spans.Span

Holds a single half-open interval.

pack-priv static class
Spans.SpanIntersection

This class ranks a pair of Span instances.

Field Summary

Modifier and TypeField and Description
private static final int
kMaxAddsSinceSort

This class will sort and collapse its span entries after this many span additions via the add method.

private int
mAddsSinceSort

The number of Span instances that have been added to this object without a sort and collapse taking place.

private List<Spans.Span>
mSpans

Holds a list of individual Span instances.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(float start, float end)

Add a span covering the half open interval including start up to but not including end.

public void
addInfinite()

Add a span which covers the entire range.

public boolean
intersects(float start, float end)

Returns true if the span defined by the half-open interval from start up to, but not including, end intersects any of the spans defined by this instance.

private void
sortAndCollapse()

Sort the spans in ascending order by their start position.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

kMaxAddsSinceSortback to summary
private static final int kMaxAddsSinceSort

This class will sort and collapse its span entries after this many span additions via the add method.

mAddsSinceSortback to summary
private int mAddsSinceSort

The number of Span instances that have been added to this object without a sort and collapse taking place.

mSpansback to summary
private List<Spans.Span> mSpans

Holds a list of individual Span instances.

Constructor Detail

Spansback to summary
public Spans()

Method Detail

addback to summary
public void add(float start, float end)

Add a span covering the half open interval including start up to but not including end.

addInfiniteback to summary
public void addInfinite()

Add a span which covers the entire range. This call is logically equivalent to add(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY) The result of making this call is that all future add calls are ignored and the intersects method always returns true.

intersectsback to summary
public boolean intersects(float start, float end)

Returns true if the span defined by the half-open interval from start up to, but not including, end intersects any of the spans defined by this instance.

sortAndCollapseback to summary
private void sortAndCollapse()

Sort the spans in ascending order by their start position. After the spans are sorted collapse any spans that intersect into a single span. The result is a sorted, non-overlapping list of spans.

sun.java2d back to summary

pack-priv Class Spans.Span

extends Object
implements Comparable<Spans.Span>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

Holds a single half-open interval.

Field Summary

Modifier and TypeField and Description
private float
mEnd

The span goes up to but does not include the ending point.

private float
mStart

The span includes the starting point.

Constructor Summary

AccessConstructor and Description
pack-priv
Span(float start, float end)

Create a half-open interval including start but not including end.

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(Spans.Span otherSpan)

Implements java.lang.Comparable.compareTo.

Rank spans according to their starting position.

pack-priv boolean
contains(float pos)

Return true if the passed in position lies in the half-open interval defined by this Span.

pack-priv final float
getEnd()

Return the end of the Span.

pack-priv final float
getStart()

Return the start of the Span.

pack-priv final void
setEnd(float end)

Change the terminal position of the Span.

pack-priv final void
setStart(float start)

Change the initial position of the Span.

pack-priv boolean
subsume(Spans.Span otherSpan)

Attempt to alter this Span to include otherSpan without altering this span's starting position.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

mEndback to summary
private float mEnd

The span goes up to but does not include the ending point.

mStartback to summary
private float mStart

The span includes the starting point.

Constructor Detail

Spanback to summary
pack-priv Span(float start, float end)

Create a half-open interval including start but not including end.

Method Detail

compareToback to summary
public int compareTo(Spans.Span otherSpan)

Implements java.lang.Comparable.compareTo.

Rank spans according to their starting position. The end position is ignored in this ranking.

Annotations
@Override
containsback to summary
pack-priv boolean contains(float pos)

Return true if the passed in position lies in the half-open interval defined by this Span.

getEndback to summary
pack-priv final float getEnd()

Return the end of the Span. The end is not considered part of the half-open interval.

getStartback to summary
pack-priv final float getStart()

Return the start of the Span. The start is considered part of the half-open interval.

setEndback to summary
pack-priv final void setEnd(float end)

Change the terminal position of the Span.

setStartback to summary
pack-priv final void setStart(float start)

Change the initial position of the Span.

subsumeback to summary
pack-priv boolean subsume(Spans.Span otherSpan)

Attempt to alter this Span to include otherSpan without altering this span's starting position. If otherSpan can be so consumed by this Span then true is returned.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

sun.java2d back to summary

pack-priv Class Spans.SpanIntersection

extends Object
implements Comparator<Spans.Span>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

This class ranks a pair of Span instances. If the instances intersect they are deemed equal otherwise they are ranked by their relative position. Use SpanIntersection.instance to get the single instance of this class.

Field Summary

Modifier and TypeField and Description
pack-priv static final Spans.SpanIntersection
instance

This class is a Singleton and the following is the single instance.

Constructor Summary

AccessConstructor and Description
private
SpanIntersection()

Only this class can create instances of itself.

Method Summary

Modifier and TypeMethod and Description
public int
compare(Spans.Span span1, Spans.Span span2)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
pack-priv static final Spans.SpanIntersection instance

This class is a Singleton and the following is the single instance.

Constructor Detail

SpanIntersectionback to summary
private SpanIntersection()

Only this class can create instances of itself.

Method Detail

compareback to summary
public int compare(Spans.Span span1, Spans.Span span2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.