Search in sources :

Example 36 with Pair

use of org.apache.commons.math3.util.Pair in project Material-Animations by lgvalle.

the class TransitionHelper method createSafeTransitionParticipants.

/**
 * Create the transition participants required during a activity transition while
 * avoiding glitches with the system UI.
 *
 * @param activity The activity used as start for the transition.
 * @param includeStatusBar If false, the status bar will not be added as the transition
 *        participant.
 * @return All transition participants.
 */
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) {
    // Avoid system UI glitches as described here:
    // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb
    View decor = activity.getWindow().getDecorView();
    View statusBar = null;
    if (includeStatusBar) {
        statusBar = decor.findViewById(android.R.id.statusBarBackground);
    }
    View navBar = decor.findViewById(android.R.id.navigationBarBackground);
    // Create pair of transition participants.
    List<Pair> participants = new ArrayList<>(3);
    addNonNullViewToTransitionParticipants(statusBar, participants);
    addNonNullViewToTransitionParticipants(navBar, participants);
    // only add transition participants if there's at least one none-null element
    if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) {
        participants.addAll(Arrays.asList(otherParticipants));
    }
    return participants.toArray(new Pair[participants.size()]);
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) Pair(android.support.v4.util.Pair)

Example 37 with Pair

use of org.apache.commons.math3.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 38 with Pair

use of org.apache.commons.math3.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 39 with Pair

use of org.apache.commons.math3.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 40 with Pair

use of org.apache.commons.math3.util.Pair in project materialistic by hidroh.

the class UserServicesClient method submit.

@Override
public void submit(Context context, String title, String content, boolean isUrl, Callback callback) {
    Pair<String, String> credentials = AppUtils.getCredentials(context);
    if (credentials == null) {
        callback.onDone(false);
        return;
    }
    /**
         * The flow:
         * POST /submit with acc, pw
         *  if 302 to /login, considered failed
         * POST /r with fnid, fnop, title, url or text
         *  if 302 to /newest, considered successful
         *  if 302 to /x, considered error, maybe duplicate or invalid input
         *  if 200 or anything else, considered error
         */
    // fetch submit page with given credentials
    execute(postSubmitForm(credentials.first, credentials.second)).flatMap(response -> response.code() != HttpURLConnection.HTTP_MOVED_TEMP ? Observable.just(response) : Observable.error(new IOException())).flatMap(response -> {
        try {
            return Observable.just(new String[] { response.header(HEADER_SET_COOKIE), response.body().string() });
        } catch (IOException e) {
            return Observable.error(e);
        } finally {
            response.close();
        }
    }).map(array -> {
        array[1] = getInputValue(array[1], SUBMIT_PARAM_FNID);
        return array;
    }).flatMap(array -> !TextUtils.isEmpty(array[1]) ? Observable.just(array) : Observable.error(new IOException())).flatMap(array -> execute(postSubmit(title, content, isUrl, array[0], array[1]))).flatMap(response -> response.code() == HttpURLConnection.HTTP_MOVED_TEMP ? Observable.just(Uri.parse(response.header(HEADER_LOCATION))) : Observable.error(new IOException())).flatMap(uri -> TextUtils.equals(uri.getPath(), DEFAULT_SUBMIT_REDIRECT) ? Observable.just(true) : Observable.error(buildException(uri))).observeOn(AndroidSchedulers.mainThread()).subscribe(callback::onDone, callback::onError);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Context(android.content.Context) Request(okhttp3.Request) Uri(android.net.Uri) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) TextUtils(android.text.TextUtils) IOException(java.io.IOException) Scheduler(rx.Scheduler) Observable(rx.Observable) Inject(javax.inject.Inject) AppUtils(io.github.hidroh.materialistic.AppUtils) Matcher(java.util.regex.Matcher) FormBody(okhttp3.FormBody) R(io.github.hidroh.materialistic.R) Pair(android.support.v4.util.Pair) Toast(android.widget.Toast) Response(okhttp3.Response) Call(okhttp3.Call) Pattern(java.util.regex.Pattern) HttpUrl(okhttp3.HttpUrl) IOException(java.io.IOException)

Aggregations

Pair (android.support.v4.util.Pair)38 ArrayList (java.util.ArrayList)22 View (android.view.View)16 Collectors (java.util.stream.Collectors)16 IntStream (java.util.stream.IntStream)16 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)13 Logger (org.apache.logging.log4j.Logger)12 ParamUtils (org.broadinstitute.hellbender.utils.param.ParamUtils)12 Intent (android.content.Intent)11 Pair (org.apache.commons.math3.util.Pair)11 IOException (java.io.IOException)10 java.util (java.util)10 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)10 Pair (org.apache.commons.lang3.tuple.Pair)10 RealMatrix (org.apache.commons.math3.linear.RealMatrix)10 File (java.io.File)9 List (java.util.List)9 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)8 UserException (org.broadinstitute.hellbender.exceptions.UserException)8 org.broadinstitute.hellbender.tools.exome (org.broadinstitute.hellbender.tools.exome)8