root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / PlacementProperties.java @ 11195
History | View | Annotate | Download (19.9 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: PlacementProperties.java 11195 2007-04-13 12:10:56Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.5 2007-04-13 12:10:56 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.4 2007/04/12 16:01:32 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.3 2007/03/28 15:38:56 jaume
|
53 |
* GUI for lines, points and polygons
|
54 |
*
|
55 |
* Revision 1.2 2007/03/09 11:25:00 jaume
|
56 |
* Advanced symbology (start committing)
|
57 |
*
|
58 |
* Revision 1.1.2.2 2007/02/09 11:00:03 jaume
|
59 |
* *** empty log message ***
|
60 |
*
|
61 |
* Revision 1.1.2.1 2007/02/01 12:12:41 jaume
|
62 |
* theme manager window and all its components are now dynamic
|
63 |
*
|
64 |
*
|
65 |
*/
|
66 |
package com.iver.cit.gvsig.project.documents.view.legend.gui; |
67 |
|
68 |
import java.awt.BorderLayout; |
69 |
import java.awt.Component; |
70 |
import java.awt.Dimension; |
71 |
import java.awt.FlowLayout; |
72 |
import java.awt.GridLayout; |
73 |
import java.awt.event.ActionEvent; |
74 |
import java.awt.event.ActionListener; |
75 |
|
76 |
import javax.swing.BorderFactory; |
77 |
import javax.swing.BoxLayout; |
78 |
import javax.swing.ButtonGroup; |
79 |
import javax.swing.ImageIcon; |
80 |
import javax.swing.JCheckBox; |
81 |
import javax.swing.JComponent; |
82 |
import javax.swing.JLabel; |
83 |
import javax.swing.JPanel; |
84 |
import javax.swing.JRadioButton; |
85 |
|
86 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
87 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
88 |
import org.gvsig.gui.beans.swing.JBlank; |
89 |
import org.gvsig.gui.beans.swing.JButton; |
90 |
|
91 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
92 |
import com.iver.andami.PluginServices; |
93 |
import com.iver.andami.ui.mdiManager.IWindow; |
94 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
95 |
import com.iver.cit.gvsig.fmap.core.FShape; |
96 |
import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
97 |
import com.iver.cit.gvsig.fmap.core.styles.PointLabelPositioneer; |
98 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
99 |
import com.iver.cit.gvsig.fmap.rendering.styling.IPlacementConstraints; |
100 |
import com.iver.cit.gvsig.fmap.rendering.styling.LabelingFactory; |
101 |
import com.iver.cit.gvsig.gui.styling.StyleSelector; |
102 |
import com.iver.cit.gvsig.gui.styling.SelectorFilter; |
103 |
import com.iver.cit.gvsig.gui.styling.StylePreviewer; |
104 |
import com.iver.utiles.swing.JComboBox; |
105 |
import com.vividsolutions.jts.geom.Point; |
106 |
/**
|
107 |
*
|
108 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
109 |
*
|
110 |
*/
|
111 |
public class PlacementProperties extends JPanel implements IWindow, ActionListener { |
112 |
private PointLabelPositioneer pointStyle = new PointLabelPositioneer( |
113 |
new byte[] { 2, 2, 1, 3, 2, 3, 3, 2 }, |
114 |
PluginServices.getText(this, "prefer_top_right_all_allowed") |
115 |
); |
116 |
private int shapeType; |
117 |
private JPanel pnlContent = null; |
118 |
private JPanel pnlCenter = null; |
119 |
private GridBagLayoutPanel pnlSouth = null; |
120 |
private JRadioButton rdBtnRemoveDuplicates; |
121 |
private IPlacementConstraints constraints;
|
122 |
private JRadioButton rdBtnOnePerFeature; |
123 |
private JRadioButton rdBtnOnePerFeaturePart; |
124 |
private GridBagLayoutPanel orientationPanel;
|
125 |
private JRadioButton rdBtnHorizontal; |
126 |
private JRadioButton rdBtnParallel; |
127 |
private JRadioButton rdBtnFollowingLine; |
128 |
private JRadioButton rdBtnPerpendicular; |
129 |
private GridBagLayoutPanel positionPanel;
|
130 |
private JLabel polygonIcon; |
131 |
private JLabel lineIcon; |
132 |
private ActionListener action = new ActionListener() { |
133 |
public void actionPerformed(ActionEvent e) { |
134 |
if ("OK".equals(e.getActionCommand())) |
135 |
applyConstraints(); |
136 |
|
137 |
if ("CANCEL".equals(e.getActionCommand())) |
138 |
constraints = oldConstraints; |
139 |
PluginServices.getMDIManager().closeWindow(PlacementProperties.this); |
140 |
} |
141 |
}; |
142 |
private GridBagLayoutPanel polygonSettingsPanel;
|
143 |
private JRadioButton rdBtnAlwaysHorizontal; |
144 |
private JRadioButton rdBtnAlwaysStraight; |
145 |
private GridBagLayoutPanel pointSettingsPanel;
|
146 |
private JRadioButton rdBtnOffsetLabelHorizontally; |
147 |
private JRadioButton rdBtnOffsetLabelOnTopPoint; |
148 |
private StylePreviewer stylePreview;
|
149 |
private JButton btnChangeLocation; |
150 |
private JPanel locationPanel; |
151 |
private JComboBox cmbLocationAlongLines; |
152 |
private JCheckBox chkBelow; |
153 |
private JCheckBox chkOnTheLine; |
154 |
private JCheckBox chkAbove; |
155 |
private JComboBox cmbOrientationSystem; |
156 |
private JLabel lblPointPosDesc = new JLabel(pointStyle.getDescription()); |
157 |
private IPlacementConstraints oldConstraints;
|
158 |
|
159 |
public PlacementProperties(FLyrVect layer, IPlacementConstraints constraints) throws ReadDriverException { |
160 |
this.shapeType = layer.getShapeType();
|
161 |
this.oldConstraints = constraints;
|
162 |
this.constraints = constraints != null ? |
163 |
LabelingFactory.createPlacementConstraints(constraints.getXMLEntity()) : |
164 |
LabelingFactory.createPlacementConstraints(layer); |
165 |
initialize(); |
166 |
} |
167 |
|
168 |
private void initialize() { |
169 |
this.setLayout(new BorderLayout()); |
170 |
this.setSize(new Dimension(410,380)); |
171 |
this.add(getPnlContent(), BorderLayout.CENTER); |
172 |
this.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH); |
173 |
} |
174 |
|
175 |
public WindowInfo getWindowInfo() {
|
176 |
WindowInfo viewInfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
177 |
viewInfo.setWidth(getWidth()); |
178 |
viewInfo.setHeight(getHeight()); |
179 |
viewInfo.setTitle(PluginServices.getText(this,"placement_properties")); |
180 |
return viewInfo;
|
181 |
} |
182 |
|
183 |
private JPanel getPnlContent() { |
184 |
if (pnlContent == null) { |
185 |
pnlContent = new JPanel(); |
186 |
pnlContent.setLayout(new BorderLayout()); |
187 |
pnlContent.add(getPnlCenter(), java.awt.BorderLayout.CENTER); |
188 |
pnlContent.add(getPnlSouth(), java.awt.BorderLayout.SOUTH); |
189 |
} |
190 |
return pnlContent;
|
191 |
} |
192 |
|
193 |
private JPanel getPnlCenter() { |
194 |
if (pnlCenter == null) { |
195 |
pnlCenter = new JPanel(); |
196 |
switch (shapeType) {
|
197 |
case FShape.POINT:
|
198 |
pnlCenter.setBorder(BorderFactory.
|
199 |
createTitledBorder(null,
|
200 |
PluginServices.getText(this, "point_settings"))); |
201 |
pnlCenter.add(getPointSettingsPanel()); |
202 |
break;
|
203 |
case FShape.LINE:
|
204 |
pnlCenter.setLayout(new BorderLayout()); |
205 |
pnlCenter.setBorder(BorderFactory.
|
206 |
createTitledBorder(null,
|
207 |
PluginServices.getText(this, "line_settings"))); |
208 |
JPanel aux = new JPanel( |
209 |
new GridLayout(1, 2)); |
210 |
aux.add(getOrientationPanel()); |
211 |
aux.add(getPositionPanel()); |
212 |
pnlCenter.add(aux, BorderLayout.CENTER);
|
213 |
pnlCenter.add(getLocationPanel(), BorderLayout.SOUTH);
|
214 |
|
215 |
break;
|
216 |
|
217 |
case FShape.POLYGON:
|
218 |
pnlCenter.setBorder(BorderFactory.
|
219 |
createTitledBorder(null,
|
220 |
PluginServices.getText(this, "polygon_settings"))); |
221 |
pnlCenter.add(getPolygonSettingsPanel()); |
222 |
break;
|
223 |
|
224 |
default:
|
225 |
break;
|
226 |
} |
227 |
} |
228 |
return pnlCenter;
|
229 |
} |
230 |
|
231 |
private JPanel getLocationPanel() { |
232 |
if (locationPanel == null) { |
233 |
locationPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
234 |
locationPanel.setBorder(BorderFactory.
|
235 |
createTitledBorder(null,
|
236 |
PluginServices.getText(this, "location"))); |
237 |
locationPanel.add(new JLabel(PluginServices.getText(this, "location_along_the_lines")+":")); |
238 |
locationPanel.add(getCmbLocationAlongLines()); |
239 |
} |
240 |
|
241 |
return locationPanel;
|
242 |
} |
243 |
|
244 |
private JComboBox getCmbLocationAlongLines() { |
245 |
if (cmbLocationAlongLines == null) { |
246 |
cmbLocationAlongLines = new JComboBox(new String[] { |
247 |
PluginServices.getText(this, "in_the_middle"), |
248 |
PluginServices.getText(this, "at_begin"), |
249 |
PluginServices.getText(this, "at_end"), |
250 |
PluginServices.getText(this, "at_best"), |
251 |
}); |
252 |
cmbLocationAlongLines.setSelectedIndex(0);
|
253 |
} |
254 |
|
255 |
return cmbLocationAlongLines;
|
256 |
} |
257 |
|
258 |
private GridBagLayoutPanel getPointSettingsPanel() {
|
259 |
if (pointSettingsPanel == null) { |
260 |
pointSettingsPanel = new GridBagLayoutPanel();
|
261 |
pointSettingsPanel.addComponent(getRdOffsetLabelHorizontally()); |
262 |
JPanel aux = new JPanel(); |
263 |
aux.add(getStylePreviewer()); |
264 |
|
265 |
JPanel aux2 = new JPanel(); |
266 |
aux2.setLayout(new BoxLayout(aux2, BoxLayout.Y_AXIS)); |
267 |
aux2.add(lblPointPosDesc); |
268 |
aux2.add(new JBlank(20, 20)); |
269 |
aux2.add(getBtnChangeLocation()); |
270 |
|
271 |
aux.add(aux2); |
272 |
pointSettingsPanel.addComponent("", aux);
|
273 |
pointSettingsPanel.addComponent("",
|
274 |
new JLabel(PluginServices.getText(this, "label-point-priority-help"))); |
275 |
pointSettingsPanel.addComponent(getRdOffsetLabelOnTopPoint()); |
276 |
ButtonGroup group = new ButtonGroup(); |
277 |
group.add(getRdOffsetLabelHorizontally()); |
278 |
group.add(getRdOffsetLabelOnTopPoint()); |
279 |
} |
280 |
|
281 |
return pointSettingsPanel;
|
282 |
} |
283 |
|
284 |
|
285 |
|
286 |
private JButton getBtnChangeLocation() { |
287 |
if (btnChangeLocation == null) { |
288 |
btnChangeLocation = new JButton(PluginServices.getText(this, "change_location")); |
289 |
btnChangeLocation.addActionListener(this);
|
290 |
} |
291 |
|
292 |
return btnChangeLocation;
|
293 |
} |
294 |
|
295 |
private StylePreviewer getStylePreviewer() {
|
296 |
if (stylePreview == null) { |
297 |
stylePreview = new StylePreviewer();
|
298 |
stylePreview.setStyle(pointStyle); |
299 |
stylePreview.setPreferredSize(new Dimension(80, 80)); |
300 |
} |
301 |
return stylePreview;
|
302 |
} |
303 |
|
304 |
private JRadioButton getRdOffsetLabelOnTopPoint() { |
305 |
if (rdBtnOffsetLabelOnTopPoint == null) { |
306 |
rdBtnOffsetLabelOnTopPoint = new JRadioButton( |
307 |
PluginServices.getText(this, "offset_labels_on_top_of_the_points")); |
308 |
|
309 |
} |
310 |
|
311 |
return rdBtnOffsetLabelOnTopPoint;
|
312 |
} |
313 |
|
314 |
private JRadioButton getRdOffsetLabelHorizontally() { |
315 |
if (rdBtnOffsetLabelHorizontally == null) { |
316 |
rdBtnOffsetLabelHorizontally = new JRadioButton( |
317 |
PluginServices.getText(this, "offset_labels_horizontally")); |
318 |
|
319 |
} |
320 |
|
321 |
return rdBtnOffsetLabelHorizontally;
|
322 |
} |
323 |
|
324 |
private GridBagLayoutPanel getPolygonSettingsPanel() {
|
325 |
if (polygonSettingsPanel == null) { |
326 |
polygonSettingsPanel = new GridBagLayoutPanel();
|
327 |
JPanel aux = new JPanel(); |
328 |
aux.setLayout(new BoxLayout(aux, BoxLayout.Y_AXIS)); |
329 |
aux.add(new JBlank(10,10)); |
330 |
aux.add(getRdBtnAlwaysHorizontal()); |
331 |
aux.add(new JBlank(10,10)); |
332 |
aux.add(getRdBtnAlwaysStraight()); |
333 |
polygonSettingsPanel.addComponent(getPolygonIcon(), aux); |
334 |
ButtonGroup group = new ButtonGroup(); |
335 |
group.add(getRdBtnAlwaysHorizontal()); |
336 |
group.add(getRdBtnAlwaysStraight()); |
337 |
getRdBtnAlwaysHorizontal().setSelected(true);
|
338 |
} |
339 |
|
340 |
return polygonSettingsPanel;
|
341 |
} |
342 |
|
343 |
private JRadioButton getRdBtnAlwaysStraight() { |
344 |
if (rdBtnAlwaysStraight == null) { |
345 |
rdBtnAlwaysStraight = new JRadioButton( |
346 |
PluginServices.getText(this, "always_straight")); |
347 |
rdBtnAlwaysStraight.addActionListener(this);
|
348 |
} |
349 |
|
350 |
return rdBtnAlwaysStraight;
|
351 |
} |
352 |
|
353 |
private JRadioButton getRdBtnAlwaysHorizontal() { |
354 |
if (rdBtnAlwaysHorizontal == null) { |
355 |
rdBtnAlwaysHorizontal = new JRadioButton( |
356 |
PluginServices.getText(this, "always_horizontal")); |
357 |
rdBtnAlwaysHorizontal.addActionListener(this);
|
358 |
} |
359 |
|
360 |
return rdBtnAlwaysHorizontal;
|
361 |
} |
362 |
|
363 |
private JLabel getPolygonIcon() { |
364 |
if (polygonIcon == null) { |
365 |
polygonIcon = new JLabel(new ImageIcon( |
366 |
getClass().getClassLoader(). |
367 |
getResource("images/label-polygon-always-horizontal.png")));
|
368 |
} |
369 |
return polygonIcon;
|
370 |
} |
371 |
|
372 |
private JLabel getLineIcon() { |
373 |
if (lineIcon == null) { |
374 |
lineIcon = new JLabel(new ImageIcon( |
375 |
getClass().getClassLoader(). |
376 |
getResource("images/label-line.png")));
|
377 |
} |
378 |
return lineIcon;
|
379 |
} |
380 |
|
381 |
private GridBagLayoutPanel getPositionPanel() {
|
382 |
if (positionPanel == null) { |
383 |
positionPanel = new GridBagLayoutPanel();
|
384 |
positionPanel.setBorder(BorderFactory.
|
385 |
createTitledBorder(null,
|
386 |
PluginServices.getText(this, "position"))); |
387 |
JPanel aux = new JPanel(new GridLayout(3, 1)); |
388 |
aux.add(getChkAbove()); |
389 |
aux.add(getChkOnTheLine()); |
390 |
aux.add(getChkBelow()); |
391 |
positionPanel.addComponent(aux, getLineIcon()); |
392 |
positionPanel.addComponent( |
393 |
PluginServices.getText(this, "orientation_system"), getCmbOrientationSystem()); |
394 |
|
395 |
} |
396 |
return positionPanel;
|
397 |
} |
398 |
|
399 |
private JComboBox getCmbOrientationSystem() { |
400 |
if (cmbOrientationSystem == null) { |
401 |
cmbOrientationSystem = new JComboBox(new String[] { |
402 |
PluginServices.getText(this, "line"), |
403 |
PluginServices.getText(this, "page") |
404 |
}); |
405 |
cmbOrientationSystem.setSelectedIndex(0);
|
406 |
} |
407 |
|
408 |
return cmbOrientationSystem;
|
409 |
} |
410 |
|
411 |
private JCheckBox getChkBelow() { |
412 |
if (chkBelow == null) { |
413 |
chkBelow = new JCheckBox(PluginServices.getText(this, "below")); |
414 |
} |
415 |
return chkBelow;
|
416 |
} |
417 |
|
418 |
private JCheckBox getChkOnTheLine() { |
419 |
if (chkOnTheLine == null) { |
420 |
chkOnTheLine = new JCheckBox(PluginServices.getText(this, "on_the_line")); |
421 |
} |
422 |
return chkOnTheLine;
|
423 |
} |
424 |
|
425 |
private JCheckBox getChkAbove() { |
426 |
if (chkAbove == null) { |
427 |
chkAbove = new JCheckBox(PluginServices.getText(this, "above")); |
428 |
chkAbove.setSelected(true);
|
429 |
} |
430 |
return chkAbove;
|
431 |
} |
432 |
|
433 |
private GridBagLayoutPanel getOrientationPanel() {
|
434 |
if (orientationPanel == null) { |
435 |
orientationPanel = new GridBagLayoutPanel();
|
436 |
orientationPanel.setBorder(BorderFactory.
|
437 |
createTitledBorder(null,
|
438 |
PluginServices.getText(this, "orientation"))); |
439 |
orientationPanel.addComponent(getRdBtnHorizontal()); |
440 |
orientationPanel.addComponent(getRdBtnParallel()); |
441 |
orientationPanel.addComponent(getRdBtnFollowingLine()); |
442 |
orientationPanel.addComponent(getRdBtnPerpendicular()); |
443 |
ButtonGroup group = new ButtonGroup(); |
444 |
group.add(getRdBtnHorizontal()); |
445 |
group.add(getRdBtnParallel()); |
446 |
group.add(getRdBtnFollowingLine()); |
447 |
group.add(getRdBtnPerpendicular()); |
448 |
getRdBtnParallel().setSelected(true);
|
449 |
|
450 |
} |
451 |
return orientationPanel;
|
452 |
} |
453 |
|
454 |
private JRadioButton getRdBtnParallel() { |
455 |
if (rdBtnParallel == null) { |
456 |
rdBtnParallel = new JRadioButton( |
457 |
PluginServices.getText(this, "parallel"), |
458 |
constraints.isParallel()); |
459 |
|
460 |
rdBtnParallel.addActionListener(this);
|
461 |
} |
462 |
return rdBtnParallel;
|
463 |
} |
464 |
|
465 |
private JRadioButton getRdBtnFollowingLine() { |
466 |
if (rdBtnFollowingLine == null) { |
467 |
rdBtnFollowingLine = new JRadioButton( |
468 |
PluginServices.getText(this, "following_line"), |
469 |
constraints.isFollowingLine()); |
470 |
rdBtnFollowingLine.addActionListener(this);
|
471 |
} |
472 |
return rdBtnFollowingLine;
|
473 |
} |
474 |
|
475 |
private JRadioButton getRdBtnPerpendicular() { |
476 |
if (rdBtnPerpendicular == null) { |
477 |
rdBtnPerpendicular = new JRadioButton( |
478 |
PluginServices.getText(this, "perpedicular"), |
479 |
constraints.isPerpendicular()); |
480 |
rdBtnPerpendicular.addActionListener(this);
|
481 |
} |
482 |
return rdBtnPerpendicular;
|
483 |
} |
484 |
|
485 |
private JRadioButton getRdBtnHorizontal() { |
486 |
if (rdBtnHorizontal == null) { |
487 |
rdBtnHorizontal = new JRadioButton( |
488 |
PluginServices.getText(this, "horizontal"), |
489 |
constraints.isHorizontal()); |
490 |
rdBtnHorizontal.addActionListener(this);
|
491 |
} |
492 |
return rdBtnHorizontal;
|
493 |
} |
494 |
|
495 |
private JPanel getPnlSouth() { |
496 |
if (pnlSouth == null) { |
497 |
pnlSouth = new GridBagLayoutPanel();
|
498 |
pnlSouth.setBorder(BorderFactory.
|
499 |
createTitledBorder(null,
|
500 |
PluginServices.getText(this, "duplicate_labels"))); |
501 |
pnlSouth.addComponent(getRdBtnRemoveDuplicates()); |
502 |
pnlSouth.addComponent(getRdBtnOnePerFeature()); |
503 |
pnlSouth.addComponent(getRdBtnOnePerFeaturePart()); |
504 |
|
505 |
ButtonGroup group = new ButtonGroup(); |
506 |
group.add(getRdBtnOnePerFeature()); |
507 |
group.add(getRdBtnOnePerFeaturePart()); |
508 |
group.add(getRdBtnRemoveDuplicates()); |
509 |
} |
510 |
return pnlSouth;
|
511 |
} |
512 |
|
513 |
private JRadioButton getRdBtnOnePerFeaturePart() { |
514 |
if (rdBtnOnePerFeaturePart == null) { |
515 |
rdBtnOnePerFeaturePart = new JRadioButton( |
516 |
PluginServices.getText(this, "place_one_label_per_feature_part"), |
517 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.ONE_LABEL_PER_FEATURE_PART); |
518 |
} |
519 |
return rdBtnOnePerFeaturePart;
|
520 |
} |
521 |
|
522 |
private JRadioButton getRdBtnOnePerFeature() { |
523 |
if (rdBtnOnePerFeature == null) { |
524 |
rdBtnOnePerFeature = new JRadioButton( |
525 |
PluginServices.getText(this, "place_one_label_per_feature"), |
526 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.ONE_LABEL_PER_FEATURE); |
527 |
} |
528 |
return rdBtnOnePerFeature;
|
529 |
} |
530 |
|
531 |
private JRadioButton getRdBtnRemoveDuplicates() { |
532 |
if (rdBtnRemoveDuplicates == null) { |
533 |
rdBtnRemoveDuplicates = new JRadioButton( |
534 |
PluginServices.getText(this, "remove_duplicate_labels"), |
535 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.REMOVE_DUPLICATE_LABELS); |
536 |
|
537 |
} |
538 |
return rdBtnRemoveDuplicates;
|
539 |
} |
540 |
|
541 |
private void applyConstraints() { |
542 |
switch (shapeType) {
|
543 |
case FShape.POINT:
|
544 |
break;
|
545 |
case FShape.LINE:
|
546 |
int mode;
|
547 |
if (getRdBtnFollowingLine().isSelected()) {
|
548 |
mode = IPlacementConstraints.FOLLOWING_LINE; |
549 |
} else if (getRdBtnParallel().isSelected()) { |
550 |
mode = IPlacementConstraints.PARALLEL; |
551 |
} else if (getRdBtnPerpendicular().isSelected()) { |
552 |
mode = IPlacementConstraints.PERPENDICULAR; |
553 |
} else {
|
554 |
mode = IPlacementConstraints.HORIZONTAL; |
555 |
} |
556 |
|
557 |
constraints.setPlacementMode(mode); |
558 |
constraints.setAboveTheLine(getChkAbove().isSelected()); |
559 |
constraints.setBellowTheLine(getChkBelow().isSelected()); |
560 |
// what about ON THE LINE??
|
561 |
|
562 |
constraints.setPageOriented( |
563 |
getCmbOrientationSystem().getSelectedIndex() == 1);
|
564 |
int i = getCmbLocationAlongLines().getSelectedIndex();
|
565 |
if (i == 0) { |
566 |
i = IPlacementConstraints.AT_THE_MIDDLE_OF_THE_LINE; |
567 |
} else if (i == 1) { |
568 |
i = IPlacementConstraints.AT_THE_BEGINING_OF_THE_LINE; |
569 |
} else {
|
570 |
i = IPlacementConstraints.AT_THE_END_OF_THE_LINE; |
571 |
} |
572 |
constraints.setLocationAlongTheLine(i); |
573 |
break;
|
574 |
case FShape.POLYGON:
|
575 |
break;
|
576 |
} |
577 |
} |
578 |
|
579 |
private void setComponentEnabled(Component c, boolean b) { |
580 |
if (c instanceof JComponent) { |
581 |
JComponent c1 = (JComponent) c; |
582 |
for (int i = 0; i < c1.getComponentCount(); i++) { |
583 |
setComponentEnabled(c1.getComponent(i), b); |
584 |
} |
585 |
} |
586 |
c.setEnabled(b); |
587 |
} |
588 |
|
589 |
|
590 |
public IPlacementConstraints getPlacementConstraints() {
|
591 |
return constraints;
|
592 |
} |
593 |
|
594 |
public void actionPerformed(ActionEvent e) { |
595 |
JComponent c = (JComponent) e.getSource(); |
596 |
if (c.equals(rdBtnAlwaysHorizontal) || c.equals(rdBtnAlwaysStraight) ) {
|
597 |
boolean horizontal = rdBtnAlwaysHorizontal.isSelected();
|
598 |
if (horizontal) {
|
599 |
getPolygonIcon().setIcon(new ImageIcon( |
600 |
getClass().getClassLoader(). |
601 |
getResource("images/label-polygon-always-horizontal.png")));
|
602 |
} else {
|
603 |
getPolygonIcon().setIcon(new ImageIcon( |
604 |
getClass().getClassLoader(). |
605 |
getResource("images/label-polygon-always-straight.png")));
|
606 |
} |
607 |
} else if (c.equals(rdBtnHorizontal)) { |
608 |
// lock position panel and location panel
|
609 |
setComponentEnabled(getPositionPanel(), false);
|
610 |
setComponentEnabled(getLocationPanel(), false);
|
611 |
} else if (c.equals(rdBtnParallel) || c.equals(rdBtnPerpendicular)) { |
612 |
// unlock position panel and location panel but keep orientation system locked
|
613 |
setComponentEnabled(getLocationPanel(), true);
|
614 |
setComponentEnabled(getPositionPanel(), true);
|
615 |
getCmbOrientationSystem().setEnabled(true);
|
616 |
} else if (c.equals(rdBtnFollowingLine)) { |
617 |
// lock location panel, unlock position panel, but keep orientation system locked
|
618 |
setComponentEnabled(getLocationPanel(), false);
|
619 |
setComponentEnabled(getPositionPanel(), true);
|
620 |
getCmbOrientationSystem().setEnabled(true);
|
621 |
// } else if (c.equals(rdBtnPerpendicular)) {
|
622 |
// // unlock location panel and position panel but keep orientation system locked
|
623 |
// setComponentEnabled(getLocationPanel(), true);
|
624 |
// setComponentEnabled(getPositionPanel(), true);
|
625 |
// getCmbOrientationSystem().setEnabled(true);
|
626 |
} else if (c.equals(btnChangeLocation)) { |
627 |
StyleSelector stySel = new StyleSelector(
|
628 |
pointStyle, |
629 |
FShape.POINT, new SelectorFilter() {
|
630 |
public boolean accepts(Object obj) { |
631 |
return obj instanceof PointLabelPositioneer; |
632 |
} |
633 |
}); |
634 |
PluginServices.getMDIManager().addWindow(stySel); |
635 |
IStyle sty = (IStyle) stySel.getSelectedObject(); |
636 |
if (sty != null) { |
637 |
stylePreview.setStyle(sty); |
638 |
lblPointPosDesc.setText(sty.getDescription()); |
639 |
} |
640 |
} |
641 |
} |
642 |
|
643 |
} // @jve:decl-index=0:visual-constraint="10,10"
|