// // WhiteSSCell.java // /* You can get the DisplayImpl from a BasicSSCell (a spreadsheet cell) by calling BasicSSCell.getDisplay(). However, whenever a BasicSSCell switches dimensions, a new DisplayImpl must be initialized. So, the best way to ensure the spreadsheet always has cells with white backgrounds is to make a simple extension. Below is an extension of visad.ss.FancySSCell that does the trick. */ import java.io.*; import java.awt.Frame; import java.rmi.*; import visad.*; import visad.formula.*; import visad.ss.*; /** An extension of visad.ss.FancySSCell for cells with white backgrounds. */ public class WhiteSSCell extends FancySSCell { /** Extended from visad.ss.FancySSCell. */ public WhiteSSCell(String name, FormulaManager fman, RemoteServer rs, boolean slave, String save, Frame parent) throws VisADException, RemoteException { super(name, fman, rs, slave, save, parent); } /** * Extends visad.ss.FancySSCell.constructDisplay so that whenever a * new DisplayImpl is constructed, its background is set to white. */ public synchronized boolean constructDisplay() { boolean success = super.constructDisplay(); if (success) { DisplayRenderer dRenderer = VDisplay.getDisplayRenderer(); try { // set background color dRenderer.setBackgroundColor(1.0f, 1.0f, 1.0f); // white dRenderer.setBoxColor(0.0f, 0.0f, 0.0f); // black } catch (VisADException exc) { exc.printStackTrace(); } catch (RemoteException exc) { exc.printStackTrace(); } } return success; } public static void main(String[] args) { SpreadSheet.setSSCellClass(WhiteSSCell.class); SpreadSheet.main(args); } }