Package uk.ac.starlink.topcat.plot
Class PointSelection
- java.lang.Object
-
- uk.ac.starlink.topcat.plot.PointSelection
-
- All Implemented Interfaces:
uk.ac.starlink.ttools.plot.PlotData
public class PointSelection extends java.lang.Object implements uk.ac.starlink.ttools.plot.PlotData
Encapsulates the selection of the list of points which is to be plotted. This may be composed of points from one or more than one tables.- Since:
- 2 Nov 2005
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PointSelection.TableMask
Struct-type class which defines an association of a TopcatModel and a BitSet.
-
Constructor Summary
Constructors Constructor Description PointSelection(PointSelector[] selectors, int[][] subsetPointers, java.lang.String[] subsetNames)
Constructs a new selection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description uk.ac.starlink.ttools.plot.PlotData
createPlotData(Points points)
Returns a PlotData object based on this point selection but with a given points object.boolean
equals(java.lang.Object otherObject)
Equals is implemented efficiently to identify two PointSelection objects which will behave in the same way.Points
getEmptyPoints()
Returns a dummy Points object compatible with this selection.int
getNdim()
int
getNerror()
long
getPointRow(long ipoint)
Given a point index from this selection, returns the row number in its table (seegetPointTable(long)
that it represents.Points
getPoints()
uk.ac.starlink.ttools.plot.PointSequence
getPointSequence()
long[]
getPointsForRow(TopcatModel tcModel, long lrow)
Given a table and a row index into that table, returns the point indices of any points in this selection which correspond to that row.TopcatModel
getPointTable(long ipoint)
Given a point index from this selection, returns the table that it comes from.int
getSetCount()
SetId[]
getSetIds()
Returns the list of set ID labels which identify where each set comes from.java.lang.String
getSetName(int iset)
uk.ac.starlink.ttools.plot.Style
getSetStyle(int iset)
uk.ac.starlink.ttools.plot.Style[]
getStyles()
Returns a list of styles for subset plotting.RowSubset[]
getSubsets()
Returns a list of subsets to be plotted.PointSelection.TableMask[]
getTableMasks(java.util.BitSet pointMask)
Given a bit vector which represents a selection of the points in this object, returns an array of TableMask objects which represent selections of rows within any of the tables this object knows about.int
hashCode()
boolean
hasLabels()
Points
readPoints(javax.swing.BoundedRangeModel progress)
Reads a data points list for this selection.boolean
sameAxes(PointSelection other)
Determines if the axes defining this point selection are the same as those for another one.boolean
sameData(PointSelection other)
Determines if the data required to plot this point selection is the same as the data required to plot another one.void
setPoints(Points points)
-
-
-
Constructor Detail
-
PointSelection
public PointSelection(PointSelector[] selectors, int[][] subsetPointers, java.lang.String[] subsetNames)
Constructs a new selection.As well as the point selectors themselves which hold almost all the required state, an additional array,
subsetPointers
is given to indicate in what order the subsets should be plotted. Each element of this array is a two-element int array; the first element is the index of the point selector, and the second element the index of the subset within that selector.- Parameters:
selectors
- array of PointSelector objects whose current state determines the points to be plottedsubsetPointers
- pointers to subsetssubsetNames
- labels to be used for the subsets insubsetPointers
-
-
Method Detail
-
readPoints
public Points readPoints(javax.swing.BoundedRangeModel progress) throws java.io.IOException, java.lang.InterruptedException
Reads a data points list for this selection. The data are actually read from the table objects in this call, so it may be time-consuming. So, don't call it if you already have the data it would return (seesameData(uk.ac.starlink.topcat.plot.PointSelection)
). If a progress bar model is supplied it will be updated as the read progresses.This method checks for interruption status on its calling thread. If an interruption is made, it will cease calculating and throw an InterruptedException.
- Parameters:
progress
- bar model to be updated as read is done- Returns:
- points list
- Throws:
java.lang.InterruptedException
- if the calling thread is interruptedjava.io.IOException
-
getEmptyPoints
public Points getEmptyPoints()
Returns a dummy Points object compatible with this selection. It contains no data.- Returns:
- points object with
getCount()==0
-
getSubsets
public RowSubset[] getSubsets()
Returns a list of subsets to be plotted. The row indices used by these subsets correspond to the row sequence returned by a call toreadPoints(javax.swing.BoundedRangeModel)
.- Returns:
- subset array
-
getStyles
public uk.ac.starlink.ttools.plot.Style[] getStyles()
Returns a list of styles for subset plotting. This corresponds to the subset list returned bygetSubsets()
.- Returns:
- style array
-
getSetCount
public int getSetCount()
- Specified by:
getSetCount
in interfaceuk.ac.starlink.ttools.plot.PlotData
-
getSetName
public java.lang.String getSetName(int iset)
- Specified by:
getSetName
in interfaceuk.ac.starlink.ttools.plot.PlotData
-
getSetStyle
public uk.ac.starlink.ttools.plot.Style getSetStyle(int iset)
- Specified by:
getSetStyle
in interfaceuk.ac.starlink.ttools.plot.PlotData
-
getNdim
public int getNdim()
- Specified by:
getNdim
in interfaceuk.ac.starlink.ttools.plot.PlotData
-
getNerror
public int getNerror()
- Specified by:
getNerror
in interfaceuk.ac.starlink.ttools.plot.PlotData
-
hasLabels
public boolean hasLabels()
- Specified by:
hasLabels
in interfaceuk.ac.starlink.ttools.plot.PlotData
-
createPlotData
public uk.ac.starlink.ttools.plot.PlotData createPlotData(Points points)
Returns a PlotData object based on this point selection but with a given points object. Since PointSelection implements PlotData in any case, this is not always necessary, but what this method provides is a PlotData whose data will not change if the points object owned by this PointSelection is replaced.- Parameters:
points
- fixed points data- Returns:
- plot data closure
-
getPointSequence
public uk.ac.starlink.ttools.plot.PointSequence getPointSequence()
- Specified by:
getPointSequence
in interfaceuk.ac.starlink.ttools.plot.PlotData
-
setPoints
public void setPoints(Points points)
-
getPoints
public Points getPoints()
-
getSetIds
public SetId[] getSetIds()
Returns the list of set ID labels which identify where each set comes from. This corresponds to the subset list returned bygetSubsets()
.- Returns:
- set ID array
-
getPointTable
public TopcatModel getPointTable(long ipoint)
Given a point index from this selection, returns the table that it comes from.- Parameters:
ipoint
- point index- Returns:
- topcat model that the point is from
- See Also:
getPointRow(long)
-
getPointRow
public long getPointRow(long ipoint)
Given a point index from this selection, returns the row number in its table (seegetPointTable(long)
that it represents.- Parameters:
ipoint
- point index- Returns:
- row number of point index in its table
-
getPointsForRow
public long[] getPointsForRow(TopcatModel tcModel, long lrow)
Given a table and a row index into that table, returns the point indices of any points in this selection which correspond to that row.- Parameters:
tcModel
- tablelrow
- row index intcModel
- Returns:
- array of point indices for that row
-
getTableMasks
public PointSelection.TableMask[] getTableMasks(java.util.BitSet pointMask)
Given a bit vector which represents a selection of the points in this object, returns an array of TableMask objects which represent selections of rows within any of the tables this object knows about.- Parameters:
pointMask
- bit vector reprsenting a subset of the points in this object- Returns:
- array of table/mask pairs representing non-empty row subsets
-
sameAxes
public boolean sameAxes(PointSelection other)
Determines if the axes defining this point selection are the same as those for another one. This resemblessameData(uk.ac.starlink.topcat.plot.PointSelection)
, except that PointSelections with different error or label information can be considered to have the same axes.- Parameters:
other
- comparison object- Returns:
- true iff the data axes are the same
-
sameData
public boolean sameData(PointSelection other)
Determines if the data required to plot this point selection is the same as the data required to plot another one. More exactly, it returns true only ifreadPoints(javax.swing.BoundedRangeModel)
will return the same result for this object andother
.- Parameters:
other
- comparison object- Returns:
- true iff the data is the same
-
equals
public boolean equals(java.lang.Object otherObject)
Equals is implemented efficiently to identify two PointSelection objects which will behave in the same way.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-