/** * Removes the color bar. */ public void removeColorBar() { if (_colorBar!=null) { remove(_colorBar); revalidate(); _colorBar = null; } }
/** * Sets the format for major tic annotation of the color bar. * The default format is "%1.4G", which yields a minimum of 1 digit, * with up to 4 digits of precision. Any trailing zeros and decimal * point are removed from tic annotation. * @param format the format. */ public void setColorBarFormat(String format) { _colorBarFormat = format; if (_colorBar!=null) { _colorBar.setFormat(format); revalidate(); } }
/** * Sets a minimum width (in pixels) for a color bar. * This method is useful when attempting to construct multiple plot * panels with the same layout. In this scenario, set this minimum * equal to the width of the widest color bar. Then all color bars * will have the same width. Those widths might otherwise vary as tic * and axes labels vary for the different panels. * @param widthMinimum the minimum width. */ public void setColorBarWidthMinimum(int widthMinimum) { _colorBarWidthMinimum = widthMinimum; if (_colorBar!=null) { _colorBar.setWidthMinimum(widthMinimum); revalidate(); } }
/** * Called when the color bar in this panel may need resizing. * This implementation simply removes and adds any existing color bar. * This method is necessary because we want the colorbar height to equal * that of the tiles in the mosaic, but not including any tile axes. */ private void adjustColorBar() { if (_colorBar!=null) { GridBagLayout gbl = (GridBagLayout)getLayout(); gbl.setConstraints(_colorBar,makeColorBarConstraints()); revalidate(); //remove(_colorBar); //add(_colorBar,makeColorBarConstraints()); } }
add(_mosaic,gbc); setPreferredSize(new Dimension(200+300*ncol,100+300*nrow)); revalidate();
/** * Sets the font in all components of this panel. * Sets the title font to be 1.5 times larger than the specified font. * @param font the font. */ public void setFont(Font font) { super.setFont(font); if (_mosaic!=null) _mosaic.setFont(font); if (_colorBar!=null) _colorBar.setFont(font); if (_title!=null) _title.setFont(font.deriveFont(1.5f*font.getSize2D())); adjustColorBar(); revalidate(); }
/** * Ensures that the colorbar (if any) reflects the correct color map. */ private void updateColorMapped() { ColorMapped cm = findBestColorMapped(); if (cm!=_colorMapped && _colorBar!=null) { if (_colorMapped!=null) _colorMapped.getColorMap().removeListener(_colorBar); _colorMapped = cm; _colorMapped.getColorMap().addListener(_colorBar); revalidate(); } } private class ColorMapHandler implements ColorMapListener {
revalidate(); } else { _title.set(title); revalidate(); _title = null;
_colorBar.setLabel(label); revalidate(); return _colorBar;