Esempio n. 1
0
  private void sortList(List<PatientModel> list) {

    boolean sorted = true;
    for (int i = 0; i < COLUMN_NAMES.length; i++) {
      if (sorter.getSortingStatus(i) == 0) {
        Log.outputFuncLog(
            Log.LOG_LEVEL_0, Log.FUNCTIONLOG_KIND_INFORMATION, "ソート済み", String.valueOf(i));
        sorted = false;
        break;
      }
    }

    if (!sorted) {

      switch (sortItem) {
        case 0:
          Log.outputFuncLog(Log.LOG_LEVEL_0, Log.FUNCTIONLOG_KIND_INFORMATION, "患者IDでソート");
          Comparator c =
              new Comparator<PatientModel>() {

                @Override
                public int compare(PatientModel o1, PatientModel o2) {
                  return o1.getPatientId().compareTo(o2.getPatientId());
                }
              };
          Collections.sort(list, c);
          break;
        case 1:
          Log.outputFuncLog(Log.LOG_LEVEL_0, Log.FUNCTIONLOG_KIND_INFORMATION, "患者カナでソート");
          Comparator c2 =
              new Comparator<PatientModel>() {

                @Override
                public int compare(PatientModel p1, PatientModel p2) {
                  String kana1 = p1.getKanaName();
                  String kana2 = p2.getKanaName();
                  if (kana1 != null && kana2 != null) {
                    return p1.getKanaName().compareTo(p2.getKanaName());
                  } else if (kana1 != null && kana2 == null) {
                    return -1;
                  } else if (kana1 == null && kana2 != null) {
                    return 1;
                  } else {
                    return 0;
                  }
                }
              };
          Collections.sort(list, c2);
          break;
      }
    }
  }
Esempio n. 2
0
 public TDTree(Point[] pts, boolean cd) {
   this();
   // for(Point p : pts)
   // insert(p);
   this.size = pts.length;
   // TreeNode newRoot = buildBalanced(new ArrayList<Point>(Arrays.asList(pts)), true);
   ArrayList<Point> xSorted = new ArrayList<Point>(Arrays.asList(pts));
   ArrayList<Point> ySorted = new ArrayList<Point>(Arrays.asList(pts));
   Collections.sort(xSorted, new PointComparator(true));
   Collections.sort(ySorted, new PointComparator(false));
   TreeNode newRoot = buildBalanced(xSorted, ySorted, cd);
   recalculateData(newRoot);
   root = newRoot;
 }
 @Override
 @NotNull
 public List<Usage> getSortedUsages() {
   List<Usage> usages = new ArrayList<Usage>(getUsages());
   Collections.sort(usages, USAGE_COMPARATOR);
   return usages;
 }
Esempio n. 4
0
  private JPanel getClickableTagsPanel() {
    JPanel pnl = new JPanel();

    pnl.setLayout(new GridLayout(0, 3));

    ArrayList<Commontags> listTags = new ArrayList<>(mapAllTags.values());
    Collections.sort(listTags);

    for (final Commontags ctag : listTags) {
      JCheckBox cb = new JCheckBox(ctag.getText());

      cb.setForeground(GUITools.getColor(ctag.getColor()));
      cb.setFont(ctag.getType() == 0 ? SYSConst.ARIAL12 : SYSConst.ARIAL12BOLD);

      cb.setSelected(listSelectedTags.contains(ctag));

      cb.addItemListener(
          e -> {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              listSelectedTags.add(ctag);
              add(createButton(ctag));
            } else {
              listSelectedTags.remove(ctag);
              mapButtons.remove(ctag);
            }
            notifyListeners(ctag);
          });

      pnl.add(cb);
    }
    return pnl;
  }
Esempio n. 5
0
  void handleScanFiles(JTextField field, String[] extensions) {
    String[] dataFiles = scanDataFolderForFilesByType(extensions);
    if (dataFiles == null || dataFiles.length == 0) return;

    String[] oldFileList = field.getText().trim().split(",");
    ArrayList<String> newFileList = new ArrayList<String>();
    for (String c : oldFileList) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) // TODO check exists() here?
      {
        newFileList.add(c);
      }
    }
    for (String c : dataFiles) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) {
        newFileList.add(c);
      }
    }
    Collections.sort(newFileList);
    String finalFileList = "";
    int i = 0;
    for (String s : newFileList) {
      finalFileList += (i > 0 ? ", " : "") + s;
      i++;
    }
    field.setText(finalFileList);
  }
  private static UsageGroupingRule[] getActiveGroupingRules(final Project project) {
    final UsageGroupingRuleProvider[] providers =
        Extensions.getExtensions(UsageGroupingRuleProvider.EP_NAME);
    List<UsageGroupingRule> list = new ArrayList<UsageGroupingRule>(providers.length);
    for (UsageGroupingRuleProvider provider : providers) {
      ContainerUtil.addAll(list, provider.getActiveRules(project));
    }

    Collections.sort(
        list,
        new Comparator<UsageGroupingRule>() {
          @Override
          public int compare(final UsageGroupingRule o1, final UsageGroupingRule o2) {
            return getRank(o1) - getRank(o2);
          }

          private int getRank(final UsageGroupingRule rule) {
            if (rule instanceof OrderableUsageGroupingRule) {
              return ((OrderableUsageGroupingRule) rule).getRank();
            }

            return Integer.MAX_VALUE;
          }
        });

    return list.toArray(new UsageGroupingRule[list.size()]);
  }
    @Override
    public void actionPerformed(ActionEvent e) {
      if (e.getSource() == add) {
        // int sel = userTable.getSelectedRow();
        // if (sel < 0)
        //    sel = 0;

        nameTf.setText("");
        abbrTf.setText("");
        if (JOptionPane.showConfirmDialog(
                dialog,
                journalEditPanel,
                Localization.lang("Edit journal"),
                JOptionPane.OK_CANCEL_OPTION)
            == JOptionPane.OK_OPTION) {
          journals.add(new JournalEntry(nameTf.getText(), abbrTf.getText()));
          // setValueAt(nameTf.getText(), sel, 0);
          // setValueAt(abbrTf.getText(), sel, 1);
          Collections.sort(journals);
          fireTableDataChanged();
        }
      } else if (e.getSource() == remove) {
        int[] rows = userTable.getSelectedRows();
        if (rows.length > 0) {
          for (int i = rows.length - 1; i >= 0; i--) {
            journals.remove(rows[i]);
          }
          fireTableDataChanged();
        }
      }
    }
  private static void sortNode(ParentNode node, final Comparator<ElementNode> sortComparator) {
    ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
    Enumeration<MemberNode> children = node.children();
    while (children.hasMoreElements()) {
      arrayList.add(children.nextElement());
    }

    Collections.sort(arrayList, sortComparator);

    replaceChildren(node, arrayList);
  }
Esempio n. 9
0
 /**
  * Gets the list of the vnmrj users(operators) for the current unix user logged in
  *
  * @return the list of vnmrj users
  */
 protected Object[] getOperators() {
   String strUser = System.getProperty("user.name");
   User user = LoginService.getDefault().getUser(strUser);
   ArrayList<String> aListOperators = user.getOperators();
   if (aListOperators == null || aListOperators.isEmpty())
     aListOperators = new ArrayList<String>();
   Collections.sort(aListOperators);
   if (aListOperators.contains(strUser)) aListOperators.remove(strUser);
   aListOperators.add(0, strUser);
   return (aListOperators.toArray());
 }
  protected void restoreTree() {
    Pair<ElementNode, List<ElementNode>> selection = storeSelection();

    DefaultMutableTreeNode root = getRootNode();
    if (!myShowClasses || myContainerNodes.isEmpty()) {
      List<ParentNode> otherObjects = new ArrayList<ParentNode>();
      Enumeration<ParentNode> children = getRootNodeChildren();
      ParentNode newRoot =
          new ParentNode(
              null, new MemberChooserObjectBase(getAllContainersNodeName()), new Ref<Integer>(0));
      while (children.hasMoreElements()) {
        final ParentNode nextElement = children.nextElement();
        if (nextElement instanceof ContainerNode) {
          final ContainerNode containerNode = (ContainerNode) nextElement;
          Enumeration<MemberNode> memberNodes = containerNode.children();
          List<MemberNode> memberNodesList = new ArrayList<MemberNode>();
          while (memberNodes.hasMoreElements()) {
            memberNodesList.add(memberNodes.nextElement());
          }
          for (MemberNode memberNode : memberNodesList) {
            newRoot.add(memberNode);
          }
        } else {
          otherObjects.add(nextElement);
        }
      }
      replaceChildren(root, otherObjects);
      sortNode(newRoot, myComparator);
      if (newRoot.children().hasMoreElements()) root.add(newRoot);
    } else {
      Enumeration<ParentNode> children = getRootNodeChildren();
      while (children.hasMoreElements()) {
        ParentNode allClassesNode = children.nextElement();
        Enumeration<MemberNode> memberNodes = allClassesNode.children();
        ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
        while (memberNodes.hasMoreElements()) {
          arrayList.add(memberNodes.nextElement());
        }
        Collections.sort(arrayList, myComparator);
        for (MemberNode memberNode : arrayList) {
          myNodeToParentMap.get(memberNode).add(memberNode);
        }
      }
      replaceChildren(root, myContainerNodes);
    }
    myTreeModel.nodeStructureChanged(root);

    defaultExpandTree();

    restoreSelection(selection);
  }
Esempio n. 11
0
  private void updateList() {
    ActionSet actionSet = (ActionSet) combo.getSelectedItem();
    EditAction[] actions = actionSet.getActions();
    Vector listModel = new Vector(actions.length);

    for (int i = 0; i < actions.length; i++) {
      EditAction action = actions[i];
      String label = action.getLabel();
      if (label == null) continue;

      listModel.addElement(new ToolBarOptionPane.Button(action.getName(), null, null, label));
    }

    Collections.sort(listModel, new ToolBarOptionPane.ButtonCompare());
    list.setListData(listModel);
  }
Esempio n. 12
0
    // {{{ sort() method
    public void sort(int type) {
      Set<String> savedChecked = new HashSet<String>();
      Set<String> savedSelection = new HashSet<String>();
      saveSelection(savedChecked, savedSelection);

      if (sortType != type) {
        sortDirection = 1;
      }
      sortType = type;

      if (isDownloadingList()) return;

      Collections.sort(entries, new EntryCompare(type, sortDirection));
      updateFilteredEntries();
      restoreSelection(savedChecked, savedSelection);
      table.getTableHeader().repaint();
    }
Esempio n. 13
0
  protected void control(List nodes) {
    if (nodes.size() <= 1) return;

    Collections.sort(nodes, new YComparator());

    //		double d = Y_max - Y_min;
    //		d = d / (nodes.size() - 1);

    // Note: X, Y are at node centers
    for (int i = 1; i < nodes.size(); i++) {
      ((NodeView) nodes.get(i))
          .setYPosition(
              ((NodeView) nodes.get(i - 1)).getYPosition()
                  + ((NodeView) nodes.get(i - 1)).getHeight() * 0.5
                  + ((NodeView) nodes.get(i)).getHeight() * 0.5);
      ((NodeView) nodes.get(i)).setXPosition(((NodeView) nodes.get(i - 1)).getXPosition());
    }
  }
    public void mouseClicked(MouseEvent e) {
      TableColumnModel colModel = table.getColumnModel();
      int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
      int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex();

      if (modelIndex < 0) return;
      if (sortCol == modelIndex) isSortAsc = !isSortAsc;
      else sortCol = modelIndex;

      for (int i = 0; i < colNames.length; i++) {
        TableColumn column = colModel.getColumn(i);
        column.setHeaderValue(getColumnName(column.getModelIndex()));
      }
      table.getTableHeader().repaint();

      Collections.sort(rowData, new MyComparator(isSortAsc));
      table.tableChanged(new TableModelEvent(MyTableModel.this));
      table.repaint();
    }
 private MyExistLocalesListModel() {
   myLocales = new ArrayList<>();
   myLocales.add(PropertiesUtil.DEFAULT_LOCALE);
   PropertiesReferenceManager.getInstance(myProject)
       .processPropertiesFiles(
           GlobalSearchScope.projectScope(myProject),
           new PropertiesFileProcessor() {
             @Override
             public boolean process(String baseName, PropertiesFile propertiesFile) {
               final Locale locale = propertiesFile.getLocale();
               if (locale != PropertiesUtil.DEFAULT_LOCALE && !myLocales.contains(locale)) {
                 myLocales.add(locale);
               }
               return true;
             }
           },
           BundleNameEvaluator.DEFAULT);
   Collections.sort(myLocales, LOCALE_COMPARATOR);
 }
Esempio n. 16
0
 protected void updateCategoryChooser() {
   if (categoryChooser != null) {
     ArrayList<String> categories;
     categoryChooser.removeAllItems();
     categories = new ArrayList<String>(contribListing.getCategories(filter));
     //      for (int i = 0; i < categories.size(); i++) {
     //        System.out.println(i + " category: " + categories.get(i));
     //      }
     Collections.sort(categories);
     //    categories.add(0, ContributionManagerDialog.ANY_CATEGORY);
     boolean categoriesFound = false;
     categoryChooser.addItem(ContributionManagerDialog.ANY_CATEGORY);
     for (String s : categories) {
       categoryChooser.addItem(s);
       if (!s.equals(Contribution.UNKNOWN_CATEGORY)) {
         categoriesFound = true;
       }
     }
     categoryChooser.setVisible(categoriesFound);
   }
 }
 private void rulesChanged() {
   ApplicationManager.getApplication().assertIsDispatchThread();
   final ArrayList<UsageState> states = new ArrayList<UsageState>();
   captureUsagesExpandState(new TreePath(myTree.getModel().getRoot()), states);
   final List<Usage> allUsages = new ArrayList<Usage>(myUsageNodes.keySet());
   Collections.sort(allUsages, USAGE_COMPARATOR);
   final Set<Usage> excludedUsages = getExcludedUsages();
   reset();
   myBuilder.setGroupingRules(getActiveGroupingRules(myProject));
   myBuilder.setFilteringRules(getActiveFilteringRules(myProject));
   ApplicationManager.getApplication()
       .runReadAction(
           new Runnable() {
             @Override
             public void run() {
               for (Usage usage : allUsages) {
                 if (!usage.isValid()) {
                   continue;
                 }
                 if (usage instanceof MergeableUsage) {
                   ((MergeableUsage) usage).reset();
                 }
                 appendUsage(usage);
               }
             }
           });
   excludeUsages(excludedUsages.toArray(new Usage[excludedUsages.size()]));
   if (myCentralPanel != null) {
     setupCentralPanel();
   }
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           if (isDisposed) return;
           restoreUsageExpandState(states);
           updateImmediately();
         }
       });
 }
Esempio n. 18
0
 public Vector<PADEmotion> sort(Vector<PADEmotion> in) {
   for (PADEmotion e : in) e.setDistance(p, a, d);
   Collections.sort(in);
   return in;
 }
Esempio n. 19
0
  public void run() {
    while (true) {
      BALL = null;
      ball_t ballLCM = new ball_t();

      synchronized (depthMonitor) {
        try {
          depthMonitor.wait();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      ballLCM.nanoTime = depthStream.latestTimestamp;
      ArrayList<Statistics> blobs;
      depthStream.getReadLock().lock();
      try {
        blobs = finder.analyze2(depthStream.getValidImageArray());
      } finally {
        depthStream.getReadLock().unlock();
      }
      Statistics ball = null;
      Statistics robot = null;
      int minSize = pg.gi("blobThresh");

      // find robot and ball by blob size
      Collections.sort(blobs, ComparatorFactory.getStatisticsCompareSize());
      // find robot and ball by y pixel
      // Collections.sort(blobs, ComparatorFactory.getStatisticsCompareYPix());
      //			if (tracking) {
      //				System.out.println("num blobs: " + blobs.size());
      //				System.out.println("biggest blob size: " + blobs.get(0).N);
      //			}
      //			for (Statistics blob : blobs) {
      //				if (blob.N > 10) {
      //					System.out.println("blob size: " + blob.N);
      //				}
      //				else {
      //					break;
      //				}
      //			}
      if (blobs.size() == 1) {
        Statistics first = blobs.get(0);
        if (first.N > minSize) {
          ball = first;
        }
      } else if (blobs.size() >= 2) {
        Statistics first = blobs.get(0);
        Statistics second = blobs.get(1);
        if (first.N > minSize) {
          ball = first;
        }
        if (second.N > minSize) {
          robot = first;
          ball = second;
        }
      }

      // System.out.println("balls points " + depthStream.trajectory.size());

      // if not tracking keep kv.depthStream.trajectory to just one index
      if (!tracking) {
        depthStream.trajectory.clear();
      }

      if (ball != null) {
        depthStream.trajectory.add(ball);

        Point depthPix = ball.center();
        Point depthCoord = new Point();
        depthCoord.x = depthPix.x - KinectVideo.C_X;
        depthCoord.y = KinectVideo.C_Y - depthPix.y;

        // System.out.println("avg depth " + ball.Uz());

        // get depth from average depth of blob
        double realDepth = raw_depth_to_meters(ball.Uz());
        Point3D coord = depthStream.getWorldCoords(depthCoord, realDepth);
        if (depthPix != null) {
          for (int y = depthPix.y - 3; y < depthPix.y + 3; y++) {
            for (int x = depthPix.x - 3; x < depthPix.x + 3; x++) {
              try {
                depthImg.setRGB(x, y, 0xFFFF0000);
              } catch (Exception e) {
                // System.out.println(x + " " + y);
              }
              ;
            }
          }
          // if (tracking) {
          // 	//save image
          // 	depthStream.getReadLock().lock();
          // 	try {
          // 		File imgFile = new File("image" + ballNum++ + ".png");
          // 		try {
          // 			ImageIO.write(depthImg, "png", imgFile);
          // 		}
          // 		catch(Exception e) {
          // 			System.out.println("can't save img");
          // 		}
          // 	}
          // 	finally {
          // 		depthStream.getReadLock().unlock();
          // 	}
          // }

          if (tracking) {
            ballLCM.x = coord.x;
            ballLCM.y = coord.y;
            ballLCM.z = coord.z;
            // if(tracking)
            System.out.println("updating new ball (" + System.currentTimeMillis() + ")");
            //						if (ballLCM.x > CatchController.TARGET_MAX_X)
            lcm.publish("6_BALL", ballLCM);
            //						else
            //							System.out.println("ball past target zone");
          }
        }
      }
    }
  }