Package org.apache.batik.ext.awt.geom
Class RectListManager
java.lang.Object
org.apache.batik.ext.awt.geom.RectListManager
- All Implemented Interfaces:
Iterable
,Collection
RectListManager is a class to manage a list of rectangular regions.
This class contains methods to add new rectangles to the List, to
merge rectangles in the list (based on a cost function), and
functions to subract one RectListManager from another. The main
purpose of this class is to manage dirty regions on a display (for
this reason it uses Rectangle not Rectangle2D).
- Version:
- $Id: RectListManager.java 1733416 2016-03-03 07:07:13Z gadams $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Comparator for ordering rects in X.private class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Rectangle
static Comparator
The comparator used to sort the elements of this List.(package private) Rectangle[]
(package private) int
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an initially emptyRectListManager
.RectListManager
(int capacity) Construct an initially emptyRectListManager
, with initialcapacity
.RectListManager
(Rectangle rect) Construct aRectListManager
with one rectangleRectListManager
(Rectangle[] rects) Construct aRectListManager
from an Array ofRectangles
RectListManager
(Rectangle[] rects, int off, int sz) Construct aRectListManager
from an Array ofRectangles
RectListManager
(Collection rects) Construct aRectListManager
from a Collection of RectanglesConstruct aRectListManager
from anotherRectListManager
(data is copied). -
Method Summary
Modifier and TypeMethodDescriptionvoid
Ensures that this collection contains the specified elementprotected void
Ensures that this collection contains the specified element l is the lower bound index for insertion r is upper bound index for insertion.boolean
void
add
(RectListManager rlm) Adds the contents ofrlm
to this RectListManager.boolean
addAll
(Collection c) void
clear()
clone()
StandardObject
clone method.boolean
boolean
Returns true if this collection contains all of the elements in the specified collection.boolean
copy()
Similar to clone only strongly typed TODO Java 5: The use of covariant return types on clone() can eliminate this method.void
dump()
void
ensureCapacity
(int sz) protected void
insertRects
(Rectangle[] rects, int srcPos, int dstPos, int len) boolean
isEmpty()
Returns true if this collection contains no elements.iterator()
Returns an iterator over the elements in this collectionReturns a list iterator of the elements in this list (in proper sequence).void
mergeRects
(int overhead, int lineOverhead) boolean
Removes a single instance of the specified Rectangle from this collection, if it is present.boolean
Removes a single instance of the specified element from this collection, if it is present.boolean
boolean
removeAll
(RectListManager rlm) boolean
boolean
retainAll
(RectListManager rlm) int
size()
Returns the number of elements currently stored in this collection.protected void
void
subtract
(RectListManager rlm, int overhead, int lineOverhead) Object[]
toArray()
Object[]
fill the given array a with values from my internalrects
.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
Constructor Details
-
RectListManager
Construct aRectListManager
from a Collection of Rectangles- Parameters:
rects
- Collection that must only contain rectangles.
-
RectListManager
Construct aRectListManager
from an Array ofRectangles
- Parameters:
rects
- Array ofRectangles
, must not contain any null entries.
-
RectListManager
Construct aRectListManager
from an Array ofRectangles
- Parameters:
rects
- Array ofRectangles
, must not contain any null entries in the range [off, off+sz-1].off
- The offset to start copying from in rects.sz
- The number of entries to copy from rects.
-
RectListManager
Construct aRectListManager
from anotherRectListManager
(data is copied).- Parameters:
rlm
- RectListManager to copy.
-
RectListManager
Construct aRectListManager
with one rectangle- Parameters:
rect
- The rectangle to put in this rlm.
-
RectListManager
public RectListManager()Construct an initially emptyRectListManager
. -
RectListManager
public RectListManager(int capacity) Construct an initially emptyRectListManager
, with initialcapacity
.- Parameters:
capacity
- The inital capacity for the list. Setting this appropriately can save reallocations.
-
-
Method Details
-
dump
public void dump() -
getBounds
-
clone
StandardObject
clone method.- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
copy
Similar to clone only strongly typed TODO Java 5: The use of covariant return types on clone() can eliminate this method. -
size
public int size()Returns the number of elements currently stored in this collection.- Specified by:
size
in interfaceCollection
-
isEmpty
public boolean isEmpty()Returns true if this collection contains no elements.- Specified by:
isEmpty
in interfaceCollection
-
clear
public void clear()- Specified by:
clear
in interfaceCollection
-
iterator
Returns an iterator over the elements in this collection- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
-
listIterator
Returns a list iterator of the elements in this list (in proper sequence). -
toArray
- Specified by:
toArray
in interfaceCollection
-
toArray
fill the given array a with values from my internalrects
. when a is not large enough, a new array is allocated, filled and returned. the method works only, when a is a Object[] or a Rectange[]. When this is not the case, the a[] is just cleared.- Specified by:
toArray
in interfaceCollection
- Parameters:
a
- array to fill (must not be null!)- Returns:
- the content of rects, either in a[] or a fresh array.
-
add
- Specified by:
add
in interfaceCollection
-
add
Ensures that this collection contains the specified element- Parameters:
rect
- The rectangle to add
-
add
Ensures that this collection contains the specified element l is the lower bound index for insertion r is upper bound index for insertion.- Parameters:
rect
- The rectangle to addl
- the lowest possible index for a rect with greater 'x' coord.r
- the highest possible index for a rect with greater 'x' coord.
-
addAll
- Specified by:
addAll
in interfaceCollection
-
contains
- Specified by:
contains
in interfaceCollection
-
containsAll
Returns true if this collection contains all of the elements in the specified collection.- Specified by:
containsAll
in interfaceCollection
-
containsAll
-
remove
Removes a single instance of the specified element from this collection, if it is present.- Specified by:
remove
in interfaceCollection
- Parameters:
o
- Object to remove an matching instance of.
-
remove
Removes a single instance of the specified Rectangle from this collection, if it is present.- Parameters:
rect
- Rectangle to remove an matching instance of.
-
removeAll
- Specified by:
removeAll
in interfaceCollection
-
removeAll
-
retainAll
- Specified by:
retainAll
in interfaceCollection
-
retainAll
-
add
Adds the contents ofrlm
to this RectListManager. No collapsing of rectangles is done here the contents are simply added (you should generally call 'mergeRects' some time after this operation before using the contents of this RectListManager.- Parameters:
rlm
- The RectListManager to add the contents of.
-
mergeRects
public void mergeRects(int overhead, int lineOverhead) -
subtract
-
splitRect
-
insertRects
-
ensureCapacity
public void ensureCapacity(int sz)
-