List of usage examples for java.util Collections max
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp)
From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java
/** * PREVIEW STUFF//from w ww . j av a 2s . c o m */ @Override public void startPreview() { picSize = appSettingsManager.pictureSize.get(); Log.d(TAG, "Start Preview"); largestImageSize = Collections.max(Arrays.asList(cameraHolder.map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea()); picFormat = appSettingsManager.pictureFormat.get(); if (picFormat.equals("")) { picFormat = KEYS.JPEG; appSettingsManager.pictureFormat.set(KEYS.JPEG); parameterHandler.PictureFormat.onValueHasChanged(KEYS.JPEG); } if (picFormat.equals(KEYS.JPEG)) { String[] split = picSize.split("x"); int width, height; if (split.length < 2) { mImageWidth = largestImageSize.getWidth(); mImageHeight = largestImageSize.getHeight(); } else { mImageWidth = Integer.parseInt(split[0]); mImageHeight = Integer.parseInt(split[1]); } //create new ImageReader with the size and format for the image Log.d(TAG, "ImageReader JPEG"); } else if (picFormat.equals(CameraHolderApi2.RAW_SENSOR)) { Log.d(TAG, "ImageReader RAW_SENOSR"); largestImageSize = Collections.max( Arrays.asList(cameraHolder.map.getOutputSizes(ImageFormat.RAW_SENSOR)), new CompareSizesByArea()); mImageWidth = largestImageSize.getWidth(); mImageHeight = largestImageSize.getHeight(); } else if (picFormat.equals(CameraHolderApi2.RAW10)) { Log.d(TAG, "ImageReader RAW_SENOSR"); largestImageSize = Collections.max(Arrays.asList(cameraHolder.map.getOutputSizes(ImageFormat.RAW10)), new CompareSizesByArea()); mImageWidth = largestImageSize.getWidth(); mImageHeight = largestImageSize.getHeight(); } int sensorOrientation = cameraHolder.characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); int orientationToSet = (360 + cameraUiWrapper.getActivityInterface().getOrientation() + sensorOrientation) % 360; if (appSettingsManager.getApiString(AppSettingsManager.SETTING_OrientationHack).equals(KEYS.ON)) orientationToSet = (360 + cameraUiWrapper.getActivityInterface().getOrientation() + sensorOrientation + 180) % 360; cameraHolder.SetParameter(CaptureRequest.JPEG_ORIENTATION, orientationToSet); // Here, we create a CameraCaptureSession for camera preview if (parameterHandler.Burst == null) SetBurst(1); else SetBurst(parameterHandler.Burst.GetValue()); }
From source file:com.ape.camera2raw.Camera2RawFragment.java
/** * Configure the necessary {@link Matrix} transformation to `mTextureView`, * and start/restart the preview capture session if necessary. * <p/>//from ww w . java 2 s. c o m * This method should be called after the camera state has been initialized in * setUpCameraOutputs. * * @param viewWidth The width of `mTextureView` * @param viewHeight The height of `mTextureView` */ private void configureTransform(int viewWidth, int viewHeight) { Activity activity = getActivity(); synchronized (mCameraStateLock) { if (null == mTextureView || null == activity) { return; } StreamConfigurationMap map = mCharacteristics .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); // For still image captures, we always use the largest available size. Size largestJpeg = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea()); // Find the rotation of the device relative to the native device orientation. int deviceRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); Point displaySize = new Point(); activity.getWindowManager().getDefaultDisplay().getSize(displaySize); // Find the rotation of the device relative to the camera sensor's orientation. int totalRotation = sensorToDeviceRotation(mCharacteristics, deviceRotation); // Swap the view dimensions for calculation as needed if they are rotated relative to // the sensor. boolean swappedDimensions = totalRotation == 90 || totalRotation == 270; int rotatedViewWidth = viewWidth; int rotatedViewHeight = viewHeight; int maxPreviewWidth = displaySize.x; int maxPreviewHeight = displaySize.y; if (swappedDimensions) { rotatedViewWidth = viewHeight; rotatedViewHeight = viewWidth; maxPreviewWidth = displaySize.y; maxPreviewHeight = displaySize.x; } // Preview should not be larger than display size and 1080p. if (maxPreviewWidth > MAX_PREVIEW_WIDTH) { maxPreviewWidth = MAX_PREVIEW_WIDTH; } if (maxPreviewHeight > MAX_PREVIEW_HEIGHT) { maxPreviewHeight = MAX_PREVIEW_HEIGHT; } // Find the best preview size for these view dimensions and configured JPEG size. Size previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedViewWidth, rotatedViewHeight, maxPreviewWidth, maxPreviewHeight, largestJpeg); if (swappedDimensions) { mTextureView.setAspectRatio(previewSize.getHeight(), previewSize.getWidth()); } else { mTextureView.setAspectRatio(previewSize.getWidth(), previewSize.getHeight()); } // Find rotation of device in degrees (reverse device orientation for front-facing // cameras). int rotation = (mCharacteristics .get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) ? (360 + ORIENTATIONS.get(deviceRotation)) % 360 : (360 - ORIENTATIONS.get(deviceRotation)) % 360; Matrix matrix = new Matrix(); RectF viewRect = new RectF(0, 0, viewWidth, viewHeight); RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth()); float centerX = viewRect.centerX(); float centerY = viewRect.centerY(); // Initially, output stream images from the Camera2 API will be rotated to the native // device orientation from the sensor's orientation, and the TextureView will default to // scaling these buffers to fill it's view bounds. If the aspect ratios and relative // orientations are correct, this is fine. // // However, if the device orientation has been rotated relative to its native // orientation so that the TextureView's dimensions are swapped relative to the // native device orientation, we must do the following to ensure the output stream // images are not incorrectly scaled by the TextureView: // - Undo the scale-to-fill from the output buffer's dimensions (i.e. its dimensions // in the native device orientation) to the TextureView's dimension. // - Apply a scale-to-fill from the output buffer's rotated dimensions // (i.e. its dimensions in the current device orientation) to the TextureView's // dimensions. // - Apply the rotation from the native device orientation to the current device // rotation. if (Surface.ROTATION_90 == deviceRotation || Surface.ROTATION_270 == deviceRotation) { bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY()); matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL); float scale = Math.max((float) viewHeight / previewSize.getHeight(), (float) viewWidth / previewSize.getWidth()); matrix.postScale(scale, scale, centerX, centerY); } matrix.postRotate(rotation, centerX, centerY); mTextureView.setTransform(matrix); // Start or restart the active capture session if the preview was initialized or // if its aspect ratio changed significantly. if (mPreviewSize == null || !checkAspectsEqual(previewSize, mPreviewSize)) { mPreviewSize = previewSize; if (mState != STATE_CLOSED) { createCameraPreviewSessionLocked(); } } } }
From source file:net.sourceforge.fenixedu.domain.phd.PhdIndividualProgramProcess.java
public PhdProgramProcessState getLastActiveState() { return hasActiveStates() ? Collections.max(getActiveStates(), PhdProcessState.COMPARATOR_BY_DATE) : null; }
From source file:com.tesora.dve.tools.aitemplatebuilder.AiTemplateBuilder.java
private void identifyCandidateModels(final Collection<TableStats> tables, final boolean isRowWidthWeightingEnabled) throws Exception { final SortedSet<Long> sortedCardinalities = new TreeSet<Long>(); final SortedSet<Long> uniqueOperationFrequencies = new TreeSet<Long>(); for (final TableStats table : tables) { sortedCardinalities.add(table.getPredictedFutureSize(isRowWidthWeightingEnabled)); uniqueOperationFrequencies.add(table.getWriteStatementCount()); }//from w ww . ja va2s. c o m for (final TableStats table : tables) { final TemplateModelItem baseModel = findBaseModel(table); if (baseModel != null) { table.setTableDistributionModel(baseModel); table.setDistributionModelFreezed(true); logTableDistributionModel(table, MessageSeverity.ALERT); } else { final double sortsWeight = BooleanUtils.toInteger(this.enableUsingSorts); final double writesWeight = BooleanUtils.toInteger(isUsingWrites(table, this.enableUsingWrites)); final ImmutableMap<FlvName, Double> ruleWeights = ImmutableMap.<FlvName, Double>of( FuzzyTableDistributionModel.Variables.SORTS_FLV_NAME, sortsWeight, FuzzyTableDistributionModel.Variables.WRITES_FLV_NAME, writesWeight); final List<FuzzyTableDistributionModel> modelsSortedByScore = FuzzyLinguisticVariable .evaluateDistributionModels(ruleWeights, new Broadcast(table, uniqueOperationFrequencies, sortedCardinalities, isRowWidthWeightingEnabled), new Range(table, uniqueOperationFrequencies, sortedCardinalities, isRowWidthWeightingEnabled)); table.setTableDistributionModel( Collections.max(modelsSortedByScore, FuzzyLinguisticVariable.getScoreComparator())); log(table.toString().concat(": ").concat(StringUtils.join(modelsSortedByScore, ", "))); } } }
From source file:org.libreplan.business.planner.entities.ResourceAllocation.java
private List<? extends T> withoutAlreadyPresent(Collection<? extends T> assignments) { if (assignments.isEmpty()) { return Collections.emptyList(); }/*w ww.j a v a 2 s .co m*/ LocalDate min = Collections.min(assignments, DayAssignment.byDayComparator()).getDay(); LocalDate max = Collections.max(assignments, DayAssignment.byDayComparator()).getDay(); Set<LocalDate> daysPresent = DayAssignment.byDay(getAssignments(min, max.plusDays(1))).keySet(); List<T> result = new ArrayList<>(); for (T each : assignments) { if (!daysPresent.contains(each.getDay())) { result.add(each); } } return result; }
From source file:net.sourceforge.fenixedu.domain.student.Registration.java
public YearMonthDay getLastExternalApprovedEnrolmentEvaluationDate() { if (getExternalEnrolmentsSet().isEmpty()) { return null; }/*from w w w . j a v a2 s . com*/ ExternalEnrolment externalEnrolment = Collections.max(getExternalEnrolmentsSet(), ExternalEnrolment.COMPARATOR_BY_EXECUTION_PERIOD_AND_EVALUATION_DATE); return externalEnrolment.getApprovementDate() != null ? externalEnrolment.getApprovementDate() : externalEnrolment.hasExecutionPeriod() ? externalEnrolment.getExecutionPeriod().getEndDateYearMonthDay() : null; }
From source file:org.curriki.xwiki.plugin.asset.Asset.java
/** * get a sorted by date list of comments * @return the latest review object//from ww w . j av a2s .co m */ public Object getLastReview() { List reviews = getReviews(); if (reviews.isEmpty()) { return null; } return (com.xpn.xwiki.api.Object) Collections.max(reviews, new CommentsSorter()); }
From source file:net.sourceforge.fenixedu.domain.student.Student.java
public Registration getMostRecentRegistration(final DegreeCurricularPlan degreeCurricularPlan) { final List<Registration> registrations = getRegistrationsFor(degreeCurricularPlan); return registrations.isEmpty() ? null : Collections.max(registrations, Registration.COMPARATOR_BY_START_DATE); }
From source file:net.sourceforge.fenixedu.domain.Degree.java
public YearDelegateElection getYearDelegateElectionWithLastCandidacyPeriod(ExecutionYear executionYear, CurricularYear curricularYear) { List<YearDelegateElection> elections = getYearDelegateElectionsGivenExecutionYearAndCurricularYear( executionYear, curricularYear); YearDelegateElection lastYearDelegateElection = null; if (!elections.isEmpty()) { lastYearDelegateElection = Collections.max(elections, DelegateElection.ELECTION_COMPARATOR_BY_CANDIDACY_START_DATE); }// w ww . j a va 2s.c om return lastYearDelegateElection; }
From source file:net.sourceforge.fenixedu.domain.Degree.java
public YearDelegateElection getYearDelegateElectionWithLastVotingPeriod(ExecutionYear executionYear, CurricularYear curricularYear) { List<YearDelegateElection> elections = getYearDelegateElectionsGivenExecutionYearAndCurricularYear( executionYear, curricularYear); YearDelegateElection lastYearDelegateElection = null; if (!elections.isEmpty()) { lastYearDelegateElection = Collections.max(elections, DelegateElection.ELECTION_COMPARATOR_BY_VOTING_START_DATE_AND_CANDIDACY_START_DATE); }/* w w w .j a va 2 s. co m*/ return lastYearDelegateElection; }