List of usage examples for java.util HashSet toArray
Object[] toArray();
From source file:com.celements.pagetype.service.PageTypeService.java
private Set<PageTypeReference> getAllPageTypeRefs() { HashSet<PageTypeReference> pageTypeRefSet = new HashSet<PageTypeReference>(); for (IPageTypeProviderRole pageTypeProvider : pageTypeProviders.values()) { for (PageTypeReference pageTypeRef : pageTypeProvider.getPageTypes()) { pageTypeRefSet.add(pageTypeRef); }//w w w . jav a 2s. com } LOGGER.debug("getAllPageTypeRefs: return " + Arrays.deepToString(pageTypeRefSet.toArray())); return pageTypeRefSet; }
From source file:org.geogebra.common.kernel.optimization.FitRealFunction.java
public void setFunction(Function f) { kernel = f.getKernel();/*from w w w . jav a 2 s. c o m*/ FunctionVariable fvar = f.getFunctionVariable(); java.util.HashSet<GeoElement> hash = f.getVariables(); // Get a,b,c,... // to array if (hash == null) { //throw (new Exception("No gliders/parameters in fit-function...")); this.parametersOK = false; } else { gliders = hash.toArray(); } // if no gliders numberOfParameters = gliders.length; mydoubles = new MyDouble[numberOfParameters]; // Make my own parameters double temp; for (int i = 0; i < numberOfParameters; i++) { temp = ((NumberValue) gliders[i]).getDouble(); mydoubles[i] = new MyDouble(kernel); mydoubles[i].set(temp); // Set mydoubles to start values from a,b,c } // for all parameters ExpressionNode node = f.getExpression(); ExpressionNode enf = (ExpressionNode) node.deepCopy(kernel); // Make new // tree // for // new // function // ExpressionNode enf=new ExpressionNode(kernel,evf); for (int i = 0; i < numberOfParameters; i++) { enf = enf.replace((ExpressionValue) gliders[i], mydoubles[i].evaluate(StringTemplate.defaultTemplate)) .wrap(); // System.out.println("Replaced: "+((NumberValue)pars[i]).toString()+"with: "+mydoubles[i].toString()); } // for all parameters // System.out.println("enf(etter replace): "+enf.toString()); enf.resolveVariables(); // should we dispose this??? if(this.newf!=null) this.newf = new Function(enf, fvar); // System.out.println("new function: "+newf.toString()); }
From source file:geogebra.common.kernel.optimization.FitRealFunction.java
public void setFunction(Function f) { kernel = f.getKernel();//from w w w . j a v a 2s .co m FunctionVariable fvar = f.getFunctionVariable(); java.util.HashSet<GeoElement> hash = f.getVariables(); // Get a,b,c,... // to array if (hash == null) { //throw (new Exception("No gliders/parameters in fit-function...")); this.parametersOK = false; } else { gliders = hash.toArray(); } // if no gliders numberOfParameters = gliders.length; mydoubles = new MyDouble[numberOfParameters]; // Make my own parameters double temp; for (int i = 0; i < numberOfParameters; i++) { temp = ((NumberValue) gliders[i]).getDouble(); mydoubles[i] = new MyDouble(kernel); mydoubles[i].set(temp); // Set mydoubles to start values from a,b,c } // for all parameters ExpressionNode node = f.getExpression(); ExpressionNode enf = (ExpressionNode) node.deepCopy(kernel); // Make new // tree // for // new // function // ExpressionNode enf=new ExpressionNode(kernel,evf); // //System.out.println("enf(fr replace): "+enf.toString()); for (int i = 0; i < numberOfParameters; i++) { enf = enf.replace((ExpressionValue) gliders[i], mydoubles[i].evaluate(StringTemplate.defaultTemplate)) .wrap(); // System.out.println("Replaced: "+((NumberValue)pars[i]).toString()+"with: "+mydoubles[i].toString()); } // for all parameters // System.out.println("enf(etter replace): "+enf.toString()); enf.resolveVariables(); // should we dispose this??? if(this.newf!=null) this.newf = new Function(enf, fvar); // System.out.println("new function: "+newf.toString()); }
From source file:opennlp.tools.textsimilarity.TextProcessor.java
public static String removeStopListedTermsAndPhrases(String txt) { HashSet<String> stopPhrases = null; /*//from w w w . java 2s . c o m * try{ StopList sl = StopList.getInstance(); stopPhrases = * sl.getStopListMap("EXTRACTOR"); }catch(Exception e){ * log.severe("Problem loading stoplists"); } */ // segment into top 20% and bottom 20% int startIdx = txt.length() / 4; String startPart = txt.substring(0, startIdx); int endIdx = txt.length() - (txt.length() / 4); String endPart = txt.substring(endIdx, txt.length()); String middlePart = txt.substring(startIdx, endIdx); // iterate through the stop words and start removing for (Object o : stopPhrases.toArray()) { String p = (String) o; int idx = startPart.indexOf(p); if (idx != -1) { startPart = startPart.substring(idx + p.length()); } idx = endPart.indexOf(p); if (idx != -1) { endPart = endPart.substring(0, idx); } } // combine these sections String retVal = startPart + middlePart + endPart; return retVal.trim(); }
From source file:gov.nih.nci.rembrandt.web.xml.CopyNumberSampleReport.java
public Document getReportXML(Resultant resultant, Map filterMapParams) { //String theColors[] = { "B6C5F2","F2E3B5","DAE1F9","C4F2B5","819BE9", "E9CF81" }; DecimalFormat resultFormat = new DecimalFormat("0.0000"); String delim = " | "; ArrayList filter_string = new ArrayList(); // hashmap of genes | reporters | cytobands String filter_type = "show"; // show | hide String filter_element = "none"; // none | gene | reporter | cytoband if (filterMapParams.containsKey("filter_string") && filterMapParams.get("filter_string") != null) filter_string = (ArrayList) filterMapParams.get("filter_string"); if (filterMapParams.containsKey("filter_type") && filterMapParams.get("filter_type") != null) filter_type = (String) filterMapParams.get("filter_type"); if (filterMapParams.containsKey("filter_element") && filterMapParams.get("filter_element") != null) filter_element = (String) filterMapParams.get("filter_element"); Document document = DocumentHelper.createDocument(); Element report = document.addElement("Report"); Element cell = null;//from w w w. j ava 2s .c o m Element data = null; Element dataRow = null; //add the atts report.addAttribute("reportType", "Copy Number"); report.addAttribute("helpLink", ContextSensitiveHelpTag.getHelpLink("Copy Number")); //fudge these for now report.addAttribute("groupBy", "none"); String queryName = resultant.getAssociatedQuery().getQueryName(); //set the queryName to be unique for session/cache access report.addAttribute("queryName", queryName); report.addAttribute("sessionId", "the session id"); report.addAttribute("creationTime", "right now"); //hold a message to display on the report report.addAttribute("msg", (resultant.isOverLimit() ? "over limit" : "")); StringBuffer sb = new StringBuffer(); int recordCount = 0; int totalSamples = 0; ResultsContainer resultsContainer = resultant.getResultsContainer(); CopyNumberSingleViewResultsContainer copyNumberContainer = null; if (resultsContainer instanceof DimensionalViewContainer) { DimensionalViewContainer dimensionalViewContainer = (DimensionalViewContainer) resultsContainer; if (dimensionalViewContainer != null) { copyNumberContainer = dimensionalViewContainer.getCopyNumberSingleViewContainer(); } } else if (resultsContainer instanceof CopyNumberSingleViewResultsContainer) { //for single copyNumberContainer = (CopyNumberSingleViewResultsContainer) resultsContainer; } if (copyNumberContainer != null) { if (copyNumberContainer.getCytobandResultsets().size() > 0) { Collection cytobands = copyNumberContainer.getCytobandResultsets(); Collection labels = copyNumberContainer.getGroupsLabels(); Collection sampleIds = null; StringBuffer header = new StringBuffer(); StringBuffer sampleNames = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer(); /* sampleNames.append("<Tr>"); sampleNames.append("<Td> </td><Td> </td>"); header.append("<tr>"); header.append("<Td id=\"header\">Cytoband</td><td id=\"header\">Reporter</td>"); */ Element headerRow = report.addElement("Row").addAttribute("name", "headerRow"); cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Position"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Genes"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Segment ID"); data = null; cell = null; /* * Start annotations (csv only) * 1) Bp position * 2) associated genes (pipe delimimted list) */ cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Bp Position"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Genes"); data = null; cell = null; Element sampleRow = report.addElement("Row").addAttribute("name", "sampleRow"); cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("z "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; //this nested loop generates the header row and the samples row for (Iterator labelIterator = labels.iterator(); labelIterator.hasNext();) { String label = (String) labelIterator.next(); sampleIds = copyNumberContainer.getBiospecimenLabels(label); totalSamples += sampleIds.size(); cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", label) .addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "header").addText(label + " Samples"); data = null; cell = null; //header.append("<Td colspan='"+sampleIds.size()+"' class=\""+label+"\" id=\"header\">"+label+" Samples</td>"); for (Iterator sampleIdIterator = sampleIds.iterator(); sampleIdIterator.hasNext();) { BioSpecimenIdentifierDE bioSpecimenIdentifierDE = (BioSpecimenIdentifierDE) sampleIdIterator .next(); cell = sampleRow.addElement("Cell").addAttribute("type", "header") .addAttribute("class", label).addAttribute("group", label) .addAttribute("sampleId", bioSpecimenIdentifierDE.getSampleId()); //cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", label).addAttribute("group", label).addAttribute("specimen", bioSpecimenIdentifierDE.getSpecimenName()); //data = cell.addElement("Data").addAttribute("type", "header").addText(s.substring(2)); if (bioSpecimenIdentifierDE.getSpecimenName() != null) { data = cell.addElement("Data").addAttribute("type", "header") .addText(bioSpecimenIdentifierDE.getSpecimenName()); } else { data = cell.addElement("Data").addAttribute("type", "header") .addText(bioSpecimenIdentifierDE.getSampleId()); } data = null; cell = null; //sampleNames.append("<td class='"+label+"' id=\"header\"><a href=\"report.do?s="+s+"&report=ss\">"+s.substring(2)+"</a></td>"); //theColspan += sampleIds.size(); } } //header.append("</tr>\n"); //sampleNames.append("</tr>\n"); /* done with the headerRow and SampleRow Elements, time to add data rows */ for (Iterator cytobandIterator = cytobands.iterator(); cytobandIterator.hasNext();) { CytobandResultset cytobandResultset = (CytobandResultset) cytobandIterator.next(); String cytoband = cytobandResultset.getCytoband().getValue().toString(); Collection reporters = copyNumberContainer.getRepoterResultsets(cytoband); // if(!filter_element.equals("cytoband") || (filter_element.equals("cytoband") && !filter_string.contains(cytoband))) { if (FilterHelper.checkFilter(filter_element, "cytoband", cytoband, filter_type, filter_string)) { recordCount += reporters.size(); for (Iterator reporterIterator = reporters.iterator(); reporterIterator.hasNext();) { ReporterResultset reporterResultset = (ReporterResultset) reporterIterator.next(); /* * * store our annotations * */ String bp_position = ""; try { bp_position = reporterResultset.getStartPhysicalLocation().getValue().toString(); } catch (Exception e) { } //there is a much better way to do this, but this is reused from 0.50 //this code will be cleaned up for 1.0 String genes = ""; try { if (reporterResultset.getAssiciatedGeneSymbols() != null) { HashSet geneSymbols = new HashSet(reporterResultset.getAssiciatedGeneSymbols()); genes = StringUtils.join(geneSymbols.toArray(), delim); } else { genes = "-"; } } catch (Exception e) { genes = "--"; } String reporterName = reporterResultset.getReporter().getValue().toString(); if (FilterHelper.checkFilter(filter_element, "reporter", reporterName, filter_type, filter_string)) { //if(!filter_element.equals("reporter") || (filter_element.equals("reporter") && !filter_string.contains(reporterName))) { dataRow = report.addElement("Row").addAttribute("name", "dataRow"); cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "cytoband").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(cytoband); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "gene").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(genes); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "reporter").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(reporterName); data = null; cell = null; //sb.append("<tr><td>"+cytoband+"</td><td>"+reporterName+"</td>"); /* * * actually add the annotations to the report * */ cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "csv").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(bp_position); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "csv").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(genes); data = null; cell = null; for (Iterator labelIterator = labels.iterator(); labelIterator.hasNext();) { String label = (String) labelIterator.next(); ViewByGroupResultset groupResultset = (ViewByGroupResultset) reporterResultset .getGroupByResultset(label); sampleIds = copyNumberContainer.getBiospecimenLabels(label); String hClass = label; if (groupResultset != null) { for (Iterator sampleIdIterator = sampleIds.iterator(); sampleIdIterator .hasNext();) { BioSpecimenIdentifierDE sampleId = (BioSpecimenIdentifierDE) sampleIdIterator .next(); SampleCopyNumberValuesResultset sampleResultset2 = (SampleCopyNumberValuesResultset) groupResultset .getBioSpecimenResultset(sampleId.getSpecimenName()); if (sampleResultset2 != null) { //JB Begin: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) String tooltip = "Position = " + cytoband + ", Gene = " + genes + ", Reporter = " + reporterName + ", Sample = " + sampleId.getSampleId() + " (" + sampleId.getSpecimenName() + ")"; //JB End: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) if (sampleResultset2.isHighlighted()) hClass = "highlighted"; else hClass = label; Double ratio = (Double) sampleResultset2.getCopyNumber().getValue(); Double segMean = (Double) sampleResultset2.getSegmentMean() .getValue(); if (ratio != null && segMean != null) { //sb.append("<td class='"+label+"'>"+resultFormat.format(ratio)+"</td>"); cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass) .addAttribute("group", label); //JB Begin: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) //data = cell.addElement("Data").addAttribute("type", "data").addText(resultFormat.format(ratio)); data = cell.addElement("Data").addAttribute("type", "data") .addAttribute("datainfo", tooltip) .addText(resultFormat.format(ratio) + "(" + resultFormat.format(segMean) + ")"); //JB End: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) data = null; cell = null; } else { //sb.append("<td class='"+label+"'>-</td>"); cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass) .addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "data") .addText("-"); data = null; cell = null; } } else { //sb.append("<td class='"+label+"'>-</td>"); cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass).addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "data") .addText("-"); data = null; cell = null; } } } else { for (int s = 0; s < sampleIds.size(); s++) { cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass).addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "data") .addText("-"); data = null; cell = null; //sb.append("<td class='"+label+"'>-</td>"); } } } //sb.append("</tr>\n"); } /* close reporter filter */ } //sb.append("<tr><td colspan=\""+theColspan+"\" class=\"geneSpacerStyle\"> </td></tr>\n"); } /* close cyto filter */ //sb.append("</table><Br><br>"); } } else { //TODO: handle these errs sb.append("<br><br>Copy Number container is empty"); } } else { //TODO: handle these errs sb.append("<br><br>Copy Number container is empty"); } return document; //return "<div class=\"rowCount\">"+ helpFul +recordCount+" records returned. "+ totalSamples + " samples returned. " + links +"</div>\n" + sb.toString(); }
From source file:org.pgptool.gui.encryption.implpgp.EncryptionServicePgpImpl.java
@SuppressWarnings("rawtypes") @Override//from www. j a va2 s . c om public Set<String> findKeyIdsForDecryption(InputStream inputStream) { Preconditions.checkArgument(inputStream != null, "Input stream must not be null"); try { PGPObjectFactory factory = new PGPObjectFactory(PGPUtil.getDecoderStream(inputStream), KeyFilesOperationsPgpImpl.fingerprintCalculator); for (Iterator iter = factory.iterator(); iter.hasNext();) { Object section = iter.next(); log.debug(section); if (section instanceof PGPEncryptedDataList) { PGPEncryptedDataList d = (PGPEncryptedDataList) section; HashSet<String> ret = new HashSet<>(); for (Iterator dataIter = d.getEncryptedDataObjects(); dataIter.hasNext();) { PGPPublicKeyEncryptedData data = (PGPPublicKeyEncryptedData) dataIter.next(); ret.add(KeyDataPgp.buildKeyIdStr(data.getKeyID())); } log.debug("Possible decryption with IDS: " + Arrays.toString(ret.toArray())); return ret; } } throw new RuntimeException("Information about decryption methods was not found"); } catch (Throwable t) { throw new RuntimeException("This file doesn't look like encrypted file OR format is not supported", t); } }
From source file:gov.nih.nci.rembrandt.web.xml.GeneExprSampleReport.java
public Document getReportXML(Resultant resultant, Map filterMapParams) { DecimalFormat resultFormat = new DecimalFormat("0.0000"); String delim = " | "; /* testing hardcoded vals - these will be params of this method soon */ /*// w w w .j a v a 2 s.c om ArrayList g = new ArrayList(); g.add("EGFR"); g.add("VEGF"); String tmp_filter_type = "hide"; String tmp_filter_element = "gene"; HashMap filterMapParams = new HashMap(); filterMapParams.put("filter_string", g); filterMapParams.put("filter_type", tmp_filter_type); filterMapParams.put("filter_element", tmp_filter_element); */ ArrayList filter_string = new ArrayList(); // hashmap of genes | reporters | cytobands String filter_type = "show"; // show | hide String filter_element = "none"; // none | gene | reporter | cytoband if (filterMapParams.containsKey("filter_string") && filterMapParams.get("filter_string") != null) filter_string = (ArrayList) filterMapParams.get("filter_string"); if (filterMapParams.containsKey("filter_type") && filterMapParams.get("filter_type") != null) filter_type = (String) filterMapParams.get("filter_type"); if (filterMapParams.containsKey("filter_element") && filterMapParams.get("filter_element") != null) filter_element = (String) filterMapParams.get("filter_element"); Document document = DocumentHelper.createDocument(); Element report = document.addElement("Report"); Element cell = null; Element data = null; Element dataRow = null; //add the atts report.addAttribute("reportType", "Gene Expression Sample"); report.addAttribute("helpLink", ContextSensitiveHelpTag.getHelpLink("Gene Expression Sample")); //fudge these for now report.addAttribute("groupBy", "none"); String queryName = resultant.getAssociatedQuery().getQueryName(); //set the queryName to be unique for session/cache access report.addAttribute("queryName", queryName); report.addAttribute("sessionId", "the session id"); report.addAttribute("creationTime", "right now"); //hold a message to display on the report report.addAttribute("msg", (resultant.isOverLimit() ? "over limit" : "")); ResultsContainer resultsContainer = resultant.getResultsContainer(); GeneExprSingleViewResultsContainer geneViewContainer = null; StringBuffer sb = new StringBuffer(); //String helpFul = helpLink + "?sect=sample" + helpLinkClose; DimensionalViewContainer dimensionalViewContainer = null; int recordCount = 0; int totalSamples = 0; if (resultsContainer instanceof DimensionalViewContainer) { dimensionalViewContainer = (DimensionalViewContainer) resultsContainer; if (dimensionalViewContainer != null) { geneViewContainer = dimensionalViewContainer.getGeneExprSingleViewContainer(); } } else if (resultsContainer instanceof GeneExprSingleViewResultsContainer) { //for single geneViewContainer = (GeneExprSingleViewResultsContainer) resultsContainer; } if (geneViewContainer != null) { Collection genes = geneViewContainer.getGeneResultsets(); Collection labels = geneViewContainer.getGroupsLabels(); Collection sampleIds = null; StringBuffer header = new StringBuffer(); //header.append("<table cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n"); StringBuffer sampleNames = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer(); Element headerRow = report.addElement("Row").addAttribute("name", "headerRow"); cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Gene"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Reporter"); data = null; cell = null; //starting annotations cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Locus link"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("GenBank Acc"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("GO Id"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Pathways"); data = null; cell = null; Element sampleRow = report.addElement("Row").addAttribute("name", "sampleRow"); cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(" "); data = null; cell = null; //set up the header for the table //header.append("<Td id=\"header\">Gene</td>\n<td id=\"header\">Reporter</td>\n"); //sampleNames.append("<tr><Td> </td><Td> </tD>"); for (Iterator labelIterator = labels.iterator(); labelIterator.hasNext();) { String label = (String) labelIterator.next(); sampleIds = geneViewContainer.getBiospecimenLabels(label); // theColspan += sampleIds.size(); totalSamples += sampleIds.size(); cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", label) .addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "header").addText(label + " Samples"); data = null; cell = null; //header.append("<td colspan="+sampleIds.size()+" class='"+label+"' id=\"header\">"+label+" Samples</td>"); for (Iterator sampleIdIterator = sampleIds.iterator(); sampleIdIterator.hasNext();) { BioSpecimenIdentifierDE bioSpecimenIdentifierDE = (BioSpecimenIdentifierDE) sampleIdIterator .next(); cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", label) .addAttribute("group", label) .addAttribute("sampleId", bioSpecimenIdentifierDE.getSampleId()); //cell = sampleRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", label).addAttribute("group", label).addAttribute("specimen", bioSpecimenIdentifierDE.getSpecimenName()); //data = cell.addElement("Data").addAttribute("type", "header").addText(s.substring(2)); if (bioSpecimenIdentifierDE.getSpecimenName() != null) { data = cell.addElement("Data").addAttribute("type", "header") .addText(bioSpecimenIdentifierDE.getSpecimenName()); } else { data = cell.addElement("Data").addAttribute("type", "header") .addText(bioSpecimenIdentifierDE.getSampleId()); } data = null; cell = null; //sampleNames.append("<td class='"+label+"' id=\"header\"><a href=\"report.do?s="+s+"&report=ss\">"+s.substring(2)+"</a></td>"); //header.append("\t"); } //header.deleteCharAt(header.lastIndexOf("\t")); } //sampleNames.append("</tr>"); //header.append("</tr>"); /* done with the headerRow and SampleRow Elements, time to add data rows */ for (Iterator geneIterator = genes.iterator(); geneIterator.hasNext();) { GeneResultset geneResultset = (GeneResultset) geneIterator.next(); Collection reporters = geneResultset.getReporterResultsets(); String the_gene = ""; /* hard code filter for now */ if (geneResultset.getGeneSymbol() != null) { the_gene = geneResultset.getGeneSymbol().getValueObject().toString(); } //if(!the_gene.equalsIgnoreCase(filter_string)) { if (FilterHelper.checkFilter(filter_element, "gene", the_gene, filter_type, filter_string)) { //if(!filter_element.equals("gene") || (filter_element.equals("gene") && !filter_string.contains(the_gene))) { recordCount += reporters.size(); for (Iterator reporterIterator = reporters.iterator(); reporterIterator.hasNext();) { ReporterResultset reporterResultset = (ReporterResultset) reporterIterator.next(); Collection groupTypes = reporterResultset.getGroupByResultsets(); String reporterName = reporterResultset.getReporter().getValue().toString(); /* test filtration by reporter */ //if(!filter_element.equals("reporter") || (filter_element.equals("reporter") && !filter_string.contains(reporterName))) { if (FilterHelper.checkFilter(filter_element, "reporter", reporterName, filter_type, filter_string)) { GeneSymbol gene = geneResultset.getGeneSymbol(); //String geneSymbol = " "; String geneSymbol = "-"; if (gene != null) { geneSymbol = geneResultset.getGeneSymbol().getValueObject().toString(); } dataRow = report.addElement("Row").addAttribute("name", "dataRow"); cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "gene").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(geneSymbol); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "reporter").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(reporterName); data = null; cell = null; //sb.append("<tr><td>"+geneSymbol+"</td><td>"+reporterName+"</td>"); /* * adding our 4 annotations. this code needs to be cleaned up... * * I will pull all this logic out into a seperate Annotations Class ... * or something like that ASAP * * RCL * */ String ll = ""; try { HashSet locusLinkIds = new HashSet(reporterResultset.getAssiciatedLocusLinkIDs()); if (locusLinkIds != null) { ll = StringUtils.join(locusLinkIds.toArray(), delim); } else { ll = "-"; } } catch (Exception e) { ll = "--"; } String acc = ""; try { HashSet accNumbers = new HashSet( reporterResultset.getAssiciatedGenBankAccessionNos()); if (accNumbers != null) { acc = StringUtils.join(accNumbers.toArray(), delim); } else { acc = "-"; } } catch (Exception e) { } String go_ids = ""; try { HashSet go_idsHS = new HashSet(reporterResultset.getAssociatedGOIds()); if (go_idsHS != null) { go_ids = StringUtils.join(go_idsHS.toArray(), delim); } else { go_ids = "-"; } } catch (Exception e) { } String pathways = ""; try { HashSet pathwaysHS = new HashSet(reporterResultset.getAssociatedPathways()); if (pathwaysHS != null) { pathways = StringUtils.join(pathwaysHS.toArray(), delim); } else { pathways = "-"; } } catch (Exception e) { } /* * * actually add the annotations to the report * */ cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "csv").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(ll); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "csv").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(acc); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "csv").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(go_ids); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "csv").addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(pathways); data = null; cell = null; for (Iterator labelIterator = labels.iterator(); labelIterator.hasNext();) { String label = (String) labelIterator.next(); ViewByGroupResultset groupResultset = (ViewByGroupResultset) reporterResultset .getGroupByResultset(label); sampleIds = geneViewContainer.getBiospecimenLabels(label); String hClass = label; if (groupResultset != null) { for (Iterator sampleIdIterator = sampleIds.iterator(); sampleIdIterator .hasNext();) { BioSpecimenIdentifierDE sampleId = (BioSpecimenIdentifierDE) sampleIdIterator .next(); SampleFoldChangeValuesResultset biospecimenResultset = (SampleFoldChangeValuesResultset) groupResultset .getBioSpecimenResultset(sampleId.getSpecimenName()); if (biospecimenResultset != null) { //JB Begin: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) String tooltip = "Gene = " + geneSymbol + ", Reporter = " + reporterName + ", Sample = " + sampleId.getSampleId() + " (" + sampleId.getSpecimenName() + ")"; //JB End: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) if (biospecimenResultset.isHighlighted()) hClass = "highlighted"; else hClass = label; Double ratio = (Double) biospecimenResultset.getFoldChangeRatioValue() .getValue(); if (ratio != null) { cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass).addAttribute("group", label); //JB Begin: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) //data = cell.addElement("Data").addAttribute("type", "data").addText(resultFormat.format(ratio)); data = cell.addElement("Data").addAttribute("type", "data") .addAttribute("datainfo", tooltip) .addText(resultFormat.format(ratio)); //JB End: Add for GForge # 17783 - Advance Query Reports - Make the report more user friendly (Provide tool tip) data = null; cell = null; //sb.append("<Td class='"+label+"'>"+resultFormat.format(ratio)+" </td>"); } else { cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass).addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "data") .addText("-"); data = null; cell = null; //sb.append("<td class='"+label+"'>-</td>"); } } else { cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass).addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "data") .addText("-"); data = null; cell = null; //sb.append("<td class='"+label+"'>-</td>"); } } } else { for (int s = 0; s < sampleIds.size(); s++) { cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", hClass).addAttribute("group", label); data = cell.addElement("Data").addAttribute("type", "data").addText("-"); data = null; cell = null; //sb.append("<td class='"+label+"'>-</td>"); } } } //sb.append("</tr>\n"); } /* end reporter filter */ //sb.append("<tr><td colspan=\""+theColspan+"\" class=\"geneSpacerStyle\"> </td></tr>\n"); } } /* end gene filter */ //sb.append("</table>"); } } else { //TODO: handle this error sb.append("<br><Br>Gene Container is empty<br>"); } //return "<div class=\"rowCount\">"+ helpFul +recordCount+" records returned. " + totalSamples +" samples returned. " + links + "</div>\n" + sb.toString(); return document; }
From source file:co.mcme.animations.animations.MCMEAnimation.java
public String toHtml() { HashSet clips = new HashSet(); String framesString = ""; String clipsString = ""; MCMEAnimations.MCMEAnimationsInstance.getLogger().log(Level.FINE, "generating frame info for {0}", animationName);//ww w .ja v a 2 s . co m for (int i = 0; i < frames.size(); i++) { MCMEAnimationFrame f = frames.get(i); clips.add(f.getFrameName()); framesString += String.format(framesTemplate, String.valueOf(i), f.getFrameName(), String.valueOf(f.getDuration())); } MCMEAnimations.MCMEAnimationsInstance.getLogger().log(Level.FINE, "generating clip info for {0}", animationName); Object[] clipsArray = clips.toArray(); for (int i = 0; i < clipsArray.length; i++) { clipsString += String.format(clipTemplate, clipsArray[i].toString(), "0"); } MCMEAnimations.MCMEAnimationsInstance.getLogger().log(Level.FINE, "generating trigger info for {0}", animationName); String triggersString = ""; for (AnimationTrigger t : MCMEAnimations.triggers) { if (t.getParent().equals(this)) { triggersString += t.toHtml(); } } MCMEAnimations.MCMEAnimationsInstance.getLogger().log(Level.FINE, "generating actions info for {0}", animationName); String actionsString = ""; for (AnimationAction a : MCMEAnimations.actions) { if (a.getAnimationName().equals(this.animationName)) { actionsString += a.toHtml(); } } //ANIMATION NAME //ANIMATION TYPE //ANIMATION DESCRIPTION //ORIGIN //CREATOR //WORLD //CLIPBOARDS LIST //FRAMES LIST //TRIGGERS LIST //ACTIONS LIST String originString = "X:" + origin.getX() + " Y:" + origin.getY() + " Z:" + origin.getZ(); String worldString = localWorldName; MCMEAnimations.MCMEAnimationsInstance.getLogger().log(Level.INFO, "wrapping data for {0}", animationName); return String.format(HtmlTemplate, animationName, getType().toString(), animationDescription, originString, (String) animationConfiguration.get("creator"), worldString, clipsString, framesString, triggersString, actionsString); }
From source file:web.diva.server.model.pca.PCAImageGenerator.java
@SuppressWarnings("CallToPrintStackTrace") public int[] getPCASelection(int startX, int startY, int endX, int endY) { double[] selectRect = null; if (zoom) {/*w w w.j a va 2 s . c o m*/ try { selectRect = getZoomedSelectionRecatangle(startX, startY, endX, endY); } catch (Exception exp) { exp.printStackTrace(); } } else { selectRect = this.getSelectionRecatangle(startX, startY, endX, endY); } if (selectRect == null) return new int[] {}; HashSet<Integer> selectedPoints = new HashSet<Integer>(); for (int x = 0; x < points[0].length; x++) { double pointX = points[0][x]; double pointY = points[1][x]; if (pointX >= selectRect[0] && pointX <= selectRect[1] && pointY >= selectRect[2] && pointY <= selectRect[3]) { selectedPoints.add(x); } } if (selectedPoints.size() > 0) { Integer[] selectedIndexes = new Integer[selectedPoints.size()]; System.arraycopy(selectedPoints.toArray(), 0, selectedIndexes, 0, selectedIndexes.length); int[] arr = new int[selectedIndexes.length]; arr = org.apache.commons.lang3.ArrayUtils.toPrimitive(selectedIndexes, selectedIndexes.length); return arr; } return new int[] {}; }
From source file:org.broadleafcommerce.core.workflow.BaseProcessor.java
/** * Called after the properties have been set, Ensures the list of activities * is not empty and each activity is supported by this Workflow Processor * * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() *//* ww w. j a v a2 s .c o m*/ @Override public void afterPropertiesSet() throws Exception { if (!(beanFactory instanceof ListableBeanFactory)) { throw new BeanInitializationException("The workflow processor [" + beanName + "] " + "is not managed by a ListableBeanFactory, please re-deploy using some derivative of ListableBeanFactory such as" + "ClassPathXmlApplicationContext "); } if (CollectionUtils.isEmpty(activities) && !isAllowEmptyActivities()) { throw new UnsatisfiedDependencyException(getBeanDesc(), beanName, "activities", "No activities were wired for this workflow"); } //sort the activities based on their configured order OrderComparator.sort(activities); HashSet<String> moduleNames = new HashSet<String>(); for (Iterator<Activity<ProcessContext<? extends Object>>> iter = activities.iterator(); iter.hasNext();) { Activity<? extends ProcessContext<? extends Object>> activity = iter.next(); if (!supports(activity)) { throw new BeanInitializationException("The workflow processor [" + beanName + "] does " + "not support the activity of type" + activity.getClass().getName()); } if (activity instanceof ModuleActivity) { moduleActivities.add((ModuleActivity) activity); moduleNames.add(((ModuleActivity) activity).getModuleName()); } } if (CollectionUtils.isNotEmpty(moduleActivities)) { //log the fact that we've got some modifications to the workflow StringBuffer message = new StringBuffer(); message.append("The following modules have made changes to the " + getBeanName() + " workflow: "); message.append(Arrays.toString(moduleNames.toArray())); message.append("\n"); message.append("The final ordering of activities for the " + getBeanName() + " workflow is: \n"); ArrayList<String> activityNames = new ArrayList<String>(); CollectionUtils.collect(activities, new Transformer() { @Override public Object transform(Object input) { return ((Activity) input).getBeanName(); } }, activityNames); message.append(Arrays.toString(activityNames.toArray())); supportLogger.lifecycle(LifeCycleEvent.CONFIG, message.toString()); } }