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

📄 mapperclientapplet.java

📁 实现网络GPS定位车辆的位置
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package MapperClientApplet;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

import java.net.*;
import java.io.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
import java.lang.*;
import java.applet.AudioClip;
import java.text.DecimalFormat;
import java.text.*;

import java.util.Date;


import javax.swing.table.*;


import com.mapinfo.util.DoublePoint;

public class MapperClientApplet extends Applet {
  boolean isStandalone = false;
  /********************add*********************************/
    String info="";
//    private static String m_servletName ="http://211.101.210.166:8080/samples45/servlet/mapper";
    private static String m_servletName ="http://219.237.4.34:8080/samples47/servlet/mapper";

    public String m_sessionURL;

    // Tools
    public String m_tool="0";

    public final String NO_TOOL = "0";
    public final String ZOOM_IN_TOOL = "1";
    public final String ZOOM_OUT_TOOL = "2";
    public final String PAN_TOOL = "3";
    public final String Telephone_tool="4";
    public final String FIND_TOOL = "5";
    public final String TRACE_TOOL = "6";
    public final String SETSIZE = "7";
    public final String INITCAR_TOOL = "8";
    public final String CENTER_TOOL = "9";
    public final String RULER_TOOL = "10";
    public final String KILLCAR_TOOL="11";
    public final String Clear_Operat_TOOL="12";
    public final String FindAlarm_TOOL="13";
    public final String Border_TOOL="14";
    public final String No_Border_TOOL="15";
    public final String RESET_TOOL="18";
    public final String StopAlarm_TOOL="19";
    private boolean m_isStandalone = false;
    private Button m_zoomIn = new Button();
    private Button m_zoomOut = new Button();
    private Button m_StopAlarm = new Button();
    private Button m_pan = new Button();

    private Button m_telephone = new Button();
    private Button m_point = new Button();
    private Button m_trace = new Button();
    public  MCanvas m_map = new MCanvas();
    private java.awt.List list1 = new java.awt.List();
    TextField textField1 = new TextField();
    public JLabel lCarStatus = new JLabel();
    private Label lLayNameList = new Label();


    private Choice ListBeginYear = new Choice();
    private Choice ListBeginMonth = new Choice();
    private Choice ListBeginDay  = new Choice();
    private Choice ListBeginHour = new Choice();
    private Choice ListBeginMinute  = new Choice();

    private Choice ListEndYear = new Choice();
    private Choice ListEndMonth = new Choice();
    private Choice ListEndDay  = new Choice();
    private Choice ListEndHour = new Choice();
    private Choice ListEndMinute  = new Choice();
    public static String m_cardid;


    private Choice ListCarInfomation = new Choice();
    //public JTable jTable = new JTable();
    public JScrollPane jScrollPaneRight = new JScrollPane();
    public Connection dbCon;
    public Statement  sqlStatement;
    public AudioClip bgmusic,speak;
    public boolean TraceFlag=true;
    public Thread TraceThread;
    public Thread FindAlarmThread;
    //the car infomation
//    public String m_CarTel="";
    public String m_SIMNum="";
    public String m_CarNum="";
    public String m_OwerName="";
    public String m_username;
    public String user_cardid;
    public String  m_carlicence;
    public  String CarPlate;
    public String StopAlarm_tel;
    public String user_SIMNum;
    public String O_CarPlate;
    public PropertyEditor jTable = new PropertyEditor();
    int MapPicWidth=500;   //装载时重新赋值
    int MapPicHeigth=416;
    public double dDistance=0;
    public String companyName = "";//公司名称
    public String companyid="";
    public int Ismanager;
    public String m_CarPlate="";


    public int RowID=0;
    public DlgFindAlarm m_DlgFindAlarm;

   // public int tel;  //发信息给车辆用到的电话号码

    /////////////////////////////////
    URL mapServer = null;
    BufferedReader in = null;


    //////////////////////////////////

  //JTable jdbTable1 = new JTable();  //装载时重新赋值
  //点坐标
  int xUp,yUp;
  int xDown,yDown;
  int xTemp,yTemp;
  int PointCount;
  boolean DrawLine;

  /////////////////////////
  //轨迹回放后清除时用的坐标点

  public String mym_x;
  public String mym_y;

  ////////////////////////
  int xOra,yOra;

  boolean blnClear;

  //////////////////////
  public DefaultTableModel tableModel=new DefaultTableModel();
  public DialogAlam m_DialogAlam = new DialogAlam();

  //Get a parameter value
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
  }

  public MapperClientApplet() {
  }
  //Initialize the applet
  public void init()
  {
    //连接GPS服务器
    //conn();
     // servlet to call
    String strParm ="http://219.237.4.34:8080/samples47/servlet/mapper";

    ////////////////////////////////////////////////////////////////
    //报警
    ////////////////////////////////////////////////////////////////
    //bgmusic=getAudioClip(getCodeBase(),"alarm.au");//报警

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    int height = d.height;
    int width = d.width;
    int MapPicTop=53;
    int MapPicLeft=62;

    int MaxWidth=2000;
    int MinWidth=800;
    int MaxHeight=1500;
    int MinHeight=600;
    int PageWidth=800;     //装载时重新赋值
    int PageHeight=600;    //装载时重新赋值



    MapPicWidth= width-800+500;
        MapPicHeigth=height-600+416;
    if (strParm != null  &&  strParm.length() > 1) {
             m_servletName = strParm;
    }
    setBackground(null);
/*//////////////////////////////////////////////////////////////////////////////////////////////////
    放大
///////////////////////////////////////////////////////////////////////////////////////////////////*/
    m_zoomIn.setBounds(new Rectangle(10, 8, 50,25));
    m_zoomIn.setLabel("in");
    m_zoomIn.addMouseListener(new java.awt.event.MouseAdapter()
    {
             public void mouseClicked(MouseEvent e)
             {
                     //m_tool=ZOOM_IN_TOOL;
                     // m_map.setBounds(new Rectangle(5, 50, 600,200));
                     ZoomIn();

             }
    });

/*//////////////////////////////////////////////////////////////////////////////////////////////////
    缩小
///////////////////////////////////////////////////////////////////////////////////////////////////*/
    m_zoomOut.setBounds(new Rectangle(60, 8, 49,25));
    m_zoomOut.setLabel("Out");
    m_zoomOut.addMouseListener(new java.awt.event.MouseAdapter()
    {
             public void mouseClicked(MouseEvent e)
             {
                      //m_tool=Clear_Operat_TOOL;
                      ZoomOut();


             }
    });
/*///////////////////////////////////////////////////////////////////////////////////////////////////
//////// 漫游_暂时当呼车
///////////////////////////////////////////////////////////////////////////////////////////////////*/

    m_pan.setBounds(new Rectangle(110, 8, 49,25));
    m_pan.setLabel("Call");
    m_pan.addMouseListener(new java.awt.event.MouseAdapter()
    {
             public void mouseClicked(MouseEvent e)
             {
//                      m_tool=StopAlarm_TOOL;
                      CallCar();

             }
    });
/*//////////////////////////////////////////////////////////////////////////////////////////////////
    位置查询
///////////////////////////////////////////////////////////////////////////////////////////////////*/

    m_telephone.setBounds(new Rectangle(160, 8, 78,25));
    m_telephone.setLabel("车载电话");
    m_telephone.addMouseListener(new java.awt.event.MouseAdapter()
    {
             public void mouseClicked(MouseEvent e)
             {
                String tel=textField1.getText();
                String in_str="";
                tel.trim();
                //in_str="13693548440*D1359523955594511619611160023030603400000#";
                String url = m_sessionURL;
                m_tool=Telephone_tool;
                url += "?tool=" + m_tool;
                url += "&message=" + in_str;
                System.out.println(tel);
             }
    });

    textField1.setBounds(250, 8, 78,25);
    textField1.setBackground(Color.white);
/*//////////////////////////////////////////////////////////////////////////////////////////////////
// 停止报警
///////////////////////////////////////////////////////////////////////////////////////////////////*/
    m_StopAlarm.setBounds(new Rectangle(330, 38, 80,25));
    m_StopAlarm.setLabel("停止报警");
    m_StopAlarm.addMouseListener(new java.awt.event.MouseAdapter()
    {
             public void mouseClicked(MouseEvent e)
             {
                      bgmusic.stop();
             }
    });

/*//////////////////////////////////////////////////////////////////////////////////////////////////
    轨迹回放
///////////////////////////////////////////////////////////////////////////////////////////////////*/

    m_trace.setBounds(new Rectangle(330, 8, 78,25));
    m_trace.setLabel("轨迹回放");
    m_trace.addMouseListener(new java.awt.event.MouseAdapter()
    {
         public void mouseClicked(MouseEvent e)
         {
           String url = m_sessionURL;
           m_tool=TRACE_TOOL;
           url += "?tool=" + m_tool;
           String tel=textField1.getText();
           String m_BeginDateTime=ListBeginYear.getSelectedItem()+ListBeginMonth.getSelectedItem()+ListBeginDay.getSelectedItem()
                                  +ListBeginHour.getSelectedItem()+ListBeginMinute.getSelectedItem();
           String m_EndDateTime=ListEndYear.getSelectedItem()+ListEndMonth.getSelectedItem()+ListEndDay.getSelectedItem()
                                  +ListEndHour.getSelectedItem()+ListEndMinute.getSelectedItem();
           String Sql="0#select LONGITUDE,LATITUDE,SPEED,SENTTIME FROM SMSG_INFO where CardId =10000024 and TO_CHAR(SENTTIME,'YYYYMMDDHH24MI')>='200301010000' and TO_CHAR(SENTTIME,'YYYYMMDD HH24MI')<='200401010000' order by senttime";

           if(TraceFlag==true)
           {
             TraceThread=new tcpServerTraceThread(tel,Sql,lCarStatus,url,m_map);
             TraceThread.start();
             TraceFlag=false;
             m_trace.setLabel("停止回放");
           }
           else
           {
             //TraceThread.stop();
             TraceFlag=true;
             m_trace.setLabel("轨迹回放");
           }

         }
    });


/*//////////////////////////////////////////////////////////////////////////////////////////////////
    选择车辆
///////////////////////////////////////////////////////////////////////////////////////////////////*/

  jTable.addMouseListener(new java.awt.event.MouseAdapter()
  {
    public void mouseClicked(MouseEvent e)
    {
     //String temp=jdbTable.getColumnName(0);
     //int x=tableModel.getColumnCount();
     int y=jTable.getSelectedRow();
     CarPlate=(String)tableModel.getValueAt(y,1);
     System.out.println("this is the CarPlate from table: "+CarPlate);
     m_SIMNum=(String)tableModel.getValueAt(y,2);

     m_OwerName=(String)tableModel.getValueAt(y,0);
     String m_x=(String)tableModel.getValueAt(y,7);
     System.out.println("this is the M_x get from table "+m_x );
     String m_y=(String)tableModel.getValueAt(y,6);
     System.out.println("this is the M_y get from table "+m_y );
//     m_username=(String)tableModel.getValueAt(y,2);


     String url = m_sessionURL;
     m_tool=CENTER_TOOL;
     url += "?tool=" + m_tool+"&m_x=" + m_x + "&m_y=" + m_y;
     adjustMap(url);//居中车辆
     lCarStatus.setText("当前选择车辆:"+CarPlate+",要对车辆进行操作请点击相应按钮,请慎重,以免造成不必要损失!");

        }
       });

/*//////////////////////////////////////////////////////////////////////////////////////////////////
    地图MapTreame
///////////////////////////////////////////////////////////////////////////////////////////////////*/

        //m_map.setBounds(0,0,MapPicWidth,MapPicHeigth);
        m_map.setBounds(new Rectangle(0,0, MapPicWidth,MapPicHeigth-100));
        //System.out.println(MapPicWidth+":"+MapPicHeigth);
        m_map.setBackground(Color.gray);
        m_map.addMouseListener(new java.awt.event.MouseAdapter()
    {

⌨️ 快捷键说明

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