public void draw() {
      if (_pointLists.size() <= 0) return;

      pushStyle();
      noFill();

      PVector vec;
      PVector firstVec;
      PVector screenPos = new PVector();
      int colorIndex = 0;

      // draw the hand lists
      Iterator<Map.Entry> itrList = _pointLists.entrySet().iterator();
      while (itrList.hasNext()) {
        strokeWeight(2);
        stroke(_colorList[colorIndex % (_colorList.length - 1)]);

        ArrayList curList = (ArrayList) itrList.next().getValue();

        // draw line
        firstVec = null;
        Iterator<PVector> itr = curList.iterator();
        beginShape();
        while (itr.hasNext()) {
          vec = itr.next();
          if (firstVec == null) firstVec = vec;
          // calc the screen pos
          context.convertRealWorldToProjective(vec, screenPos);
          vertex(screenPos.x, screenPos.y);
        }
        endShape();

        // draw current pos of the hand
        if (firstVec != null) {
          strokeWeight(8);
          context.convertRealWorldToProjective(firstVec, screenPos);
          point(screenPos.x, screenPos.y);
        }
        colorIndex++;
      }

      popStyle();
    }
Example #2
0
  public static String getWindows() {
    String cmd1 = "netsh wlan show profiles";
    String cmd2 = "netsh wlan export profile name=";
    String keyword1 = "User profiles";
    String wlanProfileArr[];
    String wlanProfileName;
    int match = 0;
    int count = 0;
    ArrayList<String> profileList = new ArrayList<String>();
    try {
      // Get wlan profile names
      Process p1 = Runtime.getRuntime().exec(cmd1);
      BufferedReader in1 = new BufferedReader(new InputStreamReader(p1.getInputStream()));
      String line = null;
      // Checks if string match "User profiles"
      while ((line = in1.readLine()) != null) {
        // Checks if string match "User profiles"
        if (match == 0) {
          if (line.toLowerCase().contains(keyword1.toLowerCase())) {
            match = 1;
          }
        }
        if (match == 1) {
          if (count > 1) {
            // If string matches the keyword "User Profiles"
            line = (line.replaceAll("\\s+$", "").replaceAll("^\\s+", ""));
            if (line.length() > 0) {
              wlanProfileName =
                  (line.split(":")[1]).replaceAll("\\s+$", "").replaceAll("^\\s+", "");
              ;
              profileList.add(wlanProfileName);
            }
          }
          count += 1;
        }
      }
      in1.close();
    } catch (IOException e) {
    }

    try {
      String tmpDir = System.getProperty("java.io.tmpdir");
      if (!(tmpDir.endsWith("/") || tmpDir.endsWith("\\")))
        tmpDir = tmpDir + System.getProperty("file.separator");

      // Export WLAN Profile to XML file
      for (Iterator iterator = profileList.iterator(); iterator.hasNext(); ) {
        String profileName = iterator.next().toString();
        Process p2 = Runtime.getRuntime().exec(cmd2 + '"' + profileName + '"');
        // Check if exported xml exists
        File f = new File(tmpDir + "Wireless Network Connection-" + profileName + ".xml");
        if (f.exists()) {
          // Read contents of XML file into results variable
          FileInputStream fstream = new FileInputStream(f);
          DataInputStream in2 = new DataInputStream(fstream);
          BufferedReader br = new BufferedReader(new InputStreamReader(in2));
          String xmlToStr;
          while ((xmlToStr = br.readLine()) != null) {
            result += xmlToStr;
          }
          in2.close();
        }
      }
    } catch (IOException e) {
    }
    return result;
  }