gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.algorithm / org.gvsig.raster.tools.algorithm.swing / org.gvsig.raster.tools.algorithm.swing.impl / src / main / java / org / gvsig / raster / tools / algorithm / swing / impl / saveraster / PrintAndPxSelectionPanel.java @ 2480
History | View | Annotate | Download (3.16 KB)
1 |
package org.gvsig.raster.tools.algorithm.swing.impl.saveraster; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.GridBagConstraints; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.Insets; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
|
10 |
import javax.swing.ButtonGroup; |
11 |
import javax.swing.JLabel; |
12 |
import javax.swing.JPanel; |
13 |
|
14 |
import org.gvsig.i18n.Messages; |
15 |
|
16 |
/**
|
17 |
* Panel to select coordinates of the output layer
|
18 |
*
|
19 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
20 |
*/
|
21 |
public class PrintAndPxSelectionPanel extends JPanel implements ActionListener { |
22 |
private static final long serialVersionUID = 1L; |
23 |
private PixelSelectionPanel pixelSelectionPanel = null; |
24 |
private PrintSelectionPanel printSelectionPanel = null; |
25 |
private JLabel sizeImage = null; |
26 |
|
27 |
public PrintAndPxSelectionPanel() {
|
28 |
init(); |
29 |
} |
30 |
|
31 |
private void init() { |
32 |
ButtonGroup group = new ButtonGroup(); |
33 |
group.add(getPixelSelectionPanel().getRadioPxSelection()); |
34 |
group.add(getPrintSelectionPanel().getRadioPrintSelection()); |
35 |
getPixelSelectionPanel().setEnable(true);
|
36 |
getPrintSelectionPanel().setEnable(false);
|
37 |
|
38 |
setLayout(new GridBagLayout()); |
39 |
|
40 |
GridBagConstraints gbc = new GridBagConstraints(); |
41 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
42 |
gbc.insets = new Insets(2, 2, 2, 2); |
43 |
gbc.weightx = 1;
|
44 |
gbc.weighty = 0;
|
45 |
|
46 |
gbc.gridy = 0;
|
47 |
add(getPixelSelectionPanel(), gbc); |
48 |
|
49 |
gbc.gridy = 1;
|
50 |
add(getPrintSelectionPanel(), gbc); |
51 |
|
52 |
gbc.gridy = 2;
|
53 |
add(getSizeImage(), gbc); |
54 |
|
55 |
/*gbc.fill = GridBagConstraints.BOTH;
|
56 |
gbc.weightx = 1;
|
57 |
gbc.weighty = 1;
|
58 |
gbc.gridy = 3;
|
59 |
add(new JPanel(), gbc);*/
|
60 |
} |
61 |
|
62 |
public PixelSelectionPanel getPixelSelectionPanel() {
|
63 |
if(pixelSelectionPanel == null) { |
64 |
pixelSelectionPanel = new PixelSelectionPanel();
|
65 |
pixelSelectionPanel.getRadioPxSelection().addActionListener(this);
|
66 |
} |
67 |
return pixelSelectionPanel;
|
68 |
} |
69 |
|
70 |
public PrintSelectionPanel getPrintSelectionPanel() {
|
71 |
if(printSelectionPanel == null) { |
72 |
printSelectionPanel = new PrintSelectionPanel();
|
73 |
printSelectionPanel.getRadioPrintSelection().addActionListener(this);
|
74 |
} |
75 |
return printSelectionPanel;
|
76 |
} |
77 |
|
78 |
public JLabel getSizeImage() { |
79 |
if(sizeImage == null) { |
80 |
sizeImage = new JLabel(Messages.getText("result_size") + ": 0 MB"); |
81 |
sizeImage.setForeground(Color.red);
|
82 |
} |
83 |
return sizeImage;
|
84 |
} |
85 |
|
86 |
public void setSize(double size) { |
87 |
getSizeImage().setText(Messages.getText("result_size") + ": " + size + " MB"); |
88 |
} |
89 |
|
90 |
public void actionPerformed(ActionEvent e) { |
91 |
if(e.getSource() == getPixelSelectionPanel().getRadioPxSelection()) {
|
92 |
if(getPixelSelectionPanel().getRadioPxSelection().isEnabled()) {
|
93 |
getPixelSelectionPanel().setEnable(true);
|
94 |
getPrintSelectionPanel().setEnable(false);
|
95 |
} else {
|
96 |
getPixelSelectionPanel().setEnable(false);
|
97 |
getPrintSelectionPanel().setEnable(true);
|
98 |
} |
99 |
} |
100 |
|
101 |
if(e.getSource() == getPrintSelectionPanel().getRadioPrintSelection()) {
|
102 |
if(getPrintSelectionPanel().getRadioPrintSelection().isEnabled()) {
|
103 |
getPixelSelectionPanel().setEnable(false);
|
104 |
getPrintSelectionPanel().setEnable(true);
|
105 |
} else {
|
106 |
getPixelSelectionPanel().setEnable(true);
|
107 |
getPrintSelectionPanel().setEnable(false);
|
108 |
} |
109 |
} |
110 |
} |
111 |
} |