svn-gvsig-desktop / trunk / extSymbology / src / org / gvsig / symbology / gui / layerproperties / PlacementProperties.java @ 18755
History | View | Annotate | Download (23.3 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 15674 2007-10-30 16:39:02Z jdominguez $
|
45 |
* $Log$
|
46 |
* Revision 1.7 2007-04-19 14:22:29 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.6 2007/04/13 12:43:08 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.5 2007/04/13 12:10:56 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.4 2007/04/12 16:01:32 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.3 2007/03/28 15:38:56 jaume
|
59 |
* GUI for lines, points and polygons
|
60 |
*
|
61 |
* Revision 1.2 2007/03/09 11:25:00 jaume
|
62 |
* Advanced symbology (start committing)
|
63 |
*
|
64 |
* Revision 1.1.2.2 2007/02/09 11:00:03 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.1.2.1 2007/02/01 12:12:41 jaume
|
68 |
* theme manager window and all its components are now dynamic
|
69 |
*
|
70 |
*
|
71 |
*/
|
72 |
package org.gvsig.symbology.gui.layerproperties; |
73 |
|
74 |
import java.awt.BorderLayout; |
75 |
import java.awt.Component; |
76 |
import java.awt.Dimension; |
77 |
import java.awt.FlowLayout; |
78 |
import java.awt.GridLayout; |
79 |
import java.awt.event.ActionEvent; |
80 |
import java.awt.event.ActionListener; |
81 |
import java.util.ArrayList; |
82 |
|
83 |
import javax.swing.BorderFactory; |
84 |
import javax.swing.BoxLayout; |
85 |
import javax.swing.ButtonGroup; |
86 |
import javax.swing.JCheckBox; |
87 |
import javax.swing.JComponent; |
88 |
import javax.swing.JLabel; |
89 |
import javax.swing.JPanel; |
90 |
import javax.swing.JRadioButton; |
91 |
|
92 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
93 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
94 |
import org.gvsig.gui.beans.swing.JBlank; |
95 |
import org.gvsig.gui.beans.swing.JButton; |
96 |
import org.gvsig.symbology.fmap.labeling.PlacementManager; |
97 |
import org.gvsig.symbology.fmap.labeling.placements.PointPlacementConstraints; |
98 |
import org.gvsig.symbology.fmap.styles.PointLabelPositioneer; |
99 |
|
100 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
101 |
import com.iver.andami.PluginServices; |
102 |
import com.iver.andami.ui.mdiManager.IWindow; |
103 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
104 |
import com.iver.cit.gvsig.fmap.core.FShape; |
105 |
import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
106 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
107 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IPlacementConstraints; |
108 |
import com.iver.cit.gvsig.gui.styling.SelectorFilter; |
109 |
import com.iver.cit.gvsig.gui.styling.StylePreviewer; |
110 |
import com.iver.cit.gvsig.gui.styling.StyleSelector; |
111 |
import com.iver.utiles.swing.JComboBox; |
112 |
/**
|
113 |
*
|
114 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
115 |
*
|
116 |
*/
|
117 |
public class PlacementProperties extends JPanel implements IWindow, ActionListener { |
118 |
private PointLabelPositioneer pointStyle = new PointLabelPositioneer( |
119 |
new byte[] { 2, 2, 1, 3, 2, 3, 3, 2 }, |
120 |
PluginServices.getText(this, "prefer_top_right_all_allowed") |
121 |
); |
122 |
private int shapeType; |
123 |
private JPanel pnlContent = null; |
124 |
private JPanel pnlCenter = null; |
125 |
private GridBagLayoutPanel pnlSouth = null; |
126 |
private JRadioButton rdBtnRemoveDuplicates; |
127 |
private IPlacementConstraints constraints;
|
128 |
private JRadioButton rdBtnOnePerFeature; |
129 |
private JRadioButton rdBtnOnePerFeaturePart; |
130 |
private GridBagLayoutPanel orientationPanel;
|
131 |
private JRadioButton rdBtnHorizontal; |
132 |
private JRadioButton rdBtnParallel; |
133 |
private JRadioButton rdBtnFollowingLine; |
134 |
private JRadioButton rdBtnPerpendicular; |
135 |
private GridBagLayoutPanel positionPanel;
|
136 |
private JLabel polygonIcon; |
137 |
private JLabel lineIcon; |
138 |
private ArrayList<String> linePositionItem = new ArrayList<String>(); |
139 |
|
140 |
private ActionListener action = new ActionListener() { |
141 |
public void actionPerformed(ActionEvent e) { |
142 |
if ("OK".equals(e.getActionCommand())) |
143 |
applyConstraints(); |
144 |
|
145 |
if ("CANCEL".equals(e.getActionCommand())) |
146 |
constraints = oldConstraints; |
147 |
PluginServices.getMDIManager().closeWindow(PlacementProperties.this); |
148 |
} |
149 |
}; |
150 |
private GridBagLayoutPanel polygonSettingsPanel;
|
151 |
private JRadioButton rdBtnAlwaysHorizontal; |
152 |
private JRadioButton rdBtnAlwaysStraight; |
153 |
private GridBagLayoutPanel pointSettingsPanel;
|
154 |
private JRadioButton rdBtnOffsetLabelHorizontally; |
155 |
private JRadioButton rdBtnOffsetLabelOnTopPoint; |
156 |
private StylePreviewer stylePreview;
|
157 |
private JButton btnChangeLocation; |
158 |
private JPanel locationPanel; |
159 |
private JComboBox cmbLocationAlongLines; |
160 |
private JCheckBox chkBelow; |
161 |
private JCheckBox chkOnTheLine; |
162 |
private JCheckBox chkAbove; |
163 |
private JComboBox cmbOrientationSystem; |
164 |
private JLabelHTML lblPointPosDesc = new JLabelHTML(pointStyle.getDescription()); |
165 |
private IPlacementConstraints oldConstraints;
|
166 |
private JCheckBox chkFitInsidePolygon; |
167 |
|
168 |
|
169 |
private void quitaEsteMetodo() { |
170 |
getRdBtnOnePerFeature().setEnabled(false);
|
171 |
getRdBtnRemoveDuplicates().setEnabled(false);
|
172 |
getRdOffsetLabelHorizontally().setEnabled(false);
|
173 |
getRdBtnFollowingLine().setEnabled(false);
|
174 |
} |
175 |
|
176 |
public PlacementProperties(FLyrVect layer, IPlacementConstraints constraints) throws ReadDriverException { |
177 |
this.shapeType = layer.getShapeType();
|
178 |
this.oldConstraints = constraints;
|
179 |
this.constraints = constraints != null ? |
180 |
PlacementManager.createPlacementConstraints(constraints.getXMLEntity()) : |
181 |
PlacementManager.createPlacementConstraints(layer); |
182 |
initialize(); |
183 |
refreshComponents(); |
184 |
// quitaEsteMetodo();
|
185 |
} |
186 |
|
187 |
private void refreshComponents() { |
188 |
getChkOnTheLine().setSelected(constraints.isOnTheLine()); |
189 |
getChkAbove().setSelected(constraints.isAboveTheLine()); |
190 |
getChkBelow().setSelected(constraints.isBellowTheLine()); |
191 |
|
192 |
getRdBtnHorizontal().setSelected(constraints.isHorizontal()); |
193 |
getRdBtnParallel().setSelected(constraints.isParallel()); |
194 |
getRdBtnFollowingLine().setSelected(constraints.isFollowingLine()); |
195 |
getRdBtnPerpendicular().setSelected(constraints.isPerpendicular()); |
196 |
|
197 |
getCmbOrientationSystem().setSelectedIndex(constraints.isPageOriented() ? 1 : 0); |
198 |
|
199 |
// points mode
|
200 |
if (constraints.isOnTopOfThePoint()) {
|
201 |
getRdOffsetLabelOnTopPoint().setSelected(true);
|
202 |
} else if (constraints.isAroundThePoint()) { |
203 |
getRdOffsetLabelHorizontally().setSelected(true);
|
204 |
} |
205 |
|
206 |
// lines mode
|
207 |
if (constraints.isAtTheBeginingOfLine()) {
|
208 |
getCmbLocationAlongLines().setSelectedIndex(1);
|
209 |
} else if (constraints.isInTheMiddleOfLine()) { |
210 |
getCmbLocationAlongLines().setSelectedIndex(0);
|
211 |
} else if (constraints.isAtTheEndOfLine()) { |
212 |
getCmbLocationAlongLines().setSelectedIndex(2);
|
213 |
} else if (constraints.isAtBestOfLine()) { |
214 |
getCmbLocationAlongLines().setSelectedIndex(3);
|
215 |
} |
216 |
|
217 |
// polygon mode
|
218 |
getChkFitInsidePolygon().setSelected(constraints.isFitInsidePolygon()); |
219 |
if (constraints.isHorizontal()) {
|
220 |
getRdBtnAlwaysHorizontal().setSelected(true);
|
221 |
} else if (constraints.isParallel()) { |
222 |
getRdBtnAlwaysStraight().setSelected(true);
|
223 |
} |
224 |
|
225 |
} |
226 |
|
227 |
private void initialize() { |
228 |
linePositionItem.add(PluginServices.getText(this, "in_the_middle")); |
229 |
linePositionItem.add(PluginServices.getText(this, "at_begin")); |
230 |
linePositionItem.add(PluginServices.getText(this, "at_end")); |
231 |
linePositionItem.add(PluginServices.getText(this, "at_best")); |
232 |
|
233 |
this.setLayout(new BorderLayout()); |
234 |
this.setSize(new Dimension(410,380)); |
235 |
this.add(getPnlContent(), BorderLayout.CENTER); |
236 |
this.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH); |
237 |
} |
238 |
|
239 |
public WindowInfo getWindowInfo() {
|
240 |
WindowInfo viewInfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
241 |
viewInfo.setWidth(getWidth()); |
242 |
viewInfo.setHeight(getHeight()); |
243 |
viewInfo.setTitle(PluginServices.getText(this,"placement_properties")); |
244 |
return viewInfo;
|
245 |
} |
246 |
|
247 |
private JPanel getPnlContent() { |
248 |
if (pnlContent == null) { |
249 |
pnlContent = new JPanel(); |
250 |
pnlContent.setLayout(new BorderLayout()); |
251 |
pnlContent.add(getPnlCenter(), java.awt.BorderLayout.CENTER); |
252 |
pnlContent.add(getPnlSouth(), java.awt.BorderLayout.SOUTH); |
253 |
} |
254 |
return pnlContent;
|
255 |
} |
256 |
|
257 |
private JPanel getPnlCenter() { |
258 |
if (pnlCenter == null) { |
259 |
pnlCenter = new JPanel(); |
260 |
switch (shapeType) {
|
261 |
case FShape.POINT:
|
262 |
case FShape.MULTIPOINT: // TODO (09/01/08) is this correct?? if not fix it also in PlacementManager, MarkerPlacementAroundPoint |
263 |
pnlCenter.setBorder(BorderFactory.
|
264 |
createTitledBorder(null,
|
265 |
PluginServices.getText(this, "point_settings"))); |
266 |
pnlCenter.add(getPointSettingsPanel()); |
267 |
break;
|
268 |
case FShape.LINE:
|
269 |
pnlCenter.setLayout(new BorderLayout()); |
270 |
pnlCenter.setBorder(BorderFactory.
|
271 |
createTitledBorder(null,
|
272 |
PluginServices.getText(this, "line_settings"))); |
273 |
JPanel aux = new JPanel( |
274 |
new GridLayout(1, 2)); |
275 |
aux.add(getOrientationPanel()); |
276 |
aux.add(getPositionPanel()); |
277 |
pnlCenter.add(aux, BorderLayout.CENTER);
|
278 |
pnlCenter.add(getLocationPanel(), BorderLayout.SOUTH);
|
279 |
|
280 |
break;
|
281 |
|
282 |
case FShape.POLYGON:
|
283 |
pnlCenter.setBorder(BorderFactory.
|
284 |
createTitledBorder(null,
|
285 |
PluginServices.getText(this, "polygon_settings"))); |
286 |
pnlCenter.add(getPolygonSettingsPanel()); |
287 |
break;
|
288 |
|
289 |
default:
|
290 |
break;
|
291 |
} |
292 |
} |
293 |
return pnlCenter;
|
294 |
} |
295 |
|
296 |
private JPanel getLocationPanel() { |
297 |
if (locationPanel == null) { |
298 |
locationPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); |
299 |
locationPanel.setBorder(BorderFactory.
|
300 |
createTitledBorder(null,
|
301 |
PluginServices.getText(this, "location"))); |
302 |
locationPanel.add(new JLabel(PluginServices.getText(this, "location_along_the_lines")+":")); |
303 |
locationPanel.add(getCmbLocationAlongLines()); |
304 |
} |
305 |
|
306 |
return locationPanel;
|
307 |
} |
308 |
|
309 |
private JComboBox getCmbLocationAlongLines() { |
310 |
if (cmbLocationAlongLines == null) { |
311 |
cmbLocationAlongLines = new JComboBox((String[]) linePositionItem.toArray(new String[linePositionItem.size()])); |
312 |
|
313 |
} |
314 |
|
315 |
return cmbLocationAlongLines;
|
316 |
} |
317 |
|
318 |
private GridBagLayoutPanel getPointSettingsPanel() {
|
319 |
if (pointSettingsPanel == null) { |
320 |
pointSettingsPanel = new GridBagLayoutPanel();
|
321 |
pointSettingsPanel.addComponent(getRdOffsetLabelHorizontally()); |
322 |
JPanel aux = new JPanel(); |
323 |
aux.add(getStylePreviewer()); |
324 |
|
325 |
JPanel aux2 = new JPanel(); |
326 |
aux2.setLayout(new BoxLayout(aux2, BoxLayout.Y_AXIS)); |
327 |
aux2.add(lblPointPosDesc); |
328 |
aux2.add(new JBlank(20, 5)); |
329 |
aux2.add(getBtnChangeLocation()); |
330 |
|
331 |
aux.add(aux2); |
332 |
pointSettingsPanel.addComponent("", aux);
|
333 |
pointSettingsPanel.addComponent("",
|
334 |
new JLabel(PluginServices.getText(this, "label-point-priority-help"))); |
335 |
pointSettingsPanel.addComponent(getRdOffsetLabelOnTopPoint()); |
336 |
ButtonGroup group = new ButtonGroup(); |
337 |
group.add(getRdOffsetLabelHorizontally()); |
338 |
group.add(getRdOffsetLabelOnTopPoint()); |
339 |
} |
340 |
|
341 |
return pointSettingsPanel;
|
342 |
} |
343 |
|
344 |
|
345 |
|
346 |
private JButton getBtnChangeLocation() { |
347 |
if (btnChangeLocation == null) { |
348 |
btnChangeLocation = new JButton(PluginServices.getText(this, "change_location")); |
349 |
btnChangeLocation.addActionListener(this);
|
350 |
} |
351 |
|
352 |
return btnChangeLocation;
|
353 |
} |
354 |
|
355 |
private StylePreviewer getStylePreviewer() {
|
356 |
if (stylePreview == null) { |
357 |
stylePreview = new StylePreviewer();
|
358 |
stylePreview.setStyle(pointStyle); |
359 |
stylePreview.setPreferredSize(new Dimension(80, 80)); |
360 |
} |
361 |
return stylePreview;
|
362 |
} |
363 |
|
364 |
private JRadioButton getRdOffsetLabelOnTopPoint() { |
365 |
if (rdBtnOffsetLabelOnTopPoint == null) { |
366 |
rdBtnOffsetLabelOnTopPoint = new JRadioButton( |
367 |
PluginServices.getText(this, "offset_labels_on_top_of_the_points")) ; |
368 |
|
369 |
} |
370 |
|
371 |
return rdBtnOffsetLabelOnTopPoint;
|
372 |
} |
373 |
|
374 |
private JRadioButton getRdOffsetLabelHorizontally() { |
375 |
if (rdBtnOffsetLabelHorizontally == null) { |
376 |
rdBtnOffsetLabelHorizontally = new JRadioButton( |
377 |
PluginServices.getText(this, "offset_labels_horizontally")); |
378 |
|
379 |
} |
380 |
|
381 |
return rdBtnOffsetLabelHorizontally;
|
382 |
} |
383 |
|
384 |
private GridBagLayoutPanel getPolygonSettingsPanel() {
|
385 |
if (polygonSettingsPanel == null) { |
386 |
polygonSettingsPanel = new GridBagLayoutPanel();
|
387 |
JPanel aux = new JPanel(); |
388 |
aux.setLayout(new BoxLayout(aux, BoxLayout.Y_AXIS)); |
389 |
aux.add(new JBlank(10,10)); |
390 |
aux.add(getRdBtnAlwaysHorizontal()); |
391 |
aux.add(new JBlank(10,10)); |
392 |
aux.add(getRdBtnAlwaysStraight()); |
393 |
polygonSettingsPanel.addComponent(getPolygonIcon(), aux); |
394 |
ButtonGroup group = new ButtonGroup(); |
395 |
group.add(getRdBtnAlwaysHorizontal()); |
396 |
group.add(getRdBtnAlwaysStraight()); |
397 |
polygonSettingsPanel.addComponent(new JBlank(20, 30)); |
398 |
polygonSettingsPanel.addComponent(getChkFitInsidePolygon()); |
399 |
} |
400 |
|
401 |
return polygonSettingsPanel;
|
402 |
} |
403 |
|
404 |
private JCheckBox getChkFitInsidePolygon() { |
405 |
if (chkFitInsidePolygon == null) { |
406 |
chkFitInsidePolygon = new JCheckBox(PluginServices.getText(this, "fit_inside_polygon")); |
407 |
|
408 |
} |
409 |
|
410 |
return chkFitInsidePolygon;
|
411 |
} |
412 |
|
413 |
private JRadioButton getRdBtnAlwaysStraight() { |
414 |
if (rdBtnAlwaysStraight == null) { |
415 |
rdBtnAlwaysStraight = new JRadioButton( |
416 |
PluginServices.getText(this, "always_straight")); |
417 |
rdBtnAlwaysStraight.addActionListener(this);
|
418 |
} |
419 |
|
420 |
return rdBtnAlwaysStraight;
|
421 |
} |
422 |
|
423 |
private JRadioButton getRdBtnAlwaysHorizontal() { |
424 |
if (rdBtnAlwaysHorizontal == null) { |
425 |
rdBtnAlwaysHorizontal = new JRadioButton( |
426 |
PluginServices.getText(this, "always_horizontal")); |
427 |
rdBtnAlwaysHorizontal.addActionListener(this);
|
428 |
} |
429 |
|
430 |
return rdBtnAlwaysHorizontal;
|
431 |
} |
432 |
|
433 |
private JLabel getPolygonIcon() { |
434 |
if (polygonIcon == null) { |
435 |
polygonIcon = new JLabel(PluginServices.getIconTheme().get("polygon-al-h-label")); |
436 |
} |
437 |
return polygonIcon;
|
438 |
} |
439 |
|
440 |
private JLabel getLineIcon() { |
441 |
if (lineIcon == null) { |
442 |
lineIcon = new JLabel(PluginServices.getIconTheme().get("line-label")); |
443 |
} |
444 |
return lineIcon;
|
445 |
} |
446 |
|
447 |
private GridBagLayoutPanel getPositionPanel() {
|
448 |
if (positionPanel == null) { |
449 |
positionPanel = new GridBagLayoutPanel();
|
450 |
positionPanel.setBorder(BorderFactory.
|
451 |
createTitledBorder(null,
|
452 |
PluginServices.getText(this, "position"))); |
453 |
JPanel aux = new JPanel(new GridLayout(3, 1)); |
454 |
aux.add(getChkAbove()); |
455 |
aux.add(getChkOnTheLine()); |
456 |
aux.add(getChkBelow()); |
457 |
positionPanel.addComponent(aux, getLineIcon()); |
458 |
positionPanel.addComponent( |
459 |
PluginServices.getText(this, "orientation_system"), getCmbOrientationSystem()); |
460 |
|
461 |
} |
462 |
return positionPanel;
|
463 |
} |
464 |
|
465 |
private JComboBox getCmbOrientationSystem() { |
466 |
if (cmbOrientationSystem == null) { |
467 |
cmbOrientationSystem = new JComboBox(new String[] { |
468 |
PluginServices.getText(this, "line"), |
469 |
PluginServices.getText(this, "page") |
470 |
}); |
471 |
cmbOrientationSystem.setSelectedIndex(0);
|
472 |
} |
473 |
|
474 |
return cmbOrientationSystem;
|
475 |
} |
476 |
|
477 |
private JCheckBox getChkBelow() { |
478 |
if (chkBelow == null) { |
479 |
chkBelow = new JCheckBox(PluginServices.getText(this, "below")); |
480 |
} |
481 |
return chkBelow;
|
482 |
} |
483 |
|
484 |
private JCheckBox getChkOnTheLine() { |
485 |
if (chkOnTheLine == null) { |
486 |
chkOnTheLine = new JCheckBox(PluginServices.getText(this, "on_the_line")); |
487 |
} |
488 |
return chkOnTheLine;
|
489 |
} |
490 |
|
491 |
private JCheckBox getChkAbove() { |
492 |
if (chkAbove == null) { |
493 |
chkAbove = new JCheckBox(PluginServices.getText(this, "above")); |
494 |
} |
495 |
return chkAbove;
|
496 |
} |
497 |
|
498 |
private GridBagLayoutPanel getOrientationPanel() {
|
499 |
if (orientationPanel == null) { |
500 |
orientationPanel = new GridBagLayoutPanel();
|
501 |
orientationPanel.setBorder(BorderFactory.
|
502 |
createTitledBorder(null,
|
503 |
PluginServices.getText(this, "orientation"))); |
504 |
orientationPanel.addComponent(getRdBtnHorizontal()); |
505 |
orientationPanel.addComponent(getRdBtnParallel()); |
506 |
orientationPanel.addComponent(getRdBtnFollowingLine()); |
507 |
orientationPanel.addComponent(getRdBtnPerpendicular()); |
508 |
ButtonGroup group = new ButtonGroup(); |
509 |
group.add(getRdBtnHorizontal()); |
510 |
group.add(getRdBtnParallel()); |
511 |
group.add(getRdBtnFollowingLine()); |
512 |
group.add(getRdBtnPerpendicular()); |
513 |
|
514 |
|
515 |
|
516 |
} |
517 |
return orientationPanel;
|
518 |
} |
519 |
|
520 |
private JRadioButton getRdBtnParallel() { |
521 |
if (rdBtnParallel == null) { |
522 |
rdBtnParallel = new JRadioButton( |
523 |
PluginServices.getText(this, "parallel")); |
524 |
|
525 |
rdBtnParallel.addActionListener(this);
|
526 |
} |
527 |
return rdBtnParallel;
|
528 |
} |
529 |
|
530 |
private JRadioButton getRdBtnFollowingLine() { |
531 |
if (rdBtnFollowingLine == null) { |
532 |
rdBtnFollowingLine = new JRadioButton( |
533 |
PluginServices.getText(this, "following_line")); |
534 |
rdBtnFollowingLine.addActionListener(this);
|
535 |
} |
536 |
return rdBtnFollowingLine;
|
537 |
} |
538 |
|
539 |
private JRadioButton getRdBtnPerpendicular() { |
540 |
if (rdBtnPerpendicular == null) { |
541 |
rdBtnPerpendicular = new JRadioButton( |
542 |
PluginServices.getText(this, "perpedicular")); |
543 |
rdBtnPerpendicular.addActionListener(this);
|
544 |
} |
545 |
return rdBtnPerpendicular;
|
546 |
} |
547 |
|
548 |
private JRadioButton getRdBtnHorizontal() { |
549 |
if (rdBtnHorizontal == null) { |
550 |
rdBtnHorizontal = new JRadioButton( |
551 |
PluginServices.getText(this, "horizontal")); |
552 |
rdBtnHorizontal.addActionListener(this);
|
553 |
} |
554 |
return rdBtnHorizontal;
|
555 |
} |
556 |
|
557 |
private JPanel getPnlSouth() { |
558 |
if (pnlSouth == null) { |
559 |
pnlSouth = new GridBagLayoutPanel();
|
560 |
pnlSouth.setBorder(BorderFactory.
|
561 |
createTitledBorder(null,
|
562 |
PluginServices.getText(this, "duplicate_labels"))); |
563 |
pnlSouth.addComponent(getRdBtnRemoveDuplicates()); |
564 |
pnlSouth.addComponent(getRdBtnOnePerFeature()); |
565 |
pnlSouth.addComponent(getRdBtnOnePerFeaturePart()); |
566 |
|
567 |
ButtonGroup group = new ButtonGroup(); |
568 |
group.add(getRdBtnOnePerFeature()); |
569 |
group.add(getRdBtnOnePerFeaturePart()); |
570 |
group.add(getRdBtnRemoveDuplicates()); |
571 |
} |
572 |
return pnlSouth;
|
573 |
} |
574 |
|
575 |
private JRadioButton getRdBtnOnePerFeaturePart() { |
576 |
if (rdBtnOnePerFeaturePart == null) { |
577 |
rdBtnOnePerFeaturePart = new JRadioButton( |
578 |
PluginServices.getText(this, "place_one_label_per_feature_part"), |
579 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.ONE_LABEL_PER_FEATURE_PART); |
580 |
} |
581 |
return rdBtnOnePerFeaturePart;
|
582 |
} |
583 |
|
584 |
private JRadioButton getRdBtnOnePerFeature() { |
585 |
if (rdBtnOnePerFeature == null) { |
586 |
rdBtnOnePerFeature = new JRadioButton( |
587 |
PluginServices.getText(this, "place_one_label_per_feature"), |
588 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.ONE_LABEL_PER_FEATURE); |
589 |
} |
590 |
return rdBtnOnePerFeature;
|
591 |
} |
592 |
|
593 |
private JRadioButton getRdBtnRemoveDuplicates() { |
594 |
if (rdBtnRemoveDuplicates == null) { |
595 |
rdBtnRemoveDuplicates = new JRadioButton( |
596 |
PluginServices.getText(this, "remove_duplicate_labels"), |
597 |
constraints.getDuplicateLabelsMode() == IPlacementConstraints.REMOVE_DUPLICATE_LABELS); |
598 |
|
599 |
} |
600 |
return rdBtnRemoveDuplicates;
|
601 |
} |
602 |
|
603 |
private void applyConstraints() { |
604 |
int mode=0; |
605 |
|
606 |
switch (shapeType) {
|
607 |
case FShape.POINT:
|
608 |
case FShape.MULTIPOINT: // TODO (09/01/08) is this correct? if not fix it also in PlacementManager, MarkerPlacementAroundPoint |
609 |
if (getRdOffsetLabelOnTopPoint().isSelected()) {
|
610 |
mode = IPlacementConstraints.ON_TOP_OF_THE_POINT; |
611 |
} else if (getRdOffsetLabelHorizontally().isSelected()) { |
612 |
mode = IPlacementConstraints.OFFSET_HORIZONTALY_AROUND_THE_POINT; |
613 |
} |
614 |
((PointPlacementConstraints) constraints). |
615 |
setPositioneer((PointLabelPositioneer) stylePreview.getStyle()); |
616 |
break;
|
617 |
case FShape.LINE:
|
618 |
if (getRdBtnFollowingLine().isSelected()) {
|
619 |
mode = IPlacementConstraints.FOLLOWING_LINE; |
620 |
} else if (getRdBtnParallel().isSelected()) { |
621 |
mode = IPlacementConstraints.PARALLEL; |
622 |
} else if (getRdBtnPerpendicular().isSelected()) { |
623 |
mode = IPlacementConstraints.PERPENDICULAR; |
624 |
} else {
|
625 |
mode = IPlacementConstraints.HORIZONTAL; |
626 |
} |
627 |
|
628 |
constraints.setAboveTheLine(getChkAbove().isSelected()); |
629 |
constraints.setBellowTheLine(getChkBelow().isSelected()); |
630 |
constraints.setOnTheLine(getChkOnTheLine().isSelected()); |
631 |
|
632 |
constraints.setPageOriented( |
633 |
getCmbOrientationSystem().getSelectedIndex() == 1);
|
634 |
int i = getCmbLocationAlongLines().getSelectedIndex();
|
635 |
if (i == 0) { |
636 |
i = IPlacementConstraints.AT_THE_MIDDLE_OF_THE_LINE; |
637 |
} else if (i == 1) { |
638 |
i = IPlacementConstraints.AT_THE_BEGINING_OF_THE_LINE; |
639 |
} else if (i == 2) { |
640 |
i = IPlacementConstraints.AT_THE_END_OF_THE_LINE; |
641 |
} else if (i == 3) { |
642 |
i = IPlacementConstraints.AT_BEST_OF_LINE; |
643 |
} |
644 |
constraints.setLocationAlongTheLine(i); |
645 |
break;
|
646 |
case FShape.POLYGON:
|
647 |
if (getRdBtnAlwaysHorizontal().isSelected()) {
|
648 |
mode = IPlacementConstraints.HORIZONTAL; |
649 |
} else if (getRdBtnAlwaysStraight().isSelected()) { |
650 |
mode = IPlacementConstraints.PARALLEL; |
651 |
} |
652 |
|
653 |
constraints.setFitInsidePolygon(getChkFitInsidePolygon().isSelected()); |
654 |
break;
|
655 |
} |
656 |
constraints.setPlacementMode(mode); |
657 |
} |
658 |
|
659 |
private void setComponentEnabled(Component c, boolean b) { |
660 |
if (c instanceof JComponent) { |
661 |
JComponent c1 = (JComponent) c; |
662 |
for (int i = 0; i < c1.getComponentCount(); i++) { |
663 |
setComponentEnabled(c1.getComponent(i), b); |
664 |
} |
665 |
} |
666 |
c.setEnabled(b); |
667 |
} |
668 |
|
669 |
|
670 |
public IPlacementConstraints getPlacementConstraints() {
|
671 |
return constraints;
|
672 |
} |
673 |
|
674 |
public void actionPerformed(ActionEvent e) { |
675 |
JComponent c = (JComponent) e.getSource(); |
676 |
if (c.equals(rdBtnAlwaysHorizontal) || c.equals(rdBtnAlwaysStraight) ) {
|
677 |
boolean horizontal = rdBtnAlwaysHorizontal.isSelected();
|
678 |
if (horizontal) {
|
679 |
getPolygonIcon().setIcon(PluginServices.getIconTheme() |
680 |
.get("polygon-al-h-label"));
|
681 |
} else {
|
682 |
getPolygonIcon().setIcon(PluginServices.getIconTheme() |
683 |
.get("polygon-al-s-label"));
|
684 |
} |
685 |
} else if (c.equals(rdBtnHorizontal)) { |
686 |
// lock position panel and location panel
|
687 |
setComponentEnabled(getPositionPanel(), false);
|
688 |
setComponentEnabled(getLocationPanel(), false);
|
689 |
} else if (c.equals(rdBtnParallel) || c.equals(rdBtnPerpendicular)) { |
690 |
// unlock position panel and location panel but keep orientation system locked
|
691 |
setComponentEnabled(getLocationPanel(), true);
|
692 |
setComponentEnabled(getPositionPanel(), true);
|
693 |
getCmbOrientationSystem().setEnabled(true);
|
694 |
} else if (c.equals(rdBtnFollowingLine)) { |
695 |
// lock location panel, unlock position panel, but keep orientation system locked
|
696 |
setComponentEnabled(getLocationPanel(), false);
|
697 |
setComponentEnabled(getPositionPanel(), true);
|
698 |
getCmbOrientationSystem().setEnabled(true);
|
699 |
// } else if (c.equals(rdBtnPerpendicular)) {
|
700 |
// // unlock location panel and position panel but keep orientation system locked
|
701 |
// setComponentEnabled(getLocationPanel(), true);
|
702 |
// setComponentEnabled(getPositionPanel(), true);
|
703 |
// getCmbOrientationSystem().setEnabled(true);
|
704 |
} else if (c.equals(btnChangeLocation)) { |
705 |
StyleSelector stySel = new StyleSelector(
|
706 |
pointStyle, |
707 |
FShape.POINT, new SelectorFilter() {
|
708 |
public boolean accepts(Object obj) { |
709 |
return obj instanceof PointLabelPositioneer; |
710 |
} |
711 |
}); |
712 |
PluginServices.getMDIManager().addWindow(stySel); |
713 |
IStyle sty = (IStyle) stySel.getSelectedObject(); |
714 |
if (sty != null) { |
715 |
stylePreview.setStyle(sty); |
716 |
lblPointPosDesc.setText(sty.getDescription()); |
717 |
} |
718 |
} |
719 |
|
720 |
|
721 |
|
722 |
} |
723 |
|
724 |
private class JLabelHTML extends JLabel { |
725 |
private static final long serialVersionUID = -5031405572546951108L; |
726 |
|
727 |
public JLabelHTML(String text) { |
728 |
super(text);
|
729 |
setPreferredSize(new Dimension(250, 60)); |
730 |
} |
731 |
|
732 |
@Override
|
733 |
public void setText(String text) { |
734 |
// silly fix to avoid too large text lines
|
735 |
super.setText("<html>"+text+"</html>"); |
736 |
} |
737 |
} |
738 |
} // @jve:decl-index=0:visual-constraint="10,10"
|