annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java @ 880:22dc88b17253

Added tooltips for the maptoolbar. flys-client/trunk@2709 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 13 Sep 2011 04:49:10 +0000
parents f5855350fc03
children d3b4010d2c89
rev   line source
800
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui.map;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.LinkedHashMap;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import com.google.gwt.core.client.GWT;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import com.smartgwt.client.types.SelectionType;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import com.smartgwt.client.widgets.ImgButton;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import com.smartgwt.client.widgets.events.ClickEvent;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import com.smartgwt.client.widgets.events.ClickHandler;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import com.smartgwt.client.widgets.form.DynamicForm;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import com.smartgwt.client.widgets.form.fields.SelectItem;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import com.smartgwt.client.widgets.form.fields.FormItem;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import com.smartgwt.client.widgets.layout.HLayout;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.gwtopenmaps.openlayers.client.Map;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.gwtopenmaps.openlayers.client.control.Control;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.gwtopenmaps.openlayers.client.control.DrawFeature;
850
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
21 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener;
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
22 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener.FeatureAddedEvent;
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
23 import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
800
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import org.gwtopenmaps.openlayers.client.handler.Handler;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import org.gwtopenmaps.openlayers.client.handler.PathHandler;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import org.gwtopenmaps.openlayers.client.handler.PolygonHandler;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import org.gwtopenmaps.openlayers.client.layer.Vector;
850
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
28 import org.gwtopenmaps.openlayers.client.util.Attributes;
800
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 import de.intevation.flys.client.client.FLYSConstants;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import de.intevation.flys.client.client.utils.EnableDisableCmd;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
850
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
34 public class DrawControl extends HLayout implements VectorFeatureAddedListener {
800
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 public static final String BARRIER_PIPE1 = "pipe1";
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public static final String BARRIER_PIPE2 = "pipe2";
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 public static final String BARRIER_DITCH = "ditch";
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 public static final String BARRIER_DAM = "dam";
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 public static final String BARRIER_RINGDIKE = "ring_dike";
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 public static final String FIELD_BARRIER_TYPE = "field_barrier_type";
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 protected EnableDisableCmd cmd;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 protected ImgButton button;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 protected DynamicForm form;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 protected Map map;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 protected Vector layer;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 protected Control control;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 public DrawControl(Map map, Vector layer, EnableDisableCmd cmd) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 this.map = map;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 this.layer = layer;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 this.cmd = cmd;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 initialize();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 protected void initialize() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 setWidth(100);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 setMembersMargin(0);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 button = new ImgButton();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 String baseUrl = GWT.getHostPageBaseURL();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 button.setSrc(baseUrl + MSG.digitize());
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 button.setActionType(SelectionType.CHECKBOX);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 button.setSize(20);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 button.setShowRollOver(false);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 button.setSelected(false);
880
22dc88b17253 Added tooltips for the maptoolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 860
diff changeset
79 button.setTooltip(MSG.digitizeObjects());
800
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 button.addClickHandler(new ClickHandler() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 public void onClick(ClickEvent e) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 if (button.isSelected()) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 cmd.enable();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 else {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 cmd.disable();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 });
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 form = new DynamicForm();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 form.setWidth(75);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 form.setTitlePrefix("");
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 form.setTitleSuffix("");
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 map.put(BARRIER_PIPE1, MSG.getString(BARRIER_PIPE1));
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 map.put(BARRIER_PIPE2, MSG.getString(BARRIER_PIPE2));
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 map.put(BARRIER_DITCH, MSG.getString(BARRIER_DITCH));
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 map.put(BARRIER_DAM, MSG.getString(BARRIER_DAM));
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 map.put(BARRIER_RINGDIKE, MSG.getString(BARRIER_RINGDIKE));
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 SelectItem box = new SelectItem(FIELD_BARRIER_TYPE);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 box.setTitle("");
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 box.setWidth(75);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 box.setValueMap(map);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 box.addChangedHandler(new ChangedHandler() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 public void onChanged(ChangedEvent e) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 setSelectedControl();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 });
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 form.setFields(box);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 addMember(button);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 addMember(form);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118
850
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
119 layer.addVectorFeatureAddedListener(this);
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
120
800
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 activate(false);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 protected String getSelectedType() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 return form.getValueAsString(FIELD_BARRIER_TYPE);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
850
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
130 public void onFeatureAdded(FeatureAddedEvent evt) {
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
131 setCurrentType(evt.getVectorFeature());
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
132 }
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
133
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
134
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
135 protected void setCurrentType(VectorFeature feature) {
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
136 Attributes attrs = feature.getAttributes();
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
137 String type = attrs.getAttributeAsString("typ");
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
138
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
139 if (type == null || type.length() == 0) {
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
140 type = getSelectedType();
860
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
141
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
142 if (type.equals(BARRIER_PIPE1)) {
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
143 attrs.setAttribute("typ", "Rohr 1");
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
144 }
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
145 else if (type.equals(BARRIER_PIPE2)) {
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
146 attrs.setAttribute("typ", "Rohr 2");
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
147 }
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
148 else if (type.equals(BARRIER_DAM)) {
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
149 attrs.setAttribute("typ", "Damm");
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
150 }
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
151 else if (type.equals(BARRIER_DITCH)) {
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
152 attrs.setAttribute("typ", "Graben");
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
153 }
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
154 else if (type.equals(BARRIER_RINGDIKE)) {
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
155 attrs.setAttribute("typ", "Ringdeich");
f5855350fc03 Set WSPLGEN specific 'type' attributes after digitizing new geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 850
diff changeset
156 }
850
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
157 }
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
158 }
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
159
d02c3835df28 Set the 'typ' attribute of new features (digitized) in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 800
diff changeset
160
800
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 protected void removeControl() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 if (control != null) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 control.deactivate();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 map.removeControl(control);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 protected void setSelectedControl() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 removeControl();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 String type = getSelectedType();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 if (type == null || type.length() == 0) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 return;
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 if (type.equalsIgnoreCase(BARRIER_RINGDIKE)) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 control = createDrawPolygonControl();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 else {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 control = createDrawLineControl();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 map.addControl(control);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 control.activate();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 protected Control createDrawControl(Handler handler) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191 return new DrawFeature(layer, handler);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 protected Control createDrawPolygonControl() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 return createDrawControl(new PolygonHandler());
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 protected Control createDrawLineControl() {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 return createDrawControl(new PathHandler());
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 public void activate(boolean activate) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 FormItem item = form.getField(FIELD_BARRIER_TYPE);
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 if (activate) {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 button.select();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 item.enable();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 setSelectedControl();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 else {
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 removeControl();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 button.deselect();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 item.disable();
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 }
95cc560ce7c4 Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org