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

📄 e00layer.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/e00/E00Layer.java,v $// $RCSfile: E00Layer.java,v $// $Revision: 1.4.2.3 $// $Date: 2005/08/09 18:10:45 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.e00;import java.awt.Color;import java.awt.Component;import java.awt.Container;import java.awt.Font;import java.awt.Frame;import java.awt.Paint;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.PrintStream;import java.util.Properties;import java.util.Vector;import javax.swing.AbstractButton;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JSeparator;import javax.swing.JTextField;import com.bbn.openmap.event.SelectMouseMode;import com.bbn.openmap.layer.OMGraphicHandlerLayer;import com.bbn.openmap.layer.location.BasicLocation;import com.bbn.openmap.omGraphics.OMGraphic;import com.bbn.openmap.omGraphics.OMGraphicList;import com.bbn.openmap.omGraphics.OMPoly;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PaletteHelper;import com.bbn.openmap.util.PropUtils;/** * Description of the Class an Layer showing data from an .e00 file * data is extracted with E00Parser class possibilities to filter arcs * according to their types or value. * <P> *  * Examples of properties for OpenMap: * <P> *  * <pre> *  *   *    *     *      *       *        *         *         ### E00 layer *         e00.class=com.bbn.openmap.layer.e00.E00Layer *         e00.prettyName=E00 file *         e00.FileName=data/france/hynet.e00 *         ### E00 layer *         es00.class=E00.E00Layer *         es00.prettyName=ES00 file *         es00.FileName=data/france/rdline.e00 *         es00.ArcColors= FF0000FF,FFEE5F3C,FFFFCC00,FF339700,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FF666666,FFFFFFFF *         es00.ArcVisible=true *         es00.LabVisible=false *         es00.Tx7Visible=true *         es00.LabFont =Arial 10 ITALIC BOLD *         ###other properties Tx7Color LabColors SelectTx7Color SelectLabColor SelectArcColor LabTextColor Tx7Font *           *         *        *       *      *     *    *   * </pre> *  * @since OpenMap 4.5.5 * @author Thomas Paricaud */public class E00Layer extends OMGraphicHandlerLayer implements ActionListener {    protected OMGraphicList arcs;    protected OMGraphicList labs;    protected OMGraphicList tx7;    protected boolean ArcVisible = true;    protected boolean LabVisible = true;    protected boolean Tx7Visible = true;    protected JPanel gui;    protected JLabel label;    protected Paint[] ArcColors, LabColors;    protected Paint Tx7Color;    protected Paint SelectTx7Color;    protected Paint SelectLabColor;    protected Paint SelectArcColor;    protected Paint LabTextColor;    protected OMGraphic LabMarker;    protected Font LabFont, Tx7Font;    protected int filtreValeur = Integer.MIN_VALUE;    protected int filtreType = Integer.MIN_VALUE;    protected JFileChooser fileChooser;    protected File E00File;    public E00Layer() {        super();        setMouseModeIDsForEvents(new String[] { SelectMouseMode.modeID });    }    /**     * OMGraphicHandlerLayer method, get the OMGraphics from the data     * in the file.     */    public OMGraphicList prepare() {        OMGraphicList g = getList();        if (g == null) {            try {                E00Parser parser = new E00Parser(E00File);                parser.setPaints(ArcColors,                        LabColors,                        Tx7Color,                        SelectTx7Color,                        SelectLabColor,                        SelectArcColor,                        LabTextColor);                parser.setLabMarker(LabMarker);                parser.setFonts(LabFont, Tx7Font);                g = parser.getOMGraphics();                arcs = parser.getArcList();                labs = parser.getLabList();                tx7 = parser.getTx7List();                setListVisibility();            } catch (Exception ex) {                ex.printStackTrace(System.out);                Debug.error("E00Layer|" + getName() + ".prepare(): "                        + ex.getMessage());            }        }        Projection proj = getProjection();        if (proj != null && g != null) {            g.generate(proj);        }        return g;    }    /**     * Sets the properties for the <code>Layer</code>. This allows     * <code>Layer</code> s to get a richer set of parameters than     * the <code>setArgs</code> method.     *      * @param prefix the token to prefix the property names     * @param props the <code>Properties</code> object     * @since     */    public void setProperties(String prefix, java.util.Properties props) {        super.setProperties(prefix, props);        String E00FileName = props.getProperty(prefix + ".FileName");        ArcVisible = PropUtils.booleanFromProperties(props, prefix                + ".ArcVisible", ArcVisible);        LabVisible = PropUtils.booleanFromProperties(props, prefix                + ".LabVisible", LabVisible);        Tx7Visible = PropUtils.booleanFromProperties(props, prefix                + ".Tx7Visible", Tx7Visible);        Paint dfault = null;        ArcColors = parseColors(props, prefix, "ArcColors", Color.black);        LabColors = parseColors(props, prefix, "LabColors", Color.black);        Tx7Color = parseColor(props, prefix, "Tx7Color", dfault);        SelectTx7Color = parseColor(props, prefix, "SelectTx7Color", null);        SelectLabColor = parseColor(props, prefix, "SelectLabColor", null);        SelectArcColor = parseColor(props, prefix, "SelectArcColor", null);        LabTextColor = parseColor(props, prefix, "LabTextColor", null);        LabFont = parseFont(props, prefix, "LabFont", null);        Tx7Font = parseFont(props, prefix, "tx7Font", null);        try {            openFile(new File(E00FileName));        } catch (Exception ex) {            Debug.error("E00Layer: error - " + ex.getMessage());            if (Debug.debugging("e00")) {                ex.printStackTrace();            }        }    }    /**     * Gets the GUI attribute of the E00Layer object     *      * @return The GUI value     * @since     */    public Component getGUI() {        if (gui == null) {            gui = PaletteHelper.createPaletteJPanel("E00");            label = new JLabel((E00File != null) ? E00File.getName()                    : "       ");            gui.add(label);            addToGUI(gui, new JCheckBox("Arcs", ArcVisible), "ARCS");            addToGUI(gui, new JCheckBox("Points", LabVisible), "LABS");            addToGUI(gui, new JCheckBox("Tx7", Tx7Visible), "TX7");            gui.add(new JLabel("Filter"));            gui.add(new JLabel(" By Value"));            addToGUI(gui, new JTextField(10), "VALEUR");            gui.add(new JLabel(" By Type"));            addToGUI(gui, new JTextField(10), "TYPE");            gui.add(new JSeparator());            addToGUI(gui, new JButton("Open File"), "OPEN");            addToGUI(gui, new JButton("Export Arcs"), "ExpArcs");            addToGUI(gui, new JButton("Export Points"), "ExpPoints");        }        return gui;    }    /**     * Adds a feature to the GUI attribute of the E00Layer object     *      * @param b The feature to be added to the GUI attribute     * @param cmd The feature to be added to the GUI attribute     * @since     */    protected void addToGUI(JPanel gui, AbstractButton b, String cmd) {        b.setActionCommand(cmd);        b.addActionListener(this);        gui.add(b);    }    /**     * Adds a feature to the Gui attribute of the E00Layer object     *      * @param b The feature to be added to the Gui attribute     * @param cmd The feature to be added to the Gui attribute     * @since     */    protected void addToGUI(JPanel gui, JTextField b, String cmd) {        b.setActionCommand(cmd);        b.addActionListener(this);        gui.add(b);    }    /**     * Description of the Method     *      * @param e Description of Parameter     * @since     */    public void actionPerformed(ActionEvent e) {        String Action = e.getActionCommand();        if ("OPEN".equals(Action)) {            openFile(chooseFile(0));            doPrepare();        } else if ("ExpArcs".equals(Action)) {            exportArcs1();        } else if ("ExpPoints".equals(Action)) {            exportPoints();        } else if ("VALEUR".equals(Action)) {            filtreValeur = getVal(e);            filtre();        } else if ("TYPE".equals(Action)) {            filtreType = getVal(e);            filtre();        } else if ("ARCS".equals(Action)) {            JCheckBox cb = (JCheckBox) e.getSource();            ArcVisible = cb.isSelected();            if (arcs != null)                arcs.setVisible(ArcVisible);            repaint();        } else if ("LABS".equals(Action)) {            JCheckBox cb = (JCheckBox) e.getSource();            LabVisible = cb.isSelected();            if (labs != null)                labs.setVisible(LabVisible);            repaint();        } else if ("TX7".equals(Action)) {            JCheckBox cb = (JCheckBox) e.getSource();            Tx7Visible = cb.isSelected();            if (tx7 != null)                tx7.setVisible(Tx7Visible);            repaint();        }    }    public String getInfoText(OMGraphic omg) {        String t = "";        if (arcs != null && arcs.contains(omg)) {            t = "arcs";        } else if (labs != null && labs.contains(omg)) {            t = "point";        }        E00Data d = (E00Data) omg.getAppObject();        return t + d;    }    /**     * Gets the Frame attribute of the E00Layer object     *      * @return The Frame value     * @since     */    protected Frame getFrame() {        if (gui == null) {            return null;        }        for (Container p = gui.getParent(); p != null; p = p.getParent()) {            if (p instanceof Frame) {                return (Frame) p;            }        }        return null;    }    /**     * Sets the LineColor attribute of the E00Layer object     *      * @param C The new LineColor value     * @since     */    void setLineColor(Color C) {        OMGraphicList graphics = getList();        if (graphics != null) {            graphics.setLinePaint(C);        }        repaint();    }    /**     * Gets the Val attribute of the E00Layer object     *      * @param e Description of Parameter     * @return The Val value     * @since     */    int getVal(ActionEvent e) {        int val;        JTextField T = (JTextField) e.getSource();        try {            val = Integer.parseInt(T.getText());        } catch (NumberFormatException ex) {            val = Integer.MIN_VALUE;        }        return val;    }    public void setListVisibility() {        if (arcs != null) {            arcs.setVisible(ArcVisible);        }        if (labs != null) {            labs.setVisible(LabVisible);        }        if (tx7 != null) {            tx7.setVisible(Tx7Visible);        }    }    /**     * Description of the Method     *      * @param f Description of Parameter     * @since     */    protected void openFile(File f) {        if (f == null) {            return;        }        if (!f.exists()) {            Debug.output("E00|" + getName() + ": missing file");            return;        }        E00File = f;

⌨️ 快捷键说明

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