Class LocatedObjects
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<LocatedObject>
-
- adams.flow.transformer.locateobjects.LocatedObjects
-
- All Implemented Interfaces:
CloneHandler<LocatedObjects>
,Serializable
,Cloneable
,Iterable<LocatedObject>
,Collection<LocatedObject>
,List<LocatedObject>
,RandomAccess
public class LocatedObjects extends ArrayList<LocatedObject> implements CloneHandler<LocatedObjects>
Container for located objects.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_PREFIX
the default prefix.static String
KEY_COUNT
the key for the overall count.static String
KEY_HEIGHT
the key for the height.static String
KEY_INDEX
the key for the index of a group.static String
KEY_LOCATION
the key for the location.static String
KEY_POLY_X
the key for the Xs of the polygon.static String
KEY_POLY_Y
the key for the Ys of the polygon.static String
KEY_WIDTH
the key for the width.static String
KEY_X
the key for the X location.static String
KEY_Y
the key for the Y location.protected Logger
m_Logger
the logger in use.-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description LocatedObjects()
Initializes the list.LocatedObjects(LocatedObject object)
Initializes the list.LocatedObjects(LocatedObject[] objects)
Initializes the list.LocatedObjects(LocatedObjects objects)
Initializes the list.LocatedObjects(List<LocatedObject> objects)
Initializes the list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkIndices()
Checks whether the indices are valid, i.e., no missing or duplicate ones.LocatedObject
find(int index)
Returns the object with the specified index.LocatedObject
find(String index)
Returns the object with the specified index.static LocatedObjects
fromReport(Report report, String prefix)
Retrieves all objects from the report.static LocatedObjects
fromReport(Report report, String[] prefixes)
Retrieves all objects from the report.static LocatedObjects
fromReport(Report report, String[] prefixes, LocatedObjectFilter filter)
Retrieves all objects from the report.static LocatedObjects
fromReport(Report report, String prefix, LocatedObjectFilter filter)
Retrieves all objects from the report.LocatedObjects
getClone()
Returns a clone of the object.Logger
getLogger()
Returns the logger instance.void
remove(int[] indices)
Removes the objects with the specified indices.int
renameMetaDataKey(String oldKey, String newKey)
Renames the meta-data key in all objects.void
resetIndex()
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list.void
resetIndex(int offset)
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list.void
resetIndexIfNecessary()
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list, but only if necessary (eg missing or duplicate indices).void
resetIndexIfNecessary(int offset)
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list, but only if necessary (eg missing or duplicate indices).void
scale(double scale)
Scales all objects with the provided scale factor.LocatedObjects
subList(int[] indices)
Returns a new instance using the specified list indices.LocatedObjects
subList(int[] indices, boolean invert)
Returns a new instance using the specified list indices.LocatedObjects
subset(int[] indices)
Returns a new instance using the specified object indices.LocatedObjects
subset(int[] indices, boolean invert)
Returns a new instance using the specified object indices.Report
toReport(String prefix)
Turns the located objects into a report.Report
toReport(String prefix, int offset)
Turns the located objects into a report.Report
toReport(String prefix, int offset, boolean updateIndex)
Turns the located objects into a report.-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Field Detail
-
KEY_X
public static final String KEY_X
the key for the X location.- See Also:
- Constant Field Values
-
KEY_Y
public static final String KEY_Y
the key for the Y location.- See Also:
- Constant Field Values
-
KEY_WIDTH
public static final String KEY_WIDTH
the key for the width.- See Also:
- Constant Field Values
-
KEY_HEIGHT
public static final String KEY_HEIGHT
the key for the height.- See Also:
- Constant Field Values
-
KEY_LOCATION
public static final String KEY_LOCATION
the key for the location.- See Also:
- Constant Field Values
-
KEY_POLY_X
public static final String KEY_POLY_X
the key for the Xs of the polygon.- See Also:
- Constant Field Values
-
KEY_POLY_Y
public static final String KEY_POLY_Y
the key for the Ys of the polygon.- See Also:
- Constant Field Values
-
KEY_COUNT
public static final String KEY_COUNT
the key for the overall count.- See Also:
- Constant Field Values
-
KEY_INDEX
public static final String KEY_INDEX
the key for the index of a group.- See Also:
- Constant Field Values
-
DEFAULT_PREFIX
public static final String DEFAULT_PREFIX
the default prefix.- See Also:
- Constant Field Values
-
m_Logger
protected Logger m_Logger
the logger in use.
-
-
Constructor Detail
-
LocatedObjects
public LocatedObjects()
Initializes the list.
-
LocatedObjects
public LocatedObjects(LocatedObjects objects)
Initializes the list.- Parameters:
objects
- the list to initialize with
-
LocatedObjects
public LocatedObjects(List<LocatedObject> objects)
Initializes the list.- Parameters:
objects
- the list to initialize with
-
LocatedObjects
public LocatedObjects(LocatedObject[] objects)
Initializes the list.- Parameters:
objects
- the array to initialize with
-
LocatedObjects
public LocatedObjects(LocatedObject object)
Initializes the list.- Parameters:
object
- the object to initialize with
-
-
Method Detail
-
getLogger
public Logger getLogger()
Returns the logger instance.- Returns:
- the logger
-
subset
public LocatedObjects subset(int[] indices)
Returns a new instance using the specified object indices.- Parameters:
indices
- the indices for the subset- Returns:
- the subset
-
subset
public LocatedObjects subset(int[] indices, boolean invert)
Returns a new instance using the specified object indices.- Parameters:
indices
- the indices for the subsetinvert
- whether to invert the matching of the indices- Returns:
- the subset
-
subList
public LocatedObjects subList(int[] indices)
Returns a new instance using the specified list indices.- Parameters:
indices
- the list indices for the subset- Returns:
- the subset
-
subList
public LocatedObjects subList(int[] indices, boolean invert)
Returns a new instance using the specified list indices.- Parameters:
indices
- the list indices for the subsetinvert
- whether to invert the matching of the indices- Returns:
- the subset
-
remove
public void remove(int[] indices)
Removes the objects with the specified indices.- Parameters:
indices
- the indices to remove (ie the indices stored with the object!)
-
find
public LocatedObject find(int index)
Returns the object with the specified index.- Parameters:
index
- the index to look for- Returns:
- the object, null if none found
-
find
public LocatedObject find(String index)
Returns the object with the specified index.- Parameters:
index
- the index to look for- Returns:
- the object, null if none found
-
scale
public void scale(double scale)
Scales all objects with the provided scale factor.- Parameters:
scale
- the scale factor
-
renameMetaDataKey
public int renameMetaDataKey(String oldKey, String newKey)
Renames the meta-data key in all objects.- Parameters:
oldKey
- the old keynewKey
- the new key- Returns:
- how many keys were updated
-
resetIndex
public void resetIndex()
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list.
-
resetIndex
public void resetIndex(int offset)
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list.- Parameters:
offset
- the offset to add to the index
-
resetIndexIfNecessary
public void resetIndexIfNecessary()
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list, but only if necessary (eg missing or duplicate indices).
-
resetIndexIfNecessary
public void resetIndexIfNecessary(int offset)
Resets the index value of all the objects (starts at 1) in the meta-data using the current order in the list, but only if necessary (eg missing or duplicate indices).- Parameters:
offset
- the offset to add to the index
-
checkIndices
public boolean checkIndices()
Checks whether the indices are valid, i.e., no missing or duplicate ones.- Returns:
- true if valid
-
getClone
public LocatedObjects getClone()
Returns a clone of the object.- Specified by:
getClone
in interfaceCloneHandler<LocatedObjects>
- Returns:
- the clone
-
toReport
public Report toReport(String prefix)
Turns the located objects into a report. Using a prefix like "Object." will result in the following report entries for a single object:Object.1.x Object.1.y Object.1.width Object.1.height
- Parameters:
prefix
- the prefix to use- Returns:
- the generated report
-
toReport
public Report toReport(String prefix, int offset)
Turns the located objects into a report. Does not update the index in the meta-data. Using a prefix like "Object." will result in the following report entries for a single object:Object.1.x Object.1.y Object.1.width Object.1.height Object.1.poly_x -- if polygon data present Object.1.poly_y -- if polygon data present
- Parameters:
prefix
- the prefix to useoffset
- the offset for the index to use- Returns:
- the generated report
-
toReport
public Report toReport(String prefix, int offset, boolean updateIndex)
Turns the located objects into a report. Using a prefix like "Object." will result in the following report entries for a single object:Object.1.x Object.1.y Object.1.width Object.1.height Object.1.poly_x -- if polygon data present Object.1.poly_y -- if polygon data present
- Parameters:
prefix
- the prefix to useoffset
- the offset for the index to useupdateIndex
- whether to update the index in the meta-data- Returns:
- the generated report
-
fromReport
public static LocatedObjects fromReport(Report report, String prefix)
Retrieves all objects from the report.- Parameters:
report
- the report to processprefix
- the prefix to look for- Returns:
- the objects found
-
fromReport
public static LocatedObjects fromReport(Report report, String prefix, LocatedObjectFilter filter)
Retrieves all objects from the report.- Parameters:
report
- the report to processprefix
- the prefix to look forfilter
- the filter to use for further filtering the objects, ignored if null- Returns:
- the objects found
-
fromReport
public static LocatedObjects fromReport(Report report, String[] prefixes)
Retrieves all objects from the report.- Parameters:
report
- the report to processprefixes
- the prefixes to look for- Returns:
- the objects found
-
fromReport
public static LocatedObjects fromReport(Report report, String[] prefixes, LocatedObjectFilter filter)
Retrieves all objects from the report.- Parameters:
report
- the report to processprefixes
- the prefixes to look forfilter
- the filter to use for further filtering the objects, ignored if null- Returns:
- the objects found
-
-