svn-gvsig-desktop / trunk / extensions / extArcims / src / es / prodevelop / cit / gvsig / arcims / gui / dialogs / LayerScaleDialog.java @ 8300
History | View | Annotate | Download (4.66 KB)
1 |
package es.prodevelop.cit.gvsig.arcims.gui.dialogs; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.Graphics; |
6 |
import java.awt.event.ActionEvent; |
7 |
import java.awt.event.ActionListener; |
8 |
import java.text.DecimalFormat; |
9 |
import java.text.DecimalFormatSymbols; |
10 |
import java.util.Vector; |
11 |
|
12 |
import javax.swing.JButton; |
13 |
import javax.swing.JLabel; |
14 |
import javax.swing.JPanel; |
15 |
import javax.swing.JScrollPane; |
16 |
import javax.swing.ScrollPaneConstants; |
17 |
|
18 |
import es.prodevelop.cit.gvsig.arcims.fmap.layers.FRasterLyrArcIMS; |
19 |
import es.prodevelop.cit.gvsig.arcims.fmap.listeners.FRasterLyrArcIMSListener; |
20 |
import es.prodevelop.cit.gvsig.arcims.gui.panels.LayerScaleDrawPanel; |
21 |
|
22 |
import com.iver.andami.PluginServices; |
23 |
import com.iver.andami.ui.mdiManager.IWindow; |
24 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
25 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
26 |
|
27 |
/**
|
28 |
* This class shows the ArcIMS layer's scale limits status.
|
29 |
*
|
30 |
* @author jldominguez
|
31 |
*/
|
32 |
public class LayerScaleDialog extends JPanel implements ActionListener, |
33 |
IWindow, FRasterLyrArcIMSListener { |
34 |
|
35 |
private JPanel button_p; |
36 |
private JButton b; |
37 |
private LayerScaleDrawPanel dp;
|
38 |
private FRasterLyrArcIMS layer;
|
39 |
private WindowInfo theViewInfo;
|
40 |
private JScrollPane sp; |
41 |
private static final long serialVersionUID = 0; |
42 |
private String vistaName; |
43 |
|
44 |
private JLabel southLabel; |
45 |
|
46 |
|
47 |
/**
|
48 |
* Needs the layer as parameter.
|
49 |
*
|
50 |
* @param lyr the layer
|
51 |
*/
|
52 |
public LayerScaleDialog(FRasterLyrArcIMS lyr, View v) { |
53 |
super();
|
54 |
layer = lyr; |
55 |
southLabel = new JLabel(); |
56 |
|
57 |
if (v != null) { |
58 |
vistaName = v.getModel().getName(); |
59 |
} else {
|
60 |
vistaName = "Unknown";
|
61 |
} |
62 |
|
63 |
lyr.addActionlistener(this);
|
64 |
lyr.addNameOrQueryListener(this);
|
65 |
Vector infoV = layer.getLayerScaleInfoVector();
|
66 |
int spHeight = 201 + 15 * infoV.size(); |
67 |
if (spHeight > 500) spHeight = 500; |
68 |
|
69 |
setLayout(new BorderLayout()); |
70 |
setSize(140 + 680, spHeight + 10); |
71 |
setMinimumSize(new Dimension(410, 226)); |
72 |
|
73 |
b = new JButton(PluginServices.getText(this, "close")); |
74 |
b.setBounds(10, 10, 90, 25); |
75 |
b.addActionListener(this);
|
76 |
|
77 |
button_p = new JPanel(); |
78 |
button_p.setLayout(new BorderLayout()); |
79 |
button_p.add(southLabel, BorderLayout.WEST); // setPreferredSize(new Dimension(10, 5)); |
80 |
// button_p.add(b);
|
81 |
|
82 |
dp = new LayerScaleDrawPanel(infoV, this, southLabel); |
83 |
dp.setDpi(lyr.getArcimsStatus().getServiceInfo().getScreen_dpi()); |
84 |
dp.setCurrentScale(1.0 * layer.getMapContext().getScaleView());
|
85 |
|
86 |
southLabel.setText(PluginServices.getText(this, "Escala") + " 1 : " + |
87 |
getFormattedInteger(Math.round(dp.getCurrentScale()))
|
88 |
); |
89 |
|
90 |
dp.setPreferredSize(new Dimension(300, 200 + 15 * infoV.size())); |
91 |
|
92 |
sp = new JScrollPane(dp); |
93 |
sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
94 |
sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
95 |
|
96 |
add(BorderLayout.CENTER, sp);
|
97 |
add(BorderLayout.SOUTH, button_p);
|
98 |
} |
99 |
|
100 |
public void resetDrawingPanel() { |
101 |
Vector infoV = layer.getLayerScaleInfoVector();
|
102 |
dp.resetInfo(infoV); |
103 |
dp.setPreferredSize(new Dimension(300, 200 + 15 * infoV.size())); |
104 |
dp.repaint(); |
105 |
} |
106 |
|
107 |
|
108 |
public void actionPerformed(ActionEvent arg0) { |
109 |
|
110 |
if (arg0.getActionCommand().compareToIgnoreCase(FRasterLyrArcIMS.SCALE_CHANGED_COMMAND) == 0) { |
111 |
dp.setCurrentScale(1.0 * layer.getScale());
|
112 |
dp.repaint(); |
113 |
return;
|
114 |
} |
115 |
|
116 |
if (arg0.getSource() == b) {
|
117 |
this.close();
|
118 |
} |
119 |
|
120 |
} |
121 |
|
122 |
public void close() { |
123 |
PluginServices.getMDIManager().closeWindow(this);
|
124 |
} |
125 |
|
126 |
public WindowInfo getWindowInfo() {
|
127 |
if (theViewInfo == null) { |
128 |
theViewInfo = new WindowInfo(
|
129 |
0 + // palette |
130 |
16 + // no modal |
131 |
0 + // modal |
132 |
4 + // iconifiable |
133 |
2 + // maximizable |
134 |
1 // resizable |
135 |
); |
136 |
theViewInfo.setTitle( |
137 |
PluginServices.getText(this, "view") + |
138 |
": " +
|
139 |
vistaName + |
140 |
" - " +
|
141 |
PluginServices.getText(this, "layer") + |
142 |
": " +
|
143 |
layer.getName() + |
144 |
" - " +
|
145 |
PluginServices.getText(this, "layer_scale_status") |
146 |
); |
147 |
theViewInfo.setWidth(getInitialWidth()); |
148 |
theViewInfo.setHeight(getInitialHeight()); |
149 |
} |
150 |
return theViewInfo;
|
151 |
} |
152 |
|
153 |
public FRasterLyrArcIMS getLayer() {
|
154 |
return layer;
|
155 |
} |
156 |
|
157 |
public void setLayer(FRasterLyrArcIMS layer) { |
158 |
this.layer = layer;
|
159 |
} |
160 |
|
161 |
|
162 |
private int getInitialWidth() { |
163 |
return 365; |
164 |
} |
165 |
|
166 |
private int getInitialHeight() { |
167 |
return 290 - 35; |
168 |
} |
169 |
|
170 |
|
171 |
public void thingsHaveChanged(String query, String name) { |
172 |
resetDrawingPanel(); |
173 |
} |
174 |
|
175 |
public static String getFormattedInteger(int n) { |
176 |
DecimalFormat df = new DecimalFormat(); |
177 |
df.setGroupingUsed(true);
|
178 |
df.setGroupingSize(3);
|
179 |
DecimalFormatSymbols dfs = new DecimalFormatSymbols(); |
180 |
dfs.setGroupingSeparator('.');
|
181 |
df.setDecimalFormatSymbols(dfs); |
182 |
return df.format(n);
|
183 |
} |
184 |
|
185 |
} |