public class BasicTablePlotter extends Object implements TablePlotter, LayerListener, ChangeListener
Note: This class was previously implemented using Diva figures for catalog symbols, however this turned out to be slow for large numbers of figures, so this version handles the drawing and selection of catalog symbols directly.
Modifier and Type | Class and Description |
---|---|
protected class |
BasicTablePlotter.FigureListItem
Local class used for SymbolListItem.figureList elements (one for each plot symbol).
|
protected class |
BasicTablePlotter.SymbolListItem
Local class used for TableListItem.symbolList elements (one for each plot
symbol entry, for each table)
|
protected class |
BasicTablePlotter.TableListItem
Local class used for tableList elements (one for each table).
|
Constructor and Description |
---|
BasicTablePlotter()
Default Constructor
(Note: you need to call setCanvasGraphics() and setCoordinateConverter()
before using this object).
|
BasicTablePlotter(CanvasGraphics canvasGraphics,
CoordinateConverter coordinateConverter)
Construct an object to plot the contents of a table (query result or local
catalog file).
|
BasicTablePlotter(JDesktopPane desktop)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addSymbolSelectionListener(SymbolSelectionListener listener)
Add a listener for selection events on symbols
|
void |
addTableSelectionListener(TableSelectionListener listener)
Add a listener for selection events on tables
|
boolean |
check(TableQueryResult table)
Check if there is an image loaded and if so, if it supports world coordinates.
|
void |
deselectSymbol(TableQueryResult table,
int tableRow)
Deselect the symbol corresponding to the given table row
|
protected void |
fireSymbolSelectionEvent(TableQueryResult table,
int row,
boolean isSelected)
Notify any listeners that a symbol was selected or deselected.
|
protected void |
fireTableSelectionEvent(TableQueryResult table,
int row,
boolean selected)
Notify any listeners that a table row was selected
|
CanvasGraphics |
getCanvasGraphics()
Return the object to use to draw catalog symbols
|
NamedCoordinates |
getCatalogPosition(Point2D.Double p)
If the given screen coordinates point is within a displayed catalog symbol, set it to
point to the center of the symbol and return the name and coordinates (and brightness,
if known) from the catalog table row.
|
JPanel |
getConfigPanel(TableQueryResult table)
Return a panel to use to configure the plot symbols for the given table.
|
CoordinateConverter |
getCoordinateConverter()
Return the object used to convert to screen coordinates for drwing
|
protected int |
getCoordType(String name)
Return the CoordinateConverter type code for the given name.
|
protected void |
getNorthAndEast(Point2D.Double center,
double size,
double ratio,
double angle,
Point2D.Double north,
Point2D.Double east) |
TablePlotSymbol[] |
getPlotSymbolInfo(TableQueryResult table)
Return the plot symbol info for the given table.
|
protected CoordinateRadius |
getTableRegion(TableQueryResult table)
Scan the given table and return an object describing the area of the sky that
it covers, or null if not known.
|
TableQueryResult[] |
getTables()
Return an array containing the tables managed by this object.
|
boolean |
isVisible()
Return true if catalog symbols are visible, false if they are hidden.
|
protected Shape |
makeShape(TablePlotSymbol symbol,
double x,
double y,
double size,
double ratio,
double angle)
Return the Shape object for the given symbol.
|
void |
mouseClicked(LayerEvent e)
Invoked when the mouse is clicked on a layer or figure.
|
void |
mouseDragged(LayerEvent e)
Invoked when the mouse moves while the button is still held down.
|
void |
mousePressed(LayerEvent e)
Invoked when the mouse is pressed on a layer or figure.
|
void |
mouseReleased(LayerEvent e)
Invoked when the mouse is released on a layer or figure.
|
void |
paintSymbols(Graphics2D g2d,
Rectangle2D region)
Paint the catalog symbols using the given graphics object.
|
void |
plot(TableQueryResult table)
Plot the given table data.
|
protected void |
plotRow(TableQueryResult table,
int row,
Vector rowVec,
double x,
double y,
int cooSys,
TablePlotSymbol symbol) |
protected void |
plotSymbol(TableQueryResult table,
int row,
TablePlotSymbol symbol,
double x,
double y,
int cooSys,
double radius,
double ratio,
double angle,
String label) |
protected void |
plotSymbols(TableQueryResult table,
TablePlotSymbol[] symbols)
Plot the table data using the given symbol descriptions.
|
void |
removeSymbolSelectionListener(SymbolSelectionListener listener)
Remove a listener for selection events on symbols
|
void |
removeTableSelectionListener(TableSelectionListener listener)
Remove a listener for selection events on tables
|
protected void |
repaint(Shape shape)
Schedule a repaint of the area given by the given shape
|
void |
replotAll()
Recalculate the coordinates and replot all symbols after a change in the coordinate system.
|
protected void |
rotatePoint(Point2D.Double p,
Point2D.Double center,
double angle) |
void |
selectSymbol(TableQueryResult table,
int tableRow)
Select the symbol corresponding to the given table row
|
void |
selectSymbol(TableQueryResult table,
int tableRow,
boolean selected)
Set the selection state of the symbol corresponding to the given table row
|
void |
setCanvasGraphics(CanvasGraphics canvasGraphics)
Set the object to use to draw catalog symbols
|
void |
setCoordinateConverter(CoordinateConverter c)
Set the object used to convert to screen coordinates for drwing
|
void |
setPlotSymbolInfo(TableQueryResult table,
TablePlotSymbol[] symbols)
Set the plot symbol info for the given table
|
void |
setVisible(boolean isVisible)
If the given argument is false, hide all plot symbols managed by this object,
otherwise show them again.
|
void |
stateChanged(ChangeEvent e)
Called when the WCS info changes
|
protected boolean |
tableInRange(TableQueryResult table)
Return true if the coordinates of the objects in the given table may be in a
range where they can be plotted in the current image.
|
void |
transformGraphics(AffineTransform trans)
Transform the plot symbols using the given AffineTransform
(called when the image is transformed, to keep the plot symbols up to date).
|
void |
unplot(TableQueryResult table)
Erase the plot of the given table data
|
void |
unplotAll()
Erase all plot symbols
|
public BasicTablePlotter()
public BasicTablePlotter(JDesktopPane desktop)
desktop
- The JDesktopPane to use for popup windows.public BasicTablePlotter(CanvasGraphics canvasGraphics, CoordinateConverter coordinateConverter)
canvasGraphics
- the object to use to draw the plot symbolscoordinateConverter
- the object to use to convert between world and image coordinatespublic void setCanvasGraphics(CanvasGraphics canvasGraphics)
setCanvasGraphics
in interface TablePlotter
public CanvasGraphics getCanvasGraphics()
getCanvasGraphics
in interface TablePlotter
public CoordinateConverter getCoordinateConverter()
getCoordinateConverter
in interface TablePlotter
public void setCoordinateConverter(CoordinateConverter c)
setCoordinateConverter
in interface TablePlotter
public boolean check(TableQueryResult table)
table
- describes the table datapublic void plot(TableQueryResult table)
plot
in interface TablePlotter
table
- describes the table datapublic void stateChanged(ChangeEvent e)
stateChanged
in interface ChangeListener
public TablePlotSymbol[] getPlotSymbolInfo(TableQueryResult table)
getPlotSymbolInfo
in interface TablePlotter
table
- object representing the catalog tablepublic void setPlotSymbolInfo(TableQueryResult table, TablePlotSymbol[] symbols)
setPlotSymbolInfo
in interface TablePlotter
protected void plotSymbols(TableQueryResult table, TablePlotSymbol[] symbols)
table
- describes the table datasymbols
- an array of objects describing the symbols to plotprotected void plotRow(TableQueryResult table, int row, Vector rowVec, double x, double y, int cooSys, TablePlotSymbol symbol)
protected void plotSymbol(TableQueryResult table, int row, TablePlotSymbol symbol, double x, double y, int cooSys, double radius, double ratio, double angle, String label)
protected int getCoordType(String name)
protected Shape makeShape(TablePlotSymbol symbol, double x, double y, double size, double ratio, double angle)
symbol
- an object describing the symbolx
- the X position screen coordinatey
- the Y position screen coordinatesize
- the radius of the symbol in screen coordinatesratio
- the x/y ratio (ellipticity ratio) of the symbolangle
- the rotation angleprotected void getNorthAndEast(Point2D.Double center, double size, double ratio, double angle, Point2D.Double north, Point2D.Double east)
protected void rotatePoint(Point2D.Double p, Point2D.Double center, double angle)
public void unplot(TableQueryResult table)
unplot
in interface TablePlotter
public void unplotAll()
unplotAll
in interface TablePlotter
public void replotAll()
replotAll
in interface TablePlotter
public TableQueryResult[] getTables()
getTables
in interface TablePlotter
protected void repaint(Shape shape)
public void selectSymbol(TableQueryResult table, int tableRow, boolean selected)
public void selectSymbol(TableQueryResult table, int tableRow)
selectSymbol
in interface TablePlotter
public void deselectSymbol(TableQueryResult table, int tableRow)
deselectSymbol
in interface TablePlotter
public void addSymbolSelectionListener(SymbolSelectionListener listener)
addSymbolSelectionListener
in interface TablePlotter
public void removeSymbolSelectionListener(SymbolSelectionListener listener)
removeSymbolSelectionListener
in interface TablePlotter
protected void fireSymbolSelectionEvent(TableQueryResult table, int row, boolean isSelected)
table
- the table containing the symbolrow
- the row index of the selected symbolisSelected
- set to true if the symbol was selected, false if deselectedpublic void addTableSelectionListener(TableSelectionListener listener)
addTableSelectionListener
in interface TablePlotter
public void removeTableSelectionListener(TableSelectionListener listener)
removeTableSelectionListener
in interface TablePlotter
protected void fireTableSelectionEvent(TableQueryResult table, int row, boolean selected)
table
- the table containing the selected rowrow
- the selected row indexisSelected
- set to true if the row was selected, false if deselectedpublic void setVisible(boolean isVisible)
setVisible
in interface TablePlotter
public boolean isVisible()
public JPanel getConfigPanel(TableQueryResult table)
getConfigPanel
in interface TablePlotter
table
- the result of a querypublic void paintSymbols(Graphics2D g2d, Rectangle2D region)
paintSymbols
in interface TablePlotter
g2D
- the graphics contextregion
- if not null, the region to paintpublic void transformGraphics(AffineTransform trans)
transformGraphics
in interface TablePlotter
protected boolean tableInRange(TableQueryResult table)
protected CoordinateRadius getTableRegion(TableQueryResult table)
public void mouseDragged(LayerEvent e)
mouseDragged
in interface LayerListener
public void mousePressed(LayerEvent e)
mousePressed
in interface LayerListener
public void mouseReleased(LayerEvent e)
mouseReleased
in interface LayerListener
public void mouseClicked(LayerEvent e)
Note that if a catalog symbol is selected, the event is modified, so that any other listeners will get the modified location, which is set to the center of the selected catalog symbol. This implements a kind of "snap to catalog symbol" feature for any layer listeners that are added after this instance.
mouseClicked
in interface LayerListener
public NamedCoordinates getCatalogPosition(Point2D.Double p)
getCatalogPosition
in interface TablePlotter
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.