?? informationdelegator.java
字號:
/** * Display a html String in a window. */ public void displayBrowserContent(String content) { MapHandler mh = (MapHandler) getBeanContext(); Frame frame = null; if (mh != null) { frame = (Frame) mh.get(java.awt.Frame.class); } com.bbn.openmap.gui.MiniBrowser.display(frame, "text/html", content); } /** * Display a line of text in a info line. */ public void displayInfoLine(String infoLine) { displayInfoLine(infoLine, MAP_OBJECT_INFO_LINE); } /** * Display a line of text in a designated info line. */ public void displayInfoLine(String infoLine, int labelDesignator) { if (infoLineHolder != null) { setLabel((infoLine != null && infoLine.length() > 0) ? infoLine : fudgeString, labelDesignator); } } /** * Display a message in a pop-up window. */ public void displayMessage(String title, String message) { if (Environment.getBoolean(Environment.UseInternalFrames)) { JOptionPane.showInternalMessageDialog(Environment.getInternalFrameDesktop(), message, title, JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE); } } /////////////////////////////////////////// // InfoDisplayListener interface /** * Handle layer requests to have a URL displayed in a Browser. * * @param event InfoDisplayEvent */ public void requestURL(InfoDisplayEvent event) { displayURL(event.getInformation()); } /** * Handle layer requests to have a message displayed in a dialog * window. * * @param event InfoDisplayEvent */ public void requestMessage(InfoDisplayEvent event) { Layer l = event.getLayer(); String layername = (l == null) ? null : l.getName(); displayMessage("Message from " + layername + " layer:", event.getInformation()); } /** * Handle layer requests to have an information line displayed in * an application status window. * * @param event InfoDisplayEvent */ public void requestInfoLine(InfoDisplayEvent event) { displayInfoLine(event.getInformation(), event.getPreferredLocation()); } /** * Handle layer requests that plain text or html text be displayed * in a browser. * * @param event InfoDisplayEvent */ public void requestBrowserContent(InfoDisplayEvent event) { displayBrowserContent(event.getInformation()); } /** * If a tooltip is required over a spot on the map then a * <code>MouseMapListener</code> should pass a MouseEvent to * this method. The Swing ToolTipManager is used to achieve this. * A call to this method should always be followed by a call to * <code>hideToolTip</code> * * @param me A MouseEvent from a <code>MapMouseListener</code> * which indicates where the tooltip is to appear (unused) * @param event an event containing the ToolTip to show * @deprecated use requestShowToolTip(InfoDisplayEvent) instead. */ public void requestShowToolTip(MouseEvent me, InfoDisplayEvent event) { requestShowToolTip(event); } /** * If a tooltip is required over a spot on the map then a * <code>MouseMapListener</code> should pass a MouseEvent to * this method. The Swing ToolTipManager is used to achieve this. * A call to this method should always be followed by a call to * <code>hideToolTip</code> * * @param event an event containing the ToolTip to show */ public void requestShowToolTip(InfoDisplayEvent event) { //shows a tooltip over the map if (map != null) { if (ttmanager == null) { initToolTip(); } map.setToolTipText(event.getInformation()); } } /** * This method should follow a call to showToolTip in order to * indicate that the tooltip should no longer be displayed. This * method should always follow a call to <code>showToolTip</code? * * @param me A MouseEvent which passes from a MapMouseListener to * indicate that a tooltip should disappear * @deprecated call requestHideToolTip() instead. */ public void requestHideToolTip(MouseEvent me) { requestHideToolTip(); } /** * This method should follow a call to showToolTip in order to * indicate that the tooltip should no longer be displayed. This * method should always follow a call to <code>showToolTip</code? */ public void requestHideToolTip() { initToolTip(); } /** * This method should be called to intialize the tooltip status so * that an old tooltip doesn't remain when a layer starts * listening to mouse events. */ public void initToolTip() { if (ttmanager == null) { //make sure the MapBean is registered first ttmanager = ToolTipManager.sharedInstance(); ttmanager.registerComponent(map); ttmanager.setEnabled(true); return; } // If it already exists, clear out the current tip if (map != null) { map.setToolTipText(null); } } /** * Change the cursor for the MapBean. If the MapBean hasn't been * set, then nothing will happen on the screen. If a null value is * passed in, the cursor is reset to the MouseMode value. If the * InformationDelegator is alowed to show the wait cursor, and the * layers are busy, the wait cursor will take precidence. The * requested cursor from a layer will be set if the layers finish. * * @param cursor java.awt.Cursor to change the cursor to. */ public void requestCursor(java.awt.Cursor cursor) { // This is interpreted as a release from a requester if (cursor == null) { // If we're not supposed to be showing the wait cursor... if (showWaitCursor && !waitingForLayers) resetCursor(); // Set this to null, so that when we're done waiting for // the layers, we'll just reset. currentMapBeanCursor = null; } else if (this.map != null) { Cursor newCursor; // If we're supposed to be showing the watch, do it, but // save the request for when the layers are done. if (showWaitCursor && waitingForLayers) { newCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); currentMapBeanCursor = cursor; } else newCursor = cursor; map.setCursor(newCursor); } } /** * Set the cursor to use when the waiting is done, if a layer * hasn't asked for one to be displayed. For the MouseMode * changes, this is automatically called. */ public void setResetCursor(java.awt.Cursor cursor) { fallbackMapBeanCursor = cursor; } /** * Sets the cursor over the mapbean to the assigned default, or * whatever has been set by the MouseMode. */ public void resetCursor() { if (this.map != null) map.setCursor(fallbackMapBeanCursor); } /** * If the value passed in is true, the cursor over the MapBean * will be the waiting cursor layers are off working. The status * lights will work, too, no matter what the value is. If false, * the cursor won't change if the layers are working. */ public void setShowWaitCursor(boolean value) { showWaitCursor = value; } /** * Returns whether the wait cursor will be shown if the layers are * working. */ public boolean isShowWaitCursor() { return showWaitCursor; } //////////// MapHandlerChild methods overridden from // OMComponentPanel /** * Called when an object has been added to the BeanContext. The * InformationDelegator will look for certain objects it needs. */ public void findAndInit(Object someObj) { if (someObj instanceof MapBean) { setMap((MapBean) someObj); } if (someObj instanceof MouseDelegator) { MouseDelegator md = (MouseDelegator) someObj; md.addPropertyChangeListener(this); } statusBar.findAndInit(someObj); } /** * Called when an object is being removed from the BeanContext. * Will cause the object to be disconnected from the * InformationDelegator if it is being used. */ public void findAndUndo(Object someObj) { if (someObj instanceof MapBean) { setMap(null); } if (someObj instanceof MouseDelegator) { MouseDelegator md = (MouseDelegator) someObj; md.removePropertyChangeListener(this); } statusBar.findAndUndo(someObj); } /////// PropertyConsumer methods overridden from OMComponentPanel public void setProperties(String prefix, Properties props) { setPropertyPrefix(prefix); prefix = PropUtils.getScopedPropertyPrefix(prefix); statusBar.setProperties(prefix, props); setShowLights(PropUtils.booleanFromProperties(props, prefix + ShowLightsProperty, showLights)); setShowInfoLine(PropUtils.booleanFromProperties(props, prefix + ShowInfoLineProperty, showInfoLine)); String pl = props.getProperty(prefix + PreferredLocationProperty); if (pl != null) { setPreferredLocation(pl); } } public Properties getProperties(Properties props) { if (props == null) { props = new Properties(); } statusBar.getProperties(props); String prefix = PropUtils.getScopedPropertyPrefix(this); props.put(prefix + ShowLightsProperty, new Boolean(showLights).toString()); props.put(prefix + ShowInfoLineProperty, new Boolean(showInfoLine).toString()); props.put(prefix + PreferredLocationProperty, getPreferredLocation()); return props; } public Properties getPropertyInfo(Properties props) { if (props == null) { props = new Properties(); } statusBar.getPropertyInfo(props); props.put(ShowLightsProperty, "Show the layer status lights"); props.put(ShowLightsProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor"); props.put(ShowInfoLineProperty, "Show the information line below the map"); props.put(ShowInfoLineProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor"); props.put(PreferredLocationProperty, "The preferred BorderLayout direction to place this component."); return props; } /////// Setters and Getters public void setInfoLineHolder(JLabel ilh) { infoLineHolder = ilh; } public JLabel getInfoLineHolder() { return infoLineHolder; } public void setProgressBar(JProgressBar progressBar) { this.progressBar = progressBar; } public JProgressBar getProgressBar() { return progressBar; } public void setShowLights(boolean set) { showLights = set; statusBar.setVisible(set); } public boolean getShowLights() { return showLights; } public void setShowInfoLine(boolean set) { showInfoLine = set; infoLineHolder.setVisible(set); infoLineHolder2.setVisible(set); } public boolean getShowInfoLine() { return showInfoLine; } public void setLightTriggers(boolean set) { statusBar.setLightTriggers(set); } public boolean getLightTriggers() { return statusBar.getLightTriggers(); } public void setFloatable(boolean value) {} /** * BorderLayout.SOUTH by default for this class. */ protected String preferredLocation = java.awt.BorderLayout.SOUTH; /** * MapPanelChild method. */ public void setPreferredLocation(String value) { preferredLocation = value; } /** * MapPanelChild method. */ public String getPreferredLocation() { return preferredLocation; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -