📄 itemvalue.java
字号:
package net.aetherial.gis.surface;
import net.aetherial.gis.garmin.*;
import org.w3c.dom.*;
import java.util.Vector;
import java.io.*;
import javax.comm.SerialPort;
import javax.comm.*;
import java.util.Enumeration;
import net.aetherial.gis.garmin.ConsoleConfig;
import java.util.*;
import net.aetherial.gis.dataType.WptType;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import net.aetherial.gis.publicuse.StringOper;
import net.aetherial.gis.publicuse.TrackOper;
import net.aetherial.gis.util.Encryption;
import net.aetherial.gis.publicuse.NodeArrayOper;
public class ItemValue {
public static Hashtable luDuanBianMa = new Hashtable();
public static Hashtable namedTracks = new Hashtable();
public static Hashtable numberedTracks = new Hashtable();
public static Hashtable hanDongShuLiang = new Hashtable();
public static Hashtable luDuanTracks = new Hashtable();
public static Hashtable hanDongTracks = new Hashtable();
public static Hashtable jzcZuoBiao = new Hashtable();
public static Hashtable sameBE = new Hashtable();
public static boolean nianBao = false;
public static boolean ganXian = false;
public static String ganXianName = "";
public static boolean baoBu = false;
//public static final String ENCODE ="GB2312";
public static Hashtable idPairs = new Hashtable();
public static String fileName = "001.gps";
public static String fileChoosePath = "E:\\核对工作\\数据\\";
public static String fileSavePath = "E:\\核对工作\\数据\\";
public static SerialPort ttyS;
public static String portDetermin = ""; //用户自己指定的端口
public static String portCanUse = ""; //自动检测的可用端口
public static String[] comm = null; //所有COM端口列表
public static boolean hasTrack = false, hasWaypoint = false;
public static int tracksNum = 0, waypointNum = 0;
public static boolean waypointPre = true; //判断内存中航点是否在航迹的前面
//public static long data = 0;
public static boolean deadThread = false;
public static int oldWaypointTopPos = 0;
public static int oldTrackTopPos = 0;
private static long idLast = 0;
public static long idLeast = 0;
public static long idLargest = 0;
private static long thisIdLargest = 0;
public static boolean showMap = false;
public static boolean test = false;
public static int SendCount = 0, RecieveCount = 0;
public static int testPoint = 0;
public static boolean encrypt = true;
public static boolean cuting = false;
public static boolean isTemp = true;
public static final String SOFTWARE_NAME = "安徽省农村公路测量数据采集工具1.1a";
private static double touzi_bili = 15.0;
private static String select_xiangzhen = "";
private static boolean showDialogMessage = true; //在批处理过程中使用,因为如果显示默认的dialog,将需要手工选择是与否
private static String log = "";
private static String runAllMessage = " "; //这个静态变量使用在(所有功能集成在一起)的状态栏显示数据
private static String arrayPath = ""; //这个静态变量使用在(所有功能集成在一起)的array数组路径
private static String errorString = "";
/**
* 如果是计划软件,则该项为true
* 否则为false;
*/
public static final boolean IS_JIHUA = false;
public ItemValue() {
}
public static void reset() {
idLast = 0;
idLeast = 0;
idLargest = 0;
thisIdLargest = 0;
log = "";
}
public static void initTest() {
if (test) {
fileChoosePath = "D:\\GIS\\GPS测量数据";
}
}
public static void setLastTracksID(long id) {
idLast = id;
}
public static void testPointIncrease() {
testPoint++;
}
public static void testPointToZero() {
testPoint = 0;
}
public static int TestPointGetValue() {
return testPoint;
}
public static void setShowDialogMessage(boolean show) {
showDialogMessage = show;
}
public static void setTouzi_bili(double touzi_bili) {
ItemValue.touzi_bili = touzi_bili;
}
public static void setSelect_xiangzhen(String select_xiangzhen) {
ItemValue.select_xiangzhen = select_xiangzhen;
}
public static void setRunAllMessage(String message) {
ItemValue.runAllMessage = message;
}
public static void setArrayPath(String arrayPath) {
ItemValue.arrayPath = arrayPath;
}
public static void addError(String error) {
System.out.println(error);
ItemValue.errorString = errorString + error + "\r\n";
}
public static String getError() {
return errorString;
}
public static boolean getShowDialogMessage() {
return showDialogMessage;
}
public static double getTouzi_bili() {
return touzi_bili;
}
public static String getSelect_xiangzhen() {
return select_xiangzhen;
}
// public static void setRunAllMessage(String message) {
// runAllMessage = message;
// }
public static String getRunAllMessage() {
return runAllMessage;
}
public static String getArrayPath() {
return arrayPath;
}
/**
* 取小数点后的几位
* n 即小数点后的位数
*/
public static double getRound(double num, int n) {
double bili = Math.pow(10, n);
long temp = Math.round(num * bili);
return temp / bili;
}
public static void send() {
SendCount++;
// System.out.println("testSendCount:"+SendCount+"testRecieveCount:"+RecieveCount);
}
public static void recieve() {
RecieveCount++;
// System.out.println("testSendCount:"+SendCount+"testRecieveCount:"+RecieveCount);
}
public static String[] getCommName() {
Enumeration e = CommPortIdentifier.getPortIdentifiers();
CommPortIdentifier cpi = null;
Vector v = new Vector();
while (e.hasMoreElements()) {
cpi = (CommPortIdentifier) e.nextElement();
//if(cpi.getName().substring(0,3).toLowerCase().equals("com")){
if (cpi.getPortType() == CommPortIdentifier.PORT_SERIAL) {
//System.out.println(cpi.getName());
v.add(cpi.getName());
}
}
String[] str = null;
if (v.size() > 0) {
str = new String[v.size()];
for (int i = 0; i < str.length; i++) {
str[i] = v.get(i) + "";
}
}
return str;
}
public static String getSavedComm() {
String line = "";
int i = 0;
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(new
FileInputStream(ConsoleConfig.cfgFile)));
for (line = in.readLine(); line != null; line = in.readLine(), i++) {
if (! (line.startsWith("#"))) {
StringTokenizer st = new StringTokenizer(line, "=");
String name = st.nextToken().trim();
String value = st.nextToken().trim();
if (name.equals("Serial Port")) {
return value;
}
}
}
}
catch (Exception ex) {
return "";
}
return "";
}
public static Node[] getWaypoint() {
int[] pos = getPosition("waypoint");
if (pos == null) {
return null;
}
Node[] wpt = new Node[pos.length];
for (int i = 0; i < pos.length; i++) {
wpt[i] = ItemValue.getWaypoint(pos[i]);
}
return wpt;
}
public static Node[] getTracks() {
int[] pos = getPosition("track");
if (pos == null) {
return null;
}
Node[] trk = new Node[pos.length];
for (int i = 0; i < pos.length; i++) {
trk[i] = ItemValue.getTracks(pos[i]);
}
return trk;
}
public static int[] getPosition(String string) {
NodeList nl = null;
Vector pos = new Vector();
if (GarminGMLDoc.root == null) {
return null;
}
if (GarminGMLDoc.root.hasChildNodes()) {
nl = GarminGMLDoc.root.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
if (nl.item(i).getNodeName().equals(string)) {
try {
pos.addElement(i + "");
}
catch (Exception e) {
System.err.println("error in ItemValue.getPositon()!");
e.printStackTrace();
}
}
}
}
if (pos.size() <= 0) {
return null;
}
int[] intPos = new int[pos.size()];
for (int i = 0; i < intPos.length; i++) {
intPos[i] = Integer.parseInt(pos.get(i) + "");
//System.out.println(string+":"+intPos[i]);
}
return intPos;
}
public static Node getTracks(int item) {
NodeList nl = GarminGMLDoc.root.getChildNodes();
//if(ItemValue.waypointPre==true){
// System.out.println("Itemvalue:(item+ItemValue.waypointNum)"+(item+ItemValue.waypointNum));
// return nl.item(item+ItemValue.waypointNum);
//}else{
return nl.item(item);
//}
}
public static Node getFirstTrack() {
int[] pos = ItemValue.getPosition("track");
if (pos == null) {
return null;
}
else {
return ItemValue.getTracks(pos[0]);
}
}
public static int getTracksPosByItem(int itemPos) {
if (getPosition("track") == null) {
return -1;
}
int[] pos = getPosition("track");
if (pos.length == 0) {
return -1;
}
else {
return pos[itemPos];
}
}
public static Node getTracksByPos(int tracksPos) {
if (getPosition("track") == null) {
return null;
}
int[] pos = getPosition("track");
if (pos.length == 0) {
return null;
}
Node node = getTracks(pos[tracksPos]);
return node;
}
public static String getTracksName(Node tracksNode) {
if (tracksNode == null) {
// System.out.println("tracksNode == null, in getTracksName in ItemValue");
return "";
}
return tracksNode.getChildNodes().item(0).getChildNodes().item(0).
getNodeValue();
}
public static String getTracksName(int tracksPos) {
if (getPosition("track") == null) {
return "";
}
int[] pos = getPosition("track");
if (pos.length == 0) {
return "";
}
Node node = getTracks(pos[tracksPos]);
return getTracksName(node);
}
public static String getTracksID(Node tracksNode) {
//System.out.println("tracksID:at"+getTracksName(tracksNode));
return tracksNode.getChildNodes().item(1).getChildNodes().item(0).
getNodeValue();
}
public static String getTracksID(int tracksPos) {
if (getPosition("track") == null) {
return "";
}
int[] pos = getPosition("track");
if (pos.length == 0) {
return "";
}
Node node = getTracks(pos[tracksPos]);
return getTracksID(node);
}
public static int getTracksNum(Node tracksNode) {
if (tracksNode == null) {
return 0;
}
return getTracksPoint(tracksNode).getLength();
}
public static String getTracksNumber(Node tracksNode) {
try {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -