List of usage examples for java.util Collections max
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)
From source file:org.dspace.content.ItemComparator.java
/** * Choose the canonical value from an item for comparison. If there are no * values, null is returned. If there is exactly one value, then it is * returned. Otherwise, either the maximum or minimum lexicographical value * is returned; the parameter to the constructor says which. * // w w w . java2 s. c o m * @param item * The item to check * @return The chosen value, or null */ private String getValue(Item item) { // The overall array and each element are guaranteed non-null DCValue[] dcvalues = item.getDC(element, qualifier, language); if (dcvalues.length == 0) { return null; } if (dcvalues.length == 1) { return normalizeTitle(dcvalues[0]); } // We want to sort using Strings, but also keep track of // which DCValue the value came from. Map<String, Integer> values = new HashMap<String, Integer>(); for (int i = 0; i < dcvalues.length; i++) { String value = dcvalues[i].value; if (value != null) { values.put(value, Integer.valueOf(i)); } } if (values.size() == 0) { return null; } Set<String> valueSet = values.keySet(); String chosen = max ? Collections.max(valueSet) : Collections.min(valueSet); int index = (values.get(chosen)).intValue(); return normalizeTitle(dcvalues[index]); }
From source file:org.wallerlab.yoink.cube.service.CubeBuilderImpl.java
private void getMinMax(List<Double> xCoordOfAllMolecules, List<Double> yCoordOfAllMolecules, List<Double> zCoordOfAllMolecules, Cube cube, double[] xyzMinimumOfCube, double[] xyzMaximumOfCube) { double xMinimumOfCube = Collections.min(xCoordOfAllMolecules); double yMinimumOfCube = Collections.min(yCoordOfAllMolecules); double zMinimumOfCube = Collections.min(zCoordOfAllMolecules); double xMaximumOfCube = Collections.max(xCoordOfAllMolecules); double yMaximumOfCube = Collections.max(yCoordOfAllMolecules); double zMaximumOfCube = Collections.max(zCoordOfAllMolecules); // build a larger cube to write cube files if (cube.getDensityTypes().size() != 0) { xMinimumOfCube -= 2;/*w w w . j av a 2 s . c o m*/ yMinimumOfCube -= 2; zMinimumOfCube -= 2; xMaximumOfCube += 2; yMaximumOfCube += 2; zMaximumOfCube += 2; } xyzMinimumOfCube[0] = xMinimumOfCube; xyzMinimumOfCube[1] = yMinimumOfCube; xyzMinimumOfCube[2] = zMinimumOfCube; xyzMaximumOfCube[0] = xMaximumOfCube; xyzMaximumOfCube[1] = yMaximumOfCube; xyzMaximumOfCube[2] = zMaximumOfCube; }
From source file:org.nuclos.common2.LangUtils.java
/** * @param ac one or more <code>Comparable</code>s, none of which may be <code>null</code>. * @return the maximum of the given <code>Comparable</code>s. * @precondition ac != null// w ww. j a va2s. co m */ public static <C extends Comparable<? super C>> C max(C... ac) { return Collections.max(Arrays.asList(ac)); }
From source file:org.libreplan.business.planner.entities.TaskElement.java
/** * @returns the biggest one among the deadline (if exists) or the end date. *//*w ww. j av a 2s . co m*/ @SuppressWarnings("unchecked") public LocalDate getBiggestAmongEndOrDeadline() { return this.getDeadline() != null ? Collections.max(asList(this.getDeadline(), this.getEndAsLocalDate())) : this.getEndAsLocalDate(); }
From source file:dkpro.similarity.algorithms.lsr.LexSemResourceComparator.java
protected double getBestRelatedness(List<Double> relatednessValues) throws SimilarityException { if (relatednessValues.size() == 0) { return NOT_FOUND; }/* w ww . jav a 2 s . c om*/ List<Double> scores = new ArrayList<Double>(); for (double d : relatednessValues) { if (d >= 0.0) { scores.add(d); } } if (scores.size() == 0) { scores.add(NOT_FOUND); } return isDistanceMeasure() ? Collections.min(scores) : Collections.max(scores); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRNormalizedController.java
/** * Initialize view.//from w w w .j av a 2 s . c om */ @Override protected void initDRNormalizedPanel() { dRNormalizedPlotPanel = new DRNormalizedPlotPanel(); //init chart panel normalizedChartPanel = new ChartPanel(null); normalizedChartPanel.setOpaque(false); /** * Action listeners for buttons */ /** * The combo box determines how the normalization is done. Bottom combo * box defines what the value for 0% response is. */ dRNormalizedPlotPanel.getBottomComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String value = (String) dRNormalizedPlotPanel.getBottomComboBox().getSelectedItem(); switch (value) { case "Smallest Mean Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMeans(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Smallest Median Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMedians(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getBottomTextField().setText(""); dRNormalizedPlotPanel.getBottomTextField().setEditable(true); break; } } }); /** * The combo box determines how the normalization is done. Top combo box * defines what the value for 100% response is. */ dRNormalizedPlotPanel.getTopComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String choice = (String) dRNormalizedPlotPanel.getTopComboBox().getSelectedItem(); switch (choice) { case "Largest Mean Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMeans(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Largest Median Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField() .setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMedians(getAllResponses( doseResponseController.getdRAnalysisGroup().getDoseResponseData())))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getTopTextField().setText(""); dRNormalizedPlotPanel.getTopTextField().setEditable(true); break; } } }); /** * If selected, the curve fit 'bottom' parameter will be constrained to * zero. This zero is defined by the text field value during * normalization. * */ dRNormalizedPlotPanel.getBottomConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { bottomConstrainValue = 0.0; } else { bottomConstrainValue = null; } } }); /** * If selected, the curve fit 'top' parameter will be constrained to * 100. This is defined by the text field value during normalization. * */ dRNormalizedPlotPanel.getTopConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { topConstrainValue = 100.0; } else { topConstrainValue = null; } } }); /** * Re-normalize and plot new dose-response graph, taking into account * any choices made by the user. */ dRNormalizedPlotPanel.getPlotGraphButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dataToFit = prepareFittingData(doseResponseController.getdRAnalysisGroup().getDoseResponseData(), doseResponseController.getLogTransform()); setTableModel(doseResponseController.updateTableModel(createTableModel(dataToFit))); doseResponseController.updateModelInTable(tableModel); doseResponseController .performFitting( dataToFit, doseResponseController.getdRAnalysisGroup() .getDoseResponseAnalysisResults().getFittingResults(true), bottomConstrainValue, topConstrainValue); doseResponseController.plotDoseResponse(normalizedChartPanel, dRNormalizedPlotPanel.getDoseResponseChartParentPanel(), dataToFit, doseResponseController.getdRAnalysisGroup(), true); //Calculate new statistics doseResponseController.calculateStatistics(); } }); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRNormalizedController.java
/** * Initialize view//from www . j a va2 s .c o m */ @Override protected void initDRNormalizedPanel() { dRNormalizedPlotPanel = new DRNormalizedPlotPanel(); //init chart panel normalizedChartPanel = new ChartPanel(null); normalizedChartPanel.setOpaque(false); /** * Action listeners for buttons */ /** * The combo box determines how the normalization is done. Bottom combo * box defines what the value for 0% response is. */ dRNormalizedPlotPanel.getBottomComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String value = (String) dRNormalizedPlotPanel.getBottomComboBox().getSelectedItem(); switch (value) { case "Smallest Mean Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMeans( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Smallest Median Value": dRNormalizedPlotPanel.getBottomTextField().setEditable(false); dRNormalizedPlotPanel.getBottomTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.min(computeMedians( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getBottomTextField().setText(""); dRNormalizedPlotPanel.getBottomTextField().setEditable(true); break; } } }); /** * The combo box determines how the normalization is done. Top combo box * defines what the value for 100% response is. */ dRNormalizedPlotPanel.getTopComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String choice = (String) dRNormalizedPlotPanel.getTopComboBox().getSelectedItem(); switch (choice) { case "Largest Mean Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMeans( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Largest Median Value": dRNormalizedPlotPanel.getTopTextField().setEditable(false); dRNormalizedPlotPanel.getTopTextField().setText(AnalysisUtils .roundTwoDecimals(Collections.max(computeMedians( doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values()))) .toString()); break; case "Other Value": dRNormalizedPlotPanel.getTopTextField().setText(""); dRNormalizedPlotPanel.getTopTextField().setEditable(true); break; } } }); /** * If selected, the curve fit 'bottom' parameter will be constrained to * zero. This zero is defined by the text field value during * normalization. * */ dRNormalizedPlotPanel.getBottomConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { bottomConstrainValue = 0.0; } else { bottomConstrainValue = null; } } }); /** * If selected, the curve fit 'top' parameter will be constrained to * 100. This is defined by the text field value during normalization. * */ dRNormalizedPlotPanel.getTopConstrainCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { topConstrainValue = 100.0; } else { topConstrainValue = null; } } }); /** * Re-normalize and plot new dose-response graph, taking into account * any choices made by the user. */ dRNormalizedPlotPanel.getPlotGraphButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dataToFit = prepareFittingData(doseResponseController.getdRAnalysisGroup()); setTableModel(createTableModel(dataToFit)); doseResponseController.updateModelInTable(tableModel); doseResponseController .performFitting( dataToFit, doseResponseController.getdRAnalysisGroup() .getDoseResponseAnalysisResults().getFittingResults(true), bottomConstrainValue, topConstrainValue); doseResponseController.plotDoseResponse(normalizedChartPanel, dRNormalizedPlotPanel.getDoseResponseChartParentPanel(), dataToFit, doseResponseController.getdRAnalysisGroup(), true); //Calculate new statistics doseResponseController.calculateStatistics(); } }); }
From source file:org.apache.accumulo.test.functional.RegexGroupBalanceIT.java
private boolean checkGroup(Table<String, String, MutableInt> groupLocationCounts, String group, int min, int max, int tsevers) { Collection<MutableInt> counts = groupLocationCounts.row(group).values(); if (counts.size() == 0) { return min == 0 && max == 0 && tsevers == 0; }// w w w. ja v a2 s .c om return min == Collections.min(counts).intValue() && max == Collections.max(counts).intValue() && counts.size() == tsevers; }
From source file:br.ufpe.cin.emergo.instrument.bitrep.BitVectorConfigRep.java
public static BitVectorConfigRep convert(BitConfigRep rep, UnmodifiableBidiMap atoms) { int max = atoms.isEmpty() ? 1 : ((Integer) Collections.max(atoms.values())) << 1; BitVector bitVector = new BitVector(max); bitVector.put(rep.getId(), true);//from www . j a v a 2s .c o m return new BitVectorConfigRep(atoms, bitVector); }
From source file:org.kuali.coeus.common.questionnaire.impl.core.QuestionnaireLookupableHelperServiceImpl.java
protected Questionnaire getQuestionnaireBySeqId(String questionnaireSeqId) { Questionnaire questionnaire = null;/*from w w w. jav a2 s. c o m*/ if (questionnaireSeqId != null) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put(QuestionnaireConstants.QUESTIONNAIRE_SEQUENCE_ID_PARAMETER_NAME, questionnaireSeqId); Collection<Questionnaire> questionnaires = getBusinessObjectService() .findMatchingOrderBy(Questionnaire.class, fieldValues, "SEQUENCE_NUMBER", false); if (questionnaires.size() > 0) { questionnaire = Collections.max(questionnaires); } } return questionnaire; }