[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/eyes/tools/java/de/tub/eyes/components NetworkViewComponent.java, 1.6, 1.7

Till Wimmer twimmer at users.sourceforge.net
Mon Apr 24 07:56:50 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/eyes/tools/java/de/tub/eyes/components
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29403

Modified Files:
	NetworkViewComponent.java 
Log Message:
put JDiagramViewer in JScrollPane; added GIS handling (set positions); added zoom pulldown handling

Index: NetworkViewComponent.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/eyes/tools/java/de/tub/eyes/components/NetworkViewComponent.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** NetworkViewComponent.java	12 Jan 2006 18:25:16 -0000	1.6
--- NetworkViewComponent.java	24 Apr 2006 14:56:43 -0000	1.7
***************
*** 12,15 ****
--- 12,16 ----
  import net.tinyos.message.Message;
  import de.tub.eyes.ps.*;
+ import de.tub.eyes.gis.GIS;
  import net.tinyos.surge.*;
  import net.tinyos.drain.*;
***************
*** 69,73 ****
      private JButton addToGraph, removeFromGraph;
      private JButton toggleLinksButton, toggleRenderButton, toggleBgButton;
!     private JComboBox mapCB;
      private java.util.List filterViewers;
      private boolean linksVisible;
--- 70,74 ----
      private JButton addToGraph, removeFromGraph;
      private JButton toggleLinksButton, toggleRenderButton, toggleBgButton;
!     private JComboBox mapCB, zoomCB;
      private java.util.List filterViewers;
      private boolean linksVisible;
***************
*** 77,80 ****
--- 78,83 ----
      private static Date startTime = new Date();
      private static ConfigComponent config = Demonstrator.getConfigComponent();
+     private GIS gis;
+     private int mapNo = -1;
  
      /**
***************
*** 83,86 ****
--- 86,92 ----
       */
      public NetworkViewComponent() {
+         gis = new GIS("../../gis/GIS.properties");
+         gis.init("jdbc");
+         gis.readDB();
          initComponents();
          buildUI();
***************
*** 114,118 ****
              
              DrainMsg mhmsg = (DrainMsg)m;
!             PSNotificationMsg msgTemp = new PSNotificationMsg(mhmsg, mhmsg.offset_data(0));
              ps2Msg = new PSNotificationMsg(mhmsg, mhmsg.offset_data(0), 
                      msgTemp.DEFAULT_MESSAGE_SIZE + msgTemp.get_dataLength());
--- 120,124 ----
              
              DrainMsg mhmsg = (DrainMsg)m;
!             PSNotificationMsg   msgTemp = new PSNotificationMsg(mhmsg, mhmsg.offset_data(0));
              ps2Msg = new PSNotificationMsg(mhmsg, mhmsg.offset_data(0), 
                      msgTemp.DEFAULT_MESSAGE_SIZE + msgTemp.get_dataLength());
***************
*** 129,134 ****
          }
                           
!         if (n != null)
!             n.setEpoch((int)((rcvTime.getTime()-startTime.getTime())/1000));        
              
          if (Demonstrator.isSurge()) {
--- 135,142 ----
          }
                           
!         if (n != null) {
!             n.setEpoch((int)((rcvTime.getTime()-startTime.getTime())/1000));
!             setPosition(n);
!         }
              
          if (Demonstrator.isSurge()) {
***************
*** 240,246 ****
          if (viewer != null && e.getSource() == mapCB) {
              int map = mapCB.getSelectedIndex();
!             if (map > -1)
                  viewer.setMap(map-1);
          }
      }
      
--- 248,261 ----
          if (viewer != null && e.getSource() == mapCB) {
              int map = mapCB.getSelectedIndex();
!             if (map > -1) {
                  viewer.setMap(map-1);
+                 mapNo = map-1;
+                 setPositionAll();
+             }
          }
+         
+         if (viewer != null && e.getSource() == zoomCB) {
+                 viewer.setZoom(zoomCB.getSelectedIndex());
+         }        
      }
      
***************
*** 314,321 ****
          toggleBgButton.addActionListener(this);
            
!         layout = new FormLayout("f:p:g,10dlu,l:p", "f:p,10dlu,t:1dlu:g,4dlu,t:p:g,6dlu,p");
          builder = new PanelBuilder(layout);
          
!         cpanelLayout = new FormLayout("p,12dlu,p,12dlu,p,12dlu,p", "p");
          cpanelBuilder = new PanelBuilder(cpanelLayout);
          cc = new CellConstraints();
--- 329,337 ----
          toggleBgButton.addActionListener(this);
            
!         //layout = new FormLayout("f:p:g,10dlu,l:p", "f:p,10dlu,t:1dlu:g,4dlu,t:p:g,6dlu,p");
!         layout = new FormLayout("f:d,10dlu,l:p", "f:p,10dlu,t:1dlu:g,4dlu,t:p:g,6dlu,p");        
          builder = new PanelBuilder(layout);
          
!         cpanelLayout = new FormLayout("p,12dlu,p,12dlu,p,12dlu,p,12dlu,p", "p");
          cpanelBuilder = new PanelBuilder(cpanelLayout);
          cc = new CellConstraints();
***************
*** 326,329 ****
--- 342,346 ----
          initCB();
          mapCB.addActionListener(this);
+         zoomCB.addActionListener(this);
      }
  
***************
*** 336,341 ****
          cpanelBuilder.add(toggleBgButton, cc.xy(3,1));
          cpanelBuilder.add(mapCB, cc.xy(5,1));
!         //cpanelBuilder.add(toggleRenderButton, cc.xy(5,1));        
!         builder.add(viewer, cc.xywh(1, 1, 1, 5, CellConstraints.FILL, CellConstraints.FILL));
          builder.add(nodePropertyViewer, cc.xy(3, 1, CellConstraints.DEFAULT, CellConstraints.TOP));
          builder.add(nodeListViewer.buildUI(), cc.xy(3,3, CellConstraints.DEFAULT, CellConstraints.TOP)); //added by Chen
--- 353,361 ----
          cpanelBuilder.add(toggleBgButton, cc.xy(3,1));
          cpanelBuilder.add(mapCB, cc.xy(5,1));
!         cpanelBuilder.add(zoomCB, cc.xy(7,1));        
!         //cpanelBuilder.add(toggleRenderButton, cc.xy(5,1));
!         JScrollPane scrViewer = new JScrollPane(viewer);
!         viewer.setScrollPane(scrViewer);
!         builder.add(scrViewer, cc.xywh(1, 1, 1, 5, CellConstraints.FILL, CellConstraints.FILL));
          builder.add(nodePropertyViewer, cc.xy(3, 1, CellConstraints.DEFAULT, CellConstraints.TOP));
          builder.add(nodeListViewer.buildUI(), cc.xy(3,3, CellConstraints.DEFAULT, CellConstraints.TOP)); //added by Chen
***************
*** 372,383 ****
      private void initCB() {
          mapCB = new JComboBox();
!         int mapCnt = Integer.parseInt(Demonstrator.getProps().getProperty("cntRoomMaps","-1"));
          
          mapCB.addItem("No Map");
          
          for (int cnt=0; cnt < mapCnt; cnt++) {
!             String propName = "Map Nr. " + cnt;
              mapCB.addItem(propName);
!         }                
      }
  }
--- 392,444 ----
      private void initCB() {
          mapCB = new JComboBox();
!         zoomCB = new JComboBox();
!         
!         int mapCnt = Integer.parseInt(Demonstrator.getProps().getProperty("map_cntImgs","-1"));
          
          mapCB.addItem("No Map");
          
          for (int cnt=0; cnt < mapCnt; cnt++) {
!             String propName = Demonstrator.getProps().getProperty("map_name_" + cnt,"Map " + cnt);
              mapCB.addItem(propName);
!         }
!         
!         zoomCB.addItem("75%");
!         zoomCB.addItem("100%");
!         zoomCB.addItem("125%");
!         zoomCB.addItem("150%");
!         zoomCB.addItem("175%");
!         zoomCB.addItem("200%");
!         zoomCB.setSelectedIndex(1);
!     }
!     
!     private void setPosition(Node n) {
!         if (mapNo == -1) {
!             n.setVisible(true);
!             return;
!         }
!         int uart = Integer.parseInt(Demonstrator.getProps().getProperty("uartAddr", "-1"));
!         int [] mapXY;
!         int id = n.getId();
!   
!         if (uart != -1 && id != uart)
!             id -= 1000;
!         if ((mapXY = gis.getFloorXY(id)) == null || mapXY[0] != mapNo ) {
!             n.setVisible(false);
!             return;
!         }
! 
!         int offX = Maps.getOffsetX(mapNo);
!         int offY = Maps.getOffsetY(mapNo);        
!         n.setPosition(mapXY[1]+offX, viewer.getHeight() - (mapXY[2]+offY));
!         n.setVisible(true);
!         
!     }
!     
!     private void setPositionAll() {
!         List nodes = viewer.getDiagram().getNodeList();
!         for (Iterator it = nodes.iterator(); it.hasNext();) {
!             setPosition((Node)it.next());
!         }
      }
+                        
  }



More information about the Tinyos-contrib-commits mailing list