Package adams.data.sequence
Class XYSequence
- java.lang.Object
-
- adams.data.container.AbstractDataContainer<XYSequencePoint>
-
- adams.data.sequence.XYSequence
-
- All Implemented Interfaces:
CloneHandler
,Mergeable<DataContainer>
,UniqueIDHandler
,DataContainer<XYSequencePoint>
,DataContainerWithSpreadSheetSupport<XYSequencePoint>
,IDHandler
,MutableIDHandler
,SpreadSheetSupporter
,Serializable
,Comparable
,Iterable<XYSequencePoint>
,Collection<XYSequencePoint>
- Direct Known Subclasses:
SequencePlotSequence
public class XYSequence extends AbstractDataContainer<XYSequencePoint> implements DataContainerWithSpreadSheetSupport<XYSequencePoint>
A sequence storing 2-dimensional points.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
FILE_EXTENSION
the file extension.protected DataPointComparator
m_Comparator
the default comparator.protected XYSequencePointComparator.Comparison
m_Comparison
the comparison to use.protected gnu.trove.map.hash.TDoubleObjectHashMap<String>
m_MappingX
string representations for the X values.protected gnu.trove.map.hash.TDoubleObjectHashMap<String>
m_MappingY
string representations for the Y values.protected XYSequencePoint
m_MaxX
the maximum X point.protected XYSequencePoint
m_MaxY
the maximum Y point.protected XYSequencePoint
m_MinX
the minimum X point.protected XYSequencePoint
m_MinY
the minimum Y point.-
Fields inherited from class adams.data.container.AbstractDataContainer
m_ID, m_Points, m_UUID
-
-
Constructor Summary
Constructors Constructor Description XYSequence()
Initializes the sequence.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assign(XYSequence other)
Obtains the stored variables from the other data point, but not the actual data points.XYSequencePoint
find(double x)
Returns the SequencePoint with the exact number, null if not found.XYSequencePoint
findClosest(double x)
Returns the SequencePoint with a number closest to the one provided.DataPointComparator<XYSequencePoint>
getComparator()
Returns the comparator in use.XYSequencePointComparator.Comparison
getComparison()
Returns the type of comparison currently in use.List<String>
getLabelsX()
Returns all the labels for X.List<String>
getLabelsY()
Returns all the labels for Y.gnu.trove.map.hash.TDoubleObjectHashMap<String>
getMappingsX()
Returns all the mappings for X.gnu.trove.map.hash.TDoubleObjectHashMap<String>
getMappingsY()
Returns all the mappings for Y.String
getMappingX(double key)
Returns the X mapping associated with the key.String
getMappingY(double key)
Returns the Y mapping associated with the key.XYSequencePoint
getMaxX()
Returns point with the maximum X.XYSequencePoint
getMaxY()
Returns point with the maximum Y.XYSequencePoint
getMinX()
Returns point with the minimum X.XYSequencePoint
getMinY()
Returns point with the minimum Y.boolean
hasMappingX()
Checks whether there are string mappings for the X values available.boolean
hasMappingY()
Checks whether there are string mappings for the Y values available.protected void
invalidateMinMax()
Invalidates the min/max points.protected boolean
modifiedListener(boolean modified)
Method that gets notified about changes in the collection of data points.DataPointComparator<XYSequencePoint>
newComparator()
Returns the comparator in use.XYSequencePoint
newPoint()
Returns a new instance of a sequence point.double
putMappingX(String s)
Adds a X mapping for the given string.double
putMappingY(String s)
Adds a Y mapping for the given string.String
removeMappingX(double x)
Removes a X mapping for the given value.String
removeMappingY(double y)
Removes a Y mapping for the given value.void
setComparison(XYSequencePointComparator.Comparison value)
Sets the type of comparison to use.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.SpreadSheet
toSpreadSheet(List<XYSequencePoint> points)
Returns the list of points as spreadsheet.protected void
validateMinMax()
Determines the min/max points.-
Methods inherited from class adams.data.container.AbstractDataContainer
add, addAll, assign, clear, compareTo, compareToData, compareToHeader, contains, containsAll, ensureCapacity, equals, equalsData, equalsHeader, getClone, getHeader, getID, getUniqueID, hashCode, isEmpty, iterator, mergeWith, newInstance, remove, removeAll, retainAll, setID, size, toArray, toArray, toList, toList, toString, toTreeSet, toTreeSet, trimToSize
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface adams.data.container.DataContainer
assign, compareToData, compareToHeader, equalsData, equalsHeader, getClone, getHeader, toList, toList, toTreeSet, toTreeSet
-
Methods inherited from interface adams.data.id.MutableIDHandler
setID
-
Methods inherited from interface adams.core.UniqueIDHandler
getUniqueID
-
-
-
-
Field Detail
-
FILE_EXTENSION
public static final String FILE_EXTENSION
the file extension.- See Also:
- Constant Field Values
-
m_Comparator
protected DataPointComparator m_Comparator
the default comparator.
-
m_Comparison
protected XYSequencePointComparator.Comparison m_Comparison
the comparison to use.
-
m_MinX
protected XYSequencePoint m_MinX
the minimum X point.
-
m_MaxX
protected XYSequencePoint m_MaxX
the maximum X point.
-
m_MinY
protected XYSequencePoint m_MinY
the minimum Y point.
-
m_MaxY
protected XYSequencePoint m_MaxY
the maximum Y point.
-
m_MappingX
protected gnu.trove.map.hash.TDoubleObjectHashMap<String> m_MappingX
string representations for the X values.
-
m_MappingY
protected gnu.trove.map.hash.TDoubleObjectHashMap<String> m_MappingY
string representations for the Y values.
-
-
Method Detail
-
assign
public void assign(XYSequence other)
Obtains the stored variables from the other data point, but not the actual data points.- Parameters:
other
- the data point to get the values from
-
hasMappingX
public boolean hasMappingX()
Checks whether there are string mappings for the X values available.- Returns:
- true if X mappings available
-
putMappingX
public double putMappingX(String s)
Adds a X mapping for the given string.- Parameters:
s
- the string to add the mapping for- Returns:
- the generated mapping
-
removeMappingX
public String removeMappingX(double x)
Removes a X mapping for the given value.- Parameters:
x
- the mapping to remove- Returns:
- the previous mapping string, if any
-
getMappingX
public String getMappingX(double key)
Returns the X mapping associated with the key.- Parameters:
key
- the mapping to look up- Returns:
- the mapping
-
getMappingsX
public gnu.trove.map.hash.TDoubleObjectHashMap<String> getMappingsX()
Returns all the mappings for X.- Returns:
- the mappings
-
hasMappingY
public boolean hasMappingY()
Checks whether there are string mappings for the Y values available.- Returns:
- true if Y mappings available
-
putMappingY
public double putMappingY(String s)
Adds a Y mapping for the given string.- Parameters:
s
- the string to add the mapping for- Returns:
- the generated mapping
-
removeMappingY
public String removeMappingY(double y)
Removes a Y mapping for the given value.- Parameters:
y
- the mapping to remove- Returns:
- the previous mapping string, if any
-
getMappingY
public String getMappingY(double key)
Returns the Y mapping associated with the key.- Parameters:
key
- the mapping to look up- Returns:
- the mapping
-
getMappingsY
public gnu.trove.map.hash.TDoubleObjectHashMap<String> getMappingsY()
Returns all the mappings for Y.- Returns:
- the mappings
-
setComparison
public void setComparison(XYSequencePointComparator.Comparison value)
Sets the type of comparison to use.- Parameters:
value
- the type of comparison to use
-
getComparison
public XYSequencePointComparator.Comparison getComparison()
Returns the type of comparison currently in use.- Returns:
- the type of comparison
-
newComparator
public DataPointComparator<XYSequencePoint> newComparator()
Returns the comparator in use.- Specified by:
newComparator
in interfaceDataContainer<XYSequencePoint>
- Returns:
- the comparator to use
-
getComparator
public DataPointComparator<XYSequencePoint> getComparator()
Returns the comparator in use.- Specified by:
getComparator
in interfaceDataContainer<XYSequencePoint>
- Returns:
- the comparator in use
-
newPoint
public XYSequencePoint newPoint()
Returns a new instance of a sequence point.- Specified by:
newPoint
in interfaceDataContainer<XYSequencePoint>
- Returns:
- the new sequence point
-
modifiedListener
protected boolean modifiedListener(boolean modified)
Method that gets notified about changes in the collection of data points. Invalidates the min/max and passes the modified state through.- Overrides:
modifiedListener
in classAbstractDataContainer<XYSequencePoint>
- Parameters:
modified
- whether the action modified the collection- Returns:
- the same as the input
-
invalidateMinMax
protected void invalidateMinMax()
Invalidates the min/max points.
-
validateMinMax
protected void validateMinMax()
Determines the min/max points.
-
getMinX
public XYSequencePoint getMinX()
Returns point with the minimum X.- Returns:
- the point
-
getMaxX
public XYSequencePoint getMaxX()
Returns point with the maximum X.- Returns:
- the point
-
getMinY
public XYSequencePoint getMinY()
Returns point with the minimum Y.- Returns:
- the point
-
getMaxY
public XYSequencePoint getMaxY()
Returns point with the maximum Y.- Returns:
- the point
-
find
public XYSequencePoint find(double x)
Returns the SequencePoint with the exact number, null if not found.- Parameters:
x
- the number to look for- Returns:
- the SequencePoint or null if not found
-
findClosest
public XYSequencePoint findClosest(double x)
Returns the SequencePoint with a number closest to the one provided.- Parameters:
x
- the number to look for- Returns:
- the SpectrumPoint
-
toSpreadSheet
public SpreadSheet toSpreadSheet(List<XYSequencePoint> points)
Returns the list of points as spreadsheet.- Specified by:
toSpreadSheet
in interfaceDataContainerWithSpreadSheetSupport<XYSequencePoint>
- Parameters:
points
- the points to convert- Returns:
- the content
-
toSpreadSheet
public SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheet
in interfaceSpreadSheetSupporter
- Returns:
- the content
-
-