package Frame; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.Iterator; import java.util.Vector; import javax.swing.Box; import javax.swing.ImageIcon; import javax.swing.JInternalFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import javax.swing.table.DefaultTableModel; import BaoWen.Stac; import ColorAndFont.English; import ColorAndFont.NothJPanel; import ColorAndFont.UIColor; import ColorAndFont.buttonTitle; import PbuliClass.JButtonModel; import PbuliClass.ShowMessage; import PbuliClass.Systems; import PbuliClass.WarningMessage; import PbuliClass.greateTables; import PbuliClass.jinternalFrame; import person.Person; import person.person_Dell; import tbDataModel.TbRealPosition; /**´ËÀàÓÃÓڲ鿴ÿ¸ö±êÇ©µÄʵʱλÖÃ×ø±ê*/ public class TagReaLocation extends jinternalFrame { /** * */ private static final long serialVersionUID = 1L; jinternalFrame jinerFrame=null; JInternalFrame jinFrame=null; JPanel innerPanel=null;//ÄÚ²¿´°ÌåÃæ°å NothJPanel northPanel=null;//Äϲ¿Ãæ°å JPanel centerPanel=null;//Öв¿Ãæ°å JTextField searchFileld=null;//ËÑË÷Îı¾¿ò JButtonModel search=null;//ËÑË÷°´Å¥ JButtonModel shuaxin=null;//ˢа´Å¥ JButtonModel add=null;//ÐÂÔö°´Å¥ JButtonModel alter=null;//Ð޸İ´Å¥ JButtonModel delete=null;//ɾ³ý°´Å¥ JButtonModel deleteAll=null;//È«²¿É¾³ý°´Å¥ JButtonModel enterPort=null;//µ¼ÈëÈËÔ±°´Å¥ JButtonModel outport=null;//µ¼³ö±í¸ñ°´Å¥ JButtonModel download=null;//Ä£°åÏÂÔØ°´Å¥ JButtonModel but_looshiwai=null;//Ä£°åÏÂÔØ°´Å¥ JButtonModel but_alertxyz=null;//Ð޸ıêÇ©ÊµÊ±×ø±ê JScrollPane gd=null;//¹ö¶¯Ãæ°å JTable table=null;//ÉêÃ÷±í¸ñ Vector> rowData=null; DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ int selectedRow;//±»Ñ¡ÖеÄÐÐ Vector list; Container rq; static boolean lookshiwai=false;//¿´ÊÒÍâ JButtonModel but_alerttag=null;//×Ô¶¯Ð޸ıêǩƵÂÊ static boolean alerttaghz=false;//¿ªÆôÐÞ¸ÄÆµÂÊ public TagReaLocation() {//¹¹Ôì·½·¨ rowData=new Vector<>(); String title="ʵʱλÖñí"; if(Systems.sys().getLanguage().equals("English")) { title="Real-time location table"; } this.setTitle(title); rq=getContentPane();//»ñÈ¡ÈÝÆ÷ rq.setLayout(new BorderLayout()); rq.setBackground(Color.white); rq.add(getNorthPanel(),BorderLayout.NORTH); rq.add(getGd(),BorderLayout.CENTER); this.setFrameIcon(new ImageIcon("image/icon/realposicon.png"));//ÉèÖô°Ìåͼ±ê this.addInternalFrameListener(new InternalFrameListener() { @Override public void internalFrameOpened(InternalFrameEvent e) { } @Override public void internalFrameIconified(InternalFrameEvent e) { } @Override public void internalFrameDeiconified(InternalFrameEvent e) { } @Override public void internalFrameDeactivated(InternalFrameEvent e) { } @Override public void internalFrameClosing(InternalFrameEvent e) { Stac.setSerchtagid("0"); Stac.setSerchperson(false); lookshiwai=false;//¿´ÊÒÍâ alerttaghz=false; person_Dell.alert_no_choose(); } @Override public void internalFrameClosed(InternalFrameEvent e) { } @Override public void internalFrameActivated(InternalFrameEvent e) { } }); } /**»ñÈ¡Äϲ¿Ãæ°åµÄ·½·¨*/ public NothJPanel getNorthPanel() { if(northPanel==null) { northPanel=new NothJPanel(); Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷ topicBox.add(getSearchFileld());//Ìí¼ÓËÑË÷Îı¾¿ò topicBox.add(Box.createHorizontalStrut(3)); topicBox.add(getSearch());//Ìí¼ÓËÑË÷°´Å¥ topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(getShuaxin());//Ìí¼Óˢа´Å¥ topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(getBut_looshiwai()); topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(getBut_alerttag()); topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(getBut_alertxyz()); northPanel.add(topicBox ); } return northPanel; } /**»ñÈ¡Öв¿Ãæ°åµÄ·½·¨*/ public JPanel getCenterPanel() { if(centerPanel==null) { centerPanel=new JPanel(); centerPanel.add(getGd());//Ìí¼Ó¹ö¶¯Ãæ°å centerPanel.setBackground(Color.WHITE); } return centerPanel; } /**»ñÈ¡ËÑË÷Îı¾¿òµÄ·½·¨*/ public JTextField getSearchFileld() { if(searchFileld==null){ searchFileld=new JTextField(10); searchFileld.addKeyListener(new KeyListener() { //¼üÅÌʼþ¼àÌý public void keyTyped(KeyEvent e) { } public void keyReleased(KeyEvent e) { int keyCode=e.getKeyCode(); if(keyCode==KeyEvent.VK_ENTER) { getSearch().doClick();//ËÑË÷°´Å¥±»µã»÷ } } public void keyPressed(KeyEvent e) { } }); } return searchFileld; } /**»ñÈ¡ËÑË÷°´Å¥µÄ·½·¨*/ public JButtonModel getSearch() { if(search==null){ search=new JButtonModel(buttonTitle.getSerch()); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String tagid=searchFileld.getText().trim(); if(tagid.length()<3) { ShowMessage.zidingyi("ÄúËÑË÷µÄ"+tagid+"²»´æÔÚ£¡"); Stac.setSerchperson(false); Stac.setSerchtagid("0"); return; }else { int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý if(tagnum !=0 ) { for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ tableModel.removeRow(0); } } if(person_Dell.serch(tagid).size()!=0) { getRowData(person_Dell.serch(tagid)); Stac.setSerchperson(true); Stac.setSerchtagid(tagid); person_Dell.get_Person(tagid).setIschoose(1); }else { ShowMessage.zidingyi("ÄúËÑË÷µÄ"+tagid+"²»´æÔÚ£¡"); Stac.setSerchperson(false); Stac.setSerchtagid("0"); person_Dell.alert_no_choose(); } } } }); } return search; } /**»ñȡˢа´Å¥µÄ·½·¨*/ public JButtonModel getShuaxin() { if(shuaxin==null){ shuaxin=new JButtonModel(buttonTitle.getRefresh()); shuaxin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTable() ; } }); } return shuaxin; } /**»ñÈ¡±í¸ñ±»Ñ¡ÖеÄÐз½·¨*/ public int getSelectedRow() { selectedRow=getTable().getSelectedRow(); return selectedRow; } /**»ñȡɾ³ý°´Å¥µÄ·½·¨*/ public JButtonModel getDelete() { if(delete==null){ delete=new JButtonModel(buttonTitle.getDelete()); delete.addActionListener(new ActionListener() { @SuppressWarnings("unused") public void actionPerformed(ActionEvent e) { int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ if(selectedRows.length !=0) { for(int i=0;i it = person_Dell.getPerson_vector().iterator();//´´½¨µü´úÆ÷ while (it.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ Person people = it.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ Vector row = new Vector<>(); String life="ÔÚÏß"; if(people.getP_online().equals("0")) { life="ÀëÏß"; } row.add(life); row.add(people.getP_tagid()); row.add(String.valueOf(people.getP_x())); row.add(String.valueOf(people.getP_y())); row.add(people.getP_floor()); row.add(people.getP_addtiem()); rowData.add(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý } } /**»ñÈ¡±í¸ñµÄ·½·¨*/ @SuppressWarnings("serial") public JTable getTable() { if(table==null) { String[] name1= {"ÐÕÃû","±êÇ©ID","״̬","X×ø±ê","Y×ø±ê","Z×ø±ê","²ã","ÐźÅ","ʱ¼ä"};//±í¸ñÁÐÃû String[] name2= {"Status", "Tag ID", "X Coordinate", "Y Coordinate", "Layer", "Time"};//±í¸ñÁÐÃû String[] columnNames=English.columnNames(name1, name2); //Ìí¼Ó±í¸ñÁÐÏòÁ¿ Vector columnName=new Vector<>(); for(int i=0;i vc ) { Iterator iterator = vc.iterator();//´´½¨µü´úÆ÷ while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ Person prs= iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ Vector row = new Vector(); String state=prs.getP_online(); if(state.equals("1")) { state="ÔÚÏß"; }else { state="ÀëÏß"; } String tagid=prs.getP_tagid(); String name=prs.getP_name(); String x=String.valueOf(prs.getP_x()); String y=String.valueOf(prs.getP_y());; String z=String.valueOf(prs.getP_z());; String floor=prs.getP_floor(); String time=prs.getP_addtiem(); String a2="N"; int indoor=prs.getIndoor_or_outdoor(); if(indoor==1) { a2="ÄÚ"; }else if(indoor==0){ a2="Íâ"; } String a3=prs.getGpsxinhao10(); if(a3==null || a3.contentEquals("")) { a3="N"; } String xinhao=a2+","+prs.getGngga_state()+","+a3; row.add(name); row.add(tagid); row.add(state); row.add(x); row.add(y); row.add(z); row.add(floor); row.add(xinhao); row.add(time); tableModel.addRow(row); } } public JButtonModel getBut_looshiwai() { if(but_looshiwai==null) { but_looshiwai=new JButtonModel("²é¿´ÊÒÍâ"); but_looshiwai.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù if(lookshiwai) { lookshiwai=false; but_looshiwai.setText(" È¡Ïû²é¿´ "); }else { lookshiwai=true; but_looshiwai.setText(" ²é¿´ÊÒÍâ "); } } }); } return but_looshiwai; } public static boolean isLookshiwai() { return lookshiwai; } public static boolean isAlerttaghz() { return alerttaghz; } public JButtonModel getBut_alerttag() { if(but_alerttag==null) { but_alerttag=new JButtonModel("×Ô¶¯¸ÄƵÂÊ"); but_alerttag.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(alerttaghz) { alerttaghz=true; but_alerttag.setText(" ¿ªÆôƵÂÊÐÞ¸Ä "); }else { alerttaghz=false; but_alerttag.setText(" ×Ô¶¯ÐÞ¸ÄÆµÂÊ "); } } }); } return but_alerttag; } public JButtonModel getBut_alertxyz() { if(but_alertxyz==null) { but_alertxyz=new JButtonModel("ÐÞ¸Ä×ø±ê"); but_alertxyz.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row=table.getSelectedRow(); if(row !=-1) { String tagid=(String) table.getValueAt(row,1); String x=(String) table.getValueAt(row,3); String y=(String) table.getValueAt(row,4); String f=(String) table.getValueAt(row,6); Person pr=person_Dell.get_Person(tagid); pr.setP_x(Integer.parseInt(x)); pr.setP_y(Integer.parseInt(y)); pr.setP_floor(f); pr.setP_online("1"); ShowMessage.zidingyi(tagid+"Ð޸ijɹ¦"); }else { ShowMessage.zidingyi("ÇëÑ¡ÖÐÐèÒªÐ޸ĵÄÐÐ"); } } }); } return but_alertxyz; } }