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:fNIRs.FNIRsStats.java
public static void oldOutputANOVAs(GroupedChannels data, List<String> groupNames, List<Integer> conditions, int numChunks, int precision) { // get all condition-group sequences: ArrayList<GroupedChannels.TaggedDataSequence> allTDSs = data.getAllSelectedTDSs(groupNames, conditions); chunkData(allTDSs, numChunks); // COMMENT THIS LATER // calculate required widths for printed names and condition numbers: int nameWidth = longestLength(groupNames); // length of longest name int conditionWidth = // number of digits in the largest condition number String.valueOf(Collections.max(conditions)).length(); // make sure the fields will be wide enough to hold the ANOVA values, // which will, in the widest case, consist of a 1 followed by a . and // precision 0s: // AM I USING "PRECISION" RIGHT? int idFieldWidth = nameWidth + conditionWidth + 2; if (idFieldWidth < precision + 2) { // for the "1." // if not, increase the condition width so the total field width is // large enough: idFieldWidth = precision + 2;//from w w w . j a v a 2 s. c o m } String idFieldFormat = "%-" + idFieldWidth + "s"; // output the first row, containing identifying information for each // group-condition combination: // first, output proper-width placeholder for the identifier column: System.out.printf("%" + idFieldWidth + "s ", ""); // TOO HACKY?? // then, output all tds identifiers: for (GroupedChannels.TaggedDataSequence tds : allTDSs) { System.out.printf(idFieldFormat + " ", tds.getGroupName() + " c" + tds.getCondition()); } System.out.println(); // print newline // output ANOVA values line by line: OneWayAnova myANOVA = new OneWayAnova(); for (GroupedChannels.TaggedDataSequence first : allTDSs) { // output tds identifier in first column: System.out.printf(idFieldFormat + " ", first.getGroupName() + " c" + first.getCondition()); // create Collection to send to the ANOVA object: LinkedList<double[]> dataSets = new LinkedList<double[]>(); // convert first's data sequence to an array, then add it to // dataSets dataSets.add(toPrimitiveDoubleArray(first.getData())); dataSets.add(null); // placeholder for second's data sequence for (GroupedChannels.TaggedDataSequence second : allTDSs) { // convert and add second's data sequence to position one in // dataSets: dataSets.set(1, toPrimitiveDoubleArray(second.getData())); double result = -1; // not a valid ANOVA value so we know if // something went wrong try { result = myANOVA.anovaPValue(dataSets); } catch (Exception ex) { System.out.println(); localError("unknown problem calculating ANOVA: " + ex.getMessage()); } System.out.printf("%-" + idFieldWidth + "." + precision + "f ", result); // dataSets.remove(1); // remove second's data from dataSets } System.out.println(); // print newline } }
From source file:uk.ac.soton.mib104.t2.workbench.ui.ActivityConfigurationPanelWithInputPortAndOutputPortComponents.java
/** * Returns the next port name with the specified <code>prefix</code>, given the set of existing <code>portNames</code>. * /*from w w w . j av a2 s.c o m*/ * @param prefix The prefix. * @param portNames The set of existing port names. * @return The next port name. * @throws IllegalArgumentException If <code>prefix == null</code>. */ private static final String nextPortName(final String prefix, final Set<String> portNames) throws IllegalArgumentException { if (prefix == null) { throw new IllegalArgumentException(new NullPointerException("portName")); } final Set<Integer> indices = new HashSet<Integer>(); if (portNames != null) { // Compile a regular expression for the prefix followed by an integer. final Pattern pattern = Pattern.compile(String.format("^\\s*?%s(\\d+)\\s*?$", Pattern.quote(prefix))); for (final String nextPortName : portNames) { final Matcher matcher = pattern.matcher(nextPortName); if (matcher.matches()) { // If the regular expression matches the 'nextPortName', then add the integer (capture group 1) to the set. indices.add(Integer.parseInt(matcher.group(1))); } } } // The next index is the successor of the maximum index. final int nextIndex = 1 + (indices.isEmpty() ? 0 : Collections.max(indices)); return String.format("%s%d", prefix, nextIndex); }
From source file:eu.ggnet.dwoss.redtape.entity.Document.java
/** * Appends a position at the and of the document. * <p/>/* w ww . j a v a2 s . c om*/ * @param position the position to be appended. * @return the added position; * @throws IllegalArgumentException if the supplied position has a document other than null.. */ public Position append(Position position) throws IllegalArgumentException { if (position == null) return null; if (position.document != null) throw new IllegalArgumentException("Position has a document other than null: + " + position); position.document = this; if (positions.keySet().isEmpty()) position.id = 1; else position.id = Collections.max(positions.keySet()) + 1; positions.put(position.id, position); return position; }
From source file:it.tizianofagni.sparkboost.DataUtils.java
public static int getNumLabels(JavaRDD<MultilabelPoint> documents) { if (documents == null) throw new NullPointerException("The documents RDD is 'null'"); int maxValidLabelID = documents.map(doc -> { List<Integer> values = Arrays.asList(ArrayUtils.toObject(doc.getLabels())); if (values.size() == 0) return 0; else// w w w. j a v a 2 s .co m return Collections.max(values); }).reduce((m1, m2) -> Math.max(m1, m2)); return maxValidLabelID + 1; }
From source file:com.p3authentication.preferences.Prefs.java
@SuppressWarnings("static-access") @Override// w w w.ja va 2 s . c o m public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub int action = event.getAction(); int N = event.getHistorySize(); if (action == event.ACTION_DOWN) { calibrator.setColorFilter(Color.BLACK); for (int i = 0; i < N; i++) { calibrate(event.getHistoricalX(i), event.getHistoricalY(i), event.getHistoricalPressure(i), event.getHistoricalSize(i)); } calibrate(event.getX(), event.getY(), event.getPressure(), event.getSize()); } else if (action == event.ACTION_UP) { Float temp = Collections.max(CalList); temp = (float) Math.ceil((Double.parseDouble(Float.valueOf(temp).toString())) / 10); LargeValue = temp * 10; calibrator.setColorFilter(Color.GREEN); // Largest.setText(String.valueOf(LargeValue)); } return true; }
From source file:com.pearson.dashboard.util.Util.java
public static void populateDefectData(DashboardForm dashboardForm, Configuration configuration) throws Exception { Map<String, List<Defect>> allDefects = null; if (dashboardForm.getTabName().startsWith("Other") || dashboardForm.getTabName().startsWith("Author")) { allDefects = Util.getMultiProjectDataFromRally(dashboardForm, configuration); } else {/* w w w . j a v a 2 s . c o m*/ allDefects = Util.getDataFromRally(dashboardForm, configuration); } int winCount = 0; int iOSCount = 0; //Open defects List<Defect> openDefects = allDefects.get("Open"); List<Priority> priorities = new ArrayList<Priority>(); Priority tbd1 = new Priority(); tbd1.setPriorityName("TBD"); Priority priority1 = new Priority(); priority1.setPriorityName("P1"); Priority priority2 = new Priority(); priority2.setPriorityName("P2"); Priority priority3 = new Priority(); priority3.setPriorityName("P3"); Priority priority4 = new Priority(); priority4.setPriorityName("P4"); for (Defect defect : openDefects) { if (defect.getPriority().equalsIgnoreCase("TBD")) { tbd1.setPriorityCount(tbd1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P1")) { priority1.setPriorityCount(priority1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P2")) { priority2.setPriorityCount(priority2.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P3")) { priority3.setPriorityCount(priority3.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P4")) { priority4.setPriorityCount(priority4.getPriorityCount() + 1); } } ArrayList<Integer> arrayList = new ArrayList<Integer>(); arrayList.add(tbd1.getPriorityCount()); arrayList.add(priority1.getPriorityCount()); arrayList.add(priority2.getPriorityCount()); arrayList.add(priority3.getPriorityCount()); arrayList.add(priority4.getPriorityCount()); Integer maximumCount = Collections.max(arrayList); if (maximumCount <= 0) { tbd1.setPxSize("0"); priority1.setPxSize("0"); priority2.setPxSize("0"); priority3.setPxSize("0"); priority4.setPxSize("0"); } else { tbd1.setPxSize(Math.round((100 * tbd1.getPriorityCount()) / maximumCount) + ""); priority1.setPxSize(Math.round((100 * priority1.getPriorityCount()) / maximumCount) + ""); priority2.setPxSize(Math.round((100 * priority2.getPriorityCount()) / maximumCount) + ""); priority3.setPxSize(Math.round((100 * priority3.getPriorityCount()) / maximumCount) + ""); priority4.setPxSize(Math.round((100 * priority4.getPriorityCount()) / maximumCount) + ""); } priorities.add(tbd1); priorities.add(priority1); priorities.add(priority2); priorities.add(priority3); priorities.add(priority4); for (Defect defect : openDefects) { if (defect.getPlatform().equalsIgnoreCase("iOS")) { iOSCount++; } else if (defect.getPlatform().equalsIgnoreCase("Windows")) { winCount++; } } dashboardForm.setComponentsCountOpen(populateComponentsMap(openDefects)); dashboardForm.setOpenDefects(openDefects); dashboardForm.setOpenPriorities(priorities); dashboardForm.setOpenDefectCount(openDefects.size()); int p1np2cnt = priority1.getPriorityCount() + priority2.getPriorityCount(); dashboardForm.setOpenP1AndP2Count(p1np2cnt); dashboardForm.setOpenMsg("iOS: " + iOSCount + ", Windows: " + winCount); //Submitted defects List<Defect> submittedDefects = allDefects.get("Submitted"); priorities = new ArrayList<Priority>(); tbd1 = new Priority(); tbd1.setPriorityName("TBD"); priority1 = new Priority(); priority1.setPriorityName("P1"); priority2 = new Priority(); priority2.setPriorityName("P2"); priority3 = new Priority(); priority3.setPriorityName("P3"); priority4 = new Priority(); priority4.setPriorityName("P4"); for (Defect defect : submittedDefects) { if (defect.getPriority().equalsIgnoreCase("TBD")) { tbd1.setPriorityCount(tbd1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P1")) { priority1.setPriorityCount(priority1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P2")) { priority2.setPriorityCount(priority2.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P3")) { priority3.setPriorityCount(priority3.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P4")) { priority4.setPriorityCount(priority4.getPriorityCount() + 1); } } arrayList = new ArrayList<Integer>(); arrayList.add(tbd1.getPriorityCount()); arrayList.add(priority1.getPriorityCount()); arrayList.add(priority2.getPriorityCount()); arrayList.add(priority3.getPriorityCount()); arrayList.add(priority4.getPriorityCount()); maximumCount = Collections.max(arrayList); if (maximumCount <= 0) { tbd1.setPxSize("0"); priority1.setPxSize("0"); priority2.setPxSize("0"); priority3.setPxSize("0"); priority4.setPxSize("0"); } else { tbd1.setPxSize(Math.round((100 * tbd1.getPriorityCount()) / maximumCount) + ""); priority1.setPxSize(Math.round((100 * priority1.getPriorityCount()) / maximumCount) + ""); priority2.setPxSize(Math.round((100 * priority2.getPriorityCount()) / maximumCount) + ""); priority3.setPxSize(Math.round((100 * priority3.getPriorityCount()) / maximumCount) + ""); priority4.setPxSize(Math.round((100 * priority4.getPriorityCount()) / maximumCount) + ""); } priorities.add(tbd1); priorities.add(priority1); priorities.add(priority2); priorities.add(priority3); priorities.add(priority4); iOSCount = 0; winCount = 0; for (Defect defect : submittedDefects) { if (defect.getPlatform().equalsIgnoreCase("iOS")) { iOSCount++; } else if (defect.getPlatform().equalsIgnoreCase("Windows")) { winCount++; } } dashboardForm.setComponentsCountSubmitted(populateComponentsMap(submittedDefects)); dashboardForm.setSubmittedDefects(submittedDefects); dashboardForm.setSubmittedPriorities(priorities); dashboardForm.setSubmittedDefectCount(submittedDefects.size()); p1np2cnt = priority1.getPriorityCount() + priority2.getPriorityCount(); dashboardForm.setSubmittedP1AndP2Count(p1np2cnt); dashboardForm.setSubmittedMsg("iOS: " + iOSCount + ", Windows: " + winCount); //Fixed defects List<Defect> fixedDefects = allDefects.get("Fixed"); priorities = new ArrayList<Priority>(); tbd1 = new Priority(); tbd1.setPriorityName("TBD"); priority1 = new Priority(); priority1.setPriorityName("P1"); priority2 = new Priority(); priority2.setPriorityName("P2"); priority3 = new Priority(); priority3.setPriorityName("P3"); priority4 = new Priority(); priority4.setPriorityName("P4"); for (Defect defect : fixedDefects) { if (defect.getPriority().equalsIgnoreCase("TBD")) { tbd1.setPriorityCount(tbd1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P1")) { priority1.setPriorityCount(priority1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P2")) { priority2.setPriorityCount(priority2.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P3")) { priority3.setPriorityCount(priority3.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P4")) { priority4.setPriorityCount(priority4.getPriorityCount() + 1); } } arrayList = new ArrayList<Integer>(); arrayList.add(tbd1.getPriorityCount()); arrayList.add(priority1.getPriorityCount()); arrayList.add(priority2.getPriorityCount()); arrayList.add(priority3.getPriorityCount()); arrayList.add(priority4.getPriorityCount()); maximumCount = Collections.max(arrayList); if (maximumCount <= 0) { tbd1.setPxSize("0"); priority1.setPxSize("0"); priority2.setPxSize("0"); priority3.setPxSize("0"); priority4.setPxSize("0"); } else { tbd1.setPxSize(Math.round((100 * tbd1.getPriorityCount()) / maximumCount) + ""); priority1.setPxSize(Math.round((100 * priority1.getPriorityCount()) / maximumCount) + ""); priority2.setPxSize(Math.round((100 * priority2.getPriorityCount()) / maximumCount) + ""); priority3.setPxSize(Math.round((100 * priority3.getPriorityCount()) / maximumCount) + ""); priority4.setPxSize(Math.round((100 * priority4.getPriorityCount()) / maximumCount) + ""); } priorities.add(tbd1); priorities.add(priority1); priorities.add(priority2); priorities.add(priority3); priorities.add(priority4); iOSCount = 0; winCount = 0; for (Defect defect : fixedDefects) { if (defect.getPlatform().equalsIgnoreCase("iOS")) { iOSCount++; } else if (defect.getPlatform().equalsIgnoreCase("Windows")) { winCount++; } } dashboardForm.setComponentsCountFixed(populateComponentsMap(fixedDefects)); dashboardForm.setFixedDefects(fixedDefects); dashboardForm.setFixedPriorities(priorities); dashboardForm.setFixedDefectCount(fixedDefects.size()); p1np2cnt = priority1.getPriorityCount() + priority2.getPriorityCount(); dashboardForm.setFixedMsg("iOS: " + iOSCount + ", Windows: " + winCount); dashboardForm.setFixedP1AndP2Count(p1np2cnt); //Closed defects List<Defect> closedDefects = allDefects.get("Closed"); priorities = new ArrayList<Priority>(); tbd1 = new Priority(); tbd1.setPriorityName("TBD"); priority1 = new Priority(); priority1.setPriorityName("P1"); priority2 = new Priority(); priority2.setPriorityName("P2"); priority3 = new Priority(); priority3.setPriorityName("P3"); priority4 = new Priority(); priority4.setPriorityName("P4"); if (null == closedDefects) { closedDefects = new ArrayList<Defect>(); } for (Defect defect : closedDefects) { if (defect.getPriority().equalsIgnoreCase("TBD")) { tbd1.setPriorityCount(tbd1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P1")) { priority1.setPriorityCount(priority1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P2")) { priority2.setPriorityCount(priority2.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P3")) { priority3.setPriorityCount(priority3.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P4")) { priority4.setPriorityCount(priority4.getPriorityCount() + 1); } } arrayList = new ArrayList<Integer>(); arrayList.add(tbd1.getPriorityCount()); arrayList.add(priority1.getPriorityCount()); arrayList.add(priority2.getPriorityCount()); arrayList.add(priority3.getPriorityCount()); arrayList.add(priority4.getPriorityCount()); maximumCount = Collections.max(arrayList); if (maximumCount <= 0) { tbd1.setPxSize("0"); priority1.setPxSize("0"); priority2.setPxSize("0"); priority3.setPxSize("0"); priority4.setPxSize("0"); } else { tbd1.setPxSize(Math.round((100 * tbd1.getPriorityCount()) / maximumCount) + ""); priority1.setPxSize(Math.round((100 * priority1.getPriorityCount()) / maximumCount) + ""); priority2.setPxSize(Math.round((100 * priority2.getPriorityCount()) / maximumCount) + ""); priority3.setPxSize(Math.round((100 * priority3.getPriorityCount()) / maximumCount) + ""); priority4.setPxSize(Math.round((100 * priority4.getPriorityCount()) / maximumCount) + ""); } priorities.add(tbd1); priorities.add(priority1); priorities.add(priority2); priorities.add(priority3); priorities.add(priority4); iOSCount = 0; winCount = 0; for (Defect defect : closedDefects) { if (defect.getPlatform().equalsIgnoreCase("iOS")) { iOSCount++; } else if (defect.getPlatform().equalsIgnoreCase("Windows")) { winCount++; } } dashboardForm.setClosedDefects(closedDefects); dashboardForm.setClosedPriorities(priorities); dashboardForm.setClosedDefectCount(closedDefects.size()); p1np2cnt = priority1.getPriorityCount() + priority2.getPriorityCount(); dashboardForm.setClosedMsg("iOS: " + iOSCount + ", Windows: " + winCount); dashboardForm.setClosedP1AndP2Count(p1np2cnt); //Closed Yesterday List<Defect> closedYesterdayDefects = allDefects.get("ClosedY"); priorities = new ArrayList<Priority>(); tbd1 = new Priority(); tbd1.setPriorityName("TBD"); priority1 = new Priority(); priority1.setPriorityName("P1"); priority2 = new Priority(); priority2.setPriorityName("P2"); priority3 = new Priority(); priority3.setPriorityName("P3"); priority4 = new Priority(); priority4.setPriorityName("P4"); if (null != closedYesterdayDefects) { for (Defect defect : closedYesterdayDefects) { if (defect.getPriority().equalsIgnoreCase("TBD")) { tbd1.setPriorityCount(tbd1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P1")) { priority1.setPriorityCount(priority1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P2")) { priority2.setPriorityCount(priority2.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P3")) { priority3.setPriorityCount(priority3.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P4")) { priority4.setPriorityCount(priority4.getPriorityCount() + 1); } } } arrayList = new ArrayList<Integer>(); arrayList.add(tbd1.getPriorityCount()); arrayList.add(priority1.getPriorityCount()); arrayList.add(priority2.getPriorityCount()); arrayList.add(priority3.getPriorityCount()); arrayList.add(priority4.getPriorityCount()); maximumCount = Collections.max(arrayList); if (maximumCount <= 0) { tbd1.setPxSize("0"); priority1.setPxSize("0"); priority2.setPxSize("0"); priority3.setPxSize("0"); priority4.setPxSize("0"); } else { tbd1.setPxSize(Math.round((100 * tbd1.getPriorityCount()) / maximumCount) + ""); priority1.setPxSize(Math.round((100 * priority1.getPriorityCount()) / maximumCount) + ""); priority2.setPxSize(Math.round((100 * priority2.getPriorityCount()) / maximumCount) + ""); priority3.setPxSize(Math.round((100 * priority3.getPriorityCount()) / maximumCount) + ""); priority4.setPxSize(Math.round((100 * priority4.getPriorityCount()) / maximumCount) + ""); } priorities.add(tbd1); priorities.add(priority1); priorities.add(priority2); priorities.add(priority3); priorities.add(priority4); iOSCount = 0; winCount = 0; if (null != closedYesterdayDefects) { for (Defect defect : closedYesterdayDefects) { if (defect.getPlatform().equalsIgnoreCase("iOS")) { iOSCount++; } else if (defect.getPlatform().equalsIgnoreCase("Windows")) { winCount++; } } } dashboardForm.setClosedYesterdayDefects(closedYesterdayDefects); dashboardForm.setClosedYesterdayPriorities(priorities); dashboardForm .setClosedYesterdayDefectCount(null == closedYesterdayDefects ? 0 : closedYesterdayDefects.size()); p1np2cnt = priority1.getPriorityCount() + priority2.getPriorityCount(); dashboardForm.setClosedYMsg("iOS: " + iOSCount + ", Windows: " + winCount); dashboardForm.setClosedYesterdayP1AndP2Count(p1np2cnt); //Open Yesterday List<Defect> openYesterdayDefects = allDefects.get("OpenY"); priorities = new ArrayList<Priority>(); tbd1 = new Priority(); tbd1.setPriorityName("TBD"); priority1 = new Priority(); priority1.setPriorityName("P1"); priority2 = new Priority(); priority2.setPriorityName("P2"); priority3 = new Priority(); priority3.setPriorityName("P3"); priority4 = new Priority(); priority4.setPriorityName("P4"); if (null != openYesterdayDefects) { for (Defect defect : openYesterdayDefects) { if (defect.getPriority().equalsIgnoreCase("TBD")) { tbd1.setPriorityCount(tbd1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P1")) { priority1.setPriorityCount(priority1.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P2")) { priority2.setPriorityCount(priority2.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P3")) { priority3.setPriorityCount(priority3.getPriorityCount() + 1); } if (defect.getPriority().equalsIgnoreCase("P4")) { priority4.setPriorityCount(priority4.getPriorityCount() + 1); } } } arrayList = new ArrayList<Integer>(); arrayList.add(tbd1.getPriorityCount()); arrayList.add(priority1.getPriorityCount()); arrayList.add(priority2.getPriorityCount()); arrayList.add(priority3.getPriorityCount()); arrayList.add(priority4.getPriorityCount()); maximumCount = Collections.max(arrayList); if (maximumCount <= 0) { tbd1.setPxSize("0"); priority1.setPxSize("0"); priority2.setPxSize("0"); priority3.setPxSize("0"); priority4.setPxSize("0"); } else { tbd1.setPxSize(Math.round((100 * tbd1.getPriorityCount()) / maximumCount) + ""); priority1.setPxSize(Math.round((100 * priority1.getPriorityCount()) / maximumCount) + ""); priority2.setPxSize(Math.round((100 * priority2.getPriorityCount()) / maximumCount) + ""); priority3.setPxSize(Math.round((100 * priority3.getPriorityCount()) / maximumCount) + ""); priority4.setPxSize(Math.round((100 * priority4.getPriorityCount()) / maximumCount) + ""); } priorities.add(tbd1); priorities.add(priority1); priorities.add(priority2); priorities.add(priority3); priorities.add(priority4); iOSCount = 0; winCount = 0; if (null != openYesterdayDefects) { for (Defect defect : openYesterdayDefects) { if (defect.getPlatform().equalsIgnoreCase("iOS")) { iOSCount++; } else if (defect.getPlatform().equalsIgnoreCase("Windows")) { winCount++; } } } dashboardForm.setOpenYesterdayDefects(openYesterdayDefects); dashboardForm.setOpenYesterdayPriorities(priorities); dashboardForm.setOpenYesterdayDefectCount(null == openYesterdayDefects ? 0 : openYesterdayDefects.size()); p1np2cnt = priority1.getPriorityCount() + priority2.getPriorityCount(); dashboardForm.setOpenYMsg("iOS: " + iOSCount + ", Windows: " + winCount); dashboardForm.setOpenYesterdayP1AndP2Count(p1np2cnt); Tab tab = Util.getSelectedProject(Integer.parseInt(dashboardForm.getTabIndex()), Integer.parseInt(dashboardForm.getSubProject()), configuration); dashboardForm.setProjectId(tab.getTabUniqueId()); dashboardForm.setProjectName(tab.getTabDisplayName()); dashboardForm.setRegressionData(tab.isRegressionData()); dashboardForm.setFilterInfo(tab.getInformation()); List<Defect> openAndSubmitted = new ArrayList<Defect>(); openAndSubmitted.addAll(openDefects); openAndSubmitted.addAll(submittedDefects); dashboardForm.setComponentsCountOpenSubmitted(populateComponentsMap(openAndSubmitted)); }
From source file:eu.ggnet.dwoss.redtape.entity.Document.java
/** * Moves the position on id down, swapping the id with it's successor. * <p/>/*from w w w. jav a 2s. c o m*/ * @param position the position to be moved. * @return true if successful. */ public boolean moveDown(Position position) { if (position.id == Collections.max(positions.keySet())) return false; positions.remove(position.id); Position tmp = positions.remove(position.id + 1); tmp.id = position.id; position.id += 1; positions.put(position.id, position); positions.put(tmp.id, tmp); return true; }
From source file:edu.cmu.tetrad.sem.LargeScaleSimulation.java
public IKnowledge getKnowledge(Graph graph) { // System.out.println("Entering getKnowledge ... "); int numLags; // need to fix this! List<Node> variables = graph.getNodes(); List<Integer> laglist = new ArrayList<>(); IKnowledge knowledge = new Knowledge2(); int lag;//from w ww . j av a 2 s. c o m for (Node node : variables) { String varName = node.getName(); String tmp; if (varName.indexOf(':') == -1) { lag = 0; laglist.add(lag); } else { tmp = varName.substring(varName.indexOf(':') + 1, varName.length()); lag = Integer.parseInt(tmp); laglist.add(lag); } } numLags = Collections.max(laglist); // System.out.println("Variable list before the sort = " + variables); Collections.sort(variables, new Comparator<Node>() { @Override public int compare(Node o1, Node o2) { String name1 = getNameNoLag(o1); String name2 = getNameNoLag(o2); // System.out.println("name 1 = " + name1); // System.out.println("name 2 = " + name2); String prefix1 = getPrefix(name1); String prefix2 = getPrefix(name2); // System.out.println("prefix 1 = " + prefix1); // System.out.println("prefix 2 = " + prefix2); int index1 = getIndex(name1); int index2 = getIndex(name2); // System.out.println("index 1 = " + index1); // System.out.println("index 2 = " + index2); if (getLag(o1.getName()) == getLag(o2.getName())) { if (prefix1.compareTo(prefix2) == 0) { return Integer.compare(index1, index2); } else { return prefix1.compareTo(prefix2); } } else { return getLag(o1.getName()) - getLag(o2.getName()); } } }); // System.out.println("Variable list after the sort = " + variables); for (Node node : variables) { String varName = node.getName(); String tmp; if (varName.indexOf(':') == -1) { lag = 0; // laglist.add(lag); } else { tmp = varName.substring(varName.indexOf(':') + 1, varName.length()); lag = Integer.parseInt(tmp); // laglist.add(lag); } knowledge.addToTier(numLags - lag, node.getName()); } //System.out.println("Knowledge in graph = " + knowledge); return knowledge; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRResultsController.java
@Override protected PdfPTable createAnalysisGroupInfoTable() { //maps log transformed conc (double) to list of velocities (double) List<DoseResponsePair> data = doseResponseController.getImportedDRDataHolder().getDoseResponseData(); // new table with 5 columns PdfPTable dataTable = new PdfPTable(5); PdfUtils.setUpPdfPTable(dataTable);//from w w w. ja va 2 s. c om // add 1st row: column names PdfUtils.addCustomizedCell(dataTable, "DOSE", boldFont); PdfUtils.addCustomizedCell(dataTable, "# TECHNICAL REPLICATES", boldFont); PdfUtils.addCustomizedCell(dataTable, "LOWEST RESPONSE", boldFont); PdfUtils.addCustomizedCell(dataTable, "HIGHEST RESPONSE", boldFont); PdfUtils.addCustomizedCell(dataTable, "MEDIAN RESPONSE", boldFont); // for each condition get results and add a cell for (DoseResponsePair condition : data) { Integer replicates = condition.getResponses().size(); List<Double> velocities = condition.getResponses(); PdfUtils.addCustomizedCell(dataTable, condition.getDose().toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, replicates.toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.min(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.max(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(AnalysisUtils.computeMedian(velocities)).toString(), bodyFont); } return dataTable; }
From source file:org.jahia.services.content.interceptor.URLInterceptor.java
private String replaceRefsByPlaceholders(final String originalValue, final Map<String, Long> newRefs, final Map<String, Long> oldRefs, String workspace, final Locale locale, final JCRNodeWrapper node, final ExtendedPropertyDefinition definition) throws RepositoryException { if (logger.isDebugEnabled()) { logger.debug("Before replaceRefsByPlaceholders : " + originalValue); }// w ww . j a v a 2 s. c o m String pathPart = originalValue; final boolean isCmsContext; if (pathPart.startsWith(dmsContext)) { // Remove DOC context part pathPart = StringUtils.substringAfter(StringUtils.substringAfter(pathPart, dmsContext), "/"); isCmsContext = false; } else if (pathPart.startsWith(cmsContext)) { // Remove CMS context part Matcher m = cmsPattern.matcher(pathPart); if (!m.matches()) { throw new PropertyConstraintViolationException(node, Messages.getInternal("label.error.invalidlink", LocaleContextHolder.getLocale(), "Invalid link") + pathPart, definition.isInternationalized() ? locale : null, definition); } pathPart = m.group(5); isCmsContext = true; } else { return originalValue; } final String path = "/" + WebUtils.urlDecode(pathPart); return JCRTemplate.getInstance().doExecuteWithSystemSessionAsUser(null, workspace, null, new JCRCallback<String>() { public String doInJCR(JCRSessionWrapper session) throws RepositoryException { String value = originalValue; String ext = null; String tpl = null; JCRNodeWrapper reference; try { String currentPath = path; if (isCmsContext) { while (true) { int i = currentPath.lastIndexOf('.'); if (i > currentPath.lastIndexOf('/')) { if (ext == null) { ext = currentPath.substring(i + 1); } else if (tpl == null) { tpl = currentPath.substring(i + 1); } else { tpl = currentPath.substring(i + 1) + "." + tpl; } currentPath = currentPath.substring(0, i); } else { throw new PathNotFoundException("not found in " + path); } try { reference = session.getNode(JCRContentUtils.escapeNodePath(currentPath)); break; } catch (PathNotFoundException e) { // continue } } value = CMS_CONTEXT_PLACEHOLDER + StringUtils.substringAfter(value, cmsContext); } else { // retrieve path while (true) { if (StringUtils.contains(currentPath, '/')) { currentPath = StringUtils.substringAfter(currentPath, "/"); } else { throw new PathNotFoundException("not found in " + path); } try { reference = session .getNode(JCRContentUtils.escapeNodePath("/" + currentPath)); break; } catch (PathNotFoundException e) { // continue } } value = DOC_CONTEXT_PLACEHOLDER + StringUtils.substringAfter(value, dmsContext); } } catch (PathNotFoundException e) { throw new PropertyConstraintViolationException(node, Messages.getInternal("label.error.invalidlink", LocaleContextHolder.getLocale(), "Invalid link") + path, definition.isInternationalized() ? locale : null, definition); } String id = reference.getIdentifier(); if (!newRefs.containsKey(id)) { if (oldRefs.containsKey(id)) { newRefs.put(id, oldRefs.get(id)); } else { Long max = Math.max(oldRefs.isEmpty() ? 0 : Collections.max(oldRefs.values()), newRefs.isEmpty() ? 0 : Collections.max(newRefs.values())); newRefs.put(id, max + 1); } } Long index = newRefs.get(id); String link = "/##ref:link" + index + "##"; if (tpl != null) { link += "." + tpl; } if (ext != null) { link += "." + ext; } value = WebUtils.urlDecode(value).replace(path, link); if (logger.isDebugEnabled()) { logger.debug("After replaceRefsByPlaceholders : " + value); } return value; } }); }