omdrawingtoollauncher.java
来自「OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你」· Java 代码 · 共 868 行 · 第 1/3 页
JAVA
868 行
return panel; } /** * Set the component that will receive the new/edited OMGraphic from the * DrawingTool. Does not change the GUI. Called when the combo box changes. * * @param name GUI pretty name of requestor. */ public void setCurrentRequestor(String name) { Enumeration objs = drawingToolRequestors.elements(); while (objs.hasMoreElements()) { DrawingToolRequestor dtr = (DrawingToolRequestor) objs.nextElement(); if (name.equals(dtr.getName())) { currentRequestor = dtr; return; } } currentRequestor = null; } /** * Set the next thing to be created to be whatever the pretty name * represents. Sets currentCreation. * * @param name GUI pretty name of thing to be created, from one of the * EditToolLoaders. */ public void setCurrentCreation(String name) { currentCreation = getEditableClassName(name); } /** * Given a pretty name, look through the EditToolLoaders and find out the * classname that goes with editing it. * * @param prettyName GUI pretty name of tool, or thing to be created, from * one of the EditToolLoaders. */ public String getEditableClassName(String prettyName) { for (Iterator it = getLoaders(); it.hasNext();) { LoaderHolder lh = (LoaderHolder) it.next(); EditToolLoader etl = lh.loader; String[] ec = etl.getEditableClasses(); for (int i = 0; i < ec.length; i++) { if (prettyName.equals(etl.getPrettyName(ec[i]))) { defaultGraphicAttributes.setEnableFillPaintChoice(!(etl instanceof NonRegional)); updateDrawingAttributesGUI(); panel3.revalidate(); return ec[i]; } } } return null; } /** * This is the method that your object can use to find other objects within * the MapHandler (BeanContext). This method gets called when the object * gets added to the MapHandler, or when another object gets added to the * MapHandler after the object is a member. * * @param someObj the object that was added to the BeanContext (MapHandler) * that is being searched for. Find the ones you need, and hook * yourself up. */ public void findAndInit(Object someObj) { if (someObj instanceof OMDrawingTool) { Debug.message("omdtl", "OMDrawingToolLauncher found a DrawingTool."); setDrawingTool((DrawingTool) someObj); } if (someObj instanceof DrawingToolRequestor) { if (Debug.debugging("omdtl")) { Debug.output("OMDrawingToolLauncher found a DrawingToolRequestor - " + ((DrawingToolRequestor) someObj).getName()); } drawingToolRequestors.add(someObj); // resetGUI(); resetCombo(); } } /** * BeanContextMembershipListener method. Called when a new object is removed * from the BeanContext of this object. For the Layer, this method doesn't * do anything. If your layer does something with the childrenAdded method, * or findAndInit, you should take steps in this method to unhook the layer * from the object used in those methods. */ public void findAndUndo(Object someObj) { if (someObj instanceof OMDrawingTool) { Debug.message("omdtl", "OMDrawingToolLauncher found a DrawingTool."); OMDrawingTool dt = (OMDrawingTool) someObj; if (dt == getDrawingTool()) { setDrawingTool(null); dt.removePropertyChangeListener(this); } } if (someObj instanceof DrawingToolRequestor) { if (Debug.debugging("omdtl")) { Debug.output("OMDrawingToolLauncher removing a DrawingToolRequestor - " + ((DrawingToolRequestor) someObj).getName()); } drawingToolRequestors.remove(someObj); if (drawingToolRequestors.size() == 0) {// there is no // Requestor, so // lets remove the // window. getWindowSupport().killWindow(); return; } // resetGUI(); resetCombo(); setRequestor(null); } } /** * Tool interface method. The retrieval tool's interface. This method * creates a button that will bring up the LauncherPanel. * * @return String The key for this tool. */ public Container getFace() { JToolBar jtb = null; if (getUseAsTool()) { jtb = new com.bbn.openmap.gui.GridBagToolBar(); // "Drawing Tool Launcher"; JButton drawingToolButton = new JButton(new ImageIcon(OMDrawingToolLauncher.class.getResource("Drawing.gif"), i18n.get(OMDrawingToolLauncher.class, "drawingToolButton", I18n.TOOLTIP, "Drawing Tool Launcher"))); drawingToolButton.setToolTipText(i18n.get(OMDrawingToolLauncher.class, "drawingToolButton", I18n.TOOLTIP, "Drawing Tool Launcher")); drawingToolButton.addActionListener(getActionListener()); jtb.add(drawingToolButton); } return jtb; } /** * Get the ActionListener that triggers the LauncherPanel. Useful to have to * provide an alternative way to bring up the LauncherPanel. * * @return ActionListener */ public ActionListener getActionListener() { return new ActionListener() { public void actionPerformed(ActionEvent evt) { MapHandler mh = (MapHandler) getBeanContext(); Frame frame = null; if (mh != null) { frame = (Frame) mh.get(java.awt.Frame.class); } // -1 will get size from pack(), and get location (initially) to // the middle of the screen if the WindowSupport doesn't have // memory of where it's been. getWindowSupport().displayInWindow(frame, -1, -1, -1, -1); } }; } /** * Get the attributes that initalize the graphic. */ public GraphicAttributes getDefaultGraphicAttributes() { return defaultGraphicAttributes; } /** * Set the attributes that initalize the graphic. */ public void setDefaultGraphicAttributes(GraphicAttributes ga) { defaultGraphicAttributes = ga; } /** * Set the loaders with an Iterator containing EditToolLoaders. */ public void setLoaders(Iterator iterator) { loaders.clear(); while (iterator.hasNext()) { addLoader((EditToolLoader) iterator.next()); } } /** * Returns an iterator of LoaderHolders. */ public Iterator getLoaders() { return loaders.iterator(); } public void addLoader(EditToolLoader etl) { if (etl != null) { String[] classNames = etl.getEditableClasses(); for (int i = 0; i < classNames.length; i++) { loaders.add(new LoaderHolder(etl.getPrettyName(classNames[i]), etl)); } } } public void removeLoader(EditToolLoader etl) { if (etl != null) { for (Iterator it = getLoaders(); it.hasNext();) { LoaderHolder lh = (LoaderHolder) it.next(); if (lh.loader == etl) { loaders.remove(lh); } } } } /** * PropertyChangeListener method, to listen for the OMDrawingTool's list of * loaders that may or may not change. */ public void propertyChange(PropertyChangeEvent pce) { if (pce.getPropertyName() == OMDrawingTool.LoadersProperty) { setLoaders(((Vector) pce.getNewValue()).iterator()); resetGUI(); } } public void setProperties(String prefix, Properties props) { super.setProperties(prefix, props); prefix = PropUtils.getScopedPropertyPrefix(prefix); maxHorNumLoaderButtons = PropUtils.intFromProperties(props, prefix + HorizontalNumberOfLoaderButtonsProperty, maxHorNumLoaderButtons); useTextEditToolTitles = PropUtils.booleanFromProperties(props, prefix + UseLoaderTextProperty, useTextEditToolTitles); } public Properties getProperties(Properties props) { props = super.getProperties(props); String prefix = PropUtils.getScopedPropertyPrefix(this); props.put(prefix + HorizontalNumberOfLoaderButtonsProperty, Integer.toString(maxHorNumLoaderButtons)); props.put(prefix + UseLoaderTextProperty, new Boolean(useTextEditToolTitles).toString()); return props; } public Properties getPropertyInfo(Properties props) { props = super.getPropertyInfo(props); String internString = i18n.get(OMDrawingToolLauncher.class, HorizontalNumberOfLoaderButtonsProperty, I18n.TOOLTIP, "Number of loader buttons to place horizontally"); props.put(HorizontalNumberOfLoaderButtonsProperty, internString); internString = i18n.get(OMDrawingToolLauncher.class, HorizontalNumberOfLoaderButtonsProperty, "# Horizontal Buttons"); props.put(HorizontalNumberOfLoaderButtonsProperty + LabelEditorProperty, internString); internString = i18n.get(OMDrawingToolLauncher.class, UseLoaderTextProperty, I18n.TOOLTIP, "Use text popup for loader selection."); props.put(UseLoaderTextProperty, internString); internString = i18n.get(OMDrawingToolLauncher.class, UseLoaderTextProperty, "Use Text For Selection"); props.put(UseLoaderTextProperty + LabelEditorProperty, internString); return props; } public static class LoaderHolder { public String prettyName; public EditToolLoader loader; public LoaderHolder(String pn, EditToolLoader etl) { prettyName = pn; loader = etl; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?