import java.awt.*; import javax.swing.*; import cds.aladin.*; import cds.tools.*; public class MouseTrackPlug extends AladinPlugin implements VOObserver { public String menu() { return "Mouse Tracking"; } public String description() { return "PLUGIN TUTORIAL:\n" + "This plugin is an example VOObserver usage and real pixel access.\n" + "This plugin uses VOObserver callback method for displaying the " + "pixel values around the mouse. It displays the result in a JFrame panel."; } public String author() { return "Pierre Fernique [CDS]"; } public String version() { return "1.1 - January 2007"; } public String url() { return "http://aladin.u-strasbg.fr/java/Plugins/MouseTrackPlug.java"; } public String category() { return "Plugin tutorial"; } static private int SIZE = 5; // Grid size private JLabel cell[][]=null; // Grid of cells /* * Usage of VOObserver interface to track Aladin mouse clicks * 1) Create Java Swing objects to generate a grid of cells * 2) register itself has a Aladin VOObserver for POSITION */ public void exec() { // Already active => nothing to do if( active ) return; active=true; // Create the grid of cells f = new JFrame(); f.getContentPane().setLayout(new GridLayout(SIZE,SIZE,2,2)); cell = new JLabel[SIZE][SIZE]; for( int y=0; y=0 && x=0 && y=0 && x=0 && y Not used here */ public void pixel(double pixValue) { } /** Can be called by Aladin to know the state of plugin */ public boolean isRunning() { return active; } /** Call by Aladin during a manual plugin stop */ public void cleanup() { if( !active ) return; aladin.addObserver(this,0); f.dispose(); active=false; } }