Package org.anchoranalysis.mpp.mark
Class MarkCollection
Object
org.anchoranalysis.mpp.mark.MarkCollection
- All Implemented Interfaces:
Serializable,Iterable<Mark>
public final class MarkCollection extends Object implements Iterable<Mark>, Serializable
An ordered collection of
Marks.
This is often termed a configuration in marked-point-processes academic literature.
- Author:
- Owen Feehan
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description MarkCollection()Creates with no elements in the collection.MarkCollection(List<Mark> marks)MarkCollection(Stream<Mark> stream)Creates from a stream ofMarks.MarkCollection(Mark mark)Creates from a singleMark. -
Method Summary
Modifier and Type Method Description booleanadd(Mark mark)Adds a mark to the collection.voidaddAll(MarkCollection marks)Adds all marks from another collection to this collection.List<org.anchoranalysis.spatial.box.BoundingBox>boxList(Dimensions dimensions, int regionID)Creates a list of bounding boxes for all marks in the collection.booleancontains(Object obj)Checks if the collection contains a specific object.Map<Mark,Integer>createHashMapToId()Creates a map of marks to their indices in the collection.int[]createIdArr()Creates an array of mark IDs.Map<Integer,Mark>createIdHashMap()Creates a map of marks indexed by their IDs.MarkCollectioncreateMerged(MarkCollection toMerge)Creates a new collection by merging this collection with another.Set<Mark>createSet()Creates a set of all marks in the collection.MarkCollectiondeepCopy()Creates a deep copy of the collection.org.anchoranalysis.image.voxel.object.ObjectCollectionderiveObjects(Dimensions dimensions, RegionMembershipWithFlags regionMembership)Derives objects from the marks in the collection.booleanequalsDeep(MarkCollection other)Checks if this collection is deeply equal to another.voidexchange(int index, Mark markToAssign)Replaces the mark at a specific index.Markget(int index)Gets a mark at a specific index.List<Mark>getMarks()intindexOf(Mark mark)Finds the index of a specific mark in the collection.booleanisEmpty()Checks if the collection is empty.Iterator<Mark>iterator()MarkCollectionmarksAt(org.anchoranalysis.spatial.point.Point3i point, RegionMap regionMap, int regionID)Finds marks at a specific point that belong to a specific region.intrandomIndex(RandomNumberGenerator randomNumberGenerator)Generates a random index within the collection.MarkrandomMark(RandomNumberGenerator randomNumberGenerator)Gets a random mark from the collection.Markremove(int index)Removes a mark at a specific index.voidremoveTwo(int index1, int index2)Removes two marks at specified indices.voidscaleXY(org.anchoranalysis.spatial.scale.ScaleFactor scaleFactor)Scales all marks in the collection in X and Y dimensions.Markset(int index, Mark element)Replaces the mark at a specific index.MarkCollectionshallowCopy()Creates a shallow copy of the collection.intsize()Returns the number of marks in the collection.StringtoString()
-
Constructor Details
-
MarkCollection
public MarkCollection()Creates with no elements in the collection. -
MarkCollection
Creates from a stream ofMarks.- 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
-
-
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 org.anchoranalysis.image.voxel.object.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
public void scaleXY(org.anchoranalysis.spatial.scale.ScaleFactor scaleFactor) throws CheckedUnsupportedOperationExceptionScales 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
public MarkCollection marksAt(org.anchoranalysis.spatial.point.Point3i point, RegionMap regionMap, int regionID)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
public List<org.anchoranalysis.spatial.box.BoundingBox> boxList(Dimensions dimensions, int regionID)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
-