1 | /*
|
---|
2 | * Indoorhelper is a JOSM plug-in to support users when creating their own indoor maps.
|
---|
3 | * Copyright (C) 2016 Erik Gruschka
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (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, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package views;
|
---|
20 |
|
---|
21 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
22 |
|
---|
23 | import java.awt.BorderLayout;
|
---|
24 | import java.awt.GridBagConstraints;
|
---|
25 | import java.awt.GridBagLayout;
|
---|
26 | import java.awt.Insets;
|
---|
27 | import java.awt.TextField;
|
---|
28 | import java.awt.event.ActionListener;
|
---|
29 | import java.awt.event.FocusEvent;
|
---|
30 | import java.awt.event.FocusListener;
|
---|
31 | import java.awt.event.ItemListener;
|
---|
32 | import java.util.List;
|
---|
33 | import java.util.ListIterator;
|
---|
34 |
|
---|
35 | import javax.swing.JButton;
|
---|
36 | import javax.swing.JLabel;
|
---|
37 | import javax.swing.JPanel;
|
---|
38 | import javax.swing.JSeparator;
|
---|
39 | import javax.swing.JToggleButton;
|
---|
40 | import javax.swing.border.EmptyBorder;
|
---|
41 |
|
---|
42 | import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
|
---|
43 | import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
|
---|
44 | import org.openstreetmap.josm.gui.widgets.JosmComboBox;
|
---|
45 |
|
---|
46 | import model.IndoorLevel;
|
---|
47 | import model.TagCatalog;
|
---|
48 | import model.TagCatalog.IndoorObject;
|
---|
49 |
|
---|
50 | /**
|
---|
51 | *
|
---|
52 | * This is the main toolbox of the indoorhelper plug-in.
|
---|
53 | *
|
---|
54 | * @author egru
|
---|
55 | *
|
---|
56 | */
|
---|
57 | @SuppressWarnings("serial")
|
---|
58 | public class ToolBoxView extends ToggleDialog {
|
---|
59 | private JPanel dialogPane;
|
---|
60 | private JPanel contentPanel;
|
---|
61 | private JToggleButton powerButton;
|
---|
62 | private JLabel levelLabel;
|
---|
63 | private JosmComboBox<String> levelBox;
|
---|
64 | private JLabel levelTagLabel;
|
---|
65 | private DisableShortcutsOnFocusGainedTextField levelTagField;
|
---|
66 | private JLabel objectLabel;
|
---|
67 | private JosmComboBox<TagCatalog.IndoorObject> objectBox;
|
---|
68 | private JLabel nameLabel;
|
---|
69 | private DisableShortcutsOnFocusGainedTextField nameField;
|
---|
70 | private JLabel refLabel;
|
---|
71 | private DisableShortcutsOnFocusGainedTextField refField;
|
---|
72 | private JPanel buttonBar;
|
---|
73 | private JButton applyButton;
|
---|
74 | private JSeparator separator1;
|
---|
75 | private JSeparator separator2;
|
---|
76 | private PresetButton preset1;
|
---|
77 | private PresetButton preset2;
|
---|
78 | private PresetButton preset3;
|
---|
79 | private PresetButton preset4;
|
---|
80 |
|
---|
81 | public ToolBoxView() {
|
---|
82 | super(tr("Indoor Mapping Helper"), "indoorhelper",
|
---|
83 | tr("Toolbox for indoor mapping assistance"), null, 300, true);
|
---|
84 |
|
---|
85 | initComponents();
|
---|
86 | }
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Creates the layout of the plug-in.
|
---|
90 | */
|
---|
91 | private void initComponents() {
|
---|
92 | dialogPane = new JPanel();
|
---|
93 | contentPanel = new JPanel();
|
---|
94 | powerButton = new JToggleButton();
|
---|
95 | levelLabel = new JLabel();
|
---|
96 | levelBox = new JosmComboBox<String>();
|
---|
97 | levelTagLabel = new JLabel();
|
---|
98 | levelTagField = new DisableShortcutsOnFocusGainedTextField();
|
---|
99 | objectLabel = new JLabel();
|
---|
100 | objectBox = new JosmComboBox<>(TagCatalog.IndoorObject.values());
|
---|
101 | nameLabel = new JLabel();
|
---|
102 | nameField = new DisableShortcutsOnFocusGainedTextField();
|
---|
103 | refLabel = new JLabel();
|
---|
104 | refField = new DisableShortcutsOnFocusGainedTextField();
|
---|
105 | buttonBar = new JPanel();
|
---|
106 | applyButton = new JButton();
|
---|
107 | separator1 = new JSeparator();
|
---|
108 | separator2 = new JSeparator();
|
---|
109 | preset1 = new PresetButton(IndoorObject.ROOM);
|
---|
110 | preset2 = new PresetButton(IndoorObject.SHELL);
|
---|
111 | preset3 = new PresetButton(IndoorObject.CONCRETE_WALL);
|
---|
112 | preset4 = new PresetButton(IndoorObject.GLASS_WALL);
|
---|
113 |
|
---|
114 | //======== this ========
|
---|
115 | //Container contentPane = this.get;
|
---|
116 | //contentPane.setLayout(new BorderLayout());
|
---|
117 |
|
---|
118 | //======== dialogPane ========
|
---|
119 | {
|
---|
120 | dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
|
---|
121 | dialogPane.setLayout(new BorderLayout());
|
---|
122 |
|
---|
123 | //======== contentPanel ========
|
---|
124 | {
|
---|
125 | contentPanel.setLayout(new GridBagLayout());
|
---|
126 | ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {
|
---|
127 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
---|
128 | ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
|
---|
129 | ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {
|
---|
130 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
|
---|
131 | ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
|
---|
132 |
|
---|
133 | //---- powerButton ----
|
---|
134 | powerButton.setText(tr("POWER"));
|
---|
135 | powerButton.setToolTipText(tr("Activates the plug-in"));
|
---|
136 | contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0,
|
---|
137 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
138 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
139 | contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0,
|
---|
140 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
141 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
142 |
|
---|
143 | //---- levelLabel ----
|
---|
144 | levelLabel.setText(tr("Working Level"));
|
---|
145 | contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0,
|
---|
146 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
147 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
148 |
|
---|
149 | //---- levelBox ----
|
---|
150 | levelBox.setEnabled(false);
|
---|
151 | levelBox.setEditable(false);
|
---|
152 | levelBox.setToolTipText(tr("Selects the working level."));
|
---|
153 | contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0,
|
---|
154 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
155 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
156 |
|
---|
157 | //---- levelTagLabel ----
|
---|
158 | levelTagLabel.setText(tr("Level Name"));
|
---|
159 | contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0,
|
---|
160 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
161 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
162 |
|
---|
163 | //---- levelTagField ----
|
---|
164 | levelTagField.setEnabled(false);
|
---|
165 | levelTagField.setColumns(6);
|
---|
166 | levelTagField.setToolTipText(tr("Optional name-tag for a level."));
|
---|
167 | contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0,
|
---|
168 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
169 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
170 | contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0,
|
---|
171 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
172 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
173 |
|
---|
174 | //---- objectLabel ----
|
---|
175 | objectLabel.setText(tr("Object"));
|
---|
176 | contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
|
---|
177 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
178 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
179 |
|
---|
180 | //---- objectBox ----
|
---|
181 | objectBox.setEnabled(false);
|
---|
182 | objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL);
|
---|
183 | objectBox.setToolTipText(tr("The object preset you want to tag."));
|
---|
184 | contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0,
|
---|
185 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
186 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
187 |
|
---|
188 | //---- nameLabel ----
|
---|
189 | nameLabel.setText(tr("Name"));
|
---|
190 | contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0,
|
---|
191 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
192 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
193 |
|
---|
194 | //---- nameField ----
|
---|
195 | nameField.setEnabled(false);
|
---|
196 | nameField.addFocusListener(new FocusListener() {
|
---|
197 |
|
---|
198 | @Override
|
---|
199 | public void focusLost(FocusEvent e) {}
|
---|
200 |
|
---|
201 | @Override
|
---|
202 | public void focusGained(FocusEvent e) {
|
---|
203 | nameField.selectAll();
|
---|
204 | }
|
---|
205 | });
|
---|
206 | nameField.setToolTipText(tr("Sets the name tag when the room-object is selected."));
|
---|
207 | contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0,
|
---|
208 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
209 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
210 |
|
---|
211 | //---- refLabel ----
|
---|
212 | refLabel.setText(tr("Reference"));
|
---|
213 | contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
|
---|
214 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
215 | new Insets(0, 0, 0, 5), 0, 0));
|
---|
216 |
|
---|
217 | //---- refField ----
|
---|
218 | refField.setEnabled(false);
|
---|
219 | refField.addFocusListener(new FocusListener() {
|
---|
220 |
|
---|
221 | @Override
|
---|
222 | public void focusLost(FocusEvent e) {}
|
---|
223 |
|
---|
224 | @Override
|
---|
225 | public void focusGained(FocusEvent e) {
|
---|
226 | refField.selectAll();
|
---|
227 | }
|
---|
228 | });
|
---|
229 | refField.setToolTipText(tr("Sets the ref tag when the room-object is selected."));
|
---|
230 | contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0,
|
---|
231 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
232 | new Insets(0, 0, 0, 5), 0, 0));
|
---|
233 |
|
---|
234 | //---- preset1 ----
|
---|
235 | preset1.setEnabled(false);
|
---|
236 | contentPanel.add(preset1, new GridBagConstraints(16, 2, 1, 1, 0.0, 0.0,
|
---|
237 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
238 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
239 | contentPanel.add(separator2, new GridBagConstraints(1, 3, 13, 1, 0.0, 0.0,
|
---|
240 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
241 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
242 |
|
---|
243 | //---- preset2 ----
|
---|
244 | preset2.setEnabled(false);
|
---|
245 | contentPanel.add(preset2, new GridBagConstraints(16, 3, 1, 1, 0.0, 0.0,
|
---|
246 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
247 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
248 |
|
---|
249 | //---- preset3 ----
|
---|
250 | preset3.setEnabled(false);
|
---|
251 | contentPanel.add(preset3, new GridBagConstraints(16, 4, 1, 1, 0.0, 0.0,
|
---|
252 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
253 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
254 |
|
---|
255 | //---- preset4 ----
|
---|
256 | preset4.setEnabled(false);
|
---|
257 | contentPanel.add(preset4, new GridBagConstraints(16, 5, 1, 1, 0.0, 0.0,
|
---|
258 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
259 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
260 | }
|
---|
261 | dialogPane.add(contentPanel, BorderLayout.CENTER);
|
---|
262 |
|
---|
263 | //======== buttonBar ========
|
---|
264 | {
|
---|
265 | buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
|
---|
266 | buttonBar.setLayout(new GridBagLayout());
|
---|
267 | ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80};
|
---|
268 | ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
|
---|
269 |
|
---|
270 | //---- applyButton ----
|
---|
271 | applyButton.setText(tr("Apply Tags"));
|
---|
272 | applyButton.setEnabled(false);
|
---|
273 | buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
|
---|
274 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
275 | new Insets(0, 0, 0, 0), 0, 0));
|
---|
276 | }
|
---|
277 | dialogPane.add(buttonBar, BorderLayout.SOUTH);
|
---|
278 | }
|
---|
279 | //contentPane.add(dialogPane, BorderLayout.CENTER);
|
---|
280 |
|
---|
281 |
|
---|
282 | this.createLayout(dialogPane, false, null);
|
---|
283 | }
|
---|
284 |
|
---|
285 | /**
|
---|
286 | * Returns the state of the power button.
|
---|
287 | *
|
---|
288 | * @return boolean which is true when the button is selected
|
---|
289 | */
|
---|
290 | public boolean getPowerButtonState() {
|
---|
291 | return this.powerButton.isSelected();
|
---|
292 | }
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * Enables or disables the interactive UI elements of the toolbox.
|
---|
296 | *
|
---|
297 | * @param enabled set this true for enabled elements
|
---|
298 | */
|
---|
299 | public void setAllUiElementsEnabled(boolean enabled) {
|
---|
300 | this.applyButton.setEnabled(enabled);
|
---|
301 | this.levelBox.setEnabled(enabled);
|
---|
302 | this.objectBox.setEnabled(enabled);
|
---|
303 | this.nameField.setEnabled(enabled);
|
---|
304 | this.refField.setEnabled(enabled);
|
---|
305 | this.levelTagField.setEnabled(enabled);
|
---|
306 | this.preset1.setEnabled(enabled);
|
---|
307 | this.preset2.setEnabled(enabled);
|
---|
308 | this.preset3.setEnabled(enabled);
|
---|
309 | this.preset4.setEnabled(enabled);
|
---|
310 |
|
---|
311 |
|
---|
312 | if (enabled == false) {
|
---|
313 | resetUiElements();
|
---|
314 | this.levelTagField.setText("");
|
---|
315 | }
|
---|
316 | }
|
---|
317 |
|
---|
318 | /**
|
---|
319 | * Enables or disables the interactive text box elements name and ref.
|
---|
320 | *
|
---|
321 | * @param enabled set this true for enabled elements
|
---|
322 | */
|
---|
323 | public void setTagUiElementsEnabled(boolean enabled) {
|
---|
324 | this.nameField.setEnabled(enabled);
|
---|
325 | this.refField.setEnabled(enabled);
|
---|
326 |
|
---|
327 | if (enabled == false) resetUiElements();
|
---|
328 | }
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Disables the power-button of the plug-in.
|
---|
332 | */
|
---|
333 | public void setPowerButtonDisabled() {
|
---|
334 | this.powerButton.setSelected(false);
|
---|
335 | }
|
---|
336 |
|
---|
337 | /**
|
---|
338 | * Getter for the selected {@link IndoorObject} in the objectBox.
|
---|
339 | *
|
---|
340 | * @return the selected indoor object in the object ComboBox.
|
---|
341 | */
|
---|
342 | public IndoorObject getSelectedObject() {
|
---|
343 | return (IndoorObject) this.objectBox.getSelectedItem();
|
---|
344 | }
|
---|
345 |
|
---|
346 |
|
---|
347 | /**
|
---|
348 | * Sets the level list for the level selection comboBox.
|
---|
349 | *
|
---|
350 | * @param levelList the list of levels which you want to set
|
---|
351 | */
|
---|
352 | public void setLevelList(List<IndoorLevel> levelList) {
|
---|
353 | this.levelBox.removeAllItems();
|
---|
354 |
|
---|
355 | ListIterator<IndoorLevel> listIterator = levelList.listIterator();
|
---|
356 |
|
---|
357 | while (listIterator.hasNext()) {
|
---|
358 | IndoorLevel level = listIterator.next();
|
---|
359 | if (level.hasEmptyName()) {
|
---|
360 | this.levelBox.addItem(Integer.toString(level.getLevelNumber()));
|
---|
361 | } else {
|
---|
362 | this.levelBox.addItem(level.getName());
|
---|
363 | }
|
---|
364 | }
|
---|
365 | }
|
---|
366 |
|
---|
367 | /**
|
---|
368 | * Getter for the selected working level.
|
---|
369 | *
|
---|
370 | * @return the index of the selected item in the level-box
|
---|
371 | */
|
---|
372 | public int getSelectedLevelIndex() {
|
---|
373 | return this.levelBox.getSelectedIndex();
|
---|
374 | }
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Checks if the level list is empty.
|
---|
378 | *
|
---|
379 | * @return boolean which is true if the level-list is empty
|
---|
380 | */
|
---|
381 | public boolean levelListIsEmpty() {
|
---|
382 | if (this.levelBox.getItemCount() == 0) {
|
---|
383 | return true;
|
---|
384 | } else {
|
---|
385 | return false;
|
---|
386 | }
|
---|
387 | }
|
---|
388 |
|
---|
389 | /**
|
---|
390 | * Getter for the level-name-field.
|
---|
391 | *
|
---|
392 | * @return the {@link String} of the levelTagField
|
---|
393 | */
|
---|
394 | public String getLevelName() {
|
---|
395 | return this.levelTagField.getText();
|
---|
396 | }
|
---|
397 |
|
---|
398 | /**
|
---|
399 | * Setter for the level name field.
|
---|
400 | *
|
---|
401 | * @param name the String for the levelTagField
|
---|
402 | */
|
---|
403 | public void setLevelName(String name) {
|
---|
404 | this.levelTagField.setText(name);
|
---|
405 | }
|
---|
406 |
|
---|
407 | /**
|
---|
408 | * Getter for the name {@link TextField}.
|
---|
409 | *
|
---|
410 | * @return {@link String} of the name text field
|
---|
411 | */
|
---|
412 | public String getNameText() {
|
---|
413 | return this.nameField.getText();
|
---|
414 | }
|
---|
415 |
|
---|
416 | /**
|
---|
417 | * Getter for the ref {@link TextField}.
|
---|
418 | *
|
---|
419 | * @return {@link String} of the ref text field
|
---|
420 | */
|
---|
421 | public String getRefText() {
|
---|
422 | return this.refField.getText();
|
---|
423 | }
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * Resets the view by making the UI elements disabled and deleting the level list.
|
---|
427 | */
|
---|
428 | public void reset() {
|
---|
429 | this.setAllUiElementsEnabled(false);
|
---|
430 | this.levelBox.removeAllItems();
|
---|
431 | }
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Clears the text boxes and sets an empty {@link String}.
|
---|
435 | */
|
---|
436 | public void resetUiElements() {
|
---|
437 | this.nameField.setText("");
|
---|
438 | this.refField.setText("");
|
---|
439 | }
|
---|
440 |
|
---|
441 | /*
|
---|
442 | * ********************************
|
---|
443 | * SETTERS FOR THE BUTTON LISTENERS
|
---|
444 | * ********************************
|
---|
445 | */
|
---|
446 |
|
---|
447 | /**
|
---|
448 | * Set the listener for the power button.
|
---|
449 | *
|
---|
450 | * @param l the listener to set
|
---|
451 | */
|
---|
452 | public void setPowerButtonListener(ActionListener l) {
|
---|
453 | this.powerButton.addActionListener(l);
|
---|
454 | }
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Set the listener for the apply button.
|
---|
458 | *
|
---|
459 | * @param l the listener to set
|
---|
460 | */
|
---|
461 | public void setApplyButtonListener(ActionListener l) {
|
---|
462 | this.applyButton.addActionListener(l);
|
---|
463 | }
|
---|
464 |
|
---|
465 | /**
|
---|
466 | * Set the listener which is called when a new item in the level list is selected.
|
---|
467 | *
|
---|
468 | * @param l the listener to set
|
---|
469 | */
|
---|
470 | public void setLevelItemListener(ItemListener l) {
|
---|
471 | this.levelBox.addItemListener(l);
|
---|
472 | }
|
---|
473 |
|
---|
474 |
|
---|
475 | /**
|
---|
476 | * Set the listener which is called when a new item in the object list is selected.
|
---|
477 | *
|
---|
478 | * @param l the listener to set
|
---|
479 | */
|
---|
480 | public void setObjectItemListener(ItemListener l) {
|
---|
481 | this.objectBox.addItemListener(l);
|
---|
482 | }
|
---|
483 |
|
---|
484 | // Preset Button Functions
|
---|
485 |
|
---|
486 | public void setPresetButtons(List<IndoorObject> objects) {
|
---|
487 | this.preset1.setIndoorObject(objects.get(0));
|
---|
488 | this.preset2.setIndoorObject(objects.get(1));
|
---|
489 | this.preset3.setIndoorObject(objects.get(2));
|
---|
490 | this.preset4.setIndoorObject(objects.get(3));
|
---|
491 | }
|
---|
492 |
|
---|
493 | public void setPreset1Listener(ActionListener l) {
|
---|
494 | this.preset1.addActionListener(l);
|
---|
495 | }
|
---|
496 |
|
---|
497 | public void setPreset2Listener(ActionListener l) {
|
---|
498 | this.preset2.addActionListener(l);
|
---|
499 | }
|
---|
500 |
|
---|
501 | public void setPreset3Listener(ActionListener l) {
|
---|
502 | this.preset3.addActionListener(l);
|
---|
503 | }
|
---|
504 |
|
---|
505 | public void setPreset4Listener(ActionListener l) {
|
---|
506 | this.preset4.addActionListener(l);
|
---|
507 | }
|
---|
508 |
|
---|
509 | public IndoorObject getPreset1() {
|
---|
510 | return preset1.getIndoorObject();
|
---|
511 | }
|
---|
512 |
|
---|
513 | public IndoorObject getPreset2() {
|
---|
514 | return preset2.getIndoorObject();
|
---|
515 | }
|
---|
516 |
|
---|
517 | public IndoorObject getPreset3() {
|
---|
518 | return preset3.getIndoorObject();
|
---|
519 | }
|
---|
520 |
|
---|
521 | public IndoorObject getPreset4() {
|
---|
522 | return preset4.getIndoorObject();
|
---|
523 | }
|
---|
524 | }
|
---|