// // CursorSSCell.java // /* Below is a simple extension of visad.ss.FancySSCell that prints range values to the console window whenever the cursor is being displayed. It shouldn't be hard to modify this code to display the range values in a JLabel or other such GUI component. You should be able to follow this pattern to extend FancySSCell in any way you desire, producing any number of different custom spreadsheet cell behaviors. */ import java.awt.Frame; import java.rmi.RemoteException; import java.util.Vector; import visad.*; import visad.formula.FormulaManager; import visad.ss.*; public class CursorSSCell extends FancySSCell { public CursorSSCell(String name, FormulaManager fman, RemoteServer rs, boolean slave, String save, Frame parent) throws VisADException, RemoteException { super(name, fman, rs, slave, save, parent); addDisplayListener(new DisplayListener() { public void displayChanged(DisplayEvent e) { // get cursor value double[] scale_offset = new double[2]; double[] dum_1 = new double[2]; double[] dum_2 = new double[2]; DisplayRenderer renderer = VDisplay.getDisplayRenderer(); double[] cur = renderer.getCursor(); Vector cursorStringVector = renderer.getCursorStringVector(); if (cursorStringVector == null || cursorStringVector.size() == 0 || cur == null || cur.length == 0 || cur[0] != cur[0]) { return; } // locate x and y mappings ScalarMap[] maps = getMaps(); ScalarMap map_x = null, map_y = null; for (int i=0; i