List of usage examples for java.util ListIterator next
E next();
From source file:vteaexploration.plottools.panels.XYExplorationPanel.java
public void makeOverlayImage(ArrayList gates, int x, int y, int xAxis, int yAxis) { //convert gate to chart x,y path Gate gate;//www . j a va2 s .c o m ListIterator<Gate> gate_itr = gates.listIterator(); //.get int total = 0; int gated = 0; int selected = 0; int gatedSelected = 0; int gatecount = gates.size(); while (gate_itr.hasNext()) { gate = gate_itr.next(); if (gate.getSelected()) { Path2D path = gate.createPath2DInChartSpace(); ArrayList<MicroObject> result = new ArrayList<MicroObject>(); ArrayList<MicroObject> volumes = (ArrayList) this.plotvalues.get(1); MicroObjectModel volume; double xValue = 0; double yValue = 0; ListIterator<MicroObject> it = volumes.listIterator(); try { while (it.hasNext()) { volume = it.next(); if (volume != null) { xValue = ((Number) processPosition(xAxis, (MicroObject) volume)).doubleValue(); yValue = ((Number) processPosition(yAxis, (MicroObject) volume)).doubleValue(); if (path.contains(xValue, yValue)) { result.add((MicroObject) volume); } } } } catch (NullPointerException e) { } ; Overlay overlay = new Overlay(); int count = 0; BufferedImage placeholder = new BufferedImage(impoverlay.getWidth(), impoverlay.getHeight(), BufferedImage.TYPE_INT_ARGB); ImageStack gateOverlay = new ImageStack(impoverlay.getWidth(), impoverlay.getHeight()); selected = getSelectedObjects(); total = volumes.size(); gated = getGatedObjects(impoverlay); gatedSelected = getGatedSelected(impoverlay); for (int i = 0; i <= impoverlay.getNSlices(); i++) { BufferedImage selections = new BufferedImage(impoverlay.getWidth(), impoverlay.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = selections.createGraphics(); ImageRoi ir = new ImageRoi(0, 0, placeholder); ListIterator<MicroObject> vitr = result.listIterator(); while (vitr.hasNext()) { try { MicroObject vol = (MicroObject) vitr.next(); int[] x_pixels = vol.getXPixelsInRegion(i); int[] y_pixels = vol.getYPixelsInRegion(i); for (int c = 0; c < x_pixels.length; c++) { g2.setColor(gate.getColor()); g2.drawRect(x_pixels[c], y_pixels[c], 1, 1); } ir = new ImageRoi(0, 0, selections); count++; } catch (NullPointerException e) { } } ir.setPosition(i); ir.setOpacity(0.4); overlay.add(ir); gateOverlay.addSlice(ir.getProcessor()); java.awt.Font f = new Font("Arial", Font.BOLD, 12); BigDecimal percentage = new BigDecimal(selected); BigDecimal totalBD = new BigDecimal(total); percentage = percentage.divide(totalBD, 4, BigDecimal.ROUND_UP); BigDecimal percentageGated = new BigDecimal(gated); BigDecimal totalGatedBD = new BigDecimal(total); percentageGated = percentageGated.divide(totalGatedBD, 4, BigDecimal.ROUND_UP); BigDecimal percentageGatedSelected = new BigDecimal(gatedSelected); BigDecimal totalGatedSelectedBD = new BigDecimal(total); percentageGatedSelected = percentageGatedSelected.divide(totalGatedSelectedBD, 4, BigDecimal.ROUND_UP); // System.out.println("PROFILING: gate fraction: " + percentage.toString()); if (impoverlay.getWidth() > 256) { TextRoi textTotal = new TextRoi(5, 10, selected + "/" + total + " gated (" + 100 * percentage.doubleValue() + "%)"); if (gated > 0) { textTotal = new TextRoi(5, 10, selected + "/" + total + " total (" + 100 * percentage.doubleValue() + "%)" + "; " + gated + "/" + total + " roi (" + 100 * percentageGated.doubleValue() + "%)" + "; " + gatedSelected + "/" + total + " overlap (" + 100 * percentageGatedSelected.doubleValue() + "%)", f); } //TextRoi textImageGated = new TextRoi(5, 18, selected + "/" + total + " gated objects (" + 100 * percentage.doubleValue() + "%)", f); textTotal.setPosition(i); //textImageGated.setPosition(i); overlay.add(textTotal); } else { f = new Font("Arial", Font.PLAIN, 10); TextRoi line1 = new TextRoi(5, 5, selected + "/" + total + " gated" + "(" + 100 * percentage.doubleValue() + "%)", f); overlay.add(line1); if (gated > 0) { f = new Font("Arial", Font.PLAIN, 10); TextRoi line2 = new TextRoi(5, 18, gated + "/" + total + " roi (" + 100 * percentageGated.doubleValue() + "%)", f); overlay.add(line2); TextRoi line3 = new TextRoi(5, 31, gatedSelected + "/" + total + " overlap (" + 100 * percentageGatedSelected.doubleValue() + "%)", f); overlay.add(line3); } line1.setPosition(i); } } impoverlay.setOverlay(overlay); //ImagePlus gateMaskImage = new ImagePlus("gates", gateOverlay); //gateMaskImage.show(); gate.setGateOverlayStack(gateOverlay); } impoverlay.draw(); impoverlay.setTitle(this.getTitle()); if (impoverlay.getDisplayMode() != IJ.COMPOSITE) { impoverlay.setDisplayMode(IJ.COMPOSITE); } if (impoverlay.getSlice() == 1) { impoverlay.setZ(Math.round(impoverlay.getNSlices() / 2)); } else { impoverlay.setSlice(impoverlay.getSlice()); } impoverlay.show(); } }
From source file:com.bringcommunications.etherpay.Payment_Processor.java
private void cancel_client_messages(Payment_Processor_Client client) { synchronized (monitor) { Integer count = client_map.get(client); int no_entries = (count == null) ? 0 : count.intValue(); ListIterator<Payment_Message> sit = send_message_list.listIterator(); while (sit.hasNext() && no_entries > 0) { if (sit.next().client.equals(client)) { --no_entries;//from www.j a va 2 s .com sit.remove(); } } ListIterator<Payment_Message> bit = balance_message_list.listIterator(); while (bit.hasNext() && no_entries > 0) { if (bit.next().client.equals(client)) { --no_entries; bit.remove(); } } count = new Integer(no_entries); client_map.put(client, count); } }
From source file:codeswarm.code_swarm.java
/** * TODO This could be made to look a lot better. *//* w w w . j av a 2s. co m*/ public void drawPopular() { CopyOnWriteArrayList<FileNode> al = new CopyOnWriteArrayList<FileNode>(); noStroke(); textFont(font); textAlign(RIGHT, TOP); fill(255, 200); text("Popular Nodes (touches):", width - 120, 0); for (int i = 0; i < nodes.size(); i++) { FileNode fn = nodes.get(i); if (fn.qualifies()) { // Insertion Sort if (al.size() > 0) { int j = 0; for (; j < al.size(); j++) { if (fn.compareTo(al.get(j)) <= 0) { continue; } else { break; } } al.add(j, fn); } else { al.add(fn); } } } int i = 1; ListIterator<FileNode> it = al.listIterator(); while (it.hasNext()) { FileNode n = it.next(); // Limit to the top 10. if (i <= 10) { text(n.getName() + " (" + n.getTouches() + ")", width - 100, 10 * i++); } else if (i > 10) { break; } } }
From source file:com.bwc.ora.models.Lrp.java
public List<XYSeries> getFWHMForLRPPeaks(XYSeries lrpPeaks, XYSeries lrpSeries) { LinkedList<XYSeries> seriesList = new LinkedList<>(); List<XYDataItem> pointList = (List<XYDataItem>) lrpSeries.getItems(); List<XYDataItem> peakList = (List<XYDataItem>) lrpPeaks.getItems(); //iterate through the peaks, process FWHM for each peak for (XYDataItem peak : peakList) { //grab index of the closest point to the peak int peakIndex = -1; for (XYDataItem pnt : pointList) { peakIndex++;// w ww .ja v a 2s . com if (Math.abs(pnt.getXValue() - peak.getXValue()) < 0.6D) { break; } } //calculate point with Y value of valley to the left of peak XYDataItem leftValleyPoint = null; ListIterator<XYDataItem> it = pointList.listIterator(peakIndex); double prevY = peak.getYValue(); while (it.hasPrevious()) { XYDataItem leftPoint = it.previous(); if (leftPoint.getYValue() <= prevY) { prevY = leftPoint.getYValue(); leftValleyPoint = leftPoint; } else { break; } } //calculate point with Y value of valley to the right of peak XYDataItem rightValleyPoint = null; it = pointList.listIterator(peakIndex); prevY = peak.getYValue(); while (it.hasNext()) { XYDataItem rightPoint = it.next(); if (rightPoint.getYValue() <= prevY) { prevY = rightPoint.getYValue(); rightValleyPoint = rightPoint; } else { break; } } //determine half max Y value double halfMaxYValue; if (rightValleyPoint.getYValue() == leftValleyPoint.getYValue()) { halfMaxYValue = peak.getYValue() - ((peak.getYValue() - leftValleyPoint.getYValue()) / 2D); } else if (rightValleyPoint.getYValue() > leftValleyPoint.getYValue()) { halfMaxYValue = peak.getYValue() - ((peak.getYValue() - rightValleyPoint.getYValue()) / 2D); } else { halfMaxYValue = peak.getYValue() - ((peak.getYValue() - leftValleyPoint.getYValue()) / 2D); } //determine the X value on both sides of the peak that corresponds to the half max Y value double leftX = pointList.get(0).getXValue(), rightX = pointList.get(pointList.size() - 1).getXValue(); XYDataItem prevPoint = pointList.get(peakIndex); it = pointList.listIterator(peakIndex); while (it.hasPrevious()) { XYDataItem leftPoint = it.previous(); if (leftPoint.getYValue() == halfMaxYValue) { leftX = leftPoint.getXValue(); break; } else { if (leftPoint.getYValue() < halfMaxYValue) { // System.out.println("Left X for peak (" + peak.getXValue() + "," + peak.getYValue() + "): "); leftX = calculateXFromYForLineWithTwoPoints(leftPoint, prevPoint, halfMaxYValue); // System.out.println(" Left X: (" + leftX + "," + halfMaxYValue + "): "); break; } else { prevPoint = leftPoint; } } } prevPoint = pointList.get(peakIndex); it = pointList.listIterator(peakIndex); while (it.hasNext()) { XYDataItem rightPoint = it.next(); if (rightPoint.getYValue() == halfMaxYValue) { rightX = rightPoint.getXValue(); break; } else { if (rightPoint.getYValue() < halfMaxYValue) { // System.out.println("Right X for peak (" + peak.getXValue() + "," + peak.getYValue() + "): "); rightX = calculateXFromYForLineWithTwoPoints(rightPoint, prevPoint, halfMaxYValue); // System.out.println(" Right X: (" + leftX + "," + halfMaxYValue + "): "); break; } else { prevPoint = rightPoint; } } } //store the two points for the half max full width line for this peak XYSeries peakSeries = new XYSeries("(" + peak.getXValue() + "," + peak.getYValue() + ")FWHM"); peakSeries.add(leftX, halfMaxYValue); peakSeries.add(rightX, halfMaxYValue); seriesList.add(peakSeries); } return seriesList; }
From source file:com.jaspersoft.studio.property.section.style.inerithance.StylesListSection.java
/** * Print the attributes of all the styles of the element * /*from w w w. ja v a 2 s. com*/ * @param styles List of styles * @param parent composite of the main widget */ private void printStyles(LinkedList<MStyle> styles, Composite parent) { ListIterator<MStyle> itr = styles.listIterator(); boolean hasDefaultStyleInGerarchy = false; while (itr.hasNext()) { MStyle style = itr.next(); String titleLabelText = MessageFormat.format(Messages.StylesSectionList_Inherited_From_Style, new Object[] { style.getPropertyValue(JRDesignStyle.PROPERTY_NAME) }); printStyleTitle(titleLabelText, style, parent); printStyleAttribute(parent, style, null, AttributeParent.STYLE); //$NON-NLS-1$ if (style == defaultStyle) hasDefaultStyleInGerarchy = true; } //FIXME: JR has a bug where it dosen't use the default styles if the element has at least one style //unit it will be fixed, to show the effective hierarchy, the default style is print only if there //aren't other styles on the element if (styles.isEmpty() && !hasDefaultStyleInGerarchy && defaultStyle != null && defaultStyle != getElement()) { String titleLabelText = MessageFormat.format(Messages.StylesListSection_Inherited_From_Default_Style, new Object[] { defaultStyle.getPropertyValue(JRDesignStyle.PROPERTY_NAME) }); printStyleTitle(titleLabelText, defaultStyle, parent); printStyleAttribute(parent, defaultStyle, null, AttributeParent.STYLE); //$NON-NLS-1$ } }
From source file:com.jaspersoft.studio.property.section.style.StylesListSection.java
/** * Print the attributes of all the styles of the element * //from ww w. j av a 2 s . c o m * @param styles * List of styles * @param parent * composite of the main widget */ private void printStyles(LinkedList<MStyle> styles, Composite parent) { ListIterator<MStyle> itr = styles.listIterator(); boolean hasDefaultStyleInGerarchy = false; while (itr.hasNext()) { MStyle style = itr.next(); printStyleAttribute(parent, style, Messages.StylesSectionList_Inherited_From_Style + style.getPropertyValue(JRDesignStyle.PROPERTY_NAME), "", elementAttributes, true); //$NON-NLS-1$ if (style == defaultStyle) hasDefaultStyleInGerarchy = true; } if (!hasDefaultStyleInGerarchy && defaultStyle != null && defaultStyle != getElement()) printStyleAttribute(parent, defaultStyle, Messages.StylesListSection_Inherited_From_Default_Style .concat(defaultStyle.getPropertyValue(JRDesignStyle.PROPERTY_NAME).toString()), "", elementAttributes, true); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:umontreal.iro.lecuyer.charts.HistogramSeriesCollection.java
public String toLatex(double XScale, double YScale, double XShift, double YShift, double xmin, double xmax, double ymin, double ymax) { // Calcule les bornes reelles du graphique, en prenant en compte la position des axes xmin = Math.min(XShift, xmin); xmax = Math.max(XShift, xmax); ymin = Math.min(YShift, ymin); ymax = Math.max(YShift, ymax); CustomHistogramDataset tempSeriesCollection = (CustomHistogramDataset) seriesCollection; Formatter formatter = new Formatter(Locale.US); double var; double margin = ((XYBarRenderer) renderer).getMargin(); for (int i = tempSeriesCollection.getSeriesCount() - 1; i >= 0; i--) { List temp = tempSeriesCollection.getBins(i); ListIterator iter = temp.listIterator(); Color color = (Color) renderer.getSeriesPaint(i); String colorString = detectXColorClassic(color); if (colorString == null) { colorString = "color" + i; formatter.format("\\definecolor{%s}{rgb}{%.2f, %.2f, %.2f}%n", colorString, color.getRed() / 255.0, color.getGreen() / 255.0, color.getBlue() / 255.0); }// w ww. j a va 2s . c om HistogramBin currentBin = null; while (iter.hasNext()) { double currentMargin; currentBin = (HistogramBin) iter.next(); currentMargin = ((margin * (currentBin.getEndBoundary() - currentBin.getStartBoundary()))) * XScale; if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax) && (currentBin.getCount() >= ymin && currentBin.getCount() <= ymax)) { var = Math.min(currentBin.getEndBoundary(), xmax); if (filled[i]) { formatter.format( "\\filldraw [line width=%.2fpt, opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale); } else { formatter.format( "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale); } } else if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax) && (currentBin.getCount() >= ymin && currentBin.getCount() > ymax)) { // Cas ou notre rectangle ne peut pas etre affiche en entier (trop haut) var = Math.min(currentBin.getEndBoundary(), xmax); if (filled[i]) { formatter.format( "\\filldraw [line width=%.2fpt, opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); formatter.format( "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); } else { formatter.format( "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); formatter.format( "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); } } } } return formatter.toString(); }
From source file:com.xmobileapp.rockplayer.LastFmEventImporter.java
/********************************************** * //from w w w .j ava 2 s. c o m * insertListInListByDate * @param singleArtistEventList * **********************************************/ public void insertListInListByDate(LinkedList<ArtistEvent> singleArtistEventList) { /* * If this artist List is empty just return */ if (singleArtistEventList.isEmpty()) return; /* * If the big list is empty just add this one to it */ if (artistEventList.isEmpty()) { artistEventList.addAll(singleArtistEventList); return; } /* * Insert the items (normal case) */ ListIterator<ArtistEvent> artistEventListIterator = artistEventList.listIterator(0); ListIterator<ArtistEvent> singleArtistEventListIterator = singleArtistEventList.listIterator(0); ArtistEvent artistEvent; ArtistEvent singleArtistEvent; while (singleArtistEventListIterator.hasNext()) { /* * Not yet at the end of the big list */ if (artistEventListIterator.hasNext()) { singleArtistEvent = singleArtistEventListIterator.next(); artistEvent = artistEventListIterator.next(); while (singleArtistEvent.dateInMillis > artistEvent.dateInMillis) { if (artistEventListIterator.hasNext()) artistEvent = artistEventListIterator.next(); else { if (artistEventListIterator.previousIndex() >= MAX_EVENT_LIST_SIZE) { return; } else { break; // TODO: add missing items to the big list } } } artistEventListIterator.previous(); artistEventListIterator.add(singleArtistEvent); } /* * At the end of the big list (but not of the 'small' list */ else { if (artistEventListIterator.previousIndex() >= MAX_EVENT_LIST_SIZE) return; singleArtistEvent = singleArtistEventListIterator.next(); artistEventListIterator.add(singleArtistEvent); artistEventListIterator.next(); } } /* * Keep the list size in check */ while (artistEventList.size() > MAX_EVENT_LIST_SIZE) artistEventList.removeLast(); }
From source file:atfrogs.ox.api.OXWebDAVApi.java
/** * Returns a list of all OXUser objects of group members of group with * given gid. You should not pass a pattern as gid. If done so you'll get * the list of OXUser objects of the group being the first search result. * //from w w w. j av a 2 s.c om * @param gid the gid of group requested. * @return the list of OXUser objects. * @throws OXWebDAVApiException if an error occurs during operation. */ public List getMembersOfGroup(String gid) throws OXWebDAVApiException { List memberIdList; // of String List userList; // of OXUser ListIterator iterator; if (gid == null) return null; try { memberIdList = this.getMemberIdsOfGroup(gid); if (memberIdList == null) return null; userList = new Vector(); iterator = memberIdList.listIterator(); while (iterator.hasNext()) { String uid; OXUser user; uid = (String) iterator.next(); user = this.getOXUser(uid); userList.add(user); } } catch (Exception exc) { exc.printStackTrace(); throw new OXWebDAVApiException(exc.getMessage(), exc); } return userList; // note: may be empty }
From source file:io.swagger.codegen.languages.AbstractJavaCodegen.java
@Override public Map<String, Object> postProcessModels(Map<String, Object> objs) { // recursively add import for mapping one type to multiple imports List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports"); if (recursiveImports == null) return objs; ListIterator<Map<String, String>> listIterator = recursiveImports.listIterator(); while (listIterator.hasNext()) { String _import = listIterator.next().get("import"); // if the import package happens to be found in the importMapping (key) // add the corresponding import package to the list if (importMapping.containsKey(_import)) { Map<String, String> newImportMap = new HashMap<String, String>(); newImportMap.put("import", importMapping.get(_import)); listIterator.add(newImportMap); }//from w w w .j a va 2 s. c om } return postProcessModelsEnum(objs); }