List of usage examples for java.util TreeSet iterator
public Iterator<E> iterator()
From source file:com.projity.server.data.Serializer.java
private void buildTaskDataHierarchy(long key, String prefix, Map taskMap, final StringBuffer b) { Object o = taskMap.get(new Long(key)); if (o == null) return;/* w ww. jav a 2s.c o m*/ TreeSet children = (TreeSet) ((TreeSet) o).clone(); for (Iterator i = children.iterator(); i.hasNext();) { TaskData taskData = (TaskData) i.next(); //System.out.println("name: "+taskData.getName()); b.append(prefix).append(taskData.getName()).append(',').append(taskData.getUniqueId()).append('\n'); if (taskData.getUniqueId() != -1L) //avoid voids buildTaskDataHierarchy(taskData.getUniqueId(), prefix + "\t", taskMap, b); } }
From source file:edu.ucla.stat.SOCR.analyses.gui.AnovaTwoWay.java
protected void doGraph() { graphPanel.removeAll();/*from w w w . j a v a 2s . c o m*/ // 1. Box plot of data: yData vs. xData (where xData is categorical) JPanel innerPanel = new JPanel(); JScrollPane graphPane = new JScrollPane(innerPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); graphPanel.add(graphPane); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); String[][] xNameData = new String[seriesCount][categoryCount]; // xNameData: category names. //////System.out.println("xNameData = "+xNameData.length); for (int i = 0; i < seriesCount; i++) { for (int j = 0; j < categoryCount; j++) { xNameData[i][j] = categoryName[j]; //////System.out.println("xNameData = " + xNameData[i][j]); } } /* the parameters to be passed are: 1.boxPlotTitle, xAxisLabel, YAxisLabel. 2. serieCount, categoryCount 3. seriesname (e.g. sex, race, etc) 4. category's name (e.g. height, weight, etc)--xData 5. yValue(double), */ ChartPanel chartPanel = null; double xDataDouble[] = null; TreeSet<String> treeSet = new TreeSet<String>(); String groupLegend = ""; boolean groupHasChar = false; // 1. scatter plot of data: yData vs. xData try { for (int i = xDataArray.length - 1; i >= 0; i--) { xData = xDataArray[i]; xDataDouble = new double[xData.length]; try { for (int j = 0; j < xData.length; j++) { xDataDouble[j] = (new Double(xData[j])).doubleValue(); } } catch (Exception e) { for (int j = 0; j < xData.length; j++) { treeSet.add((String) xData[j]); } groupHasChar = true; } Iterator iterator = treeSet.iterator(); int groupIndex = 1; String groupName = null; while (iterator.hasNext()) { groupName = (String) iterator.next(); //xDataDouble[groupIndex-1] = groupIndex; groupLegend += ("\t" + groupName + "=" + groupIndex + " "); for (int j = 0; j < xData.length; j++) { if (xData[j].equalsIgnoreCase(groupName)) { // xData[i] is a String. xDataDouble[j] = (double) groupIndex; } } groupIndex++; } independentHeader = independentHeaderArray[i]; //JFreeChart scatterChart = chartFactory.getLineChart("Scatter Plot of " + dependentHeader + " vs. " + independentHeader, independentHeader, dependentHeader, xDataDouble, yData);//getChart(title, xlabel, ylabel, xdata,ydata) JFreeChart scatterChart = chartFactory.getQQChart( "Scatter Plot of " + dependentHeader + " vs. " + independentHeader, independentHeader, dependentHeader, "Residuals ", xDataDouble, yData, " " + groupLegend, 0, 0, ""); ////System.out.println("doGraph dependentHeader = " + dependentHeader); ////System.out.println("doGraph independentHeader = " + independentHeader); chartPanel = new ChartPanel(scatterChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); if (groupHasChar) { groupLegend = "Group Names for " + independentHeaderArray[i] + ": " + groupLegend; /*JLabel legendLabel1 = new JLabel(groupLegend); legendLabel1.setBackground(Color.WHITE); JPanel labelPanel1 = new JPanel(); labelPanel1.add(legendLabel1, BorderLayout.NORTH); innerPanel.add(labelPanel1); */ } groupLegend = ""; treeSet = new TreeSet<String>(); } } catch (Exception e) { ////System.out.println("doGraph Scatter Exception = " + e); } groupHasChar = false; // 2. residual on fit plot: residuals vs. predicted //JFreeChart rfChart = chartFactory.getLineChart("Residual on Fit Plot", "Predicted", "Residuals", predicted, residuals, "Other Stuff"); JFreeChart rfChart = chartFactory.getQQChart("Residual on Fit Plot", "Predicted " + dependentHeader, "Residuals", "Residuals ", predicted, residuals, "At Residual = 0", 0, 0, ""); for (int i = 0; i < predicted.length; i++) { //System.out.println("predicted["+i+"] = " + predicted[i] + ". residuals["+i+"] = " + residuals[i]); } chartPanel = new ChartPanel(rfChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); // 3. residual on fit plot: residuals vs. xData xDataDouble = new double[xData.length]; groupLegend = ""; boolean useStringLegent = false; treeSet = new TreeSet<String>(); try { for (int i = xDataArray.length - 1; i >= 0; i--) { xData = xDataArray[i]; xDataDouble = new double[xData.length]; try { for (int j = 0; j < xData.length; j++) { xDataDouble[j] = (new Double(xData[j])).doubleValue(); } } catch (Exception e) { for (int j = 0; j < xData.length; j++) { treeSet.add((String) xData[j]); } groupHasChar = true; } Iterator<String> iterator = treeSet.iterator(); int groupIndex = 1; String groupName = null; while (iterator.hasNext()) { groupName = (String) iterator.next(); //xDataDouble[groupIndex-1] = groupIndex; groupLegend += ("\t" + groupName + "=" + groupIndex + " "); for (int j = 0; j < xData.length; j++) { if (xData[j].equalsIgnoreCase(groupName)) { // xData[i] is a String. xDataDouble[j] = (double) groupIndex; } } groupIndex++; } independentHeader = independentHeaderArray[i]; //JFreeChart scatterChart = chartFactory.getLineChart("Residual on Covariate Plot, Residual vs. " + independentHeaderArray[i], independentHeaderArray[i], dependentHeader, xDataDouble, residuals, "Other Stuff 2");//getChart(title, xlabel, ylabel, xdata,ydata) JFreeChart scatterChart = chartFactory.getQQChart( "Residual on Covariate Plot: Variable = " + independentHeaderArray[i], independentHeaderArray[i], "Residuals", "Residual ", xDataDouble, residuals, " " + groupLegend, 0, 0, "noline"); chartPanel = new ChartPanel(scatterChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); if (groupHasChar) { groupLegend = "Group Names for " + independentHeaderArray[i] + ": " + groupLegend; /* JLabel legendLabel2 = new JLabel(groupLegend); legendLabel2.setBackground(Color.WHITE); JPanel labelPanel2 = new JPanel(); labelPanel2.add(legendLabel2, BorderLayout.NORTH); innerPanel.add(labelPanel2); */ } groupLegend = ""; treeSet = new TreeSet<String>(); } } catch (Exception e) { ////System.out.println("doGraph Residuals Exception = " + e); } // 4. Normal QQ plot: need residuals and standardized normal scores //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals); JFreeChart qqChart = chartFactory.getQQChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", "Standardized Residual Value ", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals, "At Standardized Residual = 0", 0, 1, "noshape"); //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals); //JFreeChart qqChart = chartFactory.getLineChart("Residual Normal QQ Plot", "Theoretical Quantiles", "Standardized Residuals", sortedStandardizedNormalQuantiles, sortedStandardizedResiduals, "noline"); chartPanel = new ChartPanel(qqChart, false); chartPanel.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel); graphPanel.validate(); }
From source file:org.unitime.timetable.solver.studentsct.StudentSectioningDatabaseLoader.java
private String getInstructorIds(Class_ clazz) { if (!clazz.isDisplayInstructor().booleanValue()) return null; String ret = null;/*from w w w .j a va 2 s . co m*/ TreeSet ts = new TreeSet(clazz.getClassInstructors()); for (Iterator i = ts.iterator(); i.hasNext();) { ClassInstructor ci = (ClassInstructor) i.next(); if (!ci.isLead().booleanValue()) continue; if (ret == null) ret = ci.getInstructor().getUniqueId().toString(); else ret += ":" + ci.getInstructor().getUniqueId().toString(); } return ret; }
From source file:org.unitime.timetable.solver.studentsct.StudentSectioningDatabaseLoader.java
private String getInstructorNames(Class_ clazz) { if (!clazz.isDisplayInstructor().booleanValue()) return null; String ret = null;/*w w w.j ava 2 s. c o m*/ TreeSet ts = new TreeSet(clazz.getClassInstructors()); for (Iterator i = ts.iterator(); i.hasNext();) { ClassInstructor ci = (ClassInstructor) i.next(); if (!ci.isLead().booleanValue()) continue; if (ret == null) ret = ci.getInstructor().nameShort(); else ret += ":" + ci.getInstructor().nameShort(); } return ret; }
From source file:org.apache.myfaces.trinidadbuild.plugin.tagdoc.TagdocReport.java
private void _writeConverterAttributes(Writer out, ConverterBean bean) throws IOException { // Sort the names TreeSet attributes = new TreeSet(); Iterator<PropertyBean> attrs = bean.properties(); while (attrs.hasNext()) { PropertyBean property = attrs.next(); if (!property.isTagAttributeExcluded()) attributes.add(property.getPropertyName()); }// www .j a v a 2 s .co m // Now get a list of PropertyBeans List list = new ArrayList(); Iterator<String> iter = attributes.iterator(); while (iter.hasNext()) { String attrName = iter.next(); list.add(bean.findProperty(attrName)); } _writeComponentAttributes(out, list.iterator(), bean.getConverterClass(), null); }
From source file:org.apache.myfaces.trinidadbuild.plugin.tagdoc.TagdocReport.java
private void _writeValidatorAttributes(Writer out, ValidatorBean bean) throws IOException { // Sort the names TreeSet attributes = new TreeSet(); Iterator<PropertyBean> attrs = bean.properties(); while (attrs.hasNext()) { PropertyBean property = attrs.next(); if (!property.isTagAttributeExcluded()) attributes.add(property.getPropertyName()); }//from w w w . j a v a 2 s .c o m // Now get a list of PropertyBeans List list = new ArrayList(); Iterator<String> iter = attributes.iterator(); while (iter.hasNext()) { String attrName = iter.next(); list.add(bean.findProperty(attrName)); } _writeComponentAttributes(out, list.iterator(), bean.getValidatorClass(), null); }
From source file:net.sourceforge.fenixedu.domain.phd.PhdIndividualProgramProcess.java
public PrecedentDegreeInformation getLatestPrecedentDegreeInformation() { TreeSet<PrecedentDegreeInformation> degreeInformations = new TreeSet<PrecedentDegreeInformation>( Collections.reverseOrder(PrecedentDegreeInformation.COMPARATOR_BY_EXECUTION_YEAR)); ExecutionYear currentExecutionYear = ExecutionYear.readCurrentExecutionYear(); for (PrecedentDegreeInformation pdi : getPrecedentDegreeInformationsSet()) { if (!pdi.getExecutionYear().isAfter(currentExecutionYear)) { degreeInformations.add(pdi); }/*w ww.jav a 2s.c om*/ } degreeInformations.addAll(getPrecedentDegreeInformationsSet()); return (degreeInformations.iterator().hasNext()) ? degreeInformations.iterator().next() : null; }
From source file:com.ecyrd.jspwiki.ReferenceManager.java
/** * Updates the referred pages of a new or edited WikiPage. If a refersTo * entry for this page already exists, it is removed and a new one is built * from scratch. Also calls updateReferredBy() for each referenced page. * <p>/* w ww .ja v a2 s.c o m*/ * This method does not synchronize the database to disk. * * @param page Name of the page to update. * @param references A Collection of Strings, each one pointing to a page this page references. */ private void internalUpdateReferences(String page, Collection references) { page = getFinalPageName(page); // // Create a new entry in m_refersTo. // Collection oldRefTo = m_refersTo.get(page); m_refersTo.remove(page); TreeSet<String> cleanedRefs = new TreeSet<String>(); for (Iterator i = references.iterator(); i.hasNext();) { String ref = (String) i.next(); ref = getFinalPageName(ref); cleanedRefs.add(ref); } m_refersTo.put(page, cleanedRefs); // // We know the page exists, since it's making references somewhere. // If an entry for it didn't exist previously in m_referredBy, make // sure one is added now. // if (!m_referredBy.containsKey(page)) { m_referredBy.put(page, new TreeSet<String>()); } // // Get all pages that used to be referred to by 'page' and // remove that reference. (We don't want to try to figure out // which particular references were removed...) // cleanReferredBy(page, oldRefTo, cleanedRefs); // // Notify all referred pages of their referinesshoodicity. // Iterator<String> it = cleanedRefs.iterator(); while (it.hasNext()) { String referredPageName = it.next(); updateReferredBy(getFinalPageName(referredPageName), page); } }
From source file:org.apache.myfaces.trinidadbuild.plugin.tagdoc.TagdocReport.java
private void _writeComponentFacets(Writer out, ComponentBean bean, Map<String, List<QName>> compTypeMap) throws IOException { // Sort the facets TreeSet facetNames = new TreeSet(); Iterator<FacetBean> iter = bean.facets(true); while (iter.hasNext()) { FacetBean facetBean = iter.next(); if (!facetBean.isHidden()) { facetNames.add(facetBean.getFacetName()); }/* ww w . ja v a 2s .c o m*/ } out.write("<table>\n"); out.write("<tr>\n"); out.write("<th>Name</th>\n"); out.write("<th>Description</th>\n"); out.write("</tr>\n"); Iterator<String> nameIter = facetNames.iterator(); while (nameIter.hasNext()) { String name = nameIter.next(); FacetBean facet = bean.findFacet(name, true); out.write("<tr>\n"); out.write("<td>" + facet.getFacetName() + "</td>"); out.write("<td>"); if (facet.hasAllowedChildComponents()) { String formattedChildComps = _formatTagList(facet.allowedChildComponents(), compTypeMap, "Allowed Child Components"); if (formattedChildComps != null) { out.write(formattedChildComps); out.write("<br/>"); } } out.write(facet.getDescription()); out.write("</td>\n"); out.write("</tr>\n"); } out.write("</table>\n"); }
From source file:org.geoserver.importer.Importer.java
public Iterator<ImportContext> getAllContextsByUpdated() { try {/*from ww w . j av a2 s. com*/ return contextStore.iterator("updated"); } catch (UnsupportedOperationException e) { //fallback TreeSet sorted = new TreeSet<ImportContext>(new Comparator<ImportContext>() { @Override public int compare(ImportContext o1, ImportContext o2) { Date d1 = o1.getUpdated(); Date d2 = o2.getUpdated(); return -1 * d1.compareTo(d2); } }); Iterators.addAll(sorted, contextStore.iterator()); return sorted.iterator(); } }