Esempio n. 1
0
 public void add(DimsData dimension) {
   if (dimsData == null) dimsData = new ArrayList<DimsData>(3);
   if (dimsData.size() > dimension.getDimension() && dimension.getDimension() > -1) {
     dimsData.set(dimension.getDimension(), dimension);
   } else {
     dimsData.add(dimension);
   }
 }
Esempio n. 2
0
  /**
   * Set the current DimsDataList to what is defined in the pass in map.
   *
   * @param map
   * @param shape
   */
  public void fromMap(Map<Integer, String> map, int[] shape) {

    clear();

    for (int i = 0; i < shape.length; i++) {
      add(new DimsData(i));
    }

    if (map.isEmpty()) { // Make one up
      getDimsData(0).setSliceRange("all");
      if (size() == 2) {
        getDimsData(1).setPlotAxis(AxisType.X);

      } else if (size() > 2) {
        getDimsData(1).setPlotAxis(AxisType.Y);
        getDimsData(2).setPlotAxis(AxisType.X);
        for (int i = 3; i < size(); i++) {
          getDimsData(i).setSlice(0);
        }
      }

    } else { // Init one from map saved

      int dim = 0;

      for (DimsData dd : iterable()) {
        String value = map.get(dd.getDimension());
        if (value == null) value = map.get(String.valueOf(dd.getDimension()));
        if (value != null) {
          if ("all".equals(value)) {
            dd.setPlotAxis(AxisType.RANGE);
            continue;
          }

          AxisType at = AxisType.forLabel(value);
          if (at != null) {
            dd.setPlotAxis(at);
            continue;
          }

          try {
            dd.setSlice(Integer.parseInt(value));
          } catch (Exception ne) {
            dd.setSliceRange(value);
          }
        } else {
          AxisType type = AxisType.forAxis(dim);
          dd.setPlotAxis(type);
          ++dim;
        }
      }
    }
  }
Esempio n. 3
0
 /**
  * Export to Map from DimsDataList
  *
  * @return
  */
 public Map<Integer, String> toMap() {
   final Map<Integer, String> ret = new HashMap<Integer, String>(size());
   for (DimsData dd : iterable()) {
     if (dd.isSlice()) {
       ret.put(dd.getDimension(), String.valueOf(dd.getSlice()));
     } else if (dd.isTextRange()) {
       ret.put(dd.getDimension(), dd.getSliceRange() != null ? dd.getSliceRange() : "all");
     } else if (dd.getPlotAxis() != null) {
       ret.put(dd.getDimension(), dd.getPlotAxis().getName());
     }
   }
   return ret;
 }
Esempio n. 4
0
  public Slice[] toSliceArray(int[] dataShape) {

    final Slice[] ret = new Slice[size()];
    for (int i = 0; i < size(); i++) {
      DimsData dd = getDimsData(i);
      if (dd.isSlice()) {
        ret[i] = new Slice(dd.getSlice(), dd.getSlice() + 1);
      } else {
        ret[i] = new Slice(dataShape[dd.getDimension()]);
      }
    }
    return ret;
  }
Esempio n. 5
0
  public void removeLargeStacks(ISliceSystem slicingSystem, int maxStack) {

    for (DimsData dd : getDimsData()) {
      if (dd.getPlotAxis().isStack(slicingSystem)) {
        if (dd.getSliceRange(true) == null
            || "".equals(dd.getSliceRange(true))
            || "all".equals(dd.getSliceRange(true))) {
          final ILazyDataset lz = slicingSystem.getData().getLazySet();
          if (lz != null) {
            final int size = lz.getShape()[dd.getDimension()];
            if (size >= maxStack) { // We set a default slice
              dd.setSliceRange("0:25");
            }
          }
        }
      }
    }
  }