Example #1
0
  // ------------------------------------------------------------------------
  // SCREEN PAINTER
  // Put some function here to paint whatever you want over the screen before and after
  // all edges and nodes have been painted.
  public void PaintScreenBefore(Graphics g) {

    Dimension d = MainClass.mainFrame.GetGraphDisplayPanel().getSize();
    NodeInfo nodeInfo;
    int x = 0;
    int y = 0;
    int step = 10;

    for (; x < d.width; x += step) {
      for (y = 0; y < d.height; y += step) {
        double val = 0;
        double sum = 0;
        double total = 0;
        double min = 10000000;
        for (Enumeration nodes = proprietaryNodeInfo.elements(); nodes.hasMoreElements(); ) {
          nodeInfo = (NodeInfo) nodes.nextElement();
          double dist = distance(x, y, nodeInfo.centerX, nodeInfo.centerY);
          if (nodeInfo.value != -1 && nodeInfo.nodeNumber.intValue() != 1) { // 121
            if (dist < min) min = dist;
            val += ((double) nodeInfo.value) / dist / dist;
            sum += (1 / dist / dist);
          }
        }
        int reading = (int) (val / sum);
        reading = reading >> 2;
        if (reading > 255) reading = 255;
        g.setColor(new Color(reading, reading, reading));
        g.fillRect(x, y, step, step);
      }
    }
  }
Example #2
0
  protected Vector /* of TTPNode */ queryPNodes1(String query) throws IOException {
    write(query);
    Vector lines = readlines();
    Vector r = new Vector();
    for (Enumeration e = lines.elements(); e.hasMoreElements(); ) {
      Vector line = stringToVector((String) e.nextElement(), ":");

      TTLexEntry le = new TTLexEntry();
      le.citationForm = (String) line.elementAt(0);
      le.features = (String) line.elementAt(1);
      le.inflection = (String) line.elementAt(2);
      le.inflFeatures = (String) line.elementAt(3);

      TTLexEntryToObj leo = new TTLexEntryToObj();
      leo.lexentry = le;
      leo.objname = (String) line.elementAt(4);
      leo.features = (String) line.elementAt(5);

      TTPNode pn = new TTPNode();
      pn.feature = TT.featureGet(le.features, TT.FT_POS, TT.F_NULL);
      pn.leo = leo;
      pn.startpos = TT.longParse((String) line.elementAt(8), true);
      pn.endpos = TT.longParse((String) line.elementAt(9), true);

      r.addElement(pn);
    }
    return r;
  }
Example #3
0
 protected Vector /* of Object */ queryAssertionLines1(String query) throws IOException {
   write(query);
   Vector v = readlines();
   Vector r = new Vector();
   for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
     r.addElement(TT.stringToObject((String) e.nextElement()));
   }
   return r;
 }
Example #4
0
  public static void main(String args[]) {
    Hashtable<String, Integer> table = new Hashtable<String, Integer>();

    table.put("Hello", 4);
    table.put("Intro", 24);
    table.put("Auroville", 10);

    // iterate over the keys of the hash table
    Enumeration<String> keys = table.keys();
    while (keys.hasMoreElements()) {
      String k = keys.nextElement();
      System.out.println("found key " + k);
    }
  }
 @PostConstruct
 public void getHostAdderesAndConnectToMS() {
   try {
     Enumeration e = NetworkInterface.getNetworkInterfaces();
     while (e.hasMoreElements()) {
       NetworkInterface n = (NetworkInterface) e.nextElement();
       Enumeration ee = n.getInetAddresses();
       while (ee.hasMoreElements()) {
         InetAddress i = (InetAddress) ee.nextElement();
         if (i.getHostAddress().contains("10.") || i.getHostAddress().contains("192.")) {
           hostAdder = i.getHostAddress().trim();
           System.out.println("Run at start. IP:" + hostAdder);
           if (masterService.connectPS(hostAdder) == FAILED) {
             System.out.println("Could not connect to MS. Shutting down");
             System.exit(0);
           }
           return;
         }
       }
     }
   } catch (Exception e) {
   }
 }
  public void maybe_fire_guns() {
    Enumeration gs;
    Gun gun;
    TwoWheeledVehicle v;

    gs = this.guns.elements();
    while (gs.hasMoreElements()) {
      gun = (Gun) gs.nextElement();
      if (gun.firing()) {
        gun.fired_flag = true;
        v = gun.vehicle_hit_by(world);
        if (!(v == null)) {
          gun.apply_to_vehicle(v);
        }
      }
    }
  }
 public JPanel getPanelForProperties(Properties propsArg) {
   // clear();
   propKeyList = new ArrayList();
   propValueList = new ArrayList();
   for (Enumeration e = propsArg.propertyNames(); e.hasMoreElements(); ) {
     String name = (String) e.nextElement();
     String value = (String) propsArg.getProperty(name);
     XmlUIElement el = getXmlUIElementFor("textfield");
     if (el != null) {
       propKeyList.add(name);
       el.setValue(value);
       if (name.endsWith("#")) {
         el.setLabelName(name.substring(0, name.length() - 1));
       } else {
         el.setLabelName(name);
       }
       propValueList.add(el);
     }
   }
   return getPanelFor(propValueList);
 }
Example #8
0
  protected Vector /* of TTLexEntryToObj */ queryLeos1(String query) throws IOException {
    write(query);
    Vector lines = readlines();
    Vector r = new Vector();
    for (Enumeration e = lines.elements(); e.hasMoreElements(); ) {
      Vector line = stringToVector((String) e.nextElement(), ":");

      TTLexEntry le = new TTLexEntry();
      le.citationForm = (String) line.elementAt(0);
      le.features = (String) line.elementAt(1);
      le.inflection = (String) line.elementAt(2);
      le.inflFeatures = (String) line.elementAt(3);

      TTLexEntryToObj leo = new TTLexEntryToObj();
      leo.lexentry = le;
      leo.objname = (String) line.elementAt(4);
      leo.features = (String) line.elementAt(5);

      r.addElement(leo);
    }
    return r;
  }