📄 layerspanel.java
字号:
} return; } LinkedList panes = getPanes(); int row = panes.indexOf(lp); boolean boundary = false; int bls_row = -1; if (backgroundLayerSeparator != null) { bls_row = panes.indexOf(backgroundLayerSeparator); boundary = bufferedBoundary; } if (command.equals(LayerTopCmd)) { // Move layer selected layer to top panes.remove(lp); if (boundary && bls_row > 0 && row > bls_row + 1) { // If the backgroundLayerSeparator is more than one // above it, move to just below it on the first top // command. panes.add(bls_row + 1, lp); } else { panes.addFirst(lp); } rejiggerMapLayers(); } else if (command.equals(LayerBottomCmd)) { // Move layer selected layer to bottom panes.remove(lp); if (boundary && bls_row > 0 && row < bls_row - 1) { // If the backgroundLayerSeparator is more than one // below it, move to just above it on the first top // command. panes.add(bls_row - 1, lp); } else { panes.addLast(lp); } rejiggerMapLayers(); } else if (command.equals(LayerUpCmd)) { // Move layer selected layer up one if (row <= 0) return; panes.remove(row); panes.add(row - 1, lp); rejiggerMapLayers(); } else if (command.equals(LayerDownCmd)) { // Move layer selected layer up one if (row < 0 || row == panes.size() - 1) return; panes.remove(row); panes.add(row + 1, lp); rejiggerMapLayers(); } else if (command.equals(LayerRemoveCmd)) { if (layerHandler == null || !lp.getLayer().removeConfirmed()) { return; } // This order is somewhat important. lp.getLayer() will // be null after lp.cleanup. lp.setSelected() will cause // a series of property change notifications. lp.setSelected(false); lp.getLayer().setPaletteVisible(false); paneLookUp.remove(lp.getLayer()); layerHandler.removeLayer(lp.getLayer()); lp.cleanup(bg); // Shouldn't call this, but it's the only thing // that seems to make it work... if (Debug.debugging("helpgc")) { System.gc(); } return; } else if (command.equals(LayerAddCmd)) { if (layerAddPanel != null) { layerAddPanel.showPanel(); } } } /** * Find the selected LayerPane in the current LayerPane list. Will return * null if there isn't a selected pane. */ protected LayerPane findSelectedPane() { Iterator it = getPanes().iterator(); while (it.hasNext()) { LayerPane pane = (LayerPane) it.next(); if (pane.isSelected()) { return pane; } } return null; } /** * Makes a new layer cake of active layers to send to * LayerHandler.setLayers(). */ protected void rejiggerMapLayers() { Debug.message("layerspanel", "LayersPanel.rejiggerMapLayers()"); if (layerHandler == null) { // Why bother doing anything?? return; } int selectedRow = -1; panesPanel.removeAll(); LinkedList panes = getPanes(); LinkedList layerList = new LinkedList(); int bufferIndex = Integer.MAX_VALUE; int i = 0; // track layer index Iterator it = panes.iterator(); while (it.hasNext()) { LayerPane pane = (LayerPane) it.next(); if (pane == backgroundLayerSeparator) { panesPanel.add(backgroundLayerSeparator); bufferIndex = i++; continue; } Layer layer = pane.getLayer(); layer.setAddAsBackground(i > bufferIndex); panesPanel.add(pane); layerList.add(layer); if (pane.isSelected()) { selectedRow = i; } i++; } scrollPane.revalidate(); // Scroll up or down as necessary to keep selected row // viewable if (selectedRow >= 0) { int spheight = scrollPane.getHeight(); JScrollBar sb = scrollPane.getVerticalScrollBar(); int sv = sb.getValue(); int paneheight = ((LayerPane) panes.get(selectedRow)).getHeight(); int rowvalue = selectedRow * paneheight; // Don't reset scrollBar unless the selected row // is not in the viewable range if (!((rowvalue > sv) && (rowvalue < spheight + sv))) { sb.setValue(rowvalue); } } Object[] layerArray = layerList.toArray(); int length = layerArray.length; Layer[] newLayers = new Layer[length]; for (int j = 0; j < length; j++) { newLayers[j] = (Layer) layerArray[j]; } layerHandler.setLayers(newLayers); } /** * Update the layer names - if a layer name has changed, tell the LayerPanes * to check with their layers to update their labels. */ public synchronized void updateLayerLabels() { Iterator it = getPanes().iterator(); while (it.hasNext()) { ((LayerPane) it.next()).updateLayerLabel(); } } public void propertyChange(PropertyChangeEvent pce) { String command = pce.getPropertyName(); Object obj = pce.getNewValue(); if (Debug.debugging("layercontrol")) { Debug.output("LayersPanel receiving PropertyChangeEvent " + command + ", " + pce.toString()); } if ((command == LayerSelectedCmd || command == LayerDeselectedCmd) && obj instanceof Layer) { if (Debug.debugging("layercontrol")) { Debug.output("LayersPanel: layer panel notification that layer is selected: " + ((Layer) obj).getName()); } firePropertyChange(command, null, ((Layer) obj)); } else if ((command == LayersPanel.LayerTopCmd || command == LayersPanel.LayerBottomCmd || command == LayersPanel.LayerUpCmd || command == LayersPanel.LayerDownCmd || command == LayersPanel.LayerRemoveCmd) && obj instanceof Layer) { if (Debug.debugging("layercontrol")) { Debug.output("LayersPanel: layer panel notification that layer should be raised: " + ((Layer) obj).getName()); } moveLayer((Layer) obj, command); } } /** * Called when the LayersPanel is added the BeanContext, or when another * object is added to the BeanContext after the LayerHandler has been added. * This allows the LayersPanel to keep up-to-date with any objects that it * may be interested in, namely, the LayerHandler. If a LayerHandler has * already been added, the new LayerHandler will replace it. * * @param someObj the object being added to the BeanContext */ public void findAndInit(Object someObj) { if (someObj instanceof LayerHandler) { // do the initializing that need to be done here Debug.message("layerspanel", "LayersPanel found a LayerHandler"); setLayerHandler((LayerHandler) someObj); } if (someObj instanceof BufferedLayerMapBean) { if (Debug.debugging("layerspanel")) { Debug.output("LayersPanel found BufferedLayerMapBean, creating separator panel"); } backgroundLayerSeparator = LayerPane.getBackgroundLayerSeparator(" --- Background Layers --- "); } // Don't want to forward ourselves on to controls, supposedly // they already know. if (controls instanceof LightMapHandlerChild && someObj != this) { ((LightMapHandlerChild) controls).findAndInit(someObj); } } /** * BeanContextMembershipListener method. Called when an object has been * removed from the parent BeanContext. If a LayerHandler is removed, and * it's the current one being listened to, then the layers in the panel will * be wiped clean. * * @param someObj the object being removed from the BeanContext */ public void findAndUndo(Object someObj) { if (someObj instanceof LayerHandler) { // do the initializing that need to be done here Debug.message("layerspanel", "LayersPanel removing LayerHandler"); if (getLayerHandler() == (LayerHandler) someObj) { setLayerHandler(null); } } // Don't want to forward ourselves on to controls, supposedly // they already know. if (controls instanceof LightMapHandlerChild && someObj != this) { ((LightMapHandlerChild) controls).findAndUndo(someObj); } } public void setProperties(String prefix, Properties props) { super.setProperties(prefix, props); prefix = PropUtils.getScopedPropertyPrefix(prefix); String controlString = props.getProperty(prefix + ControlButtonsProperty); if (controlString != NO_CONTROLS) { if (controlString == null) { createControlButtons(); } else { Object obj = ComponentFactory.create(controlString, prefix + ControlButtonsProperty, props); if (obj instanceof LayerControlButtonPanel) { setControlsAndNotify((LayerControlButtonPanel) obj); } } } bufferedBoundary = PropUtils.booleanFromProperties(props, prefix + BufferedBoundaryProperty, bufferedBoundary); showStatus = PropUtils.booleanFromProperties(props, prefix + ShowStatusProperty, showStatus); } public Properties getProperties(Properties props) { props = super.getProperties(props); String prefix = PropUtils.getScopedPropertyPrefix(this); LayerControlButtonPanel controls = getControls(); if (controls != null) { props.put(prefix + ControlButtonsProperty, controls.getClass() .getName()); controls.getProperties(props); } props.put(prefix + BufferedBoundaryProperty, new Boolean(bufferedBoundary).toString()); props.put(prefix + ShowStatusProperty, new Boolean(showStatus).toString()); return props; } public Properties getPropertyInfo(Properties props) { props = super.getPropertyInfo(props); String interString = i18n.get(LayersPanel.class, ControlButtonsProperty, I18n.TOOLTIP, "Class to use for layer control buttons (Optional)"); props.put(ControlButtonsProperty, interString); interString = i18n.get(LayersPanel.class, ControlButtonsProperty, "Button Panel Control"); props.put(ControlButtonsProperty + LabelEditorProperty, interString); LayerControlButtonPanel controls = getControls(); if (controls != null) { controls.getPropertyInfo(props); } interString = i18n.get(LayersPanel.class, BufferedBoundaryProperty, I18n.TOOLTIP, "Force layer movement to respect background layer boundary."); props.put(BufferedBoundaryProperty, interString); interString = i18n.get(LayersPanel.class, BufferedBoundaryProperty, "Use Background Layers"); props.put(BufferedBoundaryProperty + LabelEditorProperty, interString); props.put(BufferedBoundaryProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor"); interString = i18n.get(LayersPanel.class, ShowStatusProperty, I18n.TOOLTIP, "Use Layer Panes that show layer status."); props.put(ShowStatusProperty, interString); interString = i18n.get(LayersPanel.class, ShowStatusProperty, "Show Layer Status"); props.put(ShowStatusProperty + LabelEditorProperty, interString); props.put(ShowStatusProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor"); return props; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -