Search in sources :

Example 1 with AxisType

use of net.imagej.axis.AxisType in project imagej-ui-swing by imagej.

the class SwingImageDisplayPanel method createSliders.

// -- Helper methods --
private void createSliders() {
    // remove obsolete sliders
    for (final AxisType axis : axisSliders.keySet()) {
        // axis still active
        if (display.dimensionIndex(axis) >= 0)
            continue;
        sliderPanel.remove(axisSliders.get(axis));
        sliderPanel.remove(axisLabels.get(axis));
        axisSliders.remove(axis);
        axisLabels.remove(axis);
    }
    // configure sliders to match axes and extents
    for (int i = 0; i < display.numDimensions(); i++) {
        final AxisType axis = display.axis(i).type();
        // skip spatial axes
        if (axis.isXY())
            continue;
        final int min = (int) display.min(i);
        final int max = (int) display.max(i) + 1;
        // skip length 1 axes
        if (max - min <= 1)
            continue;
        final int value = (int) display.getLongPosition(axis);
        final JScrollBar axisSlider = axisSliders.get(axis);
        if (axisSlider == null) {
            // create new slider
            final JLabel label = new JLabel(axis.getLabel());
            label.setHorizontalAlignment(SwingConstants.RIGHT);
            axisLabels.put(axis, label);
            final JScrollBar slider = new JScrollBar(Adjustable.HORIZONTAL, value, 1, min, max);
            slider.addAdjustmentListener(new AdjustmentListener() {

                @Override
                public void adjustmentValueChanged(final AdjustmentEvent e) {
                    display.setPosition(slider.getValue(), axis);
                }
            });
            axisSliders.put(axis, slider);
            // add slider to panel
            // TODO - ensure sliders are always ordered the same (alphabetical?)
            sliderPanel.add(label);
            sliderPanel.add(slider);
        } else {
            // update slider extents and value
            if (axisSlider.getMinimum() != min || axisSlider.getMaximum() != max) {
                axisSlider.setValues(value, 1, min, max);
            } else if (axisSlider.getValue() != value)
                axisSlider.setValue(value);
        }
    }
}
Also used : AdjustmentEvent(java.awt.event.AdjustmentEvent) AdjustmentListener(java.awt.event.AdjustmentListener) JLabel(javax.swing.JLabel) AxisType(net.imagej.axis.AxisType) JScrollBar(javax.swing.JScrollBar)

Example 2 with AxisType

use of net.imagej.axis.AxisType in project imagej-ui-swing by imagej.

the class JHotDrawImageCanvas method onEvent.

/**
 * When a tool creates an overlay, add the overlay/figure combo to an
 * {@link OverlayFigureView}.
 */
@EventHandler
protected void onEvent(final FigureCreatedEvent event) {
    final ImageDisplay display = event.getDisplay();
    // not this canvas's display
    if (display != getDisplay())
        return;
    final OverlayView overlay = event.getView();
    for (int i = 0; i < display.numDimensions(); i++) {
        final AxisType axisType = display.axis(i).type();
        if (axisType.isXY())
            continue;
        if (overlay.getData().dimensionIndex(axisType) < 0) {
            overlay.setPosition(display.getLongPosition(axisType), axisType);
        }
    }
    if (drawingView.getSelectedFigures().contains(event.getFigure())) {
        overlay.setSelected(true);
    }
    final OverlayFigureView figureView = new OverlayFigureView(displayViewer, overlay, event.getFigure());
    figureViews.add(figureView);
    display.add(overlay);
    display.update();
}
Also used : AxisType(net.imagej.axis.AxisType) ImageDisplay(net.imagej.display.ImageDisplay) OverlayView(net.imagej.display.OverlayView) Point(java.awt.Point) EventHandler(org.scijava.event.EventHandler)

Example 3 with AxisType

use of net.imagej.axis.AxisType in project imagej-plugins-commands by imagej.

the class ApplyLookupTable method makeData.

// -- private helpers --
private Dataset makeData() {
    String urlString;
    try {
        urlString = tableURL.toURI().getPath();
    } catch (Exception e) {
        urlString = tableURL.getPath();
    }
    String name = urlString.substring(urlString.lastIndexOf("/") + 1, urlString.length());
    long[] dims = new long[] { WIDTH, HEIGHT };
    AxisType[] axes = new AxisType[] { Axes.X, Axes.Y };
    int bitsPerPixel = 8;
    boolean signed = false;
    boolean floating = false;
    Dataset ds = datasetService.create(dims, name, axes, bitsPerPixel, signed, floating);
    ramp(ds);
    return ds;
}
Also used : Dataset(net.imagej.Dataset) AxisType(net.imagej.axis.AxisType) IOException(java.io.IOException)

Example 4 with AxisType

use of net.imagej.axis.AxisType in project imagej-plugins-commands by imagej.

the class ReorderData method setNewAxisIndex.

/**
 * Sets newAxes[index] from existingAxes[fromPosition]
 * @param index The index within the new axis order
 * @param fromPosition The index within the current axis order
 */
public void setNewAxisIndex(int index, int fromPosition) {
    AxisType axis = dataset.axis(fromPosition).type();
    setInput(name(index), axis.getLabel());
}
Also used : AxisType(net.imagej.axis.AxisType)

Example 5 with AxisType

use of net.imagej.axis.AxisType in project imagej-plugins-commands by imagej.

the class ReorderData method setupPermutationVars.

/**
 * Sets up the working variable "permutationAxisIndices" which is used to
 * actually permute positions.
 */
private void setupPermutationVars() {
    final AxisType[] currAxes = SpaceUtils.getAxisTypes(dataset);
    final AxisType[] permutedAxes = getPermutedAxes(currAxes);
    permutationAxisIndices = new int[currAxes.length];
    for (int i = 0; i < currAxes.length; i++) {
        final AxisType axis = currAxes[i];
        final int newIndex = getNewAxisIndex(permutedAxes, axis);
        permutationAxisIndices[i] = newIndex;
    }
}
Also used : AxisType(net.imagej.axis.AxisType)

Aggregations

AxisType (net.imagej.axis.AxisType)57 Dataset (net.imagej.Dataset)13 ArrayList (java.util.ArrayList)9 HyperVolumePointSet (net.imglib2.ops.pointset.HyperVolumePointSet)5 DefaultMutableModuleItem (org.scijava.module.DefaultMutableModuleItem)4 CalibratedAxis (net.imagej.axis.CalibratedAxis)3 PointSetIterator (net.imglib2.ops.pointset.PointSetIterator)3 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)3 Gaussian2D (de.mpg.biochem.mars.util.Gaussian2D)2 Context (org.scijava.Context)2 DatasetInputImage (sc.fiji.labkit.ui.inputimage.DatasetInputImage)2 SpimSource (bdv.SpimSource)1 SpimDataMinimal (bdv.spimdata.SpimDataMinimal)1 XmlIoSpimDataMinimal (bdv.spimdata.XmlIoSpimDataMinimal)1 HelpDialog (bdv.tools.HelpDialog)1 ConverterSetup (bdv.tools.brightness.ConverterSetup)1 DEFAULT_SOURCEGROUPS_CARD (bdv.ui.BdvDefaultCards.DEFAULT_SOURCEGROUPS_CARD)1 DEFAULT_VIEWERMODES_CARD (bdv.ui.BdvDefaultCards.DEFAULT_VIEWERMODES_CARD)1 Affine3DHelpers (bdv.util.Affine3DHelpers)1 Bdv (bdv.util.Bdv)1