/** * Apply the state to the display * * @return Was this successful */ protected boolean doApply() { // myInfo.setOrientation(GuiUtils.getValueFromBox(orientationBox)); String place = (String) placementBox.getSelectedItem(); if (place != null) { myInfo.setPlacement(place); } myInfo.setLabelColor(colorSwatch.getSwatchColor()); myInfo.setIsVisible(visibilityCbx.isSelected()); myInfo.setUnitVisible(unitCbx.isSelected()); myInfo.setLabelVisible(labelVisibilityCbx.isSelected()); myInfo.setUseAlpha(alphaCbx.isSelected()); myInfo.setLabelFont(fontSelector.getFont()); try { if (displayControl != null) { if (displayControl.getColorUnit() != null) { // mjh inq 1925: use colorUnit instead of displayUnit // if available; this fixes unit label when using the // "color by another value" displays. myInfo.setUnit(displayControl.getColorUnit()); } else { myInfo.setUnit(displayControl.getDisplayUnit()); } displayControl.setColorScaleInfo(new ColorScaleInfo(getInfo())); } return true; } catch (Exception exc) { LogUtil.logException("Setting color scale info", exc); return false; } }
/** * Construct the widget. with interval, min, max entry boxes and ok and cancel buttons. * * @param displayControl The display * @param title title for frame * @param info the color scale info * @param showDialog true to show the dialog */ public ColorScaleDialog( DisplayControlImpl displayControl, String title, ColorScaleInfo info, boolean showDialog) { ok = false; this.displayControl = displayControl; myInfo = new ColorScaleInfo(info); if (showDialog) { dialog = GuiUtils.createDialog( ((displayControl != null) ? displayControl.getWindow() : null), title, true); } doMakeContents(showDialog); String place = myInfo.getPlacement(); // account for old bundles if (place != null) { placementBox.setSelectedItem(place); } // orientationBox.setSelectedItem(myInfo.getOrientation()); visibilityCbx.setSelected(myInfo.getIsVisible()); unitCbx.setSelected(myInfo.isUnitVisible()); labelVisibilityCbx.setSelected(myInfo.getLabelVisible()); alphaCbx.setSelected(myInfo.getUseAlpha()); if (showDialog) { dialog.setVisible(true); } }
/** * Initialize the contents * * @param showDialog true to show the dialog */ private void doMakeContents(boolean showDialog) { placementBox = new JComboBox(positions); colorSwatch = new ColorSwatchComponent( displayControl.getIdv().getStore(), myInfo.getLabelColor(), "Color Scale Label Color"); final JComponent colorComp = colorSwatch.getSetPanel(); visibilityCbx = new JCheckBox("", myInfo.getIsVisible()); unitCbx = new JCheckBox("Show Unit", myInfo.isUnitVisible()); alphaCbx = new JCheckBox("", myInfo.getUseAlpha()); fontSelector = new FontSelector(FontSelector.COMBOBOX_UI, false, false); fontSelector.setFont(myInfo.getLabelFont()); labelVisibilityCbx = new JCheckBox("Visible", myInfo.getLabelVisible()); labelVisibilityCbx.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showLabel = ((JCheckBox) e.getSource()).isSelected(); GuiUtils.enableTree(fontSelector.getComponent(), showLabel); GuiUtils.enableTree(colorComp, showLabel); } }); GuiUtils.tmpInsets = new Insets(4, 4, 4, 4); contents = GuiUtils.doLayout( new Component[] { GuiUtils.rLabel("Visible: "), visibilityCbx, // GuiUtils.leftRight(visibilityCbx, GuiUtils.flow( new Component[] {GuiUtils.rLabel(" // Show Transparency: "), alphaCbx})), GuiUtils.rLabel("Position: "), GuiUtils.leftRight(placementBox, GuiUtils.filler()), GuiUtils.rLabel("Labels: "), GuiUtils.leftRight(labelVisibilityCbx, GuiUtils.filler()), GuiUtils.filler(), GuiUtils.leftRight(unitCbx, GuiUtils.filler()), GuiUtils.filler(), GuiUtils.leftRight(GuiUtils.rLabel("Font: "), fontSelector.getComponent()), GuiUtils.filler(), GuiUtils.leftRight( GuiUtils.rLabel("Color: "), GuiUtils.leftRight(colorComp, GuiUtils.filler())), }, 2, GuiUtils.WT_NY, GuiUtils.WT_N); contents = GuiUtils.leftRight(contents, GuiUtils.filler()); if (showDialog) { JPanel buttons; if (displayControl != null) { buttons = GuiUtils.makeApplyOkCancelButtons(this); } else { buttons = GuiUtils.makeOkCancelButtons(this); } dialog.getContentPane().add(GuiUtils.centerBottom(contents, buttons)); GuiUtils.packInCenter(dialog); } }
/** * get the display list font * * @return the font or null */ private Font getDisplayListFont() { if (displayControl == null) { return null; } Font f = displayControl.getViewManager().getDisplayListFont(); int size = (f == null) ? 12 : f.getSize(); if ((f != null) && f.getName().equals(FontSelector.DEFAULT_NAME)) { f = null; } return f; }
/** * Override the base class method to catch any events. * * @param e The action event. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); try { if (cmd.equals(CMD_BARBSIZE)) { setFlowScale(GuiUtils.getBoxValue((JComboBox) e.getSource())); } else if (cmd.equals(CMD_INTERVAL)) { setVerticalInterval(GuiUtils.getBoxValue((JComboBox) e.getSource())); } else { super.actionPerformed(e); } } catch (NumberFormatException nfe) { userErrorMessage("Incorrect number format"); } }
/** * Make the control widgets * * @param controlWidgets list of control widgets * @throws RemoteException Java RMI error * @throws VisADException VisAD Error */ public void getControlWidgets(List controlWidgets) throws VisADException, RemoteException { super.getControlWidgets(controlWidgets); JComponent barbSizeBox = GuiUtils.wrap( GuiUtils.createValueBox( this, CMD_BARBSIZE, (int) flowScaleValue, Misc.createIntervalList(1, 10, 1), true)); // make possible another component(s) to put on same line w barbSizeBox JComponent extra = doMakeExtraComponent(); JComponent rightPanel = GuiUtils.leftCenter( ((extra != null) ? (JComponent) GuiUtils.hflow(Misc.newList(barbSizeBox, extra)) : (JComponent) barbSizeBox), GuiUtils.filler()); controlWidgets.add(new WrapperWidget(this, GuiUtils.rLabel("Windbarb size: "), rightPanel)); }
/** * Utility method to notify the user with a message * * @param message The message */ public void userMessage(String message) { if (displayControl == null) { return; } displayControl.userMessage(message); }
/** * Utility method to log an exception. * * @param message The message * @param exc The exception */ public void logException(String message, Exception exc) { if (displayControl == null) { return; } displayControl.logException(message, exc); }
/** * Get the display conventions from the contol * * @return The {@link ucar.unidata.idv.DisplayConventions} to use. */ public DisplayConventions getDisplayConventions() { if (displayControl == null) { return null; } return displayControl.getDisplayConventions(); }
/** Method called after initialization. */ public void initDone() { super.initDone(); setFlowScale(flowScaleValue); setVerticalInterval(verticalIntervalValue); }