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

📄 framesetxzc.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
字号:
package net.aetherial.gis.our;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import net.aetherial.gis.surface.ItemValue;
import org.w3c.dom.Node;
import java.util.Vector;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.StringTokenizer;
import net.aetherial.gis.table.WuWei;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import net.aetherial.gis.dataType.WptType;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *    jSplitPane1.setDividerLocation((int)this.getWidth()/2);
 * @author not attributable
 * @version 1.0
 */
public class FrameSetXZC
    extends JFrame {
  WuWei ww = new WuWei();
  private boolean wpt_s_e = false;
  public FrameSetXZC() {
    try {
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    this.init();
    this.getContentPane().setLayout(borderLayout1);
    jPanel2.setLayout(xYLayout1);
    jSubmit.setText("确定");
    jSubmit.addActionListener(new FrameSetXZC_jSubmit_actionAdapter(this));
    jText.setText("村委           ");
    jButtonRun.setText("按字符寻找");
    jButtonCheckArray.setText("按表格寻找");
    jButtonCheckArray.addActionListener(new
        FrameSetXZC_jButtonCheckArray_actionAdapter(this));
    jButtonRun.addActionListener(new FrameSetXZC_jButtonRun_actionAdapter(this));
    jPanel5.setLayout(borderLayout3);
    jPanel4.setLayout(borderLayout4);
    jComboBoxXiangZhen.addItemListener(new
        FrameSetXZC_jComboBoxXiangZhen_itemAdapter(this));
    jCheckBox_S_E.setText("起点_终点");
    jCheckBox_S_E.addItemListener(new FrameSetXZC_jCheckBox_S_E_itemAdapter(this));
    this.getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);
    jPanel3.add(jSubmit);
    this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
    jPanel1.setLayout(borderLayout2);
    this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jPanel2);
    //jSplitPane1.add(jButtonCheckArray, JSplitPane.RIGHT);
    jPanel1.add(jSplitPane1, java.awt.BorderLayout.CENTER);
    jSplitPane1.add(jPanel4, JSplitPane.RIGHT);
    jSplitPane1.add(jPanel5, JSplitPane.LEFT);
    jPanel5.add(jText, java.awt.BorderLayout.WEST);
    jPanel5.add(jButtonRun, java.awt.BorderLayout.CENTER);
    jPanel4.add(jButtonCheckArray, java.awt.BorderLayout.CENTER);
    jPanel4.add(jComboBoxXiangZhen, java.awt.BorderLayout.WEST);
    jPanel4.add(jCheckBox_S_E, java.awt.BorderLayout.NORTH);
    this.addXiangZhen();
  }
  private void init(){
    this.setTitle("把村部设置成行政村");
    this.setSize(500,500);
    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(
        (screenDim.width - 500) / 2,
        (screenDim.height - 500) / 2
        );
    this.setIconImage(ItemValue.getImage("HSDIlogo.gif"));
  }
  private String[] getMatch(String text){
    StringTokenizer st = new StringTokenizer (text, "&");
    st.countTokens();
    return null;
  }
  private void addXiangZhen(){
    jComboBoxXiangZhen.addItem(this.All);
    for(int i = 0;i<ww.wuwei.length;i++){
      jComboBoxXiangZhen.addItem(ww.wuwei[i][0]);
    }
  }
  private boolean is_waypoint_s_or_e(Node waypoint){
    if(ItemValue.getWaypointKP(waypoint).equals(WptType.W8_qidian)){
      return true;
    }else if(ItemValue.getWaypointKP(waypoint).equals(WptType.W9_zhongdian)){
      return true;
    }else{
      return false;
    }
  }
  private String[] getSomeXZC(String xiangzhen){//得到指定乡镇的行政村
    String[] thisXZC = null;
    String xb1 ="",xb2 ="0";
    for(int i = 0;i<ww.wuwei.length;i++){
      if((!xb1.equals(""))){
        xb2 = ww.wuwei[i][1];
        break;
      }
      if(xiangzhen.equals(ww.wuwei[i][0])){
        xb1 = ww.wuwei[i][1];
      }
    }
    int xb1Int =Integer.parseInt(xb1),xb2Int = Integer.parseInt(xb2);
    int len = xb2Int -xb1Int;
    if(len <0){
      len = ww.wuwei_cun.length -1 - xb1Int;
    }

    thisXZC = new String[len];
    for(int i = 0;i<len;i++){
      thisXZC[i] = ww.wuwei_cun[xb1Int+i];
    }

    return thisXZC;
  }
  private void compare(Node waypoint){
    for(int i =0;i<this.XZCArray.length;i++){
      if(isSimulate(ItemValue.getWaypointName(waypoint),this.XZCArray[i])){
        this.addWaypoint(waypoint);
      }
    }
  }
  private void addWaypoint(Node waypoint){
    if(this.matchWpt != null){
      for (int i = 0; i < this.matchWpt.length; i++) {
        if (this.matchWpt[i].equals(waypoint)) {
          return;
        }
      }
    }
    this.vMatchWpt.add(waypoint);
  }
  private boolean isSimulate(String wptName,String xingzhencun){
    if(wptName.indexOf(xingzhencun)!=-1){
      return true;
    }
    return false;
  }
  private void getMatchWpt(){
    this.matchWpt = null;
    String match = jText.getText().trim();
    Node[] wpt = ItemValue.getWaypoint();
    Vector v = new Vector();
    for(int i =0;i<wpt.length;i++){
      if(this.isHave(match,(ItemValue.getWaypointName(wpt[i])))){
        v.add(wpt[i]);
      }
    }
    if(v.size()<1){
      System.out.println("没有匹配的航点");
      return;
    }else{
      this.matchWpt = new Node[v.size()];
      for (int i = 0;i<v.size();i++){
        this.matchWpt[i] = (Node)v.get(i);
      }
    }
  }
  private void addWptToShow(){
    this.printMatchWpt();
    if(this.matchWpt == null){

      return;
    }
    this.jWpt = new JCheckBox[this.matchWpt.length];
    for(int i = 0;i<this.matchWpt.length;i++){
      this.jWpt[i] = new JCheckBox();
      this.jWpt[i].setText(ItemValue.getWaypointName(this.matchWpt[i]));
      jPanel2.add(this.jWpt[i], new XYConstraints(20 + (i%3)*120, (((int)(i/3))*50 +10), -1, -1));
      this.jWpt[i].setSelected(true);
    }
  }
  private void setWptToXZC(){
    if(this.matchWpt == null){
      return;
    }
    for(int i = 0;i<this.jWpt.length;i++){
      if(this.jWpt[i].isSelected()){
        ItemValue.setWaypointKP(this.matchWpt[i],"行政村");
        //System.out.println("set " + ItemValue.getWaypointName(this.matchWpt[i]) + " to 行政村");
      }
    }
  }
  private boolean isHave(String match,String name){
    if(name.indexOf(match) > 0){
      return true;
    }else{
      return false;
    }
  }

  private boolean isHave(String[] match, String name) {

    for (int i = 0; i < match.length; i++) {
      if (name.indexOf(match[i]) > 0) {
        return true;
      }
    }
    return false;
  }
  private void removeHaveDraw(){
    this.setNull();
    if(this.jWpt == null){
      return;
    }else{
      for(int i = 0;i<this.jWpt.length;i++){
        this.jPanel2.remove(this.jWpt[i]);
      }
    }
    this.jWpt = null;
    this.validate();
    this.repaint();
  }
  public static void main(String args[]){
    FrameSetXZC fs = new FrameSetXZC();
    fs.show();
  }

  BorderLayout borderLayout1 = new BorderLayout();
  JPanel jPanel1 = new JPanel();
  JScrollPane jScrollPane1 = new JScrollPane();
  JPanel jPanel2 = new JPanel();
  XYLayout xYLayout1 = new XYLayout();
  JPanel jPanel3 = new JPanel();
  JButton jSubmit = new JButton();
  JSplitPane jSplitPane1 = new JSplitPane();
  JTextField jText = new JTextField();
  JButton jButtonRun = new JButton();
  JButton jButtonCheckArray = new JButton();
  BorderLayout borderLayout2 = new BorderLayout();
  Node[] matchWpt = null;
  Vector vMatchWpt = new Vector();
  JCheckBox[] jWpt = null;
  private String[] XZCArray = null;
  private final String All = "所有_all";
  JPanel jPanel4 = new JPanel();
  JPanel jPanel5 = new JPanel();
  JComboBox jComboBoxXiangZhen = new JComboBox();
  BorderLayout borderLayout3 = new BorderLayout();
  BorderLayout borderLayout4 = new BorderLayout();
  JCheckBox jCheckBox_S_E = new JCheckBox();
  public void jButtonRun_actionPerformed(ActionEvent e) {
    this.removeHaveDraw();
    this.getMatchWpt();
    this.addWptToShow();
    this.validate();
  }

  public void jSubmit_actionPerformed(ActionEvent e) {
    this.setWptToXZC();
    this.hide();
  }

  public void jButtonCheckArray_actionPerformed(ActionEvent e) {
    this.removeHaveDraw();
    Node[] wpt = ItemValue.getWaypoint();
    for(int i = 0; i < wpt.length ; i ++){
      if(this.wpt_s_e){
        if(this.is_waypoint_s_or_e(wpt[i])){
          this.compare(wpt[i]);
        }
      }else{
        this.compare(wpt[i]);
      }
    }
    if(this.matchWpt!=null){
      for (int i = 0; i < this.matchWpt.length; i++) {
        this.vMatchWpt.insertElementAt(this.matchWpt[i],0);
        //this.vMatchWpt.add(this.matchWpt[i]);
      }
    }
    this.matchWpt = null;
    this.matchWpt = new Node[this.vMatchWpt.size()];
    for (int i = 0; i < this.vMatchWpt.size(); i++) {
      this.matchWpt[i] = (Node) vMatchWpt.elementAt(i);
    }
    this.addWptToShow();
    this.validate();

  }
  private void setNull(){
    this.matchWpt = null;
    this.vMatchWpt = null;
    this.vMatchWpt = new Vector();
    //this.XZCArray = null;
  }
  private void printMatchWpt(){
    if(this.matchWpt == null){
      System.out.println("matchWpt == null");
    }else{
      System.out.println("matchWpt length:" + this.matchWpt.length);
    }
  }
  public void jComboBoxXiangZhen_itemStateChanged(ItemEvent e) {
    if(!(this.jComboBoxXiangZhen.getSelectedItem().equals(this.All))){
      this.XZCArray = null;
      this.matchWpt = null;
      this.vMatchWpt = null;
      this.vMatchWpt = new Vector();
      this.XZCArray = this.getSomeXZC(this.jComboBoxXiangZhen.getSelectedItem()+"");

    }else{
      this.XZCArray =null;
      this.XZCArray = ww.wuwei_cun;
    }
    System.out.println("现在查询的数组长度是:" + this.XZCArray.length);
  }

  public void jCheckBox_S_E_itemStateChanged(ItemEvent e) {
    if(this.jCheckBox_S_E.isSelected()){
      this.setWpt_s_e(true);
    }else{
      this.setWpt_s_e(false);
    }
  }

  public void setWpt_s_e(boolean wpt_s_e) {
    this.wpt_s_e = wpt_s_e;
  }
}

class FrameSetXZC_jCheckBox_S_E_itemAdapter
    implements ItemListener {
  private FrameSetXZC adaptee;
  FrameSetXZC_jCheckBox_S_E_itemAdapter(FrameSetXZC adaptee) {
    this.adaptee = adaptee;
  }

  public void itemStateChanged(ItemEvent e) {
    adaptee.jCheckBox_S_E_itemStateChanged(e);
  }
}

class FrameSetXZC_jComboBoxXiangZhen_itemAdapter
    implements ItemListener {
  private FrameSetXZC adaptee;
  FrameSetXZC_jComboBoxXiangZhen_itemAdapter(FrameSetXZC adaptee) {
    this.adaptee = adaptee;
  }

  public void itemStateChanged(ItemEvent e) {
    adaptee.jComboBoxXiangZhen_itemStateChanged(e);
  }
}

class FrameSetXZC_jButtonCheckArray_actionAdapter
    implements ActionListener {
  private FrameSetXZC adaptee;
  FrameSetXZC_jButtonCheckArray_actionAdapter(FrameSetXZC adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jButtonCheckArray_actionPerformed(e);
  }
}

class FrameSetXZC_jSubmit_actionAdapter
    implements ActionListener {
  private FrameSetXZC adaptee;
  FrameSetXZC_jSubmit_actionAdapter(FrameSetXZC adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jSubmit_actionPerformed(e);
  }
}

class FrameSetXZC_jButtonRun_actionAdapter
    implements ActionListener {
  private FrameSetXZC adaptee;
  FrameSetXZC_jButtonRun_actionAdapter(FrameSetXZC adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jButtonRun_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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