📄 dialoglinkall.java
字号:
package net.aetherial.gis.cutAndLink.resection;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.util.Vector;
import net.aetherial.gis.publicuse.track.ConcatenatedTrack;
import org.w3c.dom.Node;
import net.aetherial.gis.surface.ItemValue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import net.aetherial.gis.cutAndLink.CLFrame;
import net.aetherial.gis.cutAndLink.cut.UniteAllTrack;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class DialogLinkAll
extends JDialog {
JPanel panel1 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
XYLayout xYLayout1 = new XYLayout();
JLabel jLabelhead = new JLabel();
Vector check = new Vector();
JButton jButtonOK = new JButton();
JButton jButtonCancel = new JButton();
CLFrame clf = null;
private int hight_temp = 0;
private Vector concatenatedTracks = null;
public DialogLinkAll(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public DialogLinkAll() {
this(new Frame(), "不连续路线合并", false);
}
public DialogLinkAll(CLFrame clf) {
this(clf, "不连续路线合并", false);
this.clf = clf;
}
public void show() {
this.setSize(400, hight_temp);
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(
(screenDim.width - 400) / 2,
(screenDim.height - hight_temp) / 2
);
super.show();
}
public void initToThis(Vector concatenatedTracks) {
this.concatenatedTracks = concatenatedTracks;
int baseHeight = 0;
for (int i = 0; i < concatenatedTracks.size(); i++) {
baseHeight = this.addDuan(i,
( (ConcatenatedTrack) concatenatedTracks.get(i)),
baseHeight);
}
jLabelhead.setText("航迹组成" + concatenatedTracks.size() + "段,请选择连接:");
hight_temp = baseHeight + 100;
panel1.add(jButtonOK, new XYConstraints(70, baseHeight + 30, -1, -1));
panel1.add(jButtonCancel, new XYConstraints(140, baseHeight + 30, -1, -1));
}
/**
* panel1.add(jCheckBox, new XYConstraints(70, 57, -1, -1));
panel1.add(jLabelDuanStart, new XYConstraints(32, 61, -1, -1));
panel1.add(jLabelRow1, new XYConstraints(63, 83, -1, -1));
panel1.add(jLabelrow2, new XYConstraints(63, 104, -1, -1));
panel1.add(jLabel5, new XYConstraints(32, 145, -1, -1)); 85
*/
private int addDuan(int i, ConcatenatedTrack ctrk, int height) {
int baseHeght = 20, maxHeight = baseHeght;
JLabel jLabelDuanStart = new JLabel();
JLabel jLabelRow = new JLabel();
JCheckBox jCheckBox = new JCheckBox();
this.check.add(jCheckBox);
jLabelDuanStart.setText("第" + (i + 1) + "段:");
Node[] temp = ctrk.getConcatenatedTrack();
for (int j = 0; temp != null && j < temp.length; j++) {
jLabelRow = new JLabel();
jLabelRow.setText(ItemValue.getTracksName(temp[j]) + " {" +
ItemValue.getTracksStringDistance(temp[j]) + "公里}");
panel1.add(jLabelRow,
new XYConstraints(63, height + j * 20 + baseHeght * 4, -1, -1));
maxHeight = height + j * 20 + baseHeght * 4;
}
jCheckBox.setText("选择该段连接");
panel1.add(jCheckBox,
new XYConstraints(70, baseHeght * 3 - 3 + height, -1, -1));
panel1.add(jLabelDuanStart,
new XYConstraints(32, baseHeght * 3 + height, -1, -1));
return maxHeight;
}
private void jbInit() throws Exception {
jButtonOK.setText(" 确 定 ");
jButtonOK.addActionListener(new DialogLinkAll_jButton_actionAdapter(this));
jButtonCancel.setText(" 取 消 ");
jButtonCancel.addActionListener(new DialogLinkAll_jButton_actionAdapter(this));
this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.WEST);
panel1.setLayout(xYLayout1);
jScrollPane1.getViewport().add(panel1);
getContentPane().add(panel1);
jLabelhead.setText("航迹组成2段,请选择连接:");
panel1.add(jLabelhead, new XYConstraints(59, 23, -1, -1));
}
public void jButton_actionPerformed(ActionEvent e) {
if (e.getSource().equals(this.jButtonOK)) {
int selected = -1, selectCount = 0;
for (int i = 0; i < this.check.size(); i++) {
if ( ( (JCheckBox)this.check.get(i)).isSelected()) {
selected = i;
selectCount++;
}
}
if (selectCount == 1) {
UniteAllTrack unite = new UniteAllTrack();
Node[] series = ( (ConcatenatedTrack) concatenatedTracks.get(selected)).
getConcatenatedTrack();
try {
Node tempNode = unite.createLinkedTrk(series);
clf.tc.tadded = tempNode;
ItemValue.removeTrack(tempNode);
clf.drawPane.repaint();
this.hide();
}
catch (Exception ex) {
JOptionPane.showMessageDialog(this, ex.getMessage(), "合并错误",
JOptionPane.ERROR_MESSAGE);
}
}
else {
JOptionPane.showMessageDialog(this, "请选择1组", "请选择1组",
JOptionPane.ERROR_MESSAGE);
}
}
else if (e.getSource().equals(this.jButtonCancel)) {
this.hide();
}
}
}
class DialogLinkAll_jButton_actionAdapter
implements ActionListener {
private DialogLinkAll adaptee;
DialogLinkAll_jButton_actionAdapter(DialogLinkAll adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -