-
Notifications
You must be signed in to change notification settings - Fork 13
/
HeatMapPanel.java
72 lines (61 loc) · 1.77 KB
/
HeatMapPanel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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());
}
});
}
}
}