private void handleEntryAction(ActionEvent actionEvent)
      throws IOException, ParserConfigurationException, XPathExpressionException, SAXException,
          NoItemException {
    if (this.getGazetteer() == null) {
      Util.getLogger().severe("No gazeteer is registered");
      return;
    }

    String lookupString;

    JComboBox cmb = ((JComboBox) actionEvent.getSource());
    lookupString = cmb.getSelectedItem().toString();

    if (lookupString == null || lookupString.length() < 1) return;

    java.util.List<PointOfInterest> results = this.gazetteer.findPlaces(lookupString);
    if (results == null || results.size() == 0) return;

    this.controller.moveToLocation(results.get(0));

    // Add it to the list if not already there
    for (int i = 0; i < cmb.getItemCount(); i++) {
      Object oi = cmb.getItemAt(i);
      if (oi != null && oi.toString().trim().equals(lookupString)) return; // item exists
    }
    cmb.insertItemAt(lookupString, 0);
  }
  private Locale getLocale() {

    java.util.List result = new java.util.ArrayList();
    String language = "";
    String country = "";
    String variant = "";

    // -----------------------------------------------------------------
    // <locale language="en" country="GB" variant="J" />
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_LOCALE);
    if (result.size() == 1) {
      Element el = (Element) result.get(0);
      language = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_LANGUAGE);
      country = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_COUNTRY);
      variant = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_VARIANT);
    }

    if (language.length() == 0) {
      return null;
    }
    // if (country.length() == 0) {
    // return new Locale(language);
    // }
    // if (variant.length() == 0) {
    // return new Locale(language, country);
    // }

    return new Locale(language, country, variant);
  }
Example #3
0
  private void updateEditorView() {
    editorPane.setText("");
    numParameters = 0;
    try {
      java.util.List elements = editableTemplate.getPrintfElements();
      for (Iterator it = elements.iterator(); it.hasNext(); ) {
        PrintfUtil.PrintfElement el = (PrintfUtil.PrintfElement) it.next();
        if (el.getFormat().equals(PrintfUtil.PrintfElement.FORMAT_NONE)) {
          appendText(el.getElement(), PLAIN_ATTR);
        } else {
          insertParameter(
              (ConfigParamDescr) paramKeys.get(el.getElement()),
              el.getFormat(),
              editorPane.getDocument().getLength());
        }
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(
          this,
          "Invalid Format: " + ex.getMessage(),
          "Invalid Printf Format",
          JOptionPane.ERROR_MESSAGE);

      selectedPane = 1;
      printfTabPane.setSelectedIndex(selectedPane);
      updatePane(selectedPane);
    }
  }
Example #4
0
    public boolean importData(JComponent comp, Transferable t) {
      // Make sure we have the right starting points
      if (!(comp instanceof JTable)) {
        return false;
      }
      if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        return false;
      }

      try {
        java.util.List data = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);
        Iterator i = data.iterator();
        while (i.hasNext()) {
          File f = (File) i.next();
          frame.importDataFile(f);
        }
        return true;
      } catch (UnsupportedFlavorException ufe) {
        System.err.println("Ack! we should not be here.\nBad Flavor.");
      } catch (IOException ioe) {
        System.out.println("Something failed during import:\n" + ioe);
      } catch (ImportException e) {
        e
            .printStackTrace(); // To change body of catch statement use File | Settings | File
                                // Templates.
      }
      return false;
    }
  public void run() {
    try {

      setStatus("Gathering chunks...");
      gatherChunks();
      createCompositeCanvas();
      setStatus("Sorting chunks...");
      sortChunks();
      java.util.List<BufferedImage> batchImages = new ArrayList<BufferedImage>();
      java.util.List<Chunk> nextBatch = new ArrayList<Chunk>();
      int totalChunks = getTotalChunks();
      int chunksRendered = 0;
      while (hasChunks()) {
        getNextBatch(nextBatch);
        setStatus("Rendering... " + chunksRendered + "/" + totalChunks);
        renderChunkBatch(nextBatch, batchImages);
        chunksRendered += nextBatch.size();
        renderBatchResult(nextBatch, batchImages);
      }
      setStatus("Writing image...");
      writeAndDisplayImage();
    } catch (final Exception e) {
      e.printStackTrace();
      if (frame != null) {
        setStatus("Exception: " + e.toString());
      }
    }
  }
  public static void main(String args[]) {

    IntensityFeatureScaleSpacePyramidApp<ImageFloat32, ImageFloat32> app =
        new IntensityFeatureScaleSpacePyramidApp<ImageFloat32, ImageFloat32>(
            ImageFloat32.class, ImageFloat32.class);

    //		IntensityFeatureScaleSpacePyramidApp<ImageUInt8, ImageSInt16> app2 =
    //				new
    // IntensityFeatureScaleSpacePyramidApp<ImageUInt8,ImageSInt16>(ImageUInt8.class,ImageSInt16.class);

    java.util.List<PathLabel> inputs = new ArrayList<PathLabel>();

    inputs.add(new PathLabel("shapes", "../data/evaluation/shapes01.png"));
    inputs.add(new PathLabel("sunflowers", "../data/evaluation/sunflowers.png"));
    inputs.add(new PathLabel("beach", "../data/evaluation/scale/beach02.jpg"));

    app.setInputList(inputs);

    // wait for it to process one image so that the size isn't all screwed up
    while (!app.getHasProcessedImage()) {
      Thread.yield();
    }

    ShowImages.showWindow(app, "Feature Scale Space Pyramid Intensity");
  }
Example #7
0
  /**
   * Find the two clusters with the shortest Wishart distance among all clusters in the given
   * cluster list.
   *
   * @param clusterCenterList The cluster list.
   * @param clusterPair The indices of the two clusters with the shortest Wishart distance.
   * @return The shortest Wishart distance.
   */
  private double computeShortestDistance(
      final java.util.List<ClusterInfo> clusterCenterList, final int[] clusterPair) {

    final int numClusters = clusterCenterList.size();
    double shortestDistance = Double.MAX_VALUE;
    if (numClusters <= 3) {
      return shortestDistance;
    }

    double d;
    for (int i = 0; i < numClusters - 1; i++) {
      if (clusterCenterList.get(i).size >= maxClusterSize) {
        continue;
      }

      for (int j = i + 1; j < numClusters; j++) {
        if (clusterCenterList.get(j).size >= maxClusterSize) {
          continue;
        }

        d =
            HAlphaWishart.computeWishartDistance(
                clusterCenterList.get(i).centerRe,
                clusterCenterList.get(i).centerIm,
                clusterCenterList.get(j));

        if (d < shortestDistance) {
          shortestDistance = d;
          clusterPair[0] = i;
          clusterPair[1] = j;
        }
      }
    }
    return shortestDistance;
  }
  private void resetSemImEditor() {
    java.util.List<SemEstimator> semEstimators = wrapper.getMultipleResultList();

    if (semEstimators.size() == 1) {
      SemEstimator estimatedSem = semEstimators.get(0);
      SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem()));
      panel.removeAll();
      panel.add(editor, BorderLayout.CENTER);
      panel.revalidate();
      panel.repaint();

    } else {
      JTabbedPane tabs = new JTabbedPane();

      for (int i = 0; i < semEstimators.size(); i++) {
        SemEstimator estimatedSem = semEstimators.get(i);
        SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem()));
        JPanel _panel = new JPanel();
        _panel.setLayout(new BorderLayout());
        _panel.add(editor, BorderLayout.CENTER);
        tabs.addTab(estimatedSem.getDataSet().getName(), _panel);
      }

      panel.removeAll();
      panel.add(tabs);
      panel.validate();
    }
  }
Example #9
0
  public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
      try {
        content =
            (java.util.List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
        repaint();
      } catch (UnsupportedFlavorException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      dtde.dropComplete(true);

      boolean listsAreEqual = true;

      for (int i = 0; i < content.size(); i++) {
        if (!FileListTransferable.files[i].getName().equals(content.get(i).getName())) {
          listsAreEqual = false;
        }
      }

      if (listsAreEqual) {
        System.err.println(InterprocessMessages.EXECUTION_IS_SUCCESSFULL);
        System.exit(0);
      }
    }
    dtde.rejectDrop();
    System.err.println(InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED);
    System.exit(1);
  }
 public void setTablaPrincipal(java.util.List val) {
   DefaultTableModel modelo = ((DefaultTableModel) this.tablaPrincipal.getModel());
   for (int i = 0; i < val.size(); i++) {
     modelo.addRow(((java.util.ArrayList) val.get(i)).toArray());
   }
   this.calculaSumas();
 }
Example #11
0
  private Component iciciCodeMappings() {
    java.util.List<TableDisplayInput> displayInputs = new ArrayList<TableDisplayInput>();

    displayInputs.add(new StringDisplayInput("ICICICode", "getIciciCode"));
    displayInputs.add(new StringDisplayInput("StockCode", "getStockCode"));

    List<ICICICodeMapping> list = Controller.getIciciMappings();
    PMTableModel tableModel =
        new PMTableModel(list, displayInputs, false) {
          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return columnIndex == 1;
          }

          @Override
          public void setValueAt(Object value, int rowIndex, int columnIndex) {
            ((ICICICodeMapping) dataVOs.get(rowIndex)).setStock((StockVO) value);
          }
        };
    table = UIHelper.createTable(tableModel);
    table
        .getColumnModel()
        .getColumn(1)
        .setCellEditor(new DefaultCellEditor(UIHelper.createStockVOlistJCB()));
    return UIHelper.createScrollPane(table);
  }
 private boolean isSynthIcon(Icon icon) {
   if (_synthIconMap == null) {
     _synthIconMap = new HashMap<String, Boolean>();
   }
   Class<?> aClass = icon.getClass();
   java.util.List<String> classNamesToPut = new ArrayList<String>();
   boolean isSynthIcon = false;
   while (aClass != null) {
     String name = aClass.getCanonicalName();
     if (name != null) {
       Boolean value = _synthIconMap.get(name);
       if (value != null) {
         return value;
       }
       classNamesToPut.add(name);
       if (isSynthIconClassName(name)) {
         isSynthIcon = true;
         break;
       }
     }
     aClass = aClass.getSuperclass();
   }
   for (String name : classNamesToPut) {
     _synthIconMap.put(name, isSynthIcon);
   }
   return isSynthIcon;
 }
 public void init(java.util.List<Pair<String, TextWithImports>> data) {
   myData.clear();
   for (Iterator<Pair<String, TextWithImports>> it = data.iterator(); it.hasNext(); ) {
     final Pair<String, TextWithImports> pair = it.next();
     myData.add(new Row(pair.getFirst(), pair.getSecond()));
   }
 }
Example #14
0
 /**
  * ** Gets a list of all the argument key names ** @return a list of all the argument key names
  */
 public java.util.List<String> getArgNames() {
   java.util.List<String> knList = new Vector<String>();
   for (KeyVal kv : this.getKeyValList()) {
     knList.add(kv.getKey());
   }
   return knList;
 }
Example #15
0
  private void spawnRandomers() {
    for (int i = 0; i < randomN; i++) {
      float x = (float) Math.random() * width;
      float y = (float) Math.random() * height;
      float r =
          (float)
              Math.sqrt(
                  Math.pow(((Player) players.get(0)).getX() - x, 2)
                      + Math.pow(((Player) players.get(0)).getY() - x, 2));

      while (r < distanceLimit) {
        x = (float) Math.random() * width;
        y = (float) Math.random() * height;
        r =
            (float)
                Math.sqrt(
                    Math.pow(((Player) players.get(0)).getX() - x, 2)
                        + Math.pow(((Player) players.get(0)).getY() - y, 2));
      }

      enemies.add(new EnemyTypes.Random(x, y, 0.5f, borders));
    }

    spawnRandomersB = false;
  }
    public void actionPerformed(ActionEvent e) {
      JTextField tf = getTextField();
      final String text = tf.getText();
      final int caretIndex = tf.getCaretPosition();
      String pre = text.substring(0, caretIndex);
      java.util.List<TreeNode> nodes = null; // m_root.search(pre);
      // Collections.sort(nodes);
      if (nodes.isEmpty()) {
        return;
      }

      JPopupMenu jp = new JPopupMenu("options");

      JMenuItem lastItem = null;
      for (TreeNode node : nodes) {
        String nodeName = node.toString();
        String insertion = nodeName.substring(leaf(pre, ".").length());
        lastItem = createInsertAction(nodeName, caretIndex, insertion);
        jp.add(lastItem);
      }
      if (nodes.size() == 0) {
        return;
      }
      if (nodes.size() == 1) {
        lastItem.getAction().actionPerformed(null);
      } else {
        Point pos = tf.getCaret().getMagicCaretPosition();
        pos = pos != null ? pos : new Point(2, 2);
        jp.show(tf, pos.x, pos.y);
      }
    }
 /** Retrieve item types and fill in the item types combo box. */
 private void init() {
   Response res = ClientUtils.getData("loadItemTypes", new GridParams());
   Domain d = new Domain("ITEM_TYPES");
   if (!res.isError()) {
     ItemTypeVO vo = null;
     list = ((VOListResponse) res).getRows();
     for (int i = 0; i < list.size(); i++) {
       vo = (ItemTypeVO) list.get(i);
       d.addDomainPair(vo.getProgressiveHie02ITM02(), vo.getDescriptionSYS10());
     }
   }
   controlHierarchy.setDomain(d);
   controlHierarchy
       .getComboBox()
       .addItemListener(
           new ItemListener() {
             public void itemStateChanged(ItemEvent e) {
               if (e.getStateChange() == e.SELECTED) {
                 ItemTypeVO typeVO = (ItemTypeVO) list.get(controlHierarchy.getSelectedIndex());
                 treePanel.setCompanyCode(typeVO.getCompanyCodeSys01ITM02());
                 treePanel.setProgressiveHIE02((BigDecimal) controlHierarchy.getValue());
                 DetailSupplierVO vo =
                     (DetailSupplierVO) supplierPanel.getVOModel().getValueObject();
                 treePanel.setCompanyCode(vo.getCompanyCodeSys01REG04());
                 treePanel.reloadTree();
                 itemsGrid.clearData();
               }
             }
           });
   if (d.getDomainPairList().length == 1) controlHierarchy.getComboBox().setSelectedIndex(0);
   else controlHierarchy.getComboBox().setSelectedIndex(-1);
 }
Example #18
0
  private void listPeople() {

    try {

      jScrollPane1.getViewport().setView(null);

      JFlowPanel jPeople = new JFlowPanel();
      jPeople.applyComponentOrientation(getComponentOrientation());

      java.util.List people = m_dlSystem.listPeopleVisible();

      for (int i = 0; i < people.size(); i++) {

        AppUser user = (AppUser) people.get(i);

        JButton btn = new JButton(new AppUserAction(user));
        btn.applyComponentOrientation(getComponentOrientation());
        btn.setFocusPainted(false);
        btn.setFocusable(false);
        btn.setRequestFocusEnabled(false);
        btn.setHorizontalAlignment(SwingConstants.LEADING);
        btn.setMaximumSize(new Dimension(150, 50));
        btn.setPreferredSize(new Dimension(150, 50));
        btn.setMinimumSize(new Dimension(150, 50));

        jPeople.add(btn);
      }
      jScrollPane1.getViewport().setView(jPeople);

    } catch (BasicException ee) {
      ee.printStackTrace();
    }
  }
Example #19
0
  private void loadTopicsFromFile() throws IOException {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("ExtempFiller2");
    chooser.setFileFilter(
        new FileFilter() {
          @Override
          public boolean accept(File f) {
            return f.isDirectory() || f.getName().toLowerCase().endsWith(".txt");
          }

          @Override
          public String getDescription() {
            return "Text Files";
          }
        });
    int response = chooser.showOpenDialog(this);
    if (response == JFileChooser.APPROVE_OPTION) {
      // get everything currently researched
      java.util.List<String> researched = managerPanel.getTopics();
      // load everything from file
      File file = chooser.getSelectedFile();
      Scanner readScanner = new Scanner(file);
      while (readScanner.hasNext()) {
        String topic = readScanner.nextLine();
        if (!researched.contains(topic)) {
          Topic t = new Topic(topic);
          managerPanel.addTopic(t);
          inQueue.add(new InMessage(InMessage.Type.RESEARCH, t));
        }
      }
    }
  }
  private void reestimate() {
    SemOptimizer optimizer;

    String type = wrapper.getSemOptimizerType();

    if ("Regression".equals(type)) {
      optimizer = new SemOptimizerRegression();
    } else if ("EM".equals(type)) {
      optimizer = new SemOptimizerEm();
    } else if ("Powell".equals(type)) {
      optimizer = new SemOptimizerPowell();
    } else if ("Random Search".equals(type)) {
      optimizer = new SemOptimizerScattershot();
    } else if ("RICF".equals(type)) {
      optimizer = new SemOptimizerRicf();
    } else if ("Powell".equals(type)) {
      optimizer = new SemOptimizerPowell();
    } else {
      throw new IllegalArgumentException("Unexpected optimizer " + "type: " + type);
    }

    int numRestarts = wrapper.getNumRestarts();
    optimizer.setNumRestarts(numRestarts);

    java.util.List<SemEstimator> estimators = wrapper.getMultipleResultList();
    java.util.List<SemEstimator> newEstimators = new ArrayList<>();

    for (SemEstimator estimator : estimators) {
      SemPm semPm = estimator.getSemPm();

      DataSet dataSet = estimator.getDataSet();
      ICovarianceMatrix covMatrix = estimator.getCovMatrix();

      SemEstimator newEstimator;

      if (dataSet != null) {
        newEstimator = new SemEstimator(dataSet, semPm, optimizer);
        newEstimator.setNumRestarts(numRestarts);
        newEstimator.setScoreType(wrapper.getScoreType());
      } else if (covMatrix != null) {
        newEstimator = new SemEstimator(covMatrix, semPm, optimizer);
        newEstimator.setNumRestarts(numRestarts);
        newEstimator.setScoreType(wrapper.getScoreType());
      } else {
        throw new IllegalStateException(
            "Only continuous "
                + "rectangular data sets and covariance matrices "
                + "can be processed.");
      }

      newEstimator.estimate();
      newEstimators.add(newEstimator);
    }

    wrapper.setSemEstimator(newEstimators.get(0));

    wrapper.setMultipleResultList(newEstimators);
    resetSemImEditor();
  }
Example #21
0
 public void assignRobotRepresent(VivaeRobotRepresent repr) {
   int activePositionsCnt = positions.size();
   PositionMark pattern = positions.get(actives.size() % activePositionsCnt);
   repr.getBody().setPosition((float) pattern.getX(), (float) pattern.getY());
   repr.setArena(this);
   repr.setWorld(getWorld());
   addActive((Active) repr);
 }
 private void calcWorldPos() {
   if (project == null) return;
   for (int i = 0; i < obsUIlist.size(); i++) {
     ObservationUI s = (ObservationUI) obsUIlist.get(i);
     s.worldPos.setLocation(project.latLonToProj(s.latlonPos));
   }
   posWasCalc = true;
 }
  /**
   * Returns the set of pages contained in this wizard.
   *
   * @return Iterator
   */
  public Iterator<WizardPage> getPages() {
    java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
    firstWizardPage = new FirstWizardPage(this);

    pages.add(firstWizardPage);

    return pages.iterator();
  }
Example #24
0
 public void removeFriendFromList(String name) {
   for (int i = 0; i < list.size(); ) {
     if (list.get(i).toString().equals(name)) list.remove(i);
     else i++;
   }
   copy2view();
   list_fri.setListData(list_view.toArray());
 }
 public java.util.List<SearchResult> search(String _info, String _searchString, int _mode) {
   String passName = getName();
   if (passName.startsWith("Osejs.")) passName = passName.substring(6);
   java.util.List<SearchResult> list = new ArrayList<SearchResult>();
   for (java.util.Enumeration<Editor> e = pageList.elements(); e.hasMoreElements(); )
     list.addAll(e.nextElement().search(passName, _searchString, _mode));
   return list;
 }
Example #26
0
 public void removeRow(int index) {
   remove(rows.get(index));
   remove(struts.get(index));
   rows.remove(index);
   struts.remove(index);
   repaint();
   updateUI();
 }
  /**
   * Returns the set of pages contained in this wizard.
   *
   * @return Iterator
   */
  public Iterator<WizardPage> getPages() {
    java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
    firstWizardPage = new FirstWizardPage(registration, getWizardContainer());

    pages.add(firstWizardPage);

    return pages.iterator();
  }
Example #28
0
  public static DefaultPieDataset getPieDataset(String chartName, DBSeerDataSet dataset) {
    StatisticalPackageRunner runner = DBSeerGUI.runner;

    runner.eval(
        "[title legends Xdata Ydata Xlabel Ylabel timestamp] = plotter.plot" + chartName + ";");

    String title = runner.getVariableString("title");
    Object[] legends = (Object[]) runner.getVariableCell("legends");
    Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata");
    Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata");
    String xLabel = runner.getVariableString("Xlabel");
    String yLabel = runner.getVariableString("Ylabel");
    timestamp = runner.getVariableDouble("timestamp");

    DefaultPieDataset pieDataSet = new DefaultPieDataset();

    int numLegends = legends.length;
    int numXCellArray = xCellArray.length;
    int numYCellArray = yCellArray.length;
    int dataCount = 0;

    if (numXCellArray != numYCellArray) {
      JOptionPane.showMessageDialog(
          null,
          "The number of X dataset and Y dataset does not match.",
          "The number of X dataset and Y dataset does not match.",
          JOptionPane.ERROR_MESSAGE);
      return null;
    }

    final java.util.List<String> transactionTypeNames = dataset.getTransactionTypeNames();

    for (int i = 0; i < numYCellArray; ++i) {
      double[] xArray = (double[]) xCellArray[i];
      runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});");
      runner.eval("yArray = Ydata{" + (i + 1) + "};");
      double[] yArraySize = runner.getVariableDouble("yArraySize");
      double[] yArray = runner.getVariableDouble("yArray");

      int xLength = xArray.length;
      int row = (int) yArraySize[0];
      int col = (int) yArraySize[1];

      for (int c = 0; c < col; ++c) {
        if (c < transactionTypeNames.size()) {
          String name = transactionTypeNames.get(c);
          if (!name.isEmpty()) {
            pieDataSet.setValue(name, yArray[c]);
          } else {
            pieDataSet.setValue("Transaction Type " + (c + 1), yArray[c]);
          }
        }
      }
    }

    return pieDataSet;
  }
  private void mRemoveNode() {
    String old_node = (String) lstNodes.getSelectedValue();

    java.util.List remove_list =
        ConfigUtilities.getElementsWithDefinition(mBroker.getElements(mContext), old_node);
    for (int i = 0; i < remove_list.size(); i++) {
      mBroker.remove(mContext, (ConfigElement) remove_list.get(i));
    }
  }
Example #30
0
 public void addFriend2List(String name) {
   for (int i = 0; i < list.size(); ) {
     if (list.get(i).toString().equals(name)) return;
     else i++;
   }
   list.add(name);
   copy2view();
   list_fri.setListData(list_view.toArray());
 }