[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/eyes/tools/java/de/tub/eyes/diagram JConfigurableDiagramViewer.java, 1.2, 1.3

Till Wimmer twimmer at users.sourceforge.net
Mon Apr 24 07:16:05 PDT 2006


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

Modified Files:
	JConfigurableDiagramViewer.java 
Log Message:
move getXYTable to new GIS class; added map handling

Index: JConfigurableDiagramViewer.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/eyes/tools/java/de/tub/eyes/diagram/JConfigurableDiagramViewer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** JConfigurableDiagramViewer.java	2 Nov 2005 20:43:29 -0000	1.2
--- JConfigurableDiagramViewer.java	24 Apr 2006 14:16:03 -0000	1.3
***************
*** 8,11 ****
--- 8,13 ----
  
  import de.tub.eyes.apps.demonstrator.*;
+ import de.tub.eyes.gis.*;
+ 
  import java.util.*;
  import java.util.regex.*;
***************
*** 13,16 ****
--- 15,19 ----
  import java.io.IOException;
  
+ import java.awt.Dimension;
  /**
   *
***************
*** 20,36 ****
      
      //private Demonstrator d;
!     private Map xyMap = new TreeMap();
      /** Creates a new instance of JConfigurableDiagramViewer */
      public JConfigurableDiagramViewer() {
          super();
-         readXYTable();
      }
      
-     private class MoteXY {
-         int x;
-         int y;
-         int room;
-     }
- 
      /**
       * Convenience Method. Adds a new Node with the given id to the Diagram.
--- 23,33 ----
      
      //private Demonstrator d;
!     private int mapNo=-1;
!     
      /** Creates a new instance of JConfigurableDiagramViewer */
      public JConfigurableDiagramViewer() {
          super();
      }
      
      /**
       * Convenience Method. Adds a new Node with the given id to the Diagram.
***************
*** 50,55 ****
          return n;
      }
-     
      private int getNewX(int id) {
          MoteXY xy;
          //System.out.println("Width = "+this.getWidth());
--- 47,66 ----
          return n;
      }
      private int getNewX(int id) {
+         if (this.getWidth() == 0)
+             return random.nextInt(DEFAULT_WIDTH)+10;
+         else
+             return random.nextInt(this.getWidth()-20)+10;                                   
+     }
+          
+     private int getNewY(int id) {                     
+         if (this.getHeight() ==0)
+             return random.nextInt(DEFAULT_HEIGHT)+10;
+         else
+             return random.nextInt(this.getHeight()-20)+10;
+     }
+     
+     /*
+      private int getNewX(int id) {
          MoteXY xy;
          //System.out.println("Width = "+this.getWidth());
***************
*** 59,63 ****
          else {
              if (this.getWidth() == 0)
!                 return random.nextInt(580)+10;
              else
                  return random.nextInt(this.getWidth()-20)+10;                                   
--- 70,74 ----
          else {
              if (this.getWidth() == 0)
!                 return random.nextInt(DEFAULT_WIDTH)+10;
              else
                  return random.nextInt(this.getWidth()-20)+10;                                   
***************
*** 72,126 ****
          else {
              if (this.getHeight() ==0)
!                 return random.nextInt(580)+10;
              else
                  return random.nextInt(this.getHeight()-20)+10;
          }
      }
      
!     private int getNewZ(int id) {
!         MoteXY xy;
!         if ( (xy = (MoteXY)xyMap.get(new Integer(id))) != null ) {
!             return xy.room;           
!         }
!         else 
!             return 0;        
!     }
      
!     private void readXYTable () {
!         String line;
!         String fname;
! 
!         if ( (fname = Demonstrator.getProps().getProperty("XYtableFile")) == null 
!                 || fname.equals("") )
!             return;
! 
!         File fh = new File(fname);
!         
!         try {
!             FileReader fr = new FileReader(fh);
!             BufferedReader in = new BufferedReader(fr);
!             while ((line = in.readLine()) != null) {
!                 MoteXY xy = new MoteXY();
!                 String [] data  = Pattern.compile("\t").split(line);
!                 if (data.length < 4) {
!                     System.err.println ("readTable(): XY Parse error");
!                     continue;
!                 }
!                 Integer id = new Integer(data[0]);
!                 xy.x = Integer.parseInt(data[1]);
!                 xy.y = Integer.parseInt(data[2]);
!                 xy.room = Integer.parseInt(data[3]);
!                 
!                 //nodeMap.put(new Integer(nodeData.ID), nodeData);
!                 xyMap.put(id, xy);
!             }
!         }
!         catch (FileNotFoundException e) {
!             System.err.println("File " + fname + ":" + e);
!         }
!         catch (IOException e) {
!             System.err.println(e.getMessage());
!         }
      }
!         
  }
--- 83,100 ----
          else {
              if (this.getHeight() ==0)
!                 return random.nextInt(DEFAULT_HEIGHT)+10;
              else
                  return random.nextInt(this.getHeight()-20)+10;
          }
      }
+     */
+ 
      
!  
      
!     public void setMap(int mapNo) {
!         this.mapNo = mapNo;
!         super.setMap(mapNo);
      }
!             
  }



More information about the Tinyos-contrib-commits mailing list