public void addValue(long x, double y) {
      // calculate the bar in which this value should go
      int bar = (int) (x / barsize);

      double Y = y;
      if (ysum.containsKey(bar)) {

        double newyvalue = Y + ysum.get(bar);
        long newxvalue = x + xsum.get(bar);

        Integer newcount = count.get(bar) + 1;

        ysum.put(bar, newyvalue);
        xsum.put(bar, newxvalue);
        count.put(bar, newcount);
        Vector<Double> barvalues = values.get(bar);
        barvalues.add(Y);
        values.put(bar, barvalues);

      } else {
        ysum.put(bar, Y);
        xsum.put(bar, x);
        count.put(bar, 1);
        Vector<Double> barvalues = new Vector<Double>();
        barvalues.add(Y);
        values.put(bar, barvalues);
      }
    }
 public void actionPerformed(ActionEvent evt) {
   // 删除原来的JTable(JTable使用scrollPane来包装)
   if (scrollPane != null) {
     jf.remove(scrollPane);
   }
   try (
   // 根据用户输入的SQL执行查询
   ResultSet rs = stmt.executeQuery(sqlField.getText())) {
     // 取出ResultSet的MetaData
     ResultSetMetaData rsmd = rs.getMetaData();
     Vector<String> columnNames = new Vector<>();
     Vector<Vector<String>> data = new Vector<>();
     // 把ResultSet的所有列名添加到Vector里
     for (int i = 0; i < rsmd.getColumnCount(); i++) {
       columnNames.add(rsmd.getColumnName(i + 1));
     }
     // 把ResultSet的所有记录添加到Vector里
     while (rs.next()) {
       Vector<String> v = new Vector<>();
       for (int i = 0; i < rsmd.getColumnCount(); i++) {
         v.add(rs.getString(i + 1));
       }
       data.add(v);
     }
     // 创建新的JTable
     JTable table = new JTable(data, columnNames);
     scrollPane = new JScrollPane(table);
     // 添加新的Table
     jf.add(scrollPane);
     // 更新主窗口
     jf.validate();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Beispiel #3
0
  // 判断坦克是否被击中
  public void isHit(Bomb bomb, EnemyTank et) {
    //		敌人的坦克有四个方向,每个方向的坐标不同
    switch (et.getDirection()) {
        //		朝上和朝下效果一样
      case 0:
      case 2:
        // 子弹的坐标和坦克的坐标重合即为击中
        if (bomb.x > et.getX()
            && bomb.x < et.getX() + 25
            && bomb.y < et.getY() + 30
            && bomb.y > et.getY()) {
          // 子弹死亡,敌人坦克死亡
          bomb.isLive = false;
          et.isLive = false;
          BaoZha bz = new BaoZha(et.getX(), et.getY());

          baozhas.add(bz);
        }
        //		敌人坦克朝左右两边
      case 1:
      case 3:
        if (bomb.x > et.getX()
            && bomb.x < et.getX() + 30
            && bomb.y > et.getY()
            && bomb.y < et.getY() + 25) {
          // 子弹死亡,敌人坦克死亡
          bomb.isLive = false;
          et.isLive = false;
          BaoZha bz = new BaoZha(et.getX(), et.getY());
          baozhas.add(bz);
        }
    }
  }
Beispiel #4
0
  /**
   * Method that surrounds whole Arena with 4 rectangles, one for each side of Arena, that blocks
   * objects in Arena from falling out of it. The walls are placed outside the Arena so that they
   * won't reduce the space in Arena with their bodies.
   *
   * @param thickness Width of the walls.
   */
  private void encloseWithWalls(int thickness) {

    Fixed northWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(0, -thickness, screenWidth, thickness), "FixedObstacle", 1, this);
    Fixed southWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(0, screenHeight, screenWidth, thickness), "FixedObstacle", 1, this);
    Fixed eastWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(screenWidth, 0, thickness, screenHeight), "FixedObstacle", 1, this);
    Fixed westWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(-thickness, 0, thickness, screenHeight), "FixedObstacle", 1, this);

    walls.add(northWall);
    walls.add(southWall);
    walls.add(eastWall);
    walls.add(westWall);

    world.add(northWall.getBody());
    world.add(southWall.getBody());
    world.add(eastWall.getBody());
    world.add(westWall.getBody());

    isEnclosedWithWalls = true;
  }
Beispiel #5
0
 private GroovyTreeNode(GroovyTreeNode parent, GroovyNode node) {
   this.parent = parent;
   this.node = node;
   for (Map.Entry<String, String> entry : node.attributes().entrySet()) {
     children.add(new GroovyTreeNode(this, entry.getKey(), entry.getValue()));
   }
   if (node.getNodeValue() instanceof List) {
     string = node.getNodeName();
     toolTip = String.format("Size: %d", ((List) node.getNodeValue()).size());
   } else {
     String truncated = node.text();
     if (truncated.contains("\n") || truncated.length() >= MAX_LENGTH) {
       int index = truncated.indexOf('\n');
       if (index > 0) truncated = truncated.substring(0, index);
       if (truncated.length() >= MAX_LENGTH) truncated = truncated.substring(0, MAX_LENGTH);
       string = String.format("<html><b>%s</b> = %s ...</html>", node.getNodeName(), truncated);
       toolTip = tameTooltipText(node.text());
     } else {
       string = String.format("<html><b>%s</b> = %s</html>", node.getNodeName(), truncated);
       toolTip = truncated;
     }
   }
   if (this.node.getNodeValue() instanceof List) {
     for (Object sub : ((List) this.node.getNodeValue())) {
       GroovyNode subnode = (GroovyNode) sub;
       children.add(new GroovyTreeNode(this, subnode));
     }
     Collections.sort(children);
   }
 }
Beispiel #6
0
 private Vector<String> loadSpells() {
   Vector<String> spells = new Vector<String>();
   spells.add(null);
   for (RSpell.Enchantment spell : Editor.resources.getResources(RSpell.Enchantment.class)) {
     if (spell.item.equals("nutrition")) {
       spells.add(spell.id);
     }
   }
   return spells;
 }
Beispiel #7
0
  public void setValues() {
    fileColumn.setSelected(_prefs.getBoolean("fileColumn"));
    pdfColumn.setSelected(_prefs.getBoolean("pdfColumn"));
    urlColumn.setSelected(_prefs.getBoolean("urlColumn"));
    preferUrl.setSelected(!_prefs.getBoolean("preferUrlDoi"));
    preferDoi.setSelected(_prefs.getBoolean("preferUrlDoi"));
    fileColumn.setSelected(_prefs.getBoolean("fileColumn"));
    arxivColumn.setSelected(_prefs.getBoolean("arxivColumn"));

    /** * begin: special fields ** */
    oldRankingColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING);
    rankingColumn.setSelected(oldRankingColumn);

    oldCompcatRankingColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_RANKING_COMPACT);
    compactRankingColumn.setSelected(oldCompcatRankingColumn);

    oldQualityColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY);
    qualityColumn.setSelected(oldQualityColumn);

    oldPriorityColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY);
    priorityColumn.setSelected(oldPriorityColumn);

    oldRelevanceColumn = _prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE);
    relevanceColumn.setSelected(oldRelevanceColumn);

    oldSyncKeyWords = _prefs.getBoolean(SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS);
    syncKeywords.setSelected(oldSyncKeyWords);

    oldWriteSpecialFields = _prefs.getBoolean(SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS);
    writeSpecialFields.setSelected(oldWriteSpecialFields);

    // has to be called as last to correctly enable/disable the other settings
    oldSpecialFieldsEnabled = _prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED);
    specialFieldsEnabled.setSelected(!oldSpecialFieldsEnabled);
    specialFieldsEnabled.setSelected(
        oldSpecialFieldsEnabled); // Call twice to make sure the ChangeListener is triggered

    /** * end: special fields ** */
    oldShowOneLetterHeadingForIconColumns =
        _prefs.getBoolean(JabRefPreferences.SHOWONELETTERHEADINGFORICONCOLUMNS);
    showOneLetterHeadingForIconColumns.setSelected(oldShowOneLetterHeadingForIconColumns);

    tableRows.clear();
    String[] names = _prefs.getStringArray("columnNames"),
        lengths = _prefs.getStringArray("columnWidths");
    for (int i = 0; i < names.length; i++) {
      if (i < lengths.length) tableRows.add(new TableRow(names[i], Integer.parseInt(lengths[i])));
      else tableRows.add(new TableRow(names[i]));
    }
    rowCount = tableRows.size() + 5;
    ncWidth = _prefs.getInt("numberColWidth");
  }
Beispiel #8
0
 public void addConnectionListener(NCCPConnection.ConnectionListener l) {
   if (!listeners.contains(l)) {
     ExpCoordinator.printer.print(
         new String("NCCPConnection.addConnectionListener to " + toString()), 6);
     listeners.add(l);
   }
 }
Beispiel #9
0
  @Override
  public void valueChanged(TreeSelectionEvent e) {
    if (e.getSource() == colors && !locked) {
      TreeSelectionModel tsm = colors.getSelectionModel();
      TreePath tp[] = tsm.getSelectionPaths();
      if (tp == null) return;
      Vector<ClassedItem> tmp = new Vector<ClassedItem>();
      for (TreePath element : tp) {
        try {
          Object[] path = element.getPath();
          ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString());
          tmp.add(ci);
        } catch (Exception exp) {
          // User did not select a leafnode
        }
      }

      if (sceneElement instanceof NenyaImageSceneElement) {
        ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaTileSceneElement) {
        ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaComponentSceneElement) {
        ((NenyaComponentSceneElement) sceneElement)
            .getComponents()[itemList.getSelectedIndex()].setColorList(
                tmp.toArray(new ClassedItem[0]));
      }

      submitElement(sceneElement, null);
    } else {
      super.valueChanged(e);
    }
  }
 private Hashtable buildReverseMap(InputMap im) {
   KeyStroke k[] = im.allKeys();
   Hashtable h = new Hashtable();
   if (k != null) {
     for (int i = 0; i < k.length; i++) {
       Object nk = im.get(k[i]);
       Object cv = h.get(nk);
       if (h.containsKey(nk)) {
         ((Vector) cv).add(k[i]);
       } else {
         Vector v = new Vector();
         v.add(k[i]);
         h.put(nk, v);
       }
     }
   }
   return h;
 }
 public void insert(Object[] obj) {
   try {
     DefaultTableModel dtt = (DefaultTableModel) getModel();
     dtt.addRow(obj);
     dataBaru.add(getModel().getRowCount() - 1);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Beispiel #12
0
  public Vector getProperties() {
    Vector result = new Vector();
    Property name =
        new Property() {
          public String get() {
            return model.toString();
          }

          public void set(String s) {
            model.setName(s);
            repaint();
          }

          public boolean getEditable() {
            return true;
          }

          public String toString() {
            return "Name";
          }
        };
    result.add(name);
    Property heur =
        new Property() {
          public String get() {
            return (new Integer(model.getHeuristic())).toString();
          }

          public void set(String s) {
            model.setHeuristic(Integer.valueOf(s).intValue());
            repaint();
          }

          public String toString() {
            return "Heuristic";
          }

          public boolean getEditable() {
            return true;
          }
        };
    result.add(heur);
    return result;
  }
Beispiel #13
0
  public void saveAs() {
    Vector<RopeFileFilter> filters = new Vector<RopeFileFilter>();

    if (fileExt.equals("m") || fileExt.equals("mac")) {
      filters.add(new RopeFileFilter(new String[] {".m", ".mac"}, "Macro files (*.m *.mac)"));
      filters.add(
          new RopeFileFilter(
              new String[] {".a", ".asm", ".aut", ".s"}, "Assembly files (*.a *.asm *.aut *.s)"));
    } else {
      filters.add(
          new RopeFileFilter(
              new String[] {".a", ".asm", ".aut", ".s"}, "Assembly files (*.a *.asm *.aut *.s)"));
      filters.add(new RopeFileFilter(new String[] {".m", ".mac"}, "Macro files (*.m *.mac)"));
    }
    filters.add(new RopeFileFilter(new String[] {".txt"}, "Text files (*.txt)"));

    RopeFileChooser chooser = new RopeFileChooser(selectedPath, null, filters);
    chooser.setDialogTitle("Save Source File");
    String fileName = String.format("%s.%s", baseName, fileExt);
    chooser.setSelectedFile(new File(selectedPath, fileName));
    JTextField field = chooser.getTextField();
    field.setSelectionStart(0);
    field.setSelectionEnd(baseName.length());
    File file = chooser.save(ROPE.mainFrame);
    if (file != null) {
      selectedPath = file.getParent();

      BufferedWriter writer = null;
      try {
        writer = new BufferedWriter(new FileWriter(file));
        writer.write(sourceArea.getText());
      } catch (IOException ex) {
        ex.printStackTrace();
      } finally {
        try {
          if (writer != null) {
            writer.close();
          }
        } catch (IOException ex) {
          ex.printStackTrace();
        }
      }
    }
  }
Beispiel #14
0
  @Override
  public void adoptElement(SceneElement elem) {
    if (!(elem instanceof NenyaImageSceneElement
        || elem instanceof NenyaTileSceneElement
        || elem instanceof NenyaComponentSceneElement)) {
      enableEditor(false);
      return;
    }

    DefaultComboBoxModel dcm = (DefaultComboBoxModel) itemList.getModel();

    // Important: Work on a copy, not on the original. Otherwise we mess up the undomanager
    sceneElement = elem.copy();

    if ((sceneElement instanceof NenyaImageSceneElement) && !locked) {
      dcm.removeAllElements();
      String[] tmp = ((NenyaImageSceneElement) sceneElement).getPath();
      dcm.addElement(tmp[tmp.length - 1]);
    }
    if ((sceneElement instanceof NenyaTileSceneElement) && !locked) {
      dcm.removeAllElements();
      dcm.addElement(((NenyaTileSceneElement) sceneElement).getTileName());
    }
    if ((sceneElement instanceof NenyaComponentSceneElement) && !locked) {
      dcm.removeAllElements();
      NenyaComponentItem[] ni = ((NenyaComponentSceneElement) sceneElement).getComponents();
      for (NenyaComponentItem element : ni) {
        dcm.addElement(element);
      }
    }

    try {
      ClassedItem[] cols = null;
      if (elem instanceof NenyaTileSceneElement)
        cols = ((NenyaTileSceneElement) elem).getColorList();
      if (elem instanceof NenyaImageSceneElement)
        cols = ((NenyaImageSceneElement) elem).getColorList();
      if (elem instanceof NenyaComponentSceneElement) {
        NenyaComponentItem nci = (NenyaComponentItem) dcm.getSelectedItem();
        cols = nci.getColorList();
      }
      Vector<TreePath> collect = new Vector<TreePath>();
      TreeNode root = (TreeNode) colors.getModel().getRoot();
      for (ClassedItem col : cols) {
        String[] tmp = {root.toString(), col.getClassName(), col.getItemName()};
        collect.add(TreeUtil.findPath(root, tmp));
      }
      TreePath[] path = collect.toArray(new TreePath[0]);
      colors.getSelectionModel().setSelectionPaths(path);
    } catch (Exception e) {
      // Either the tree is filtered away or the selected item is not colorized.
    }

    enableEditor(true);
    itemList.setEnabled(elem instanceof NenyaComponentSceneElement);
  }
Beispiel #15
0
  private void browseAction() {
    if (selectedPath == null) {
      selectedPath = System.getenv("ROPE_SOURCES_DIR");
      if (selectedPath != null) {
        File dir = new File(selectedPath);
        if (!dir.exists() || !dir.isDirectory()) {
          String message =
              String.format(
                  "The sources path set in environment variable ROPE_SOURCES_DIR is not avaliable.\n%s",
                  selectedPath);
          JOptionPane.showMessageDialog(null, message, "ROPE", JOptionPane.WARNING_MESSAGE);
          selectedPath = null;
        } else {
          System.out.println("Source folder path set from ROPE_SOURCES_DIR: " + selectedPath);
        }
      }
      if (selectedPath == null) {
        selectedPath = System.getProperty("user.dir");

        System.out.println("Source folder path set to current directory: " + selectedPath);
      }
    }

    Vector<RopeFileFilter> filters = new Vector<RopeFileFilter>();
    filters.add(
        new RopeFileFilter(
            new String[] {".a", ".asm", ".aut", ".s"}, "Assembly files (*.a *.asm *.aut *.s)"));
    filters.add(new RopeFileFilter(new String[] {".m", ".mac"}, "Macro files (*.m *.mac)"));
    filters.add(new RopeFileFilter(new String[] {".lst"}, "List files (*.lst)"));
    filters.add(new RopeFileFilter(new String[] {".txt"}, "Text files (*.txt)"));

    RopeFileChooser chooser = new RopeFileChooser(selectedPath, null, filters);
    chooser.setDialogTitle("Source document selection");
    chooser.setFileFilter(filters.firstElement());
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    File file = chooser.open(this, fileText);
    if (file != null) {
      if (loadSourceFile(file)) {
        mainFrame.showExecWindow(baseName);
      }
    }
  }
 public Vector<PelicanPerson> getChildren() {
   Vector<PelicanPerson> result = new Vector<PelicanPerson>();
   Iterator<PelicanPerson> allPersonIt = pelican.getAllPeople().iterator();
   while (allPersonIt.hasNext()) {
     PelicanPerson possibleChild = allPersonIt.next();
     if ((possibleChild.father == this) || (possibleChild.mother == this))
       result.add(possibleChild);
   }
   return result;
 }
Beispiel #17
0
 /**
  * Registers a controller to an Active object. If the controller extends KeyboardVivaeController
  * it also registers it to the parent component as a new KeyListener.
  *
  * @param agent The Active the controller will control.
  * @param controller The controller specifing behavior of the Active object.
  */
 public void registerController(IRobotInterface agent, VivaeController controller) {
   controller.setControlledObject(agent);
   controllers.add(controller);
   if (agent instanceof VivaeRobotRepresent && controller instanceof KeyboardVivaeController) {
     if (parent != null) {
       parent.addKeyListener((KeyboardVivaeController) controller);
     }
     this.addKeyListener((KeyboardVivaeController) controller);
   }
 }
 public YIntervalSeries getYIntervalSeries(String rowname, long factor) {
   YIntervalSeries mydataset = new YIntervalSeries(rowname);
   double sdcount = 0;
   double total = 0;
   Vector<Double> totalvalues = new Vector<Double>();
   double avgtotal = 0;
   double minus = 0;
   double plus = 0;
   double zero = 0;
   for (Integer key : ysum.keySet()) {
     Double value = ysum.get(key) / (double) count.get(key);
     Double point = (double) xsum.get(key) / (double) count.get(key);
     Vector<Double> listofvalues = values.get(key);
     double sumofdiff = 0.0;
     for (Double onevalue : listofvalues) {
       sumofdiff += Math.pow(onevalue - value, 2);
       sdcount++;
       total += Math.pow(onevalue, 2);
       avgtotal += onevalue;
       totalvalues.add(onevalue);
       if (onevalue == 1) {
         plus++;
       }
       ;
       if (onevalue == -1) {
         minus++;
       }
       ;
       if (onevalue == 0) {
         zero++;
       }
       ;
     }
     double sd = Math.sqrt(sumofdiff / count.get(key));
     // mydataset.add(point/factor, value,value+sd,value-sd);
     // mydataset.add(point/factor, value,value,value);
     mydataset.add(
         point / factor,
         value,
         value + 1.96 * (sd / Math.sqrt(count.get(key))),
         value - 1.96 * (sd / Math.sqrt(count.get(key))));
   }
   double sdtotal = 0;
   double avgsd = total / sdcount;
   double test = 0;
   for (Double onevalue : totalvalues) {
     sdtotal += Math.pow(Math.pow(onevalue, 2) - (total / sdcount), 2);
     test += onevalue;
   }
   // System.out.println(rowname+" mean square: "+avgsd+"
   // +/-95%:"+1.96*Math.sqrt(sdtotal/sdcount)/Math.sqrt(sdcount));
   // System.out.println("total -1:"+minus+" total +1:"+plus+" zero: "+zero
   // +" total:"+sdcount);
   return mydataset;
 }
Beispiel #19
0
  /**
   * Show a dialog for printing the current drawing.
   *
   * @param fff the parent frame which will be used for dialogs and message boxes.
   * @param CCr the CircuitPanel containing the drawing to be exported.
   */
  public void printDrawing(JFrame fff, CircuitPanel CCr) {
    cc = CCr;
    DialogPrint dp = new DialogPrint(fff);
    dp.setMirror(printMirror);
    dp.setFit(printFitToPage);
    dp.setBW(printBlackWhite);
    dp.setLandscape(printLandscape);
    dp.setVisible(true);

    // Get some information about the printing options.
    printMirror = dp.getMirror();
    printFitToPage = dp.getFit();
    printLandscape = dp.getLandscape();
    printBlackWhite = dp.getBW();

    Vector<LayerDesc> ol = cc.dmp.getLayers();
    if (dp.shouldPrint()) {
      if (printBlackWhite) {
        Vector<LayerDesc> v = new Vector<LayerDesc>();

        // Here we create an alternative array of layers in
        // which all colors are pitch black. This may be
        // useful for PCB's.

        for (int i = 0; i < LayerDesc.MAX_LAYERS; ++i)
          v.add(
              new LayerDesc(
                  new ColorSwing(Color.black),
                  ((LayerDesc) ol.get(i)).getVisible(),
                  "B/W",
                  ((LayerDesc) ol.get(i)).getAlpha()));
        cc.dmp.setLayers(v);
      }
      PrinterJob job = PrinterJob.getPrinterJob();
      job.setPrintable(this);
      boolean ok = job.printDialog();
      if (ok) {
        try {
          PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
          // Set the correct printing orientation.
          if (printLandscape) {
            aset.add(OrientationRequested.LANDSCAPE);
          } else {
            aset.add(OrientationRequested.PORTRAIT);
          }
          job.print(aset);
        } catch (PrinterException ex) {
          // The job did not successfully complete
          JOptionPane.showMessageDialog(fff, Globals.messages.getString("Print_uncomplete"));
        }
      }
      cc.dmp.setLayers(ol);
    }
  }
Beispiel #20
0
  public MyPanel() {
    hero = new Hero(10, 100);

    for (int i = 0; i < enemysize; i++) {
      // 创建一辆敌人的坦克
      EnemyTank et = new EnemyTank((i + 1) * 50, 0);
      et.setColor(1);
      et.setDirect(2);
      ets.add(et);
    }
  }
  public Collection<Element> getConfigXML() {
    Vector<Element> config = new Vector<Element>();
    Element element;

    // Infinite boolean
    element = new Element("id");
    element.setText(Integer.toString(moteID));
    config.add(element);

    return config;
  }
 private void addNewRow() {
   Object[] row_data = new Object[2];
   if (rowData.size() < 1) { // add a new html filter
     row_data[0] = "text/html";
   } else {
     row_data[0] = "Enter MIME type";
   }
   row_data[1] = "Replace with " + mimeTypeEditorBuilder.getValueClassName() + " class name";
   logger.debug3("Adding new row");
   rowData.add(row_data);
   fireTableDataChanged();
 }
 public void updateTableData() {
   // we need to get the stored filters
   Object[] row_data;
   rowData.removeAllElements();
   for (Iterator it = m_filters.keySet().iterator(); it.hasNext(); ) {
     row_data = new Object[2];
     row_data[0] = it.next();
     row_data[1] = m_filters.get(row_data[0]);
     rowData.add(row_data);
   }
   fireTableDataChanged();
 }
Beispiel #24
0
  public Collection<Element> getConfigXML() {
    Vector<Element> config = new Vector<Element>();
    Element element;

    // X coordinate
    element = new Element("x");
    element.setText(Double.toString(getXCoordinate()));
    config.add(element);

    // Y coordinate
    element = new Element("y");
    element.setText(Double.toString(getYCoordinate()));
    config.add(element);

    // Z coordinate
    element = new Element("z");
    element.setText(Double.toString(getZCoordinate()));
    config.add(element);

    return config;
  }
Beispiel #25
0
  /**
   * List results by date
   *
   * @param reslist result list
   * @param ldisp
   */
  private void listByDateRun(ResultList reslist, boolean ldisp) {
    StringTokenizer tokenizer = new StringTokenizer((String) reslist.get("list"), "\n");

    Vector vdata = new Vector();
    while (tokenizer.hasMoreTokens()) {
      String data = convertToPretty(tokenizer.nextToken());
      if (datasets.contains(data) || ldisp) vdata.add(data);
    }
    datasets.removeAllElements();

    Enumeration en = vdata.elements();
    while (en.hasMoreElements()) datasets.addElement(en.nextElement());
  }
Beispiel #26
0
 public void sendMessage(NCCP.Message msg) {
   if (isClosed() || isFailed()) connect();
   if (isConnected()) {
     ExpCoordinator.printer.print("NCCPConnection::sendMessage", 5);
     if (proxy != null) proxy.sendMessage(msg, this);
     else {
       if (nonProxy != null) nonProxy.sendMessage(msg);
     }
   } else // still can't connect
   {
     pendingMessages.add(msg);
   }
 }
  public DefaultComboBoxModel createListModel(List<String> keys) {
    // convert to a list of strings
    Vector<String> stringList = new Vector<String>(keys);
    boolean sorted = preSort(stringList);

    if (!sorted && Comparable.class.isAssignableFrom(getClassModel().getContainedClass())) {
      Collections.sort(stringList);
    }

    if (!(containedByListReferenceGUI || isMandatory())) {
      stringList.add(0, NULL);
    }
    return new DefaultComboBoxModel(stringList);
  }
  private void applyChanges() {
    boolean changedFieldSet = false; // Watch if we need to rebuild entry editors

    // First remove the mappings for fields that have been deleted.
    // If these were re-added, they will be added below, so it doesn't
    // cause any harm to remove them here.
    for (Iterator<String> i = removedFields.iterator(); i.hasNext(); ) {
      String fieldName = i.next();
      metaData.remove(Globals.SELECTOR_META_PREFIX + fieldName);
      changedFieldSet = true;
    }

    // Cycle through all fields that we have created listmodels for:
    loop:
    for (Iterator<String> i = wordListModels.keySet().iterator(); i.hasNext(); ) {
      // For each field name, store the values:
      String fieldName = i.next();
      if ((fieldName == null) || FIELD_FIRST_LINE.equals(fieldName)) continue loop;
      DefaultListModel lm = wordListModels.get(fieldName);
      int start = 0;
      // Avoid storing the <new word> marker if it is there:
      if (lm.size() > 0)
        while ((start < lm.size()) && (lm.get(start)).equals(WORD_FIRSTLINE_TEXT)) start++;
      Vector<String> data = metaData.getData(Globals.SELECTOR_META_PREFIX + fieldName);
      boolean newField = false;
      if (data == null) {
        newField = true;
        data = new Vector<String>();
        changedFieldSet = true;

      } else data.clear();
      for (int wrd = start; wrd < lm.size(); wrd++) {
        String word = (String) lm.get(wrd);
        data.add(word);
      }
      if (newField) metaData.putData(Globals.SELECTOR_META_PREFIX + fieldName, data);
    }

    // System.out.println("TODO: remove metadata for removed selector field.");
    panel.markNonUndoableBaseChanged();

    // Update all selectors in the current BasePanel.
    if (changedFieldSet) {
      panel.rebuildAllEntryEditors();
    } else {
      panel.updateAllContentSelectors();
    }
    panel.addContentSelectorValuesToAutoCompleters();
  }
Beispiel #29
0
  public void nick_name(String msg) {
    try {
      String name = msg.substring(13);
      this.setName(name);
      Vector v = father.onlineList;
      boolean isRepeatedName = false;
      int size = v.size();
      for (int i = 0; i < size; i++) {
        ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
        if (tempSat.getName().equals(name)) {
          isRepeatedName = true;
          break;
        }
      }
      if (isRepeatedName == true) {
        dout.writeUTF("<#NAME_REPEATED#>");
        din.close();
        dout.close();
        sc.close();
        flag = false;
      } else {
        v.add(this);
        father.refreshList();
        String nickListMsg = "";
        StringBuilder nickListMsgSb = new StringBuilder();
        size = v.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
          nickListMsgSb.append("!");
          nickListMsgSb.append(tempSat.getName());
        }
        nickListMsgSb.append("<#NICK_LIST#>");
        nickListMsg = nickListMsgSb.toString();
        Vector tempv = father.onlineList;
        size = tempv.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) tempv.get(i);
          tempSat.dout.writeUTF(nickListMsg);
          if (tempSat != this) {
            tempSat.dout.writeUTF("<#MSG#>" + this.getName() + "is now online....");
          }
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  /**
   * Register a wizard panel
   *
   * @param id the panel ID
   * @param panel the panel
   */
  protected void registerWizardPanel(Object id, WizardPanel panel) {

    panel.key = id;
    panel.wizard = this;

    panels.add(panel);
    panelMap.put(id, panel);

    cardPanel.add(panel.getPanel(), panel.toString());

    if (firstPanel == null) {
      firstPanel = panel;
      currentPanel = panel;
      setCurrentPanel(panel);
      pack();
    }
  }