Merge "Issue #2950 Support dynamic color counts for color map editing." into development
Former-commit-id:5bad21f3e6
[formerly b196bf0463ea59d55dec4e70373ca731152123f9] Former-commit-id:5129002e91
This commit is contained in:
commit
6989999e95
5 changed files with 834 additions and 1349 deletions
File diff suppressed because it is too large
Load diff
|
@ -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;
|
||||
|
||||
|
@ -38,12 +40,13 @@ import com.raytheon.uf.common.colormap.ColorMap;
|
|||
*
|
||||
* 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>
|
||||
*
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,14 +72,15 @@ import com.raytheon.viz.ui.editor.ISelectedPanesChangedListener;
|
|||
*
|
||||
* <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>
|
||||
*
|
||||
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue