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.PlotDataEncapsulates 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 classPointSelection.TableMaskStruct-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.PlotDatacreatePlotData(Points points)Returns a PlotData object based on this point selection but with a given points object.booleanequals(java.lang.Object otherObject)Equals is implemented efficiently to identify two PointSelection objects which will behave in the same way.PointsgetEmptyPoints()Returns a dummy Points object compatible with this selection.intgetNdim()intgetNerror()longgetPointRow(long ipoint)Given a point index from this selection, returns the row number in its table (seegetPointTable(long)that it represents.PointsgetPoints()uk.ac.starlink.ttools.plot.PointSequencegetPointSequence()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.TopcatModelgetPointTable(long ipoint)Given a point index from this selection, returns the table that it comes from.intgetSetCount()SetId[]getSetIds()Returns the list of set ID labels which identify where each set comes from.java.lang.StringgetSetName(int iset)uk.ac.starlink.ttools.plot.StylegetSetStyle(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.inthashCode()booleanhasLabels()PointsreadPoints(javax.swing.BoundedRangeModel progress)Reads a data points list for this selection.booleansameAxes(PointSelection other)Determines if the axes defining this point selection are the same as those for another one.booleansameData(PointSelection other)Determines if the data required to plot this point selection is the same as the data required to plot another one.voidsetPoints(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,
subsetPointersis 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:
getSetCountin interfaceuk.ac.starlink.ttools.plot.PlotData
-
getSetName
public java.lang.String getSetName(int iset)
- Specified by:
getSetNamein interfaceuk.ac.starlink.ttools.plot.PlotData
-
getSetStyle
public uk.ac.starlink.ttools.plot.Style getSetStyle(int iset)
- Specified by:
getSetStylein interfaceuk.ac.starlink.ttools.plot.PlotData
-
getNdim
public int getNdim()
- Specified by:
getNdimin interfaceuk.ac.starlink.ttools.plot.PlotData
-
getNerror
public int getNerror()
- Specified by:
getNerrorin interfaceuk.ac.starlink.ttools.plot.PlotData
-
hasLabels
public boolean hasLabels()
- Specified by:
hasLabelsin 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:
getPointSequencein 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-