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

📄 vpfconfig.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/layer/vpf/VPFConfig.java,v $// $RCSfile: VPFConfig.java,v $// $Revision: 1.7.2.4 $// $Date: 2005/08/09 21:17:53 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.vpf;import java.awt.Component;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.util.Enumeration;import java.util.HashSet;import java.util.Hashtable;import java.util.Iterator;import java.util.LinkedList;import java.util.Properties;import javax.swing.JButton;import javax.swing.JComponent;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.JTree;import javax.swing.event.TreeSelectionEvent;import javax.swing.event.TreeSelectionListener;import javax.swing.tree.DefaultMutableTreeNode;import javax.swing.tree.TreeSelectionModel;import com.bbn.openmap.Layer;import com.bbn.openmap.LayerHandler;import com.bbn.openmap.io.FormatException;import com.bbn.openmap.omGraphics.DrawingAttributes;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PaletteHelper;import com.bbn.openmap.util.PropUtils;/** * A component that can look at the VPF configuration files at the top * level of the VPF directory structure, and provide an interface for * defining an OpenMap VPFLayer for chosen features. * <p> *  * If the VPFConfig is provided a LayerHandler, it will have a button * that will create a layer with selected features. If it doesn't have * a LayerHandler, it will provide a button to print out the * properties for a VPFLayer for the selected features. This class can * be run in stand-alone mode to create properties. */public class VPFConfig extends JPanel implements ActionListener {    //private static boolean DEBUG = false;    //Optionally play with line styles. Possible values are    //"Angled", "Horizontal", and "None" (the default).    private boolean playWithLineStyle = false;    private String lineStyle = "Angled";    protected boolean showAll = false;    protected boolean standAlone = false;    public final static String AddFeatureCmd = "AddFeatureCommand";    public final static String ClearFeaturesCmd = "ClearFeaturesCommand";    public final static String CreateLayerCmd = "CreateLayerCommand";    public final static String EMPTY_FEATURE_LIST = null;    DefaultMutableTreeNode currentFeature = null;    protected DrawingAttributes drawingAttributes = new DrawingAttributes();    protected boolean searchByFeature = true;    protected String paths = "";    protected HashSet layerCoverageTypes = new HashSet();    protected HashSet layerFeatureTypes = new HashSet();    public final static String AREA = "area";    public final static String TEXT = "text";    public final static String EDGE = "edge";    public final static String POINT = "point";    public final static String CPOINT = "cpoint";    public final static String EPOINT = "epoint";    public final static String COMPLEX = "complex";    public final static String UNKNOWN = "unknown";    protected Hashtable layerFeatures;    protected Properties layerProperties;    protected LayerHandler layerHandler;    protected LibraryBean libraryBean;    protected String layerName;    protected VPFLayer layer;    JButton addFeatureButton;    JButton clearFeaturesButton;    JButton createLayerButton;    JTextArea currentFeatureList;    JTextField nameField;    LinkedList featureList = new LinkedList();    public VPFConfig(String[] dataPaths, String layerName) {        this(dataPaths, null, layerName);    }    public VPFConfig(String[] dataPaths, LayerHandler layerHandler,            String layerName) {        this(dataPaths, layerHandler, layerName, false);    }    protected VPFConfig(String[] dataPaths, LayerHandler layerHandler,            String layerName, boolean standAlone) {        this.layerHandler = layerHandler;        this.standAlone = standAlone;        this.layerName = layerName;        if (dataPaths != null && dataPaths.length > 0) {            // Take the time to replace any \ with /, it matters if            // the properties get printed out for later.            // Permanently set them from \ to / for when they get            // passed to BinaryFile.            dataPaths[0] = dataPaths[0].replace('\\', '/');            StringBuffer buf = new StringBuffer(dataPaths[0]);            for (int i = 1; i < dataPaths.length; i++) {                buf.append(";");                // Permanently set them from \ to / for when they get                // passed to BinaryFile.                dataPaths[i] = dataPaths[i].replace('\\', '/');                buf.append(dataPaths[i]);            }            paths = buf.toString();        }        //Create the nodes.        DefaultMutableTreeNode top = new DefaultMutableTreeNode("VPF Data Libraries");        try {            createNodes(top, dataPaths);        } catch (FormatException fe) {            Debug.output("Caught FormatException reading data: "                    + fe.getMessage());            if (standAlone) {                System.exit(0);            }        }        init(top);    }    public VPFConfig(LibraryBean lb, LayerHandler layerHandler, String layerName) {        this.layerHandler = layerHandler;        this.layerName = layerName;        //Create the nodes.        DefaultMutableTreeNode top = new DefaultMutableTreeNode("VPF Data Libraries");        try {            createNodes(top, lb.getLibrarySelectionTable());        } catch (FormatException fe) {            Debug.output("Caught FormatException reading data: "                    + fe.getMessage());        }        init(top);    }    public VPFConfig(VPFLayer layer) {        if (layer != null && layer.lst != null) {            this.layer = layer;            this.layerName = layer.getName();            //Create the nodes.            DefaultMutableTreeNode top = new DefaultMutableTreeNode("VPF Data Libraries");            try {                createNodes(top, layer.lst);            } catch (FormatException fe) {                Debug.output("Caught FormatException reading data: "                        + fe.getMessage());            }            init(top);        }    }    public void init(DefaultMutableTreeNode top) {        layerFeatures = new Hashtable();        //Create a tree that allows one selection at a time.        final JTree tree = new JTree(top);        tree.getSelectionModel()                .setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);        tree.setVisibleRowCount(10);        //Listen for when the selection changes.        tree.addTreeSelectionListener(new TreeSelectionListener() {            public void valueChanged(TreeSelectionEvent e) {                DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();                if (node == null)                    return;                Object nodeInfo = node.getUserObject();                if (node.isLeaf() && nodeInfo instanceof FeatureInfo) {                    currentFeature = node;                    // enable addToLayer button here.                    addFeatureButton.setEnabled(true);                } else {                    // disable addToLayer button here.                    addFeatureButton.setEnabled(false);                }            }        });        if (playWithLineStyle) {            tree.putClientProperty("JTree.lineStyle", lineStyle);        }        //Create the scroll pane and add the tree to it.        GridBagLayout outergridbag = new GridBagLayout();        GridBagConstraints outerc = new GridBagConstraints();        JScrollPane treeView = new JScrollPane(tree);        setLayout(outergridbag);        outerc.fill = GridBagConstraints.BOTH;        outerc.anchor = GridBagConstraints.WEST;        outerc.insets = new Insets(10, 10, 10, 10);        outerc.gridx = GridBagConstraints.REMAINDER;        outerc.weighty = .75;        outerc.weightx = 1.0;        outergridbag.setConstraints(treeView, outerc);        add(treeView);        // Create the configuration pane        JPanel configPanel = new JPanel();        GridBagLayout gridbag = new GridBagLayout();        GridBagConstraints c = new GridBagConstraints();        configPanel.setLayout(gridbag);        c.gridheight = GridBagConstraints.REMAINDER;        Component da = drawingAttributes.getGUI();        gridbag.setConstraints(da, c);        configPanel.add(da);        c.gridx = 1;        c.gridheight = 1;        c.gridy = 0;        c.fill = GridBagConstraints.HORIZONTAL;        c.insets = new Insets(0, 5, 0, 5);        addFeatureButton = new JButton("Add Feature");        addFeatureButton.addActionListener(this);        addFeatureButton.setActionCommand(AddFeatureCmd);        gridbag.setConstraints(addFeatureButton, c);        configPanel.add(addFeatureButton);        addFeatureButton.setEnabled(false);        clearFeaturesButton = new JButton("Clear Features");        clearFeaturesButton.addActionListener(this);        clearFeaturesButton.setActionCommand(ClearFeaturesCmd);        c.gridy = GridBagConstraints.RELATIVE;        gridbag.setConstraints(clearFeaturesButton, c);        configPanel.add(clearFeaturesButton);        clearFeaturesButton.setEnabled(false);        if (layer != null) {            createLayerButton = new JButton("Set Features on Layer");        } else if (layerHandler != null) {            createLayerButton = new JButton("Create Layer");        } else {            createLayerButton = new JButton("Print Properties");        }        createLayerButton.addActionListener(this);        createLayerButton.setActionCommand(CreateLayerCmd);        gridbag.setConstraints(createLayerButton, c);        configPanel.add(createLayerButton);        createLayerButton.setEnabled(false);        JPanel currentFeatureListPanel = PaletteHelper.createVerticalPanel(" Current Features: ");        currentFeatureList = new JTextArea(EMPTY_FEATURE_LIST);        currentFeatureList.setEditable(false);        JScrollPane featureListScrollPane = new JScrollPane(currentFeatureList);        featureListScrollPane.setPreferredSize(new Dimension(150, 10));        currentFeatureListPanel.add(featureListScrollPane);        c.gridx = 2;        c.gridy = 0;        c.weightx = 1.0;        c.anchor = GridBagConstraints.NORTHWEST;        c.gridheight = GridBagConstraints.REMAINDER;        c.fill = GridBagConstraints.BOTH;        gridbag.setConstraints(currentFeatureListPanel, c);        configPanel.add(currentFeatureListPanel);        GridBagLayout gridbag2 = new GridBagLayout();        GridBagConstraints c2 = new GridBagConstraints();        JPanel namePanel = new JPanel();        namePanel.setLayout(gridbag2);        c2.weightx = 0;        c2.weighty = 0;        c2.anchor = GridBagConstraints.WEST;        JLabel nameLabel = new JLabel("Layer Name: ");        gridbag2.setConstraints(nameLabel, c2);        namePanel.add(nameLabel);        c2.fill = GridBagConstraints.HORIZONTAL;        c2.weightx = 1.0;        c2.weighty = 1.0;        nameField = new JTextField(layerName);        gridbag2.setConstraints(nameField, c2);        namePanel.add(nameField);        outerc.anchor = GridBagConstraints.WEST;        outerc.weighty = 0;        outergridbag.setConstraints(namePanel, outerc);        add(namePanel);        outerc.fill = GridBagConstraints.HORIZONTAL;        outerc.weighty = .25;        outerc.anchor = GridBagConstraints.CENTER;

⌨️ 快捷键说明

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