コード例 #1
0
 private void initAvailableEstimators() {
   Class<? extends TimeMap> type = column.getTypeClass();
   try {
     TimeMap dummy = type.newInstance();
     for (Estimator estimator : Estimator.values()) {
       if (dummy.isSupported(estimator)) {
         comboBox.addItem(new EstimatorWrapper(estimator));
       }
     }
   } catch (InstantiationException ex) {
     throw new RuntimeException(ex);
   } catch (IllegalAccessException ex) {
     throw new RuntimeException(ex);
   }
 }
コード例 #2
0
 private boolean isPartition(Graph graph, Column column) {
   if (column.isDynamic()) {
     Set<Object> set = new HashSet<Object>();
     boolean hasNullValue = false;
     int elements = 0;
     ElementIterable<? extends Element> iterable =
         AttributeUtils.isNodeColumn(column) ? graph.getNodes() : graph.getEdges();
     for (Element el : iterable) {
       TimeMap val = (TimeMap) el.getAttribute(column);
       if (val != null) {
         Object[] va = val.toValuesArray();
         for (Object v : va) {
           if (v != null) {
             set.add(v);
           } else {
             hasNullValue = true;
           }
           elements++;
         }
       }
     }
     double ratio = set.size() / (double) elements;
     return ratio <= 0.9;
   } else if (column.isIndexed()) {
     Index index;
     if (AttributeUtils.isNodeColumn(column)) {
       index = graphModel.getNodeIndex(graph.getView());
     } else {
       index = graphModel.getEdgeIndex(graph.getView());
     }
     int valueCount = index.countValues(column);
     int elementCount = index.countElements(column);
     double ratio = valueCount / (double) elementCount;
     return ratio <= 0.9;
   }
   return false;
 }