Issue #2950 Support dynamic color counts for color map editing.

Former-commit-id: c805a5fed7 [formerly 85528bf2bbdbbaacc9631b76ef710e9fd0210110]
Former-commit-id: c5a48642eb
This commit is contained in:
Ben Steffensmeier 2014-04-08 14:02:43 -05:00
parent 8bf64d8006
commit 9d7504e2c3
5 changed files with 834 additions and 1349 deletions

View file

@ -24,8 +24,10 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
@ -33,20 +35,21 @@ import com.raytheon.uf.common.colormap.ColorMap;
/**
* Composite for colormap editing
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 18, 2010 mschenke Initial creation
* Jan 10, 2013 15648 ryu Editing GFE discrete colormap: a check button
* is added and duplicate entries in the colormap
* are removed when it is selected.
*
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Nov 18, 2010 mschenke Initial creation
* Jan 10, 2013 15648 ryu Editing GFE discrete colormap: a check button
* is added and duplicate entries in the colormap
* are removed when it is selected.
* Apr 08, 2014 2950 bsteffen Support dynamic color counts.
*
* </pre>
*
*
* @author mschenke
* @version 1.0
*/
@ -54,6 +57,9 @@ import com.raytheon.uf.common.colormap.ColorMap;
public class ColorEditComposite extends Composite implements IColorWheelAction,
IColorBarAction {
private static final int[] COLOR_COUNT_OPTIONS = { 8, 16, 256, 512, 1024,
2048 };
/**
* Upper color wheel (composite object).
*/
@ -79,6 +85,9 @@ public class ColorEditComposite extends Composite implements IColorWheelAction,
*/
private Button hsbRdo;
/** Color count combo*/
private Combo colorCount;
/**
* GFE discrete check button.
*/
@ -112,8 +121,12 @@ public class ColorEditComposite extends Composite implements IColorWheelAction,
private void initializeComponents(Composite parent) {
// Initialize the components.
// Create the RGB and the HSB radio buttons.
createRgbHsbButtons();
Composite topComposite = new Composite(parent, SWT.NONE);
topComposite.setLayout(new GridLayout(2, false));
topComposite
.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
createRgbHsbButtons(topComposite);
createSizeCombo(topComposite);
ColorData initial = new ColorData(new RGB(255, 255, 255), 255);
// Create the upper color wheel for the display.
@ -136,14 +149,16 @@ public class ColorEditComposite extends Composite implements IColorWheelAction,
// Create the GFE discrete check button.
createGFEDiscreteButton();
updateColorCount();
}
/**
* Create the RGB and the HSB radio buttons.
*/
private void createRgbHsbButtons() {
private void createRgbHsbButtons(Composite parent) {
// Create a group to contain the RGB and HSB radio buttons.
Group colorGroup = new Group(getParent(), SWT.NONE);
Group colorGroup = new Group(parent, SWT.NONE);
colorGroup.setText(" Use color model: ");
RowLayout groupRowLayout = new RowLayout();
@ -151,7 +166,7 @@ public class ColorEditComposite extends Composite implements IColorWheelAction,
groupRowLayout.marginRight = 10;
groupRowLayout.spacing = 10;
colorGroup.setLayout(groupRowLayout);
colorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
colorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Create the RGB radio button. When the radio button is selected
// update the upper and lower color wheel objects to display the RGB
@ -179,6 +194,38 @@ public class ColorEditComposite extends Composite implements IColorWheelAction,
});
}
private void createSizeCombo(Composite parent) {
// Create a group to contain the RGB and HSB radio buttons.
Group colorGroup = new Group(parent, SWT.NONE);
colorGroup.setText(" Colormap size: ");
RowLayout groupRowLayout = new RowLayout();
groupRowLayout.marginLeft = 10;
groupRowLayout.marginRight = 10;
groupRowLayout.spacing = 10;
colorGroup.setLayout(groupRowLayout);
colorGroup
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
colorCount = new Combo(colorGroup, SWT.READ_ONLY);
for (int i = 0; i < COLOR_COUNT_OPTIONS.length; i += 1) {
int option = COLOR_COUNT_OPTIONS[i];
colorCount.add(Integer.toString(option));
}
colorCount.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = colorCount.getSelectionIndex();
String selection = colorCount.getItem(index);
int count = Integer.valueOf(selection);
colorBar.setColorCount(count);
updateColorMap();
}
});
}
/**
* Create the GFE discrete check button.
*/
@ -283,6 +330,31 @@ public class ColorEditComposite extends Composite implements IColorWheelAction,
colorMap.removeDuplicates();
}
callback.updateColorMap(colorMap);
updateColorCount();
}
public void updateColorCount() {
int newCount = colorBar.getColorCount();
boolean added = true;
for (int i = 0; i < colorCount.getItemCount(); i += 1) {
String item = colorCount.getItem(i);
int count = Integer.parseInt(item);
if (count == newCount) {
colorCount.select(i);
added = true;
break;
} else if (count > newCount) {
colorCount.add(Integer.toString(newCount), i);
colorCount.select(i);
added = true;
break;
}
}
if (!added) {
colorCount.add(Integer.toString(newCount));
colorCount.select(colorCount.getItemCount() - 1);
}
}
public ColorWheelComp getUpperColorWheel() {
@ -321,4 +393,15 @@ public class ColorEditComposite extends Composite implements IColorWheelAction,
return gfeDiscreteCheck.getSelection();
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
upperColorWheel.setEnabled(enabled);
lowerColorWheel.setEnabled(enabled);
colorBar.setEnabled(enabled);
rgbRdo.setEnabled(enabled);
hsbRdo.setEnabled(enabled);
colorCount.setEnabled(enabled);
}
}

View file

@ -69,20 +69,21 @@ import com.raytheon.viz.ui.editor.ISelectedPanesChangedListener;
/**
* This is the main dialog for the Color Edit Dialog.
*
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* lvenable Initial Creation.
* Jul 24, 2007 njensen Hooked into backend.
* Oct 17, 2012 1229 rferrel Changes for non-blocking SaveColorMapDialog.
* Jan 10, 2013 15648 ryu Editing GFE discrete colormap: a check button
* is added and duplicate entries in the colormap
* are removed when it is selected.
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* lvenable Initial Creation.
* Jul 24, 2007 njensen Hooked into backend.
* Oct 17, 2012 1229 rferrel Changes for non-blocking SaveColorMapDialog.
* Jan 10, 2013 15648 ryu Editing GFE discrete colormap: a check button
* is added and duplicate entries in the colormap
* are removed when it is selected.
* Apr 08, 2014 2950 bsteffen Support dynamic color counts.
*
* </pre>
*
*
* @author lvenable
* @version 1.0
*/
@ -333,10 +334,11 @@ public class ColorEditDialog extends CaveSWTDialog implements
this.container = container;
this.rightImages = rightImages;
if (cap != null && cap.getColorMapParameters() != null
if (cap.getColorMapParameters() != null
&& cap.getColorMapParameters().getColorMap() != null) {
colorEditComp.getColorBar().updateColorMap(
cap.getColorMapParameters());
colorEditComp.updateColorCount();
}
setText(currentColormapName != null ? currentColormapName
: "Untitled Colormap");
@ -347,12 +349,7 @@ public class ColorEditDialog extends CaveSWTDialog implements
setText(NO_COLOR_TABLE);
}
colorEditComp.getUpperColorWheel().setEnabled(enabled);
colorEditComp.getLowerColorWheel().setEnabled(enabled);
colorEditComp.getColorBar().setEnabled(enabled);
colorEditComp.getRgbRdo().setEnabled(enabled);
colorEditComp.getHsbRdo().setEnabled(enabled);
colorEditComp.getColorBar().setEnabled(enabled);
colorEditComp.setEnabled(enabled);
interpolateBtn.setEnabled(enabled);
undoBtn.setEnabled(enabled);
redoBtn.setEnabled(enabled);

View file

@ -31,6 +31,7 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.colormap.IColorMap;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
@ -47,13 +48,15 @@ import com.raytheon.uf.viz.core.exception.VizException;
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 18, 2007 njensen Initial creation
* Aug 20, 2008 dglazesk Updated for the new ColorMap interface
* and for the JiBX to JaXB transition
* Aug 06, 2013 2210 njensen Moved colormaps to common_static
* Nov 11, 2013 2361 njensen Use ColorMap.JAXB for XML processing
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jul 18, 2007 njensen Initial creation
* Aug 20, 2008 dglazesk Updated for the new ColorMap interface
* and for the JiBX to JaXB transition
* Aug 06, 2013 2210 njensen Moved colormaps to common_static
* Nov 11, 2013 2361 njensen Use ColorMap.JAXB for XML processing
* Apr 08, 2014 2950 bsteffen Allow buildColorData to take an IColorMap
*
*
* </pre>
*
@ -131,7 +134,7 @@ public class ColorUtil {
* the ColorMap to extract ColorData from
* @return
*/
public static ArrayList<ColorData> buildColorData(ColorMap aColorMap) {
public static ArrayList<ColorData> buildColorData(IColorMap aColorMap) {
ArrayList<ColorData> colors = new ArrayList<ColorData>();
if (aColorMap != null) {

View file

@ -21,10 +21,11 @@ public class ColorBarViewer extends ColorBar {
//setSliderText( sliderText );
setStartingColors( newColors );
revertColorBar();
revertColorBar();
}
protected void setStartingColors(ArrayList<ColorData> newColors) {
startingColors = new ArrayList<ColorData>(newColors);
setCurrentColors(new ArrayList<ColorData>(newColors));
updateRevertToCurrent();
}
}