예제 #1
0
파일: Projection.java 프로젝트: cns-iu/nwb
 public Tuple query(Object... keys) {
   Object key = keys[0];
   if (labels.contains(key)) {
     return PrototypedTuple.singleton(labels.indexOf(key));
   }
   return PrototypedTuple.singleton(null);
 }
예제 #2
0
파일: Projection.java 프로젝트: cns-iu/nwb
 public Tuple query(Object... args) {
   Object key = args[0];
   long value = 0;
   if (counts.containsKey(key)) {
     value = counts.get(key);
   }
   return PrototypedTuple.singleton(value);
 }
예제 #3
0
파일: Projection.java 프로젝트: cns-iu/nwb
    /**
     * Returns a color value if the first key object is between the current max and min. Otherwise
     * it returns a null-valued tuple.
     */
    public Tuple query(Object... keys) {
      float d = Float.parseFloat(keys[0].toString());

      if (d >= min && d <= max) {
        return map(keys);
      } else {
        return PrototypedTuple.singleton(null);
      }
    }
예제 #4
0
파일: Projection.java 프로젝트: cns-iu/nwb
 public Tuple map(Object... keys) {
   Tuple rv;
   Object key;
   // TODO: Handle more than just the first value...concatenate the values or something, like
   // compound keys in Rank operator
   key = keys[0];
   if (!labels.contains(key)) {
     labels.add(key.toString());
   }
   rv = PrototypedTuple.singleton(labels.indexOf(key));
   return rv;
 }
예제 #5
0
파일: Projection.java 프로젝트: cns-iu/nwb
    /**
     * Returns a value between Red (low) and White (high) that represents the percentage of the
     * difference seen between the highest and the lowest value.
     *
     * <p>If multiple keys are passed, only the first one is used. If the key passed cannot be
     * parsed as number and 'throwExceptions' is set to false, black is returned. If the key passed
     * cannot be parsed and 'throwExceptions' is set to true, an exception is thrown.
     */
    public Tuple map(Object... keys) {
      float d;
      float p = -1;
      Tuple t;

      try {
        d = Float.parseFloat(keys[0].toString());
      } catch (Exception e) {
        if (throwExceptions) {
          throw new RuntimeException(
              "Could not parse value for heat scale:" + keys[0].toString(), e);
        } else {
          return PrototypedTuple.singleton(new Color(0, 0, 0));
        }
      }

      try {
        if (d > max || Double.isNaN(max)) {
          max = d;
        }
        if (d < min || Double.isNaN(min)) {
          min = d;
        }
        if (max == min) {
          p = 1;
        } else {
          p = 1 - ((max - d) / (max - min));
        }
        t = PrototypedTuple.singleton(averageColors(p));
        //				t = BasicTuple.singleton(new Color(1.0f,p,p));
      } catch (Exception e) {
        if (throwExceptions) {
          throw new RuntimeException("Error creating colors with range point:" + p, e);
        } else {
          t = PrototypedTuple.singleton(new Color(0, 0, 0));
        }
      }

      return t;
    }
예제 #6
0
파일: Projection.java 프로젝트: cns-iu/nwb
 public Tuple map(Object... args) {
   Object key = args[0];
   long value;
   if (counts.containsKey(key)) {
     Long l = counts.get(key);
     value = l.longValue();
     value++;
     counts.put(key, value);
   } else {
     value = 1;
     counts.put(key, value);
   }
   return PrototypedTuple.singleton(value);
 }
예제 #7
0
파일: Projection.java 프로젝트: cns-iu/nwb
 public Tuple query(Object... args) {
   return PrototypedTuple.singleton(count.get());
 }
예제 #8
0
파일: Projection.java 프로젝트: cns-iu/nwb
 public Tuple map(Object... args) {
   return PrototypedTuple.singleton(count.getAndAdd(1));
 }