Package org.anchoranalysis.mpp.mark
Class MarkCollection
Object
MarkCollection
- All Implemented Interfaces:
Serializable
,Iterable<Mark>
An ordered collection of
Mark
s.
This is often termed a configuration in marked-point-processes academic literature.
- Author:
- Owen Feehan
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates with no elements in the collection.MarkCollection
(List<Mark> marks) Creates a newMarkCollection
instance.MarkCollection
(Stream<Mark> stream) Creates from a stream ofMark
s.MarkCollection
(Mark mark) Creates from a singleMark
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a mark to the collection.void
addAll
(MarkCollection marks) Adds all marks from another collection to this collection.boxList
(Dimensions dimensions, int regionID) Creates a list of bounding boxes for all marks in the collection.boolean
Checks if the collection contains a specific object.Creates a map of marks to their indices in the collection.int[]
Creates an array of mark IDs.Creates a map of marks indexed by their IDs.createMerged
(MarkCollection toMerge) Creates a new collection by merging this collection with another.Creates a set of all marks in the collection.deepCopy()
Creates a deep copy of the collection.deriveObjects
(Dimensions dimensions, RegionMembershipWithFlags regionMembership) Derives objects from the marks in the collection.boolean
equalsDeep
(MarkCollection other) Checks if this collection is deeply equal to another.final void
Replaces the mark at a specific index.get
(int index) Gets a mark at a specific index.getMarks()
int
Finds the index of a specific mark in the collection.final boolean
isEmpty()
Checks if the collection is empty.iterator()
Finds marks at a specific point that belong to a specific region.final int
randomIndex
(RandomNumberGenerator randomNumberGenerator) Generates a random index within the collection.final Mark
randomMark
(RandomNumberGenerator randomNumberGenerator) Gets a random mark from the collection.remove
(int index) Removes a mark at a specific index.void
removeTwo
(int index1, int index2) Removes two marks at specified indices.void
scaleXY
(ScaleFactor scaleFactor) Scales all marks in the collection in X and Y dimensions.Replaces the mark at a specific index.Creates a shallow copy of the collection.final int
size()
Returns the number of marks in the collection.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MarkCollection
public MarkCollection()Creates with no elements in the collection. -
MarkCollection
Creates from a stream ofMark
s.- Parameters:
stream
- the stream of marks to add to the collection.
-
MarkCollection
Creates from a singleMark
.- Parameters:
mark
- the mark to add to the collection.
-
MarkCollection
Creates a newMarkCollection
instance.
-
-
Method Details
-
shallowCopy
Creates a shallow copy of the collection.- Returns:
- a new MarkCollection with the same marks.
-
deepCopy
Creates a deep copy of the collection.- Returns:
- a new MarkCollection with duplicates of all marks.
-
add
Adds a mark to the collection.- Parameters:
mark
- the mark to add.- Returns:
- true if the mark was added successfully.
-
addAll
Adds all marks from another collection to this collection.- Parameters:
marks
- the collection of marks to add.
-
contains
Checks if the collection contains a specific object.- Parameters:
obj
- the object to check for.- Returns:
- true if the object is in the collection.
-
isEmpty
public final boolean isEmpty()Checks if the collection is empty.- Returns:
- true if the collection contains no marks.
-
size
public final int size()Returns the number of marks in the collection.- Returns:
- the size of the collection.
-
iterator
-
toString
-
remove
Removes a mark at a specific index.- Parameters:
index
- the index of the mark to remove.- Returns:
- the removed mark.
-
removeTwo
public void removeTwo(int index1, int index2) Removes two marks at specified indices.- Parameters:
index1
- the first index.index2
- the second index.
-
randomIndex
Generates a random index within the collection.- Parameters:
randomNumberGenerator
- the random number generator to use.- Returns:
- a random index.
-
get
Gets a mark at a specific index.- Parameters:
index
- the index of the mark to get.- Returns:
- the mark at the specified index.
-
randomMark
Gets a random mark from the collection.- Parameters:
randomNumberGenerator
- the random number generator to use.- Returns:
- a randomly selected mark.
-
exchange
Replaces the mark at a specific index.- Parameters:
index
- the index to replace.markToAssign
- the new mark to assign.
-
indexOf
Finds the index of a specific mark in the collection.- Parameters:
mark
- the mark to find.- Returns:
- the index of the mark, or -1 if not found.
-
deriveObjects
public ObjectCollection deriveObjects(Dimensions dimensions, RegionMembershipWithFlags regionMembership) Derives objects from the marks in the collection.- Parameters:
dimensions
- the dimensions to use.regionMembership
- the region membership to consider.- Returns:
- a collection of derived objects.
-
scaleXY
Scales all marks in the collection in X and Y dimensions.- Parameters:
scaleFactor
- how much to scale by.- Throws:
CheckedUnsupportedOperationException
- if scaling is not supported for any mark.
-
marksAt
Finds marks at a specific point that belong to a specific region.- Parameters:
point
- the point to check.regionMap
- the region map to use.regionID
- the ID of the region to consider.- Returns:
- a new MarkCollection containing the matching marks.
-
equalsDeep
Checks if this collection is deeply equal to another.- Parameters:
other
- the other collection to compare with.- Returns:
- true if the collections are deeply equal.
-
createIdHashMap
Creates a map of marks indexed by their IDs.- Returns:
- a Map where keys are mark IDs and values are the corresponding marks.
-
createIdArr
public int[] createIdArr()Creates an array of mark IDs.- Returns:
- an array containing the IDs of all marks in the collection.
-
createSet
Creates a set of all marks in the collection.- Returns:
- a Set containing all marks in the collection.
-
createHashMapToId
Creates a map of marks to their indices in the collection.- Returns:
- a Map where keys are marks and values are their indices.
-
createMerged
Creates a new collection by merging this collection with another.- Parameters:
toMerge
- the collection to merge with.- Returns:
- a new MarkCollection containing all unique marks from both collections.
-
boxList
Creates a list of bounding boxes for all marks in the collection.- Parameters:
dimensions
- the dimensions to use.regionID
- the ID of the region to consider.- Returns:
- a List of BoundingBox objects.
-
set
Replaces the mark at a specific index.- Parameters:
index
- the index to replace.element
- the new mark to set.- Returns:
- the mark previously at the specified position.
-
getMarks
-