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