Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/org/openjump/core/rasterimage/styler/ui/HeatMapPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.openjump.core.rasterimage.styler.ui; | ||
|
||
import com.vividsolutions.jump.workbench.Logger; | ||
import org.openjump.core.rasterimage.RasterImageLayer; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
|
||
public class HeatMapPanel extends JPanel { | ||
|
||
private final Component parent; | ||
private final RasterImageLayer rasterImageLayer; | ||
private final int numbands; | ||
private final JSlider[] sliders; | ||
private final JButton[] colorButtons; | ||
|
||
public HeatMapPanel(Component parent, RasterImageLayer rasterImageLayer, int numbands) { | ||
this.parent = parent; | ||
this.rasterImageLayer = rasterImageLayer; | ||
this.numbands = numbands; | ||
this.sliders = new JSlider[numbands]; | ||
this.colorButtons = new JButton[numbands]; | ||
initComponents(); | ||
fixComponents(); | ||
} | ||
|
||
private void initComponents() { | ||
GridBagConstraints c = new GridBagConstraints(); | ||
this.setLayout(new GridBagLayout()); | ||
//c.gridx = 0; | ||
c.gridy = 0; | ||
for (int i = 0 ; i < numbands ; i++) { | ||
c.gridx = 0; | ||
sliders[i] = new JSlider(0,255); | ||
add(sliders[i], c); | ||
c.gridx = 1; | ||
colorButtons[i] = new JButton(); | ||
c.gridy++; | ||
} | ||
} | ||
|
||
|
||
private void fixComponents() { | ||
|
||
} | ||
|
||
public void reset() { | ||
try { | ||
for (int i = 0 ; i < numbands ; i++) { | ||
sliders[i].setValue(127); | ||
} | ||
} catch (Exception ex) { | ||
Logger.error(ex); | ||
} | ||
} | ||
|
||
static class ColorButton extends JButton { | ||
ColorButton() { | ||
super(); | ||
this.addActionListener(new ActionListener() { | ||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
JColorChooser jcc = new JColorChooser(); | ||
jcc.setVisible(true); | ||
ColorButton.this.setBackground(jcc.getColor()); | ||
} | ||
}); | ||
} | ||
} | ||
} |