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

📄 layercontrolbuttonpanel.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************//// <copyright>//// BBN Technologies// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000//// Copyright (C) BBNT Solutions LLC. All rights reserved.//// </copyright>// **********************************************************************//// $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/gui/LayerControlButtonPanel.java,v $// $RCSfile: LayerControlButtonPanel.java,v $// $Revision: 1.3.2.4 $// $Date: 2005/08/09 19:15:57 $// $Author: dietrick $//// **********************************************************************package com.bbn.openmap.gui;import java.awt.BorderLayout;import java.awt.event.ActionListener;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.net.URL;import java.util.Properties;import javax.swing.BoxLayout;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JLabel;import com.bbn.openmap.I18n;import com.bbn.openmap.Layer;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PropUtils;import com.bbn.openmap.util.propertyEditor.OptionPropertyEditor;import com.bbn.openmap.util.propertyEditor.OrientationPropertyEditor;/** * A OMComponentPanel that provides controls to manupulate layer order * in the LayersPanel, and to provide add layer and delete layer * buttons. This panel can be embedded into the LayersPanel, or it can * be positioned somewhere else in the application. The LayersPanel * can be set to create one of these itself, in which case it will be * embedded. If you don't want an embedded version, create one and add * it to the MapHandler, it will hook up to the LayersPanel when it * finds it. The LayerPanes, LayersPanel and LayerControlButtonPanel * communicate with each other using PropertyChangeEvents. The * LayerPanes notify the LayersPanelwhen one of them is selected, and * that event gets passed to this panel. When a button on this panel * is pressed, it fires a PropertyChangeEvent with the layer and * command to take to all its PropertyChangeListeners. * <P> *  * The LayerControlButtonPanel takes these properties: *  * <pre> *  *   *    *     *     *     *     *     # Direction buttons are laid out, vertical or horizontal (vertical is *     default). *     orientation=vertical *     # Flag on whether to insert buttons onto LayersPanel (true by default). *     embedded=true *     # Configuration setting when embedding into LayersPanel (WEST, *     # NORTH, EAST, SOUTH, NORTH_SOUTH) NORTH_SOUTH puts up button above *     # list, down button below list. *     configuration=WEST *     # Flag to put button that lets the user delete layers (true by default). *     delete=true *     # Flag to put button that lets the user add layers, if the *     # LayersAddPanel is discovered in the MapHandler (true by default) *     add=true *     *     *     *      *     *    *   * </pre> */public class LayerControlButtonPanel extends OMComponentPanel implements        ActionListener, PropertyChangeListener {    // Images    protected static transient URL urlup;    protected static transient ImageIcon upgif;    protected static transient URL urlupc;    protected static transient ImageIcon upclickedgif;    protected static transient URL urltop;    protected static transient ImageIcon topgif;    protected static transient URL urltopc;    protected static transient ImageIcon topclickedgif;    protected static transient URL urldown;    protected static transient ImageIcon downgif;    protected static transient URL urldownc;    protected static transient ImageIcon downclickedgif;    protected static transient URL urlbottom;    protected static transient ImageIcon bottomgif;    protected static transient URL urlbottomc;    protected static transient ImageIcon bottomclickedgif;    protected static transient URL urldelete;    protected static transient ImageIcon deletegif;    protected static transient URL urldeletec;    protected static transient ImageIcon deleteclickedgif;    protected static transient URL urladd;    protected static transient ImageIcon addgif;    protected static transient URL urladdc;    protected static transient ImageIcon addclickedgif;    /**     * Static default initializations.     */    static {        urlup = LayersPanel.class.getResource("Up.gif");        upgif = new ImageIcon(urlup, "Up");        urlupc = LayersPanel.class.getResource("Up.gif");        upclickedgif = new ImageIcon(urlupc, "Up (clicked)");        urltop = LayersPanel.class.getResource("DoubleUp.gif");        topgif = new ImageIcon(urltop, "Top");        urltopc = LayersPanel.class.getResource("DoubleUp.gif");        topclickedgif = new ImageIcon(urltopc, "Top (clicked)");        urldown = LayersPanel.class.getResource("Down.gif");        downgif = new ImageIcon(urldown, "Down");        urldownc = LayersPanel.class.getResource("Down.gif");        downclickedgif = new ImageIcon(urldownc, "Down (clicked)");        urlbottom = LayersPanel.class.getResource("DoubleDown.gif");        bottomgif = new ImageIcon(urlbottom, "Bottom");        urlbottomc = LayersPanel.class.getResource("DoubleDown.gif");        bottomclickedgif = new ImageIcon(urlbottomc, "Bottom (clicked)");        urldelete = LayersPanel.class.getResource("DeleteLayer.gif");        deletegif = new ImageIcon(urldelete, "Delete");        urldeletec = LayersPanel.class.getResource("DeleteLayer.gif");        deleteclickedgif = new ImageIcon(urldeletec, "Delete (clicked)");        urladd = LayersPanel.class.getResource("AddLayer.gif");        addgif = new ImageIcon(urladd, "Add");        urladdc = LayersPanel.class.getResource("AddLayer.gif");        addclickedgif = new ImageIcon(urladdc, "Add (clicked)");    }    protected JButton add = null;    protected JButton delete = null;    protected JButton top = null;    protected JButton up = null;    protected JButton down = null;    protected JButton bottom = null;    protected LayerAddPanel layerAddPanel;    public final static String OrientationProperty = "orientation";    public final static String ConfigurationProperty = "configuration";    public final static String EmbeddedProperty = "embedded";    public final static String DeleteLayersProperty = "delete";    public final static String AddLayersProperty = "add";    public final static String HORIZONTAL_CONFIG = OrientationPropertyEditor.HORIZONTAL;    public final static String VERTICAL_CONFIG = OrientationPropertyEditor.VERTICAL;    public final static String WEST_CONFIG = "WEST";    public final static String EAST_CONFIG = "EAST";    public final static String NORTH_CONFIG = "NORTH";    public final static String SOUTH_CONFIG = "SOUTH";    public final static String NORTH_SOUTH_CONFIG = "NORTH_SOUTH";    public final static String DefaultConfiguration = WEST_CONFIG;    protected int orientation = BoxLayout.Y_AXIS; // BoxLayout.X_AXIS    protected String configuration = DefaultConfiguration;    protected boolean embedded = true;    protected boolean deleteLayers = true;    protected boolean addLayers = true;    public LayerControlButtonPanel() {        super();        createInterface();    }    public LayerControlButtonPanel(LayersPanel panel) {        this();        setLayersPanel(panel);    }    public void removeLayersPanel(LayersPanel panel) {        if (panel != null) {            panel.setControls(null);            panel.removePropertyChangeListener(this);            removePropertyChangeListener(panel);            if (embedded) {                if (configuration.equalsIgnoreCase(NORTH_SOUTH_CONFIG)) {                    panel.remove(up);                    panel.remove(down);                } else {                    panel.remove(this);                }            }        }    }    /**     * Sets this panel to control the LayersPanel. If you want to     * extend this class and change how the buttons are displayed in     * the LayersPanel, change this method.     */    public void setLayersPanel(LayersPanel panel) {        if (panel != null) {            // Just in case it's already been added.            panel.removePropertyChangeListener(this);            panel.addPropertyChangeListener(this);            addPropertyChangeListener(panel);            if (embedded) {                createInterface(); // again, reset for new config                // values                setLayout(new BoxLayout(this, orientation));                if (panel.getLayout() instanceof BorderLayout) {                    if (configuration.equalsIgnoreCase(WEST_CONFIG)) {                        panel.add(this, BorderLayout.WEST);                    } else if (configuration.equalsIgnoreCase(EAST_CONFIG)) {                        panel.add(this, BorderLayout.EAST);                    } else if (configuration.equalsIgnoreCase(NORTH_CONFIG)) {                        panel.add(this, BorderLayout.NORTH);                    } else if (configuration.equalsIgnoreCase(SOUTH_CONFIG)) {                        panel.add(this, BorderLayout.SOUTH);                    } else if (configuration.equalsIgnoreCase(NORTH_SOUTH_CONFIG)) {                        panel.add(up, BorderLayout.NORTH);                        panel.add(down, BorderLayout.SOUTH);                    }                } else {                    panel.add(this);                }            }            // Let the LayersPanel know who is controlling it.            //panel.setControls(this);        }    }    protected void createInterface() {        removeAll();        setAlignmentX(LEFT_ALIGNMENT);        setAlignmentY(CENTER_ALIGNMENT);        setLayout(new BoxLayout(this, orientation));        top = new JButton(topgif);        top.setActionCommand(LayersPanel.LayerTopCmd);        top.setPressedIcon(topclickedgif);        top.setToolTipText(i18n.get(LayerControlButtonPanel.class,                "moveLayerToTop",                "Move selected layer to top"));

⌨️ 快捷键说明

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