Skip to content

Commit

Permalink
ttools: add PlotDisplay.ASPECT_PROPERTY
Browse files Browse the repository at this point in the history
You can track plot display aspect changes with a PropertyChangeListener.
  • Loading branch information
mbtaylor authored and mmpcn committed Nov 27, 2014
1 parent d973aad commit 07ecb42
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ttools/src/main/uk/ac/starlink/ttools/plot2/task/PlotDisplay.java
Expand Up @@ -67,6 +67,14 @@ public class PlotDisplay<P,A> extends JComponent {
private A aspect_;
private Icon icon_;

/**
* Name of property that changes when plot Aspect is reset.
* Can be monitored by use of a PropertyChangeListener.
* The property object type is an aspect, that is of this class's
* parameterised type A.
*/
public static final String ASPECT_PROPERTY = "Plot2Aspect";

private static final Logger logger_ =
Logger.getLogger( "uk.ac.starlink.ttools.plot2" );

Expand Down Expand Up @@ -244,9 +252,11 @@ protected void paintComponent( Graphics g ) {
*/
public void setAspect( A aspect ) {
if ( aspect != null && ! aspect.equals( aspect_ ) ) {
A oldAspect = aspect_;
aspect_ = aspect;
clearPlot();
repaint();
firePropertyChange( ASPECT_PROPERTY, oldAspect, aspect );
}
}

Expand Down

0 comments on commit 07ecb42

Please sign in to comment.