📄 cutpanel.java
字号:
package net.aetherial.gis.cutAndLink;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Graphics;
import net.aetherial.gis.our.ToMap;
import org.w3c.dom.*;
import javax.swing.JPopupMenu;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.JMenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JButton;
import net.aetherial.gis.surface.ItemValue;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusAdapter;
import net.aetherial.gis.cutAndLink.cut.CutToSection;
public class CutPanel
extends JPanel {
private CLFrame clf = null;
private TempDoc tc = null;
public CutPanel() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public CutPanel(CLFrame clf, TempDoc tc) {
this();
this.clf = clf;
this.tc = tc;
}
private void jbInit() throws Exception {
this.setLayout(xYLayout1);
jLabel1.setText("起始点:");
jLabelName.setText("名称:。。。。。。");
jButtonRun.setText("执行");
jButtonRun.addActionListener(new CutPanel_jButton_actionAdapter(this));
jButtonRun.setActionCommand("Run");
jLabelNum.setText("航迹点:N个");
jLabel4.setText("结束点:");
jComboBoxBegin.addItemListener(new CutPanel_jComboBox_itemAdapter(this));
jComboBoxEnd.addItemListener(new CutPanel_jComboBox_itemAdapter(this));
jButtonFindStart.setText("定位");
jButtonFindStart.addActionListener(new CutPanel_jButton_actionAdapter(this));
jButtonFindStart.setActionCommand("Start");
jButtonFindEnd.setText("定位");
jButtonFindEnd.addActionListener(new CutPanel_jButton_actionAdapter(this));
jButtonFindEnd.setActionCommand("End");
xYLayout1.setWidth(156);
xYLayout1.setHeight(246);
this.add(jLabelName, new XYConstraints(11, 15, -1, -1));
this.add(jLabelNum, new XYConstraints(11, 45, -1, -1));
this.add(jLabel1, new XYConstraints(11, 75, -1, 16));
this.add(jButtonFindStart, new XYConstraints(60, 72, -1, -1));
this.add(jComboBoxBegin, new XYConstraints(11, 105, -1, -1));
this.add(jLabel4, new XYConstraints(11, 145, -1, -1));
this.add(jButtonFindEnd, new XYConstraints(60, 140, -1, -1));
this.add(jComboBoxEnd, new XYConstraints(11, 170, -1, -1));
this.add(jButtonRun, new XYConstraints(85, 210, -1, -1));
}
public void resetWaypointCombobox(){
this.jComboBoxBegin.removeAllItems();
this.jComboBoxEnd.removeAllItems();
}
public void init() {
this.setRunEnable();
jLabelName.setText("当前路线名称:" + ItemValue.getTracksName(tc.track));
jLabelNum.setText("包含的GPS采集数据共:" + ItemValue.getTracksNum(tc.track) + "个");
// int[] pos = ItemValue.getPosition("waypoint");
// if (pos == null) {
// return;
// }
// if (pos.length > 0) {
// for (int i = 0; i < pos.length; i++) {
// this.jComboBoxBegin.getItemCount();
// this.jComboBoxBegin.addItem(ItemValue.getWaypointName(ItemValue.
// getWaypoint(pos[i])) + "[" + (i + 1) + "]");
// this.jComboBoxEnd.addItem(ItemValue.getWaypointName(ItemValue.
// getWaypoint(pos[i])) + "[" + (i + 1) + "]");
// }
// this.drawWaypoint(0, 0);
// }
this.resetWaypointCombobox();
Node[] wpts = ItemValue.getWaypoint();
if (wpts != null) {
for (int i = 0; i < wpts.length; i++) {
this.jComboBoxBegin.getItemCount();
this.jComboBoxBegin.addItem(ItemValue.getWaypointName(wpts[i]) + "[" + (i + 1) + "]");
this.jComboBoxEnd.addItem(ItemValue.getWaypointName(wpts[i]) + "[" + (i + 1) + "]");
// System.out.println(ItemValue.getWaypointName(wpts[i]));
}
this.setDefaultWaypoint();
}
}
public void setSelectedWaypointTo(Node waypoint){
Node[] wpts = ItemValue.getWaypoint();
for (int i = 0;wpts != null && i < wpts.length; i++) {
if (wpts[i] == waypoint) {
this.jComboBoxBegin.setSelectedIndex(i);
}
}
}
private void setRunEnable(){
if (ItemValue.IS_JIHUA) {
this.jButtonRun.setEnabled(false);
}
}
private void setDefaultWaypoint(){
DefaultSelect ds = new DefaultSelect(this.tc.track);
this.jComboBoxBegin.setSelectedIndex(ds.getFirstID());
this.jComboBoxEnd.setSelectedIndex(ds.getlastID());
}
public void setDynamicPanel(DynamicPanel dp) {
this.dp = dp;
}
private void drawWaypoint(int selectedBegin, int selectedEnd) {
if (selectedBegin < 0) {
return;
}
if (selectedEnd < 0) {
return;
}
Node[] wpts = ItemValue.getWaypoint();
// for (int i = 0; i < wpts.length; i++) {
// System.out.println(ItemValue.getWaypointName(wpts[i]));
// }
// System.out.println(""+wpts.length);
if (wpts != null) {
tc.w1 = wpts[selectedBegin];
tc.w2 = wpts[selectedEnd];
}
try {
dp.drawWaypoint();
}
catch (Exception ex) {
}
try {
dp.repaint();
}
catch (Exception ex1) {
}
}
public void jComboBox_itemStateChanged(ItemEvent e) {
//(JComboBox)e.getSource().toString();
this.drawWaypoint(this.jComboBoxBegin.getSelectedIndex(),
this.jComboBoxEnd.getSelectedIndex());
}
DynamicPanel dp = null;
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JComboBox jComboBoxBegin = new JComboBox();
JLabel jLabelName = new JLabel();
JButton jButtonRun = new JButton();
public JLabel jLabelNum = new JLabel();
JLabel jLabel4 = new JLabel();
JComboBox jComboBoxEnd = new JComboBox();
JButton jButtonFindStart = new JButton();
JButton jButtonFindEnd = new JButton();
public void jButton_actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Run")) {
if ( (tc.track != null) && (tc.w1 != null) && (tc.w2 != null)) {
CutToSection cts = new CutToSection(this.clf);
cts.setTempDoc(this.tc);
cts.setTrack(tc.track);
cts.setStartEnd(tc.w1, tc.w2);
cts.insertIntoTempDoc();
dp.repaint();
}
else {
this.clf.setJTextAreaText("TempDoc's node is null.");
}
}
else if (e.getActionCommand().equals("Start")) {
this.dp.findWpt(tc.w1);
//System.out.println("CutPanel.jButton_actionPerformed:dp.height:"+dp.getHeight()+",dp.width"+dp.getWidth());
dp.repaint();
}
else if (e.getActionCommand().equals("End")) {
this.dp.findWpt(tc.w2);
dp.repaint();
}
}
class CutPanel_jButton_actionAdapter
implements ActionListener {
private CutPanel adaptee;
CutPanel_jButton_actionAdapter(CutPanel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton_actionPerformed(e);
}
}
class CutPanel_jComboBox_itemAdapter
implements ItemListener {
private CutPanel adaptee;
CutPanel_jComboBox_itemAdapter(CutPanel adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.jComboBox_itemStateChanged(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -