if (palette == null) {
if (Debug.debugging("dted"))
Debug.output("DTEDLayer: creating DTED Palette.");
palette = Box.createVerticalBox();
Box subbox1 = Box.createHorizontalBox();
Box subbox2 = Box.createVerticalBox();
Box subbox3 = Box.createHorizontalBox();
// palette = new JPanel();
// palette.setLayout(new GridLayout(0, 1));
// The DTED Level selector
JPanel levelPanel = PaletteHelper.createPaletteJPanel("DTED Level");
ButtonGroup levels = new ButtonGroup();
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (cache != null) {
String ac = e.getActionCommand();
int newLevel;
if (ac.equalsIgnoreCase(level2Command))
newLevel = DTEDFrameSubframe.LEVEL_2;
else if (ac.equalsIgnoreCase(level1Command))
newLevel = DTEDFrameSubframe.LEVEL_1;
else
newLevel = DTEDFrameSubframe.LEVEL_0;
DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
dfsi.dtedLevel = newLevel;
// cache.setSubframeInfo(dfsi);
}
}
};
JRadioButton level0 = new JRadioButton("Level 0");
level0.addActionListener(al);
level0.setActionCommand(level0Command);
JRadioButton level1 = new JRadioButton("Level 1");
level1.addActionListener(al);
level1.setActionCommand(level1Command);
JRadioButton level2 = new JRadioButton("Level 2");
level2.addActionListener(al);
level2.setActionCommand(level2Command);
levels.add(level0);
levels.add(level1);
levels.add(level2);
switch (dtedLevel) {
case 2:
level2.setSelected(true);
break;
case 1:
level1.setSelected(true);
break;
case 0:
default:
level0.setSelected(true);
}
levelPanel.add(level0);
levelPanel.add(level1);
levelPanel.add(level2);
// The DTED view selector
JPanel viewPanel = PaletteHelper.createPaletteJPanel("View Type");
String[] viewStrings = { "None", "Shading", "Elevation Shading",
"Elevation Bands (Meters)", "Elevation Bands (Feet)" };
JComboBox viewList = new JComboBox(viewStrings);
viewList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox jcb = (JComboBox) e.getSource();
int newView = jcb.getSelectedIndex();
switch (newView) {
case 0:
viewType = DTEDFrameSubframe.NOSHADING;
break;
case 1:
viewType = DTEDFrameSubframe.SLOPESHADING;
break;
case 2:
viewType = DTEDFrameSubframe.COLOREDSHADING;
break;
case 3:
viewType = DTEDFrameSubframe.METERSHADING;
break;
case 4:
viewType = DTEDFrameSubframe.FEETSHADING;
break;
default:
viewType = DTEDFrameSubframe.NOSHADING;
}
if (cache != null) {
DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
dfsi.viewType = viewType;
// cache.setSubframeInfo(dfsi);
}
}
});
int selectedView;
switch (viewType) {
case 0:
case 1:
selectedView = viewType;
break;
case 2:
case 3:
selectedView = viewType + 1;
break;
case 4:
// This puts the layer in testing mode, and the menu
// changes.
String[] viewStrings2 = { "None", "Shading",
"Elevation Bands (Meters)", "Elevation Bands (Feet)",
"Subframe Testing", "Elevation Shading" };
viewList = new JComboBox(viewStrings2);
viewList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox jcb = (JComboBox) e.getSource();
int newView = jcb.getSelectedIndex();
if (cache != null) {
DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
dfsi.viewType = newView;
// cache.setSubframeInfo(dfsi);
}
}
});
selectedView = viewType;
break;
case 5:
selectedView = 2; //DTEDFrameSubframe.COLOREDSHADING
break;
default:
selectedView = DTEDFrameSubframe.NOSHADING;
}
viewList.setSelectedIndex(selectedView);
viewPanel.add(viewList);
// The DTED Contrast Adjuster
JPanel contrastPanel = PaletteHelper.createPaletteJPanel("Contrast Adjustment");
JSlider contrastSlide = new JSlider(JSlider.HORIZONTAL, 1/* min */, 5/* max */, slopeAdjust/* inital */);
java.util.Hashtable dict = new java.util.Hashtable();
dict.put(new Integer(1), new JLabel("min"));
dict.put(new Integer(5), new JLabel("max"));
contrastSlide.setLabelTable(dict);
contrastSlide.setPaintLabels(true);
contrastSlide.setMajorTickSpacing(1);
contrastSlide.setPaintTicks(true);
contrastSlide.setSnapToTicks(true);
contrastSlide.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
JSlider slider = (JSlider) ce.getSource();
if (slider.getValueIsAdjusting()) {
fireRequestInfoLine(getName()
+ " - Contrast Slider value = "
+ slider.getValue());
slopeAdjust = slider.getValue();
if (cache != null) {
DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
dfsi.slopeAdjust = slopeAdjust;
// cache.setSubframeInfo(dfsi);
}
}
}
});
contrastPanel.add(contrastSlide);
// The DTED Band Height Adjuster
JPanel bandPanel = PaletteHelper.createPaletteJPanel("Band Elevation Spacing");
JSlider bandSlide = new JSlider(JSlider.HORIZONTAL, 0/* min */, 1000/* max */, bandHeight/* inital */);
bandSlide.setLabelTable(bandSlide.createStandardLabels(250));
bandSlide.setPaintLabels(true);
bandSlide.setMajorTickSpacing(250);
bandSlide.setMinorTickSpacing(50);
bandSlide.setPaintTicks(true);
bandSlide.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
JSlider slider = (JSlider) ce.getSource();
if (slider.getValueIsAdjusting()) {
fireRequestInfoLine(getName()
+ " - Band Slider value = " + slider.getValue());
bandHeight = slider.getValue();
if (cache != null) {
DTEDFrameSubframeInfo dfsi = cache.getSubframeInfo();
dfsi.bandHeight = bandHeight;
// cache.setSubframeInfo(dfsi);
}
}
}
});
bandPanel.add(bandSlide);
JButton redraw = new JButton("Redraw DTED Layer");
redraw.setActionCommand(RedrawCmd);
redraw.addActionListener(this);
subbox1.add(levelPanel);
subbox1.add(viewPanel);
palette.add(subbox1);
subbox2.add(contrastPanel);
subbox2.add(bandPanel);
palette.add(subbox2);
subbox3.add(redraw);
palette.add(subbox3);
}
return palette;
}