/** * A convenience method for defining a SamplingDefinition that returns a * complete copy of an ImageDisplay. * * @param display The ImageDisplay to sample * @return The specified SamplingDefinition */ public static SamplingDefinition sampleAllPlanes(final ImageDisplay display) { final SamplingDefinition definition = new SamplingDefinition(display); for (int i = 0; i < display.numDimensions(); i++) { final AxisType axisType = display.axis(i).type(); final long size = display.dimension(i); final AxisSubrange subrange = new AxisSubrange(0, size - 1); definition.constrain(axisType, subrange); } return definition; }
/** Creates an animation for the given {@link ImageDisplay}. */ public Animation(final ImageDisplay display) { this.display = display; display.getContext().inject(this); // assign default animation options if (display.numDimensions() > 2) { if (display.dimensionIndex(Axes.TIME) >= 0) { // animation over time is preferred by default axis = Axes.TIME; } else if (display.dimensionIndex(Axes.Z) >= 0) { // failing that, animation over Z is OK axis = Axes.Z; } else { // no preferred animation axes; use first non-spatial axis axis = display.axis(2).type(); } final int axisIndex = display.dimensionIndex(axis); last = display.dimension(axisIndex) - 1; } }
final long size = display.dimension(axisIndex); final AxisSubrange subrange = new AxisSubrange(0, size - 1); definition.constrain(axisType, subrange);
/** * A convenience method for defining a SamplingDefinition that returns a * single UV plane of an ImageDisplay. U and V are defined by the user. * * @param display The ImageDisplay to sample * @param uAxis The U axis of the sample space * @param vAxis The V axis of the sample space * @return The specified SamplingDefinition */ public static SamplingDefinition sampleUVPlane(final ImageDisplay display, final AxisType uAxis, final AxisType vAxis) { final SamplingDefinition definition = new SamplingDefinition(display); final Data data = display.getActiveView().getData(); for (int i = 0; i < data.numDimensions(); i++) { AxisType axisType = data.axis(i).type(); if ((axisType == uAxis) || (axisType == vAxis)) { final int axisIndex = display.dimensionIndex(axisType); final long size = display.dimension(axisIndex); final AxisSubrange subrange = new AxisSubrange(0, size - 1); definition.constrain(axisType, subrange); } else { // other axis final long pos = display.getLongPosition(axisType); final AxisSubrange subrange = new AxisSubrange(pos); definition.constrain(axisType, subrange); } } return definition; }