コード例 #1
0
 @Override
 public boolean apply(GLElementFactoryContext context) {
   if (context.get(List.class, null) != null
       && context.get("id2double", Function.class, null) != null) return true;
   if (context.get(IDoubleList.class, null) != null) return true;
   return hasTablePerspective(context);
 }
コード例 #2
0
 /**
  * @param string
  * @param context
  * @param glyph
  * @return
  */
 private EValueGlyph toGlyph(String key, GLElementFactoryContext context, EValueGlyph default_) {
   String v = context.get(key, String.class, null);
   if (StringUtils.isBlank(v)) return default_;
   try {
     EValueGlyph g = EValueGlyph.valueOf(v.toUpperCase());
     return g;
   } catch (Exception e) {
     Logger.create(SingleAxisElement.class).warn("invalid value glyph spec: " + v, e);
   }
   return default_;
 }
コード例 #3
0
  @Override
  public GLElement create(GLElementFactoryContext context) {
    SingleAxisElement elem = null;
    boolean renderOutsideBounds = context.is("renderOutsideBounds", false);

    if (hasTablePerspective(context))
      elem = new SingleAxisElement(context.getData(), renderOutsideBounds);
    else {
      EDimension dim = context.get(EDimension.class, EDimension.RECORD);
      double min = context.getDouble("min", Double.NaN);
      double max = context.getDouble("max", Double.NaN);

      if (context.get(List.class, null) != null
          && context.get("id2double", Function.class, null) != null) {
        @SuppressWarnings("unchecked")
        List<Integer> data = context.get(List.class, null);
        IDType idType = context.get(IDType.class, null);
        @SuppressWarnings("unchecked")
        Function<Integer, Double> f = context.get("id2double", Function.class, null);
        elem = new SingleAxisElement(dim, data, idType, f, min, max, renderOutsideBounds);
      } else if (context.get(IDoubleList.class, null) != null) {
        IDoubleList data = context.get(IDoubleList.class, null);
        elem = new SingleAxisElement(dim, data, min, max, renderOutsideBounds);
      }
    }
    if (elem == null) return null;
    EDetailLevel detailLevel = context.get(EDetailLevel.class, EDetailLevel.MEDIUM);
    String[] markers = context.get("markers", String[].class, null);
    if (markers != null) elem.setMarker(markers);
    else if (detailLevel == EDetailLevel.HIGH) elem.setNumberMarkers();
    elem.setInvertOrder(context.is("invertOrder"));
    elem.setGlyph(toGlyph("valueGlyph", context, elem.getGlyph()));
    return elem;
  }
コード例 #4
0
 /**
  * @param context
  * @return
  */
 private boolean hasTablePerspective(GLElementFactoryContext context) {
   TablePerspective d = context.getData();
   if (d == null) return false;
   if (!DataSupportDefinitions.homogenousColumns.apply(d)) return false;
   return d.getNrDimensions() == 1 || d.getNrRecords() == 1;
 }