246 |
* Clears the GUI of all components and adds all tool and action buttons to |
* Clears the GUI of all components and adds all tool and action buttons to |
247 |
* the tool bar. |
* the tool bar. |
248 |
*/ |
*/ |
249 |
protected void initToolBar() { |
public void initToolBar() { |
250 |
setAlignmentY(1f); |
setAlignmentY(1f); |
251 |
removeAll(); |
removeAll(); |
252 |
// Separator to the left of the tool actions to start |
// Separator to the left of the tool actions to start |
256 |
// Tool buttons |
// Tool buttons |
257 |
for (JComponent b : toolAndActionButtons.values()) |
for (JComponent b : toolAndActionButtons.values()) |
258 |
add(b); |
add(b); |
259 |
|
|
260 |
|
repaint(); |
261 |
|
|
262 |
|
if (!toolAndActionButtons.containsKey(selectedTool)) { |
263 |
|
/** |
264 |
|
* This might be a bit specific, but IF selection buttons are |
265 |
|
* available, select one of them.. if not, select the INFO tool. |
266 |
|
*/ |
267 |
|
|
268 |
|
if (toolAndActionButtons.containsKey(TOOL_SELECTION_SET)) { |
269 |
|
setSelectedTool(TOOL_SELECTION_SET); |
270 |
|
} else if (toolAndActionButtons.containsKey(TOOL_INFO)) { |
271 |
|
setSelectedTool(TOOL_INFO); |
272 |
|
} else { |
273 |
|
// TODO What to do now?! |
274 |
|
setSelectedTool(null); |
275 |
|
} |
276 |
|
|
277 |
|
} |
278 |
} |
} |
279 |
|
|
280 |
// Space between tool buttons and action buttons |
// Space between tool buttons and action buttons |
313 |
// Set the mouse tool to "Info" |
// Set the mouse tool to "Info" |
314 |
mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setWindowSelectionState(JMapPane.NONE); |
315 |
mapPane.setState(JMapPane.SELECT_TOP); // Why not: |
mapPane.setState(JMapPane.SELECT_TOP); // Why not: |
316 |
// JMapPane.SELECT_TOP_ONEONLY |
// JMapPane.SELECT_TOP_ONEONLY |
317 |
mapPane.setHighlight(false);// SK: Was true, but since it not works |
mapPane.setHighlight(false);// SK: Was true, but since it not works |
318 |
// properly removed it to save |
// properly removed it to save |
319 |
// performance |
// performance |
320 |
mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR); |
321 |
break; |
break; |
322 |
case TOOL_ZOOMIN: |
case TOOL_ZOOMIN: |
333 |
mapPane.setHighlight(false); |
mapPane.setHighlight(false); |
334 |
mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR); |
335 |
break; |
break; |
336 |
// default: |
default: |
337 |
// // Set map actions to default |
// Set map actions to default |
338 |
// mapPane.setWindowSelectionState(JMapPane.NONE); |
mapPane.setWindowSelectionState(JMapPane.NONE); |
339 |
// mapPane.setState(JMapPane.NONE); |
mapPane.setState(JMapPane.NONE); |
340 |
// mapPane.setHighlight(false); |
mapPane.setHighlight(false); |
341 |
// mapPane.setNormalCursor(null); |
mapPane.setNormalCursor(null); |
342 |
// break; |
break; |
343 |
} |
} |
344 |
mapPane.updateCursor(); |
mapPane.updateCursor(); |
345 |
} |
} |
346 |
|
|
347 |
/** |
/** |
348 |
* @param id The ID of the Component to remove |
* @param id |
349 |
|
* The ID of the Component to remove. The change will not be |
350 |
|
* visible until {@link #initToolBar()} is called. |
351 |
* @return <code>null</code> or the component that has been removed. |
* @return <code>null</code> or the component that has been removed. |
352 |
*/ |
*/ |
353 |
public JComponent removeId(int id){ |
public JComponent removeId(int id) { |
354 |
return toolAndActionButtons.remove(id); |
return toolAndActionButtons.remove(id); |
355 |
} |
} |
356 |
|
|
540 |
return; |
return; |
541 |
button.setSelected(true); |
button.setSelected(true); |
542 |
button.getAction().actionPerformed(null); |
button.getAction().actionPerformed(null); |
543 |
|
|
544 |
|
selectedTool = tool; |
545 |
} |
} |
546 |
|
|
547 |
/** |
/** |