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);
}
}
}
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();
}
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;
}
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());
}
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;
}
}
Aggregations