/**
   * Bit of a complex method. It simply tries to leave the data with two axes selected by finding
   * the most likely two dimensions that should be plot axes.
   *
   * @param firstAxis
   * @param secondAxis
   */
  public void setTwoAxesOnly(AxisType firstAxis, AxisType secondAxis) {
    boolean foundFirst = false, foundSecond = false;
    for (DimsData dd : iterable()) {
      if (dd.getPlotAxis() == firstAxis) foundFirst = true;
      if (dd.getPlotAxis() == secondAxis) foundSecond = true;
    }

    if (foundFirst && foundSecond) {
      for (DimsData dd : iterable()) {
        if (dd.getPlotAxis() == firstAxis) continue;
        if (dd.getPlotAxis() == secondAxis) continue;
        if (dd.getPlotAxis() == AxisType.RANGE) continue;
        dd.setPlotAxis(AxisType.SLICE);
      }
      return;
    } else { // We have to decide which of the others is first and second

      if (!foundFirst) foundFirst = processAxis(firstAxis, secondAxis);
      if (!foundSecond) foundSecond = processAxis(secondAxis, firstAxis);

      for (DimsData dd : iterable()) {
        if (dd.getPlotAxis() == firstAxis) continue;
        if (dd.getPlotAxis() == secondAxis) continue;
        if (dd.getPlotAxis() == AxisType.RANGE) continue;
        dd.setPlotAxis(AxisType.SLICE);
      }
      return;
    }
  }
 public boolean isXFirst() {
   for (DimsData dd : iterable()) {
     if (dd.getPlotAxis().hasValue()) continue;
     return dd.getPlotAxis() == AxisType.X;
   }
   return false;
 }
  /**
   * Probably not best algorithm but we are dealing with very small arrays here. This is simply
   * trying to ensure that only one dimension is selected as an axis because the plot has changed.
   *
   * @param iaxisToFind
   */
  public void setSingleAxisOnly(AxisType iaxisToFind, AxisType iaxisValue) {
    DimsData found = null;
    for (DimsData dd : iterable()) {
      if (dd.getPlotAxis() == iaxisToFind) {
        dd.setPlotAxis(iaxisValue);
        found = dd;
      }
    }

    if (found != null) {
      for (DimsData dd : iterable()) {
        if (dd == found) continue;
        dd.setPlotAxis(AxisType.SLICE);
      }
      return;
    } else { // We have to decide which of the others is x

      for (DimsData dd : iterable()) {
        if (!dd.getPlotAxis().hasValue()) {
          dd.setPlotAxis(iaxisValue);
          found = dd;
        }
      }
      for (DimsData dd : iterable()) {
        if (dd == found) continue;
        dd.setPlotAxis(AxisType.SLICE);
      }
    }
  }
 /**
  * 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;
 }
  public void reverseImage() {
    for (DimsData dd : iterable()) {
      if (dd.getPlotAxis() == AxisType.X) {
        dd.setPlotAxis(AxisType.Y);
        continue;
      }

      if (dd.getPlotAxis() == AxisType.Y) {
        dd.setPlotAxis(AxisType.X);
        continue;
      }
    }
  }
 public int getRangeCount() {
   int count = 0;
   for (DimsData dd : dimsData) {
     if (dd.getPlotAxis() == AxisType.RANGE) count++;
   }
   return count;
 }
 public int getAxisCount() {
   if (dimsData == null) return -1;
   int count = 0;
   for (DimsData dd : dimsData) {
     if (!dd.getPlotAxis().hasValue()) count++;
   }
   return count;
 }
  private final boolean processAxis(AxisType axis, AxisType... ignoredAxes) {

    final List<Object> ignored = asList(ignoredAxes);
    for (DimsData dd : iterable()) {
      if (!dd.getPlotAxis().hasValue() && !ignored.contains(dd.getPlotAxis())) {
        dd.setPlotAxis(axis);
        return true;
      }
    }

    for (DimsData dd : iterable()) {
      if (!ignored.contains(dd.getPlotAxis())) {
        dd.setPlotAxis(axis);
        return true;
      }
    }

    return false;
  }
  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");
            }
          }
        }
      }
    }
  }
Exemple #10
0
 public boolean isAdvanced() {
   for (DimsData dd : iterable()) {
     if (dd.getPlotAxis().isAdvanced()) return true;
   }
   return false;
 }
Exemple #11
0
 /** Sets any axes there are to the axis passed in */
 public void normalise(AxisType axis) {
   for (DimsData dd : iterable()) {
     if (!dd.getPlotAxis().hasValue()) dd.setPlotAxis(axis);
   }
 }