Java Code Examples for net.imglib2.type.numeric.IntegerType#getIntegerLong()

The following examples show how to use net.imglib2.type.numeric.IntegerType#getIntegerLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdSelector.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void accept(final MouseEvent e)
{
		final AffineTransform3D affine      = new AffineTransform3D();
		final ViewerState       viewerState = viewer.getState().copy();
		viewerState.getViewerTransform(affine);
		final AffineTransform3D screenScaleTransform = new AffineTransform3D();
		viewer.getRenderUnit().getScreenScaleTransform(0, screenScaleTransform);
		final int level = viewerState.getBestMipMapLevel(screenScaleTransform, source);

		source.getSourceTransform(0, level, affine);
		final RealRandomAccess<? extends IntegerType<?>> access =
				RealViews.transformReal(source.getInterpolatedDataSource(0, level, Interpolation.NEARESTNEIGHBOR), affine).realRandomAccess();
		viewer.getMouseCoordinates(access);
		access.setPosition(0L, 2);
		viewer.displayToGlobalCoordinates(access);
		final IntegerType<?> val = access.get();
		final long id  = val.getIntegerLong();
		actOn(id);
}
 
Example 2
Source File: LabelSourceStateMergeDetachHandler.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void accept(final MouseEvent e)
{
	synchronized (viewer)
	{

		final long lastSelection = selectedIds.getLastSelection();

		if (lastSelection == Label.INVALID) { return; }

		final AffineTransform3D screenScaleTransform = new AffineTransform3D();
		viewer.getRenderUnit().getScreenScaleTransform(0, screenScaleTransform);
		final int level = viewer.getState().getBestMipMapLevel(screenScaleTransform, source);

		final AffineTransform3D affine = new AffineTransform3D();
		source.getSourceTransform(0, level, affine);
		final RealRandomAccess<? extends IntegerType<?>> access = RealViews.transformReal(
				source.getInterpolatedDataSource(
						0,
						level,
						Interpolation.NEARESTNEIGHBOR),
				affine).realRandomAccess();
		viewer.getMouseCoordinates(access);
		access.setPosition(0L, 2);
		viewer.displayToGlobalCoordinates(access);
		final IntegerType<?> val = access.get();
		final long id = val.getIntegerLong();

		if (FOREGROUND_CHECK.test(id))
		{
			LOG.debug("Merging fragments: {} -- last selection: {}", id, lastSelection);
			final Optional<Merge> action = assignment.getMergeAction(
					id,
					lastSelection,
					idService::next);
			action.ifPresent(assignment::apply);
		}
	}
}
 
Example 3
Source File: LabelSourceStateMergeDetachHandler.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void accept(final MouseEvent e)
{
	final long lastSelection = selectedIds.getLastSelection();

	if (lastSelection == Label.INVALID) { return; }

	final AffineTransform3D screenScaleTransform = new AffineTransform3D();
	viewer.getRenderUnit().getScreenScaleTransform(0, screenScaleTransform);
	final int level = viewer.getState().getBestMipMapLevel(screenScaleTransform, source);

	final AffineTransform3D affine = new AffineTransform3D();
	source.getSourceTransform(0, level, affine);
	final RealRandomAccessible<? extends IntegerType<?>> transformedSource = RealViews
			.transformReal(
					source.getInterpolatedDataSource(0, level, Interpolation.NEARESTNEIGHBOR),
					affine);
	final RealRandomAccess<? extends IntegerType<?>> access = transformedSource.realRandomAccess();
	viewer.getMouseCoordinates(access);
	access.setPosition(0L, 2);
	viewer.displayToGlobalCoordinates(access);
	final IntegerType<?> val = access.get();
	final long id  = val.getIntegerLong();

	if (FOREGROUND_CHECK.test(id))
	{
		final Optional<Detach> detach = assignment.getDetachAction(id, lastSelection);
		detach.ifPresent(assignment::apply);
	}
}
 
Example 4
Source File: PainteraAlerts.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static long findMaxId(final RandomAccessibleInterval<? extends IntegerType<?>> rai) {
	long maxId = org.janelia.saalfeldlab.labels.Label.getINVALID();
	for (final IntegerType<?> t : Views.iterable(rai)) {
		final long id = t.getIntegerLong();
		if (id > maxId)
			maxId = id;
	}
	return maxId;
}
 
Example 5
Source File: PainteraCommandLineArgs.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static long findMaxId(final RandomAccessibleInterval<? extends IntegerType<?>> rai) {
	long maxId = org.janelia.saalfeldlab.labels.Label.getINVALID();
	for (final IntegerType<?> t : Views.iterable(rai)) {
		final long id = t.getIntegerLong();
		if (id > maxId)
			maxId = id;
	}
	return maxId;
}