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

📄 mapexplorer.java

📁 java调用ie浏览器demo源码,可以用在windows或者linux
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * Copyright (C) 2008 Sun Microsystems, Inc. All rights reserved. Use is
 * subject to license terms.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA.
 */

import org.jdic.web.BrMap;
import org.jdic.web.BrMapSprite;
import org.jdic.web.BrMapBalloonSprite;

import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.imageio.ImageIO;
import javax.print.*;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.JobName;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import java.awt.*;
import java.awt.print.Printable;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.awt.geom.Point2D;
import java.awt.image.RenderedImage;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStreamReader;
import java.io.FileWriter;
import org.jdic.web.BrMapMousePos;


/**
 * Sample map explorer implementation.
 * @author  uta
 */
public class MapExplorer extends javax.swing.JFrame
{
    MapExplorer() {
        BrMap.DESIGN_MODE = false;
        initComponents();

        progressBar.setVisible(false);

        //look and fill group
	javax.swing.ButtonGroup group = new javax.swing.ButtonGroup();

	final UIManager.LookAndFeelInfo[] LFs = UIManager.getInstalledLookAndFeels();
	for(int i = 0; i < LFs.length; i++) {
            JRadioButtonMenuItem lfsMenuItem = (JRadioButtonMenuItem)viewMenu.add(
                    new JRadioButtonMenuItem(LFs[i].getName()));
            group.add(lfsMenuItem);
            lfsMenuItem.setSelected(UIManager.getLookAndFeel().getName().equals(LFs[i].getName()));
            lfsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1 + i, ActionEvent.ALT_MASK));
            lfsMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    JRadioButtonMenuItem rb = (JRadioButtonMenuItem) evt.getSource();
                    if(rb.isSelected() ){
                        for(int j = 0; j < LFs.length; j++) {
                            if (rb.getText().equals(LFs[j].getName())) {
                                try {
                                    UIManager.setLookAndFeel(LFs[j].getClassName());
                                    SwingUtilities.updateComponentTreeUI(MapExplorer.this);
                                } catch (Exception ex) {
                                    rb.setEnabled(false);
                                }
                            }
                        }
                    }
                }
            });
	}
        setBounds(-1, -1, 800, 600);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        statusPanel = new javax.swing.JPanel();
        edLng = new javax.swing.JTextField();
        lbLat = new javax.swing.JLabel();
        edLat = new javax.swing.JTextField();
        lbLng = new javax.swing.JLabel();
        cbGrid = new javax.swing.JCheckBox();
        edScale = new javax.swing.JTextField();
        lbMeter = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        cbInGrade = new javax.swing.JCheckBox();
        tbArea = new javax.swing.JToolBar();
        cbSelectWorkingArea = new javax.swing.JToggleButton();
        btResetSelection = new javax.swing.JButton();
        tbMetro = new javax.swing.JToggleButton();
        tbComposite = new javax.swing.JToggleButton();
        lbAddress = new javax.swing.JLabel();
        edAddress = new javax.swing.JTextField();
        bnGo = new javax.swing.JButton();
        pnCentral = new javax.swing.JPanel();
        brMap = new MapClipper();
        mainJMenuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        miOpen = new javax.swing.JMenuItem();
        miSave = new javax.swing.JMenuItem();
        miOZIExport = new javax.swing.JMenuItem();
        miPrint = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JSeparator();
        miExit = new javax.swing.JMenuItem();
        viewMenu = new javax.swing.JMenu();
        toolsMenu = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Map Clipper");
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/images/icon.png")).getImage());
        setName("mainFrame"); // NOI18N

        jPanel2.setLayout(new java.awt.BorderLayout(2, 2));

        statusPanel.setRequestFocusEnabled(false);

        lbLat.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lbLat.setText("Latitude:");
        lbLat.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

        lbLng.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lbLng.setText("Longitude:");

        cbGrid.setText("Grid:");
        cbGrid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbGridActionPerformed(evt);
            }
        });

        edScale.setText("10000");

        lbMeter.setText("m");

        cbInGrade.setSelected(true);
        cbInGrade.setText("gg°mm'ss\"");
        cbInGrade.setFocusable(false);
        cbInGrade.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        cbInGrade.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        cbInGrade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbInGradeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(lbLat, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(edLat, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbLng, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(edLng, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbInGrade)
                .addGap(24, 24, 24)
                .addComponent(cbGrid)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(edScale, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbMeter, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lbLat, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(edLat, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(lbLng, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(edLng, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(cbInGrade, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(cbGrid, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(edScale, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(lbMeter, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
            .addComponent(progressBar, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel2.add(statusPanel, java.awt.BorderLayout.PAGE_END);

        tbArea.setRollover(true);
        tbArea.setMaximumSize(new java.awt.Dimension(506, 27));
        tbArea.setMinimumSize(new java.awt.Dimension(0, 0));
        tbArea.setName("Map Working Area Setup"); // NOI18N

        cbSelectWorkingArea.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/sel_zoom.png"))); // NOI18N
        cbSelectWorkingArea.setFocusable(false);
        cbSelectWorkingArea.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cbSelectWorkingArea.setMargin(new java.awt.Insets(0, 0, 0, 0));
        cbSelectWorkingArea.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/images/sel_area.png"))); // NOI18N
        cbSelectWorkingArea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbSelectWorkingAreaActionPerformed(evt);
            }
        });
        tbArea.add(cbSelectWorkingArea);

        btResetSelection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/sel_auto.png"))); // NOI18N
        btResetSelection.setEnabled(false);
        btResetSelection.setFocusable(false);
        btResetSelection.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btResetSelection.setMargin(new java.awt.Insets(0, 0, 0, 0));
        btResetSelection.setMaximumSize(null);
        btResetSelection.setMinimumSize(null);
        btResetSelection.setPreferredSize(null);
        btResetSelection.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btResetSelection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btResetSelectionActionPerformed(evt);
            }
        });
        tbArea.add(btResetSelection);

        tbMetro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/metro.png"))); // NOI18N
        tbMetro.setFocusable(false);
        tbMetro.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        tbMetro.setMargin(new java.awt.Insets(0, 0, 0, 0));
        tbMetro.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbMetro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbMetroActionPerformed(evt);
            }
        });
        tbArea.add(tbMetro);

        tbComposite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/mapover.png"))); // NOI18N
        tbComposite.setFocusable(false);
        tbComposite.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        tbComposite.setMargin(new java.awt.Insets(0, 0, 0, 0));
        tbComposite.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tbComposite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbCompositeActionPerformed(evt);
            }
        });
        tbArea.add(tbComposite);

        lbAddress.setText(" Location:");
        tbArea.add(lbAddress);

        edAddress.setText("Greenwich");
        edAddress.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                edAddressMouseClicked(evt);
            }
        });
        edAddress.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edAddressActionPerformed(evt);
            }
        });
        edAddress.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                edAddressKeyTyped(evt);
            }
            public void keyPressed(java.awt.event.KeyEvent evt) {
                edAddressKeyPressed(evt);
            }
        });
        tbArea.add(edAddress);

        bnGo.setText("Go");
        bnGo.setFocusable(false);
        bnGo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bnGo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bnGo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bnGoActionPerformed(evt);
            }
        });
        tbArea.add(bnGo);

        jPanel2.add(tbArea, java.awt.BorderLayout.PAGE_START);

        pnCentral.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                pnCentralComponentResized(evt);
            }
        });

⌨️ 快捷键说明

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