예제 #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;
      }
    }
  }
예제 #2
0
파일: TDTree.java 프로젝트: CDargis/TDTree
 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;
 }
예제 #3
0
파일: Memory.java 프로젝트: mattec92/KTH
 // Metoden makeBoard - Skapar de grafiska komponenterna för spelplanen
 public void makeBoard() {
   int k = 0;
   // Laddar in bilderna för kortens baksida till programmet
   for (int j = 1; j < 33; j++) {
     for (int i = 0; i < 2; i++) {
       bilder.add(new ImageIcon("Memorypics/" + j + ".gif"));
     }
   }
   // Skapar korten med bilder och id, blandar sedan korten
   for (int i = 0; i < 64; i++) {
     cards.add(new Card(bilder.get(i), k));
     if (i % 2 == 1) {
       k++;
     }
     Collections.shuffle(cards);
   }
   // Lägger ut korten på spelplanen
   for (int i = 0; i < 64; i++) {
     panel.add(cards.get(i));
     cards.get(i).addActionListener(this);
     cards.get(i).setBorder(new LineBorder(Color.WHITE, 1));
     cards.get(i).pos = i;
   }
   // Lägger till labels för nick och poängställning
   for (int i = 0; i < players.size(); i++) {
     playerlabels.add(new JLabel(players.get(i).nick + ": "));
     scorelabels.add(new JLabel(players.get(i).score + ""));
     panel.add(playerlabels.get(i));
     panel.add(scorelabels.get(i));
   }
 }
 @Override
 @NotNull
 public List<Usage> getSortedUsages() {
   List<Usage> usages = new ArrayList<Usage>(getUsages());
   Collections.sort(usages, USAGE_COMPARATOR);
   return usages;
 }
    @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();
        }
      }
    }
예제 #6
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;
  }
예제 #7
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);
  }
 /** {@inheritDoc} */
 public Iterable<AVList> getLinks() {
   if (this.webViewWindowPtr != 0) {
     AVList[] links = WindowsWebViewJNI.getLinks(this.webViewWindowPtr);
     if (links != null) return Arrays.asList(links);
   }
   return Collections.emptyList();
 }
  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()]);
  }
예제 #10
0
 static void handleKeyTyped(KeyEvent e) {
   if (e.getKeyChar() == ' ') {
     currentSequenceNumDisplay++;
     scribbles = Collections.synchronizedList(new ArrayList<DrawObject>());
     currentScribbleNum = 0;
   }
   drawArea.repaint();
 }
예제 #11
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());
 }
  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);
  }
예제 #13
0
 public void actionPerformed(ActionEvent e) {
   Iterator toInterp = Collections.singleton(desc).iterator();
   JMenuItem jmi = (JMenuItem) e.getSource();
   Iterator marks = mediator.getMarkerModel().getMarkersWithLabel(jmi.getText());
   if (marks.hasNext()) {
     ChronicleMarker marker = (ChronicleMarker) marks.next();
     Instant to = marker.getWhen();
     Instant from = mediator.getMajorMoment();
     mediator.getPropagator().interpolateDescriptors(toInterp, from, to);
   }
 }
  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);
  }
예제 #15
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);
  }
예제 #16
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();
    }
예제 #17
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());
    }
  }
  @Nullable
  private static List<Locale> extractLocalesFromString(final String rawLocales) {
    if (rawLocales.isEmpty()) {
      return Collections.emptyList();
    }
    final String[] splitRawLocales = rawLocales.split(",");
    final List<Locale> locales = new ArrayList<>(splitRawLocales.length);

    for (String rawLocale : splitRawLocales) {
      final Locale locale = PropertiesUtil.getLocale("_" + rawLocale + ".properties");
      if (locale == PropertiesUtil.DEFAULT_LOCALE) {
        return null;
      } else if (!locales.contains(locale)) {
        locales.add(locale);
      }
    }
    return locales;
  }
 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);
 }
예제 #20
0
    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();
    }
예제 #21
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();
         }
       });
 }
예제 #23
0
  public static void main(final String args[])
      throws FileNotFoundException, UnsupportedEncodingException, IOException {
    if (args.length != 1) {
      System.out.println("Usage: " + BundleOptionsFrame.class.getName() + " bundle");
      System.exit(1);
    }

    List<File> noFiles = Collections.emptyList();
    final Bundle bundle = new BundleFactory(noFiles, noFiles).getBundle(new File(args[0]));

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            BundleOptionsFrame fr = null;
            try {
              fr = new BundleOptionsFrame(bundle.getDisplayName(), "untitled", bundle.getOptions());
            } catch (IOException e) {
              e.printStackTrace();
              System.exit(1);
            }
            fr.addComponentListener(
                new ComponentAdapter() {
                  @Override
                  public void componentHidden(ComponentEvent e) {
                    BundleOptionsFrame fr = (BundleOptionsFrame) e.getSource();
                    System.out.println("Instance: " + fr.getInstanceName());
                    System.out.println("Option map:");
                    Map<String, String> optionMap = fr.getOptionMap();
                    for (String name : optionMap.keySet()) {
                      System.out.println(name + "\t" + optionMap.get(name));
                    }
                    System.exit(0);
                  }
                });
            fr.setVisible(true);
          }
        });
  }
예제 #24
0
 public java.util.List<AirspaceEntry> getEntries() {
   return Collections.unmodifiableList(this.entryList);
 }
예제 #25
0
  private void updateNodes() {
    nodes = spauldingApp.getNodesSorted();
    nodeIDToRow = Collections.synchronizedMap(new HashMap<Integer, Integer>());

    for (int r = 0; r < nodes.size(); ++r) nodeIDToRow.put(nodes.get(r).getNodeID(), r);
  }
예제 #26
0
class NodeStatusTableModel extends AbstractTableModel implements NodeListener, RequestListener {
  private JTable table;
  private SpauldingApp spauldingApp;
  // We want fast lookup by index (row) and by nodeID
  private Vector<Node> nodes;
  private Map<Integer, Integer> nodeIDToRow; // Map<nodeID, rowIndex>
  private Map<Integer, Request> nodeIDToRequest =
      Collections.synchronizedMap(new HashMap<Integer, Request>());

  private String[] columnNames = {
    "NodeID", "State", "Tail", "Head", "Local time", "Global time", "Time synched", "Last request",
  };

  private void initColumnWidths(final JTable table) {
    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            table.getColumnModel().getColumn(0).setMaxWidth(100);
            table.getColumnModel().getColumn(1).setPreferredWidth(150);
            //                table.getColumnModel().getColumn(2).setPreferredWidth(5);
            //                table.getColumnModel().getColumn(3).setPreferredWidth(5);
            //                table.getColumnModel().getColumn(4).setPreferredWidth(5);
            //                table.getColumnModel().getColumn(5).setPreferredWidth(5);
            table.getColumnModel().getColumn(7).setPreferredWidth(175);
          }
        });
  }

  // ----------- Custom Renderers ----------------------------------------------------------------
  class LastRequestCellRendererClass {} // wrapper class

  class LastRequestCellRenderer extends JProgressBar implements TableCellRenderer {
    LastRequestCellRenderer() {
      super(0, 100);
      this.setBorderPainted(true);
      this.setStringPainted(true);
      // this.setForeground(new Color(0, 0, 150));
    }

    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (isSelected) this.setBackground(table.getSelectionBackground());
      else this.setBackground(table.getBackground());

      Node node = nodes.get(row);
      Request request = nodeIDToRequest.get(node.getNodeID());
      if (request == null) {
        this.setString("NONE");
        this.setValue(0);
      } else {
        int percent = (int) Math.round(request.getPercentDone());
        this.setString(request.getType().toString() + "  " + percent + "%");
        this.setValue(percent);
      }
      return this;
    }
  }
  // ---------------------------------------------------------------------------------------------

  NodeStatusTableModel(SpauldingApp spauldingGUI, JTable table) {
    assert (spauldingGUI != null && table != null);
    this.table = table;
    this.spauldingApp = spauldingGUI;

    // set custom renderers
    table.setDefaultRenderer(
        new LastRequestCellRendererClass().getClass(), new LastRequestCellRenderer());

    this.initColumnWidths(table);
    updateNodes();
  }

  private void updateNodes() {
    nodes = spauldingApp.getNodesSorted();
    nodeIDToRow = Collections.synchronizedMap(new HashMap<Integer, Integer>());

    for (int r = 0; r < nodes.size(); ++r) nodeIDToRow.put(nodes.get(r).getNodeID(), r);
  }

  public Node getNode(int row) {
    return nodes.get(row);
  }

  public int getColumnCount() {
    return columnNames.length;
  }

  public int getRowCount() {
    return nodes.size();
  }

  public String getColumnName(int col) {
    return columnNames[col];
  }

  public synchronized Object getValueAt(int row, int col) {
    Node node = nodes.get(row);

    switch (col) {
      case 0:
        return node.getNodeID();
      case 1:
        return node.getCurrState();
      case 2:
        return node.getTailBlockID();
      case 3:
        return node.getHeadBlockID();
      case 4:
        return node.getLocalTime();
      case 5:
        return node.getGlobalTime();
      case 6:
        return node.getIsTimeSynchronized();
      case 7:
        return new LastRequestCellRendererClass();
      default:
        return "UNKNOWN";
    }
  }

  /*
   * JTable uses this method to determine the default renderer/
   * editor for each cell.  If we didn't implement this method,
   * then the last column would contain text ("true"/"false"),
   * rather than a check box.
   */
  public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
  }

  public void updateNodeID(int nodeID) {
    Integer rowIndex = nodeIDToRow.get(nodeID);
    if (rowIndex == null) updateAll();
    else fireTableRowsUpdated(rowIndex, rowIndex);
  }

  public synchronized void updateAll() {
    updateNodes();
    fireTableDataChanged();
  }

  // ----------- Listening Interfaces ---------
  public void newSamplingMsg(
      SamplingMsg samplingMsg) { // Just ignore, we don't care about new samples
  }

  public void newReplyMsg(ReplyMsg replyMsg) {
    updateNodeID(replyMsg.get_srcAddr());
  }

  public void requestDone(Request request, boolean isSuccessful) {}

  public void percentCompletedChanged(Request request, double percentCompleted) {
    assert (request != null);
    this.nodeIDToRequest.put(request.getDestAddr(), request);
    updateNodeID(request.getDestAddr());
  }
}
예제 #27
0
  static {
    points = Collections.synchronizedList(new ArrayList<DrawObject>());
    lines = Collections.synchronizedList(new ArrayList<DrawObject>());
    ovals = Collections.synchronizedList(new ArrayList<DrawObject>());
    rectangles = Collections.synchronizedList(new ArrayList<DrawObject>());
    images = Collections.synchronizedList(new ArrayList<DrawObject>());
    labels = Collections.synchronizedList(new ArrayList<DrawObject>());
    scribbles = Collections.synchronizedList(new ArrayList<DrawObject>());
    eqnLines = Collections.synchronizedList(new ArrayList<DrawObject>());

    animPoints = Collections.synchronizedList(new ArrayList<DrawObject>());
    animLines = Collections.synchronizedList(new ArrayList<DrawObject>());
    animOvals = Collections.synchronizedList(new ArrayList<DrawObject>());
    animRectangles = Collections.synchronizedList(new ArrayList<DrawObject>());
    animLabels = Collections.synchronizedList(new ArrayList<DrawObject>());

    df.setMaximumFractionDigits(4);
  }
예제 #28
0
 public Vector<PADEmotion> sort(Vector<PADEmotion> in) {
   for (PADEmotion e : in) e.setDistance(p, a, d);
   Collections.sort(in);
   return in;
 }
예제 #29
0
 public void actionPerformed(ActionEvent e) {
   Iterator toInterp = Collections.singleton(desc).iterator();
   ViperViewMediator m = getMediator();
   InterpQuery iq = new InterpQuery(toInterp, m);
   iq.setVisible(true);
 }
예제 #30
0
  /** Add the UI components for the given file sequence to the panel. */
  private void addFileSeqPanel(FileSeq fseq) {
    boolean isPresentInWorking = false;
    if ((pStatus != null) && pStatus.hasLightDetails()) {
      NodeDetailsLight details = pStatus.getLightDetails();
      NodeMod mod = details.getWorkingVersion();
      if (mod != null) {
        if (mod.getPrimarySequence().equals(fseq)) isPresentInWorking = true;
        else {
          for (FileSeq sfseq : mod.getSecondarySequences()) {
            if (sfseq.equals(fseq)) {
              isPresentInWorking = true;
              break;
            }
          }
        }
      }
    }

    /* collate the row information */
    ArrayList<VersionID> vids = new ArrayList<VersionID>();
    ArrayList<FileSeq> singles = new ArrayList<FileSeq>();
    TreeSet<FileSeq> enabled = new TreeSet<FileSeq>();
    TreeMap<FileSeq, FileState> fstates = new TreeMap<FileSeq, FileState>();
    TreeMap<FileSeq, NativeFileInfo> finfos = new TreeMap<FileSeq, NativeFileInfo>();
    TreeMap<FileSeq, QueueState> qstates = new TreeMap<FileSeq, QueueState>();
    TreeMap<FileSeq, Boolean[]> novel = new TreeMap<FileSeq, Boolean[]>();
    {
      TreeMap<FileSeq, Integer> wsingles = new TreeMap<FileSeq, Integer>();
      if ((pStatus != null) && pStatus.hasLightDetails()) {
        if (isPresentInWorking) {
          if (pStatus.hasHeavyDetails()) {
            NodeDetailsHeavy details = pStatus.getHeavyDetails();

            FileState[] fs = details.getFileStates(fseq);
            QueueState[] qs = details.getQueueStates();
            NativeFileInfo[] infos = details.getFileInfos(fseq);
            if ((fs != null) && (qs != null) && (infos != null)) {
              int wk;
              for (wk = 0; wk < fs.length; wk++) {
                FileSeq sfseq = new FileSeq(fseq, wk);
                wsingles.put(sfseq, wk);

                fstates.put(sfseq, fs[wk]);
                finfos.put(sfseq, infos[wk]);
                qstates.put(sfseq, qs[wk]);

                if (fs[wk] != FileState.CheckedIn) enabled.add(sfseq);
              }
            }
          } else {
            NodeDetailsLight details = pStatus.getLightDetails();

            int wk;
            for (wk = 0; wk < fseq.numFrames(); wk++) {
              FileSeq sfseq = new FileSeq(fseq, wk);
              wsingles.put(sfseq, wk);

              if (details.getVersionState() == VersionState.CheckedIn) {
                fstates.put(sfseq, FileState.CheckedIn);
                qstates.put(sfseq, QueueState.Undefined);
              } else {
                enabled.add(sfseq);
              }
            }
          }
        }

        {
          vids.addAll(pNovelty.keySet());
          Collections.reverse(vids);

          int idx = 0;
          for (VersionID vid : vids) {
            TreeMap<FileSeq, boolean[]> table = pNovelty.get(vid);
            for (FileSeq nfseq : table.keySet()) {
              if (fseq.similarTo(nfseq)) {
                boolean[] flags = table.get(nfseq);

                int wk;
                for (wk = 0; wk < flags.length; wk++) {
                  FileSeq sfseq = new FileSeq(nfseq, wk);
                  if (!wsingles.containsKey(sfseq)) wsingles.put(sfseq, null);

                  Boolean[] rflags = novel.get(sfseq);
                  if (rflags == null) {
                    rflags = new Boolean[pNovelty.size()];
                    novel.put(sfseq, rflags);
                  }

                  rflags[idx] = new Boolean(flags[wk]);
                }

                break;
              }
            }

            idx++;
          }
        }
      }

      TreeMap<Integer, FileSeq> order = new TreeMap<Integer, FileSeq>();
      for (FileSeq sfseq : wsingles.keySet()) {
        int frame = -1;
        if (sfseq.hasFrameNumbers()) frame = sfseq.getFrameRange().getStart();

        order.put(frame, sfseq);
      }

      singles.addAll(order.values());
    }

    /* add the panel */
    {
      JFileSeqPanel panel =
          new JFileSeqPanel(
              this,
              pManagerPanel,
              pStatus,
              pPrivilegeDetails,
              fseq,
              vids,
              pOffline,
              singles,
              fstates,
              finfos,
              qstates,
              enabled,
              novel,
              pIsListLayout);

      if (pIsListLayout) pFileSeqsBox.add(panel);
      else pFileSeqsTab.addTab(fseq.getFilePattern().toString(), sTabIcon, panel);

      pFileSeqPanels.put(fseq, panel);
    }
  }