uk.ac.starlink.topcat.plot
Class PointSelection

java.lang.Object
  extended by uk.ac.starlink.topcat.plot.PointSelection
All Implemented Interfaces:
uk.ac.starlink.ttools.plot.PlotData

public class PointSelection
extends 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
static class PointSelection.TableMask
          Struct-type class which defines an association of a TopcatModel and a BitSet.
 
Constructor Summary
PointSelection(PointSelector[] selectors, int[][] subsetPointers, String[] subsetNames)
          Constructs a new selection.
 
Method Summary
 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(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 (see getPointTable(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.
 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(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(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)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PointSelection

public PointSelection(PointSelector[] selectors,
                      int[][] subsetPointers,
                      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 plotted
subsetPointers - pointers to subsets
subsetNames - labels to be used for the subsets in subsetPointers
Method Detail

readPoints

public Points readPoints(BoundedRangeModel progress)
                  throws IOException,
                         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 (see sameData(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:
InterruptedException - if the calling thread is interrupted
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 to readPoints(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 by getSubsets().

Returns:
style array

getSetCount

public int getSetCount()
Specified by:
getSetCount in interface uk.ac.starlink.ttools.plot.PlotData

getSetName

public String getSetName(int iset)
Specified by:
getSetName in interface uk.ac.starlink.ttools.plot.PlotData

getSetStyle

public uk.ac.starlink.ttools.plot.Style getSetStyle(int iset)
Specified by:
getSetStyle in interface uk.ac.starlink.ttools.plot.PlotData

getNdim

public int getNdim()
Specified by:
getNdim in interface uk.ac.starlink.ttools.plot.PlotData

getNerror

public int getNerror()
Specified by:
getNerror in interface uk.ac.starlink.ttools.plot.PlotData

hasLabels

public boolean hasLabels()
Specified by:
hasLabels in interface uk.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 interface uk.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 by getSubsets().

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 (see getPointTable(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 - table
lrow - row index in tcModel
Returns:
array of point indices for that row

getTableMasks

public PointSelection.TableMask[] getTableMasks(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 resembles sameData(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 if readPoints(javax.swing.BoundedRangeModel) will return the same result for this object and other.

Parameters:
other - comparison object
Returns:
true iff the data is the same

equals

public boolean equals(Object otherObject)
Equals is implemented efficiently to identify two PointSelection objects which will behave in the same way.

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.