Search in sources :

Example 26 with Pair

use of mpicbg.trakem2.util.Pair in project vcell by virtualcell.

the class PlotROIStats method run.

@Override
public void run() {
    Plot plot = new ColorPlot("ROI Mean Intensity", "Time", "Mean Intensity");
    StringBuilder legendLabels = new StringBuilder();
    for (RandomAccessibleInterval<T> data : datasetROIsMap.keySet()) {
        if (data instanceof Dataset) {
            legendLabels.append(((Dataset) data).getName());
            legendLabels.append(": ");
        }
        List<Overlay> overlays = datasetROIsMap.get(data);
        for (int i = 0; i < overlays.size(); i++) {
            Overlay overlay = overlays.get(i);
            RandomAccessibleInterval<T> cropped = crop(data, overlay);
            Pair<double[], double[]> xyPair = (Pair<double[], double[]>) ops.run("imageStatsForPlotting", ImageStatsForPlotting.MEAN, cropped);
            plot.addPoints(xyPair.getA(), xyPair.getB(), Plot.LINE);
            legendLabels.append("ROI ");
            legendLabels.append(i + 1);
            legendLabels.append("\n");
        }
    }
    plot.addLegend(legendLabels.toString());
    plot.show();
}
Also used : ColorPlot(org.vcell.imagej.common.gui.ColorPlot) Dataset(net.imagej.Dataset) Plot(ij.gui.Plot) ColorPlot(org.vcell.imagej.common.gui.ColorPlot) Overlay(net.imagej.overlay.Overlay) Pair(net.imglib2.util.Pair)

Example 27 with Pair

use of mpicbg.trakem2.util.Pair in project vcell by virtualcell.

the class PlotImageStats method run.

@Override
public void run() {
    Plot plot = new ColorPlot("Frame mean intensity", "Time", "Mean intensity");
    StringBuilder legendLabels = new StringBuilder();
    for (int i = 0; i < datasets.size(); i++) {
        RandomAccessibleInterval<T> data = datasets.get(i);
        if (data instanceof Dataset) {
            legendLabels.append(((Dataset) data).getName());
            legendLabels.append(": ");
        }
        Pair<double[], double[]> xyPair = (Pair<double[], double[]>) ops.run("imageStatsForPlotting", ImageStatsForPlotting.MEAN, data, mask);
        plot.addPoints(xyPair.getA(), xyPair.getB(), Plot.LINE);
        legendLabels.append("ROI ");
        legendLabels.append(i + 1);
        legendLabels.append("\n");
    }
    plot.addLegend(legendLabels.toString());
    plot.show();
}
Also used : ColorPlot(org.vcell.imagej.common.gui.ColorPlot) Dataset(net.imagej.Dataset) Plot(ij.gui.Plot) ColorPlot(org.vcell.imagej.common.gui.ColorPlot) Pair(net.imglib2.util.Pair)

Example 28 with Pair

use of mpicbg.trakem2.util.Pair in project mica2 by obiba.

the class AbstractFileSystemResource method doGetAttachment.

protected Attachment doGetAttachment(String path, @Nullable String version, @Nullable String shareKey) {
    String basePath = normalizePath(path);
    if (isPublishedFileSystem())
        subjectAclService.checkAccess("/file", basePath);
    else
        subjectAclService.checkPermission("/draft/file", "VIEW", basePath, shareKey);
    if (path.endsWith("/"))
        throw new IllegalArgumentException("Folder download is not supported");
    Pair<String, String> pathName = FileSystemService.extractPathName(basePath);
    AttachmentState state = fileSystemService.getAttachmentState(pathName.getKey(), pathName.getValue(), isPublishedFileSystem());
    if (isPublishedFileSystem())
        return state.getPublishedAttachment();
    if (Strings.isNullOrEmpty(version))
        return state.getAttachment();
    List<Attachment> attachments = fileSystemService.getAttachmentRevisions(state).stream().filter(a -> a.getId().equals(version)).collect(Collectors.toList());
    if (attachments.isEmpty())
        throw new NoSuchElementException("No file version " + version + " found at path: " + basePath);
    return attachments.get(0);
}
Also used : RevisionStatus(org.obiba.mica.core.domain.RevisionStatus) Attachment(org.obiba.mica.file.Attachment) SubjectAclService(org.obiba.mica.security.service.SubjectAclService) Pair(org.apache.commons.math3.util.Pair) AttachmentState(org.obiba.mica.file.AttachmentState) FileUtils(org.obiba.mica.file.FileUtils) FileSystemService(org.obiba.mica.file.service.FileSystemService) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) NoSuchEntityException(org.obiba.mica.NoSuchEntityException) FileUtils.normalizePath(org.obiba.mica.file.FileUtils.normalizePath) FileUtils.isRoot(org.obiba.mica.file.FileUtils.isRoot) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) List(java.util.List) Lists(com.google.common.collect.Lists) Mica(org.obiba.mica.web.model.Mica) NoSuchElementException(java.util.NoSuchElementException) Dtos(org.obiba.mica.web.model.Dtos) Nullable(javax.annotation.Nullable) AttachmentState(org.obiba.mica.file.AttachmentState) Attachment(org.obiba.mica.file.Attachment) NoSuchElementException(java.util.NoSuchElementException)

Example 29 with Pair

use of mpicbg.trakem2.util.Pair in project android_packages_apps_crDroidSettings by crdroidandroid.

the class PagerSlidingTabStrip method getIndicatorCoordinates.

public Pair<Float, Float> getIndicatorCoordinates() {
    // default: line below current tab
    View currentTab = mTabsContainer.getChildAt(mCurrentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();
    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (mCurrentPositionOffset > 0f && mCurrentPosition < mTabCount - 1) {
        View nextTab = mTabsContainer.getChildAt(mCurrentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();
        lineLeft = (mCurrentPositionOffset * nextTabLeft + (1f - mCurrentPositionOffset) * lineLeft);
        lineRight = (mCurrentPositionOffset * nextTabRight + (1f - mCurrentPositionOffset) * lineRight);
    }
    return new Pair<>(lineLeft, lineRight);
}
Also used : HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) Pair(android.support.v4.util.Pair)

Example 30 with Pair

use of mpicbg.trakem2.util.Pair in project incubator-gobblin by apache.

the class CouchbaseWriter method write.

@Override
public Future<WriteResponse> write(final D record, final WriteCallback callback) {
    assertRecordWritable(record);
    if (record instanceof TupleDocument) {
        ((TupleDocument) record).content().value1().retain();
    }
    Observable<D> observable = _bucket.async().upsert(record);
    if (callback == null) {
        return new WriteResponseFuture<>(observable.timeout(_operationTimeout, _operationTimeunit).toBlocking().toFuture(), _defaultWriteResponseMapper);
    } else {
        final AtomicBoolean callbackFired = new AtomicBoolean(false);
        final BlockingQueue<Pair<WriteResponse, Throwable>> writeResponseQueue = new ArrayBlockingQueue<>(1);
        final Future<WriteResponse> writeResponseFuture = new Future<WriteResponse>() {

            @Override
            public boolean cancel(boolean mayInterruptIfRunning) {
                return false;
            }

            @Override
            public boolean isCancelled() {
                return false;
            }

            @Override
            public boolean isDone() {
                return callbackFired.get();
            }

            @Override
            public WriteResponse get() throws InterruptedException, ExecutionException {
                Pair<WriteResponse, Throwable> writeResponseThrowablePair = writeResponseQueue.take();
                return getWriteResponseorThrow(writeResponseThrowablePair);
            }

            @Override
            public WriteResponse get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
                Pair<WriteResponse, Throwable> writeResponseThrowablePair = writeResponseQueue.poll(timeout, unit);
                if (writeResponseThrowablePair == null) {
                    throw new TimeoutException("Timeout exceeded while waiting for future to be done");
                } else {
                    return getWriteResponseorThrow(writeResponseThrowablePair);
                }
            }
        };
        observable.timeout(_operationTimeout, _operationTimeunit).subscribe(new Subscriber<D>() {

            @Override
            public void onCompleted() {
            }

            @Override
            public void onError(Throwable e) {
                callbackFired.set(true);
                writeResponseQueue.add(new Pair<WriteResponse, Throwable>(null, e));
                callback.onFailure(e);
            }

            @Override
            public void onNext(D doc) {
                try {
                    callbackFired.set(true);
                    WriteResponse writeResponse = new GenericWriteResponse<D>(doc);
                    writeResponseQueue.add(new Pair<WriteResponse, Throwable>(writeResponse, null));
                    callback.onSuccess(writeResponse);
                } finally {
                    if (doc instanceof TupleDocument) {
                        ((TupleDocument) doc).content().value1().release();
                    }
                }
            }
        });
        return writeResponseFuture;
    }
}
Also used : WriteResponseFuture(org.apache.gobblin.writer.WriteResponseFuture) WriteResponse(org.apache.gobblin.writer.WriteResponse) GenericWriteResponse(org.apache.gobblin.writer.GenericWriteResponse) TupleDocument(org.apache.gobblin.couchbase.common.TupleDocument) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) WriteResponseFuture(org.apache.gobblin.writer.WriteResponseFuture) Future(java.util.concurrent.Future) TimeUnit(java.util.concurrent.TimeUnit) Pair(org.apache.commons.math3.util.Pair) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Pair (android.support.v4.util.Pair)79 ArrayList (java.util.ArrayList)39 View (android.view.View)28 Pair (org.apache.commons.math3.util.Pair)20 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)16 TextView (android.widget.TextView)15 Intent (android.content.Intent)14 List (java.util.List)13 ImageView (android.widget.ImageView)10 ByteProcessor (ij.process.ByteProcessor)9 RecyclerView (android.support.v7.widget.RecyclerView)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AlertDialog (android.support.v7.app.AlertDialog)7 Pair (mpicbg.trakem2.util.Pair)7 NonNull (android.support.annotation.NonNull)6 Patch (ini.trakem2.display.Patch)6 OsmandSettings (net.osmand.plus.OsmandSettings)6 DialogInterface (android.content.DialogInterface)5 IOException (java.io.IOException)5