Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
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;
 }