@Override public void min(final long[] min) { for (int i = 0; i < min.length; i++) { min[i] = min(i); } }
@Override public long dimension(final int d) { return max(d) - min(d) + 1; }
@Override public void min(final Positionable min) { for (int i = 0; i < min.numDimensions(); i++) { min.setPosition(min(i), i); } }
@Override public long getLongPosition(final AxisType axis) { final int d = dimensionIndex(axis); if (d < 0) { // untracked axes are all at position 0 by default return 0; } final Long value = pos.get(axis); if (value == null) return 0; final long min = min(d); if (value < min) return min; final long max = max(d); if (value > max) return max; return value; }
@Override public void setPosition(final long position, final AxisType axis) { final int axisIndex = dimensionIndex(axis); if (axisIndex < 0) { throw new IllegalArgumentException("Invalid axis: " + axis); } // clamp new position value to [min, max] final long min = min(axisIndex); final long max = max(axisIndex); long value = position; if (value < min) value = min; if (value > max) value = max; // update position pos.put(axis, value); // notify interested parties of the change // NB: DataView.setPosition is called only in update method. if (eventService != null) { // NB: BDZ changed from publish() to publishLater(). This fixes bug #1234. // We may want to change order of events to allow publish() instead. eventService.publishLater(new AxisPositionEvent(this, axis)); } }
if (!pos.containsKey(axis)) { pos.put(axis, min(i));