/** * Take out the histogram-related stuff that was in doMakeContents and put it in a standalone * method, so we can wait and call it only after the histogram is actually initialized. */ private void setInitialHistogramRange() { try { Range range = getRange(); double lo = range.getMin(); double hi = range.getMax(); histoWrapper.setHigh(hi); histoWrapper.setLow(lo); } catch (Exception exc) { logException("setInitialHistogramRange", exc); } }
public void resetColorTable() { try { revertToDefaultColorTable(); revertToDefaultRange(); histoWrapper.resetPlot(); } catch (Exception e) { logger.error("problem resetting color table", e); } }
protected JComponent getHistogramTabComponent() { List choices = new ArrayList(); if (datachoice == null) { datachoice = getDataChoice(); } choices.add(datachoice); histoWrapper = new McIDASVHistogramWrapper("histo", choices, (DisplayControlImpl) this); dataSource = getDataSource(); if (dataSource == null) { try { image = (FlatField) ((ComboDataChoice) datachoice).getData(); histoWrapper.loadData(image); } catch (Exception e) { } } else { Hashtable props = dataSource.getProperties(); try { DataSelection testSelection = datachoice.getDataSelection(); DataSelection realSelection = getDataSelection(); if (testSelection == null) { datachoice.setDataSelection(realSelection); } ImageSequenceImpl seq = null; if (dataSelection == null) dataSelection = dataSource.getDataSelection(); if (dataSelection == null) { image = (FlatField) dataSource.getData(datachoice, null, props); if (image == null) { image = (FlatField) datachoice.getData(null); } } else { Data data = dataSource.getData(datachoice, null, dataSelection, props); if (data instanceof ImageSequenceImpl) { seq = (ImageSequenceImpl) data; } else if (data instanceof FlatField) { image = (FlatField) data; } else if (data instanceof FieldImpl) { image = (FlatField) ((FieldImpl) data).getSample(0, false); } else { throw new Exception("Histogram must be made from a FlatField"); } } if (seq != null) { if (seq.getImageCount() > 0) image = (FlatField) seq.getImage(0); } histoWrapper.loadData(image); } catch (Exception e) { logger.error("attempting to set up histogram", e); } } JComponent histoComp = histoWrapper.doMakeContents(); JButton resetButton = new JButton("Reset"); resetButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { resetColorTable(); } }); JPanel resetPanel = GuiUtils.center(GuiUtils.inset(GuiUtils.wrap(resetButton), 4)); return GuiUtils.centerBottom(histoComp, resetPanel); }