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

📄 framemain.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		// CreateFile cf = new CreateFile(new File("c:\\GPSStruct.txt"));
		// cf.setEncode("GB2312");
		// cf.memoryToFile(GarminGMLDoc.printStucture(GarminGMLDoc.d));

		// FrameSetXZC fs = new FrameSetXZC();
		// fs.show();
		// SubmitTableText stt = new SubmitTableText();
		// stt.test();
		// System.out.println(GarminGMLDoc.printStucture(GarminGMLDoc.d));
		// for(int i=0;i<GarminGMLDoc.id.size();i++){
		// System.out.println(GarminGMLDoc.id.get(i));
		// }
		// System.out.println("oldWaypointTopPos:"+ItemValue.oldWaypointTopPos);
		// System.out.println("waypointNum:"+ItemValue.waypointNum);
		// TestNode.getNodeTree(GarminGMLDoc.root, 0);
		// ItemValue.test();
		// ItemValue.testScr();
		/*
		 * FrameHelp fh = new FrameHelp();
		 * fh.setIconImage(ItemValue.getImage("HSDIlogo.gif"));
		 * fh.setTitle("帮助"); fh.setSize(500,550); fh.show();
		 */

	}

	void jMenuItem2_actionPerformed(ActionEvent e) {
		// Frame splashFrame = null;
		Splash.splash();

	}

	public synchronized void reset() {
		GarminGMLDoc.d = null;
		GarminGMLDoc.root = null;
		GarminGMLDoc.id = null;
		GarminGMLDoc.id = new Vector();
		ConsoleFrame.resetAll();
		this.jTree1.clear();
		// ItemValue.data = 0;
		ItemValue.deadThread = false;
		ItemValue.oldWaypointTopPos = 0;
		ItemValue.RecieveCount = 0;
		ItemValue.SendCount = 0;
		ItemValue.idLargest = 0;
		ItemValue.idLeast = 0;
		ItemValue.reset();
		// ItemValue.fileChoosePath = "";
		this.setTitle(ItemValue.SOFTWARE_NAME);
		setTracksReset();
		setWaypointReset();
	}

	void setTracksReset() {
		ItemValue.hasTrack = false;
		ItemValue.tracksNum = 0;
		ItemValue.waypointPre = false;
		this.jTextField1.setText("");
		this.jTextField2.setText("");
		this.jTextField3.setText("");
		this.jTextField4.setText("");
		this.jTextField5.setText("");
		this.jTextField13.setText("");
		this.jTextField14.setText("");
		jCB_Jishu.setSelectedItem("");
		this.df1.setDate(null);
		this.df2.setDate(null);
		this.df3.setDate(null);
		this.jP_Yanghu.setText("");
		this.jTextArea1.setText("");
		this.jTextArea2.setText("");
		this.jComboBox1.setSelectedItem("");
		this.jComboBox2.setSelectedItem("");
		this.jButton3.setEnabled(false);
		this.jButton4.setEnabled(false);
		this.jButton5.setEnabled(false);
		this.jButton13.setEnabled(false);
		this.jButton14.setEnabled(false);
		this.jButton16.setEnabled(false);
		this.jButton17.setEnabled(false);
		this.jButton18.setEnabled(false);
		this.jButton19.setEnabled(false);
		this.jLabel_licheng.setText("");
	}

	void setWaypointReset() {
		ItemValue.hasWaypoint = false;
		ItemValue.waypointNum = 0;

		this.jTextField6.setText("");
		this.jTextField7.setText("");
		this.jTextField8.setText("");
		this.jTextField9.setText("");
		this.jTextField10.setText("");
		this.jTextField11.setText("");
		this.jTextField12.setText("");
		this.jComboBox3.setSelectedItem("");
		this.jComboBox5.setSelectedItem("");
		this.jButton7.setEnabled(false);
		this.jButton8.setEnabled(false);
		this.jButton9.setEnabled(false);
		this.jtb_xzc = null;
		this.jtb_qiaoliang = null;
		this.jtb_suidao = null;
		this.jtb_dukou = null;
		this.jButtonWaypointDelete.setEnabled(false);
		this.jButtonWaypointDeleteAll.setEnabled(false);
		jButtonDrawWaypoint.setEnabled(false);
	}

	void jMenuItem7_actionPerformed(ActionEvent e) {
		// GarminGMLDoc.resetGMLDoc();
		if (this.dataSave == false) {
			int i = JOptionPane.showConfirmDialog(this, "保存GPS数据吗?");
			if (i == 0) {
				jButton10_actionPerformed(null);
				if (this.dataSave == true) {
					this.reset();
				}
			} else if (i == 1) {
				this.reset();
				this.dataSave = true;
			}
		} else {
			this.reset();
		}
		// this.memoryShow();
	}

	void jButton12_actionPerformed(ActionEvent e) {
		this.memoryShow();
	}

	void jMenuItem10_actionPerformed(ActionEvent e) {
		this.jButton12_actionPerformed(e);
	}

	private void setTracksNameToNumberAndBeginEnd(Node track) {
		String number = ItemValue.getTracksNumber(track);
		int[] pos = ItemValue.getPosition("waypoint");
		// Node[] waypoints = new Node[pos.length];
		Node node = null;
		String firstWaypoint = "", lastWaypoint = "";
		Vector v = new Vector();
		if (pos != null) {
			for (int i = 0; i < pos.length; i++) {
				node = ItemValue.getWaypoint(pos[i]);
				if (ItemValue.getWaypointTracksID(node).equals(
						ItemValue.getTracksID(track))) {
					v.add(node);
				}
			}
		} else {
			ItemValue.setTracksName(track, (number + "("
					+ ItemValue.getTracksName(track) + ")"));
		}
		if (v.size() > 1) {
			firstWaypoint = ItemValue.getWaypointName((Node) v.get(0));
			lastWaypoint = ItemValue
					.getWaypointName((Node) v.get(v.size() - 1));
			ItemValue.setTracksName(track, (number + "(" + firstWaypoint + "-"
					+ lastWaypoint + ")"));
		}
	}

	private void setSavedFile(Node track) {
		String fileName = ItemValue.getTracksNumber(track);
		ItemValue.fileName = fileName + ".gps";
	}

	private void deleteAllTracksExceptThis(Node track) {
		int[] pos = ItemValue.getPosition("track");
		Node[] tracks = new Node[pos.length];
		for (int i = 0; i < pos.length; i++) {
			tracks[i] = ItemValue.getTracks(pos[i]);
		}
		for (int i = 0; i < tracks.length; i++) {
			try {
				if (!(tracks[i].equals(track))) {
					ItemValue.removeTrack(tracks[i]);
				}
			} catch (Exception ex) {
				System.out.println(i + " is null.");
			}
		}
	}

	private void deleteAllWaypointExceptThisTrack(Node track) {
		long trackID = Long.parseLong(ItemValue.getTracksID(track).replaceAll(
				"new", ""));
		int[] pos = ItemValue.getPosition("waypoint");
		Node[] waypoints = new Node[pos.length];
		for (int i = 0; i < pos.length; i++) {
			waypoints[i] = ItemValue.getWaypoint(pos[i]);
		}
		long wayID = 0;
		for (int i = 0; i < waypoints.length; i++) {
			wayID = Long.parseLong(ItemValue.getWaypointTracksID(waypoints[i])
					.replaceAll("new", ""));
			if (trackID != wayID) {
				ItemValue.removeWaypoint(waypoints[i]);
			}
		}

	}

	void jButton14_actionPerformed(ActionEvent e) {
		ItemValue iv = new ItemValue();
		if (iv.getPosition("track") == null) {
			return;
		}
		int[] pos = iv.getPosition("track");
		if (pos.length == 0) {
			return;
		}
		Node node = iv.getTracks(pos[tracksPos]);

		// /////////////////////////////////////////////////////////////////////////////////////
		int i = JOptionPane.showConfirmDialog(this, "删除航迹"
				+ iv.getTracksName(node) + "吗?", "choose one",
				JOptionPane.YES_NO_OPTION);
		if (i == 0) {
			GarminGMLDoc.root.removeChild(node);
			iv.tracksNum--;
			if (iv.tracksNum == 0) {
				setTracksReset();
				if (iv.waypointNum == 0) {
					this.reset();
				}
			}
			this.memoryShow();
			this.jTree1.expandTree(true);
			// System.out.println("i:"+i+"/ttracksPos:"+this.tracksPos);

		}
		/*
		 * //////////////////////////////////////////////////////////////////
		 * int i = JOptionPane.showConfirmDialog(this, "删除除" +
		 * iv.getTracksName(node) + "以外的航迹吗?", "choose one",
		 * JOptionPane.YES_NO_OPTION); if (i == 0) {
		 * this.deleteAllTracksExceptThis(node);
		 * this.deleteAllWaypointExceptThisTrack(node);
		 * this.setTracksNameToNumberAndBeginEnd(node); this.setSavedFile(node);
		 * iv.tracksNum = 1; this.memoryShow(); this.jTree1.expandTree(true);
		 * /////////////////////
		 * 
		 * /////////////////////
		 * //System.out.println("i:"+i+"/ttracksPos:"+this.tracksPos);
		 *  }
		 */
	}

	public int getselectTrackPos() {
		return tracksPos;
	}

	public Node getselectTrackNode() {
		if (ItemValue.getPosition("track") == null) {
			return null;
		}
		int[] pos = ItemValue.getPosition("track");
		if (pos.length == 0) {
			return null;
		}
		return ItemValue.getTracks(pos[tracksPos]);
	}

	/**
	 * 显示选择行政村面板
	 */
	public void showSelect_Xingzhengcun() {
		this.cunFrame.show();
		this.cunFrame.setSelectedTable1Data(this.jtb_xzc);
	}

	/**
	 * 显示选择行政村数据
	 */
	public void setSelect_Xingzhengcun() {
		if (this.jtb_xzc != null) {
			if (!((this.jtb_xzc[1].trim()).equals(""))) {
				if (this.jtb_xzc[1].indexOf("居委会") != -1) {
					this.setWaypointName(this.jtb_xzc[1]);
				} else {
					this.setWaypointName(this.jtb_xzc[1] + "村委会");
				}

			}
			// this.cunpanel.setAll(select[1]+"",select[2]+"",select[3]+"",select[4]+"");
		}
	}

	/**
	 * 得到航点名称
	 */
	public String getWaypointName() {
		return this.jTextField7.getText();
	}

	/**
	 * 设置航点名称
	 */
	public void setWaypointName(String name) {
		this.jTextField7.setText(name);
	}

	public void setJTB_XZC(String[] xzc) {
		this.jtb_xzc = xzc;
	}

	public void setJTB_Qiaoliang(String[] qiaoliang) {
		this.jtb_qiaoliang = qiaoliang;
	}

	public void setJTB_Suidao(String[] suidao) {
		this.jtb_suidao = suidao;
	}

	public void setJTB_Dukou(String[] dukou) {
		this.jtb_dukou = dukou;
	}

	public String[] getJTB_XZC() {
		return this.jtb_xzc;
	}

	public String[] getJTB_Qiaoliang() {
		return this.jtb_qiaoliang;
	}

	public String[] getJTB_Suidao() {
		return this.jtb_suidao;
	}

	public String[] getJTB_Dukou() {
		return this.jtb_dukou;
	}

	void jButtonWaypointDelete_actionPerformed(ActionEvent e) {

		// ItemValue iv = new ItemValue();
		if (ItemValue.getPosition("waypoint") == null) {
			return;
		}
		int[] pos = ItemValue.getPosition("waypoint");
		if (pos.length == 0) {
			return;
		}
		int posTemp = 0;
		Node node = ItemValue.getWaypoint(pos[this.waypointPos]);
		posTemp = this.waypointPos;
		int i = JOptionPane.showConfirmDialog(this, "删航点"
				+ ItemValue.getWaypointName(node) + "吗?", "choose one",
				JOptionPane.YES_NO_OPTION);
		if (i == 0) {
			GarminGMLDoc.root.removeChild(node);
			ItemValue.waypointNum--;
			if (ItemValue.waypointNum == 0) {
				setWaypointReset();
				if (ItemValue.tracksNum == 0) {
					this.reset();
				}
			}
			this.memoryShow();
			if (this.clf != null) {
				clf.jPanelCut.resetWaypointCombobox();
				clf.jPanelCut.init();
				clf.jPanelCut.jComboBox_itemStateChanged(null);
			}
			if (isWaypointPosInvalid(posTemp)) {
				this.setWaypoint(posTemp);
			}

			// System.out.println("i:"+i+"/ttracksPos:"+this.tracksPos);
		}
		this.jTree1.expandTree(false);

	}

	/**
	 * 判断航点的位置是否有效
	 */
	private boolean isWaypointPosInvalid(int position) {
		if (ItemValue.getPosition("waypoint") == null) {
			return false;
		}
		int[] pos = ItemValue.getPosition("waypoint");
		if (pos.length == 0) {
			return false;
		}

		if (position < pos.length) {
			return true;
		} else {
			return false;
		}
	}

	void drawMap_actionPerformed(ActionEvent e) {

		Graphics g = this.jPanel4.getGraphics();
		int jPanel4Width = this.jPanel4.getWidth();
		int jPanel4Height = this.jPanel4.getHeight();
		ToMap tm = new ToMap();
		tm.determinScale(jPanel4Width, jPanel4Height);
		if (e.getActionCommand().equals("Draw_Tracks")) {
			tm.drawTracks(g);
		}
		if (e.getActionCommand().equals("Draw_Waypoint")) {
			tm.drawWaypoint(g);
		}
		if (e.getActionCommand().equals("Clear")) {
			jPanel4.repaint();
		}

		// System.out.println("x1:"+tm.x1+",x2:"+tm.x2+",y1:"+tm.y1+",y2:"+tm.y2);

	}

	void jButton16_actionPerformed(ActionEvent e) {
		DialogInsertTracks dit

⌨️ 快捷键说明

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