⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omdrawingtoollauncher.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    }    /**     * Build the stuff that goes in the launcher.     */    public void resetGUI() {        removeAll();        JPanel palette = new JPanel();        palette.setLayout(new BoxLayout(palette, BoxLayout.Y_AXIS));        palette.setAlignmentX(Component.CENTER_ALIGNMENT); // LEFT        palette.setAlignmentY(Component.CENTER_ALIGNMENT); // BOTTOM        String[] requestorNames = new String[drawingToolRequestors.size()];        if (Debug.debugging("omdtl")) {            Debug.output("Have " + requestorNames.length + " REQUESTORS");        }        for (int i = 0; i < requestorNames.length; i++) {            requestorNames[i] = ((DrawingToolRequestor) drawingToolRequestors.elementAt(i)).getName();            if (requestorNames[i] == null) {                Debug.output("OMDrawingToolLauncher has a requestor that is unnamed.  Please assign a name to the requestor");                requestorNames[i] = "-- Unnamed --";            }            if (Debug.debugging("omdtl")) {                Debug.output("Adding REQUESTOR " + requestorNames[i]                        + " to menu");            }        }        Object oldChoice = null;        if (requestors != null) {            oldChoice = requestors.getSelectedItem();        }        requestors = new JComboBox(requestorNames);        requestors.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                JComboBox jcb = (JComboBox) e.getSource();                String currentChoice = (String) jcb.getSelectedItem();                setCurrentRequestor(currentChoice);            }        });        if (requestorNames.length > 0) {            if (oldChoice == null) {                requestors.setSelectedIndex(0);            } else {                requestors.setSelectedItem(oldChoice);            }        }        JPanel panel = PaletteHelper.createPaletteJPanel(i18n.get(OMDrawingToolLauncher.class,                "panelSendTo",                "Send To:"));        panel.add(requestors);        palette.add(panel);        if (Debug.debugging("omdtl")) {            Debug.output("Figuring out tools, using names");        }        panel = PaletteHelper.createPaletteJPanel(i18n.get(OMDrawingToolLauncher.class,                "panelGraphicType",                "Graphic Type:"));        panel.add(getToolWidgets(useTextEditToolTitles));        palette.add(panel);        String[] renderTypes = new String[3];        renderTypes[OMGraphic.RENDERTYPE_LATLON - 1] = rtc[0];        renderTypes[OMGraphic.RENDERTYPE_XY - 1] = rtc[1];        renderTypes[OMGraphic.RENDERTYPE_OFFSET - 1] = rtc[2];        JComboBox renderTypeList = new JComboBox(renderTypes);        renderTypeList.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                JComboBox jcb = (JComboBox) e.getSource();                String currentChoice = (String) jcb.getSelectedItem();                if (currentChoice == rtc[2]) {                    defaultGraphicAttributes.setRenderType(OMGraphic.RENDERTYPE_OFFSET);                } else if (currentChoice == rtc[1]) {                    defaultGraphicAttributes.setRenderType(OMGraphic.RENDERTYPE_XY);                } else {                    defaultGraphicAttributes.setRenderType(OMGraphic.RENDERTYPE_LATLON);                }            }        });        renderTypeList.setSelectedIndex(defaultGraphicAttributes.getRenderType() - 1);        panel = PaletteHelper.createVerticalPanel(i18n.get(OMDrawingToolLauncher.class,                "panelGraphicAttributes",                "Graphic Attributes:"));        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));        JPanel panel2 = PaletteHelper.createVerticalPanel(i18n.get(OMDrawingToolLauncher.class,                "panelRenderingType",                "Rendering Type:"));        panel2.add(renderTypeList);        JPanel panel3 = PaletteHelper.createVerticalPanel(i18n.get(OMDrawingToolLauncher.class,                "panelLineColorTypes",                "Line Types and Colors:"));        panel3.add(defaultGraphicAttributes.getGUI());        panel.add(panel2);        panel.add(panel3);        palette.add(panel);        JButton createButton = new JButton(i18n.get(OMDrawingToolLauncher.class,                "createButton",                "Create Graphic"));        createButton.setActionCommand(CreateCmd);        createButton.addActionListener(this);        JPanel dismissBox = new JPanel();        JButton dismiss = new JButton(i18n.get(OMDrawingToolLauncher.class,                "dismiss",                "Close"));        dismissBox.setLayout(new BoxLayout(dismissBox, BoxLayout.X_AXIS));        dismissBox.setAlignmentX(Component.CENTER_ALIGNMENT);        dismissBox.setAlignmentY(Component.BOTTOM_ALIGNMENT);        dismissBox.add(createButton);        dismissBox.add(dismiss);        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));        setAlignmentX(Component.CENTER_ALIGNMENT);        setAlignmentY(Component.BOTTOM_ALIGNMENT);        add(palette);        add(dismissBox);        dismiss.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                getWindowSupport().killWindow();            }        });    }    protected JComponent getToolWidgets() {        JPanel iconBar = new JPanel();        // this parameters should be read from properties!        iconBar.setLayout(new GridLayout(2, 4));        ButtonGroup bg = new ButtonGroup();        JToggleButton btn = null;        boolean setFirstButtonSelected = true;        for (Iterator it = getLoaders(); it.hasNext();) {            LoaderHolder lh = (LoaderHolder) it.next();            String pName = lh.prettyName;            EditToolLoader etl = lh.loader;            ImageIcon icon = etl.getIcon(getEditableClassName(pName));            btn = new JToggleButton(icon);            btn.setMargin(new Insets(0, 0, 0, 0));            btn.setToolTipText(pName);            btn.setActionCommand(pName);            btn.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent ae) {                    setCurrentCreation(ae.getActionCommand());                }            });            if (setFirstButtonSelected) {                btn.setSelected(true);                setCurrentCreation(pName);                setFirstButtonSelected = false;            }            bg.add(btn);            iconBar.add(btn);        }        return iconBar;    }    protected JComponent getToolWidgets(boolean useText) {        if (useText) {            // Set editables with all the pretty names.            Vector editables = new Vector();            for (Iterator it = getLoaders(); it.hasNext();) {                LoaderHolder lh = (LoaderHolder) it.next();                editables.add(lh.prettyName);            }            return createToolOptionMenu(editables);        } else {            return createToolButtonPanel();        }    }    private JComboBox createToolOptionMenu(Vector editables) {        String[] toolNames = new String[editables.size()];        for (int i = 0; i < toolNames.length; i++) {            toolNames[i] = (String) editables.elementAt(i);            if (Debug.debugging("omdtl")) {                Debug.output("Adding TOOL " + toolNames[i] + " to menu");            }        }        JComboBox tools = new JComboBox(toolNames);        tools.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent e) {                JComboBox jcb = (JComboBox) e.getSource();                String currentChoice = (String) jcb.getSelectedItem();                setCurrentCreation(currentChoice);            }        });        if (toolNames.length > 0) {            tools.setSelectedIndex(0);        }        return tools;    }    private JPanel createToolButtonPanel() {        // Otherwise, create a set of buttons.        JPanel panel = new JPanel();        GridBagLayout gridbag = new GridBagLayout();        GridBagConstraints c = new GridBagConstraints();        c.gridwidth = GridBagConstraints.REMAINDER;        panel.setLayout(gridbag);        ButtonGroup bg = new ButtonGroup();        int toolbarCount = 0;        boolean limitWidth = false;        if (maxHorNumLoaderButtons >= 0) {            limitWidth = true;        }        JToggleButton btn;        JToolBar iconBar = null;        boolean activeSet = false;        for (Iterator it = getLoaders(); it.hasNext();) {            if (toolbarCount == 0) {                iconBar = new JToolBar();                iconBar.setFloatable(false);                gridbag.setConstraints(iconBar, c);                panel.add(iconBar);            }            LoaderHolder lh = (LoaderHolder) it.next();            String pName = lh.prettyName;            EditToolLoader etl = lh.loader;            ImageIcon icon = etl.getIcon(getEditableClassName(pName));            btn = new JToggleButton(icon, !activeSet);            btn.setToolTipText(pName);            btn.setActionCommand(pName);            btn.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent ae) {                    setCurrentCreation(ae.getActionCommand());                }            });            bg.add(btn);            if (iconBar != null) {                iconBar.add(btn);            }            toolbarCount++;            // Just set one as active, the first one.            if (!activeSet) {                setCurrentCreation(pName);                activeSet = true;            }            if (limitWidth && toolbarCount >= maxHorNumLoaderButtons) {                toolbarCount = 0;            }        }        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();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -