diff --git a/QBiCMainPortlet/ivy.xml b/QBiCMainPortlet/ivy.xml index c4657db..3241eae 100644 --- a/QBiCMainPortlet/ivy.xml +++ b/QBiCMainPortlet/ivy.xml @@ -57,7 +57,7 @@ - + diff --git a/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/PatientView.java b/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/PatientView.java index 7605a99..22df9fd 100644 --- a/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/PatientView.java +++ b/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/PatientView.java @@ -1006,8 +1006,9 @@ public VerticalLayout initProjectStatus() { return projectStatus; } - void resetGraph() { + void resetGraphs() { graphSectionContent.removeAllComponents(); + newGraphContent.removeAllComponents(); // VerticalLayout graphSection = (VerticalLayout) graphSectionContent.getParent(); // graphSection.getComponent(1).setVisible(true); // graphSection.getComponent(1).setEnabled(true); @@ -1217,7 +1218,7 @@ public void enter(ViewChangeEvent event) { ProjectBean pbean = datahandler.getProject2(currentValue); // if the new project bean is different than reset the graph. if (currentBean != null && !pbean.getId().equals(currentBean.getId())) { - resetGraph(); + resetGraphs(); patientViewTab.setSelectedTab(0); } this.currentBean = pbean; diff --git a/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/ProjectView.java b/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/ProjectView.java index 18daaf4..ae1ddba 100644 --- a/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/ProjectView.java +++ b/QBiCMainPortlet/src/de/uni_tuebingen/qbic/qbicmainportlet/ProjectView.java @@ -529,8 +529,9 @@ void updateContentTable() { /** * */ - void resetGraph() { + void resetGraphs() { graphSectionContent.removeAllComponents(); + newGraphContent.removeAllComponents(); // VerticalLayout graphSection = (VerticalLayout) graphSectionContent.getParent(); // graphSection.getComponent(1).setVisible(true); // graphSection.getComponent(1).setEnabled(true); @@ -957,7 +958,7 @@ public void enter(ViewChangeEvent event) { ProjectBean pbean = datahandler.getProject2(currentValue); // if the new project bean is different than reset the graph. if (currentBean != null && !pbean.getId().equals(currentBean.getId())) { - resetGraph(); + resetGraphs(); projectview_tab.setSelectedTab(0); } this.currentBean = pbean; diff --git a/QBiCMainPortlet/src/helpers/SummaryFetcher.java b/QBiCMainPortlet/src/helpers/SummaryFetcher.java index bca2a93..0db9115 100644 --- a/QBiCMainPortlet/src/helpers/SummaryFetcher.java +++ b/QBiCMainPortlet/src/helpers/SummaryFetcher.java @@ -17,16 +17,12 @@ import model.notes.Note; import model.notes.Notes; -import org.docx4j.jaxb.Context; -import org.docx4j.model.datastorage.XPathEnhancerParser.main_return; import org.docx4j.openpackaging.exceptions.Docx4JException; import org.docx4j.openpackaging.exceptions.InvalidFormatException; import org.docx4j.openpackaging.packages.WordprocessingMLPackage; import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; import org.docx4j.wml.Br; -import org.docx4j.wml.ObjectFactory; import org.docx4j.wml.P; -import org.docx4j.wml.R; import parser.XMLParser; import properties.Property; @@ -95,7 +91,6 @@ public class SummaryFetcher { put("Q_MHC_LIGAND_EXTRACTION", "MHC Ligand Extraction"); }; }; - private ObjectFactory factory; private WordprocessingMLPackage wordMLPackage; private Docx4jHelper docxHelper; private Component summaryComponent; @@ -262,7 +257,6 @@ private void addSummaryDownload(VerticalLayout res) { } private void initDocx4J() { - factory = Context.getWmlObjectFactory(); docxHelper = new Docx4jHelper(); try { wordMLPackage = WordprocessingMLPackage.createPackage(); diff --git a/QBiCMainPortlet/src/samplegraph/GraphPage.java b/QBiCMainPortlet/src/samplegraph/GraphPage.java index 68a6781..e8e7ca4 100644 --- a/QBiCMainPortlet/src/samplegraph/GraphPage.java +++ b/QBiCMainPortlet/src/samplegraph/GraphPage.java @@ -46,11 +46,6 @@ public GraphPage(Map taxMap, Map tissueMap) { .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); parser = new ProjectParser(reverseTaxMap, reverseTissueMap); - - this.factorBox = new ComboBox("Experimental Factor"); - factorBox.setVisible(false); - - addComponent(factorBox); } private String buildImagePath() { @@ -74,8 +69,9 @@ private String buildImagePath() { public void loadProjectGraph(String projectIdentifier, List samples, List datasets) { - factorBox.removeAllItems(); + this.factorBox = new ComboBox("Experimental Factor"); factorBox.setVisible(false); + addComponent(factorBox); currentSamples = samples; // openbis @@ -87,6 +83,7 @@ public void loadProjectGraph(String projectIdentifier, List samples, } else { // structure = parser.parseAll(currentSamples, datasets); try { + // load here structure = parser.parseSamplesBreadthFirst(currentSamples, datasets); if (!structure.getFactorsToSamples().isEmpty()) { factorBox.addItems(structure.getFactorsToSamples().keySet()); @@ -119,7 +116,7 @@ public void valueChange(ValueChangeEvent event) { } public void showDatasetsForSamples(String label, List sampleCodes) { - Window subWindow = new Window(" " + label + " Dataset information"); + Window subWindow = new Window(" " + label + " information"); subWindow.setWidth("680px"); VerticalLayout layout = new VerticalLayout(); @@ -135,7 +132,7 @@ public void showDatasetsForSamples(String label, List sampleCodes) { samplesWithoutData.add(s); } - Table haveData = new Table("Samples with Data"); + Table haveData = new Table("Samples/Entities with Data"); haveData.setStyleName(ValoTheme.TABLE_SMALL); haveData.addContainerProperty("Sample", String.class, null); haveData.addContainerProperty("Secondary Name", String.class, null); @@ -159,7 +156,7 @@ public void showDatasetsForSamples(String label, List sampleCodes) { haveData.addItem(row.toArray(new Object[row.size()]), s); } - Table noData = new Table("Samples without Data"); + Table noData = new Table("Samples/Entities without Data"); noData.setStyleName(ValoTheme.TABLE_SMALL); noData.addContainerProperty("Sample", String.class, null); noData.addContainerProperty("Secondary Name", String.class, null); @@ -207,25 +204,4 @@ public void buttonClick(ClickEvent event) { ui.addWindow(subWindow); } - // - // public void showSamples(List nodeEntries) { - // sampleTable.setPageLength(Math.min(6, nodeEntries.size())); - // sampleTable.removeAllItems(); - // sampleTable.addContainerProperty("Code", String.class, null); - // sampleTable.addContainerProperty("Secondary Name", String.class, null); - // int i = 0; - // for (Sample s : currentSamples) { - // i++; - // String code = s.getCode(); - // String name = s.getProperties().get("Q_SECONDARY_NAME"); - // if (nodeEntries.contains(code)) { - // List row = new ArrayList(); - // row.add(code); - // row.add(name); - // sampleTable.addItem(row.toArray(new Object[row.size()]), i); - // } - // } - // sampleTable.setVisible(true); - // } - } diff --git a/QBiCMainPortlet/src/samplegraph/ProjectParser.java b/QBiCMainPortlet/src/samplegraph/ProjectParser.java index a344bb2..0bf1419 100644 --- a/QBiCMainPortlet/src/samplegraph/ProjectParser.java +++ b/QBiCMainPortlet/src/samplegraph/ProjectParser.java @@ -52,8 +52,6 @@ private boolean collectCodesOfDatasetsAttachedToSamples(List samples, String code = s.getCode(); if (sampCodeToDS.containsKey(code)) { hasDatasets = true; - // for (DataSet ds : sampCodeToDS.get(code))//TODO codes needed? - // dsCodes.add(ds.getCode()); } hasDatasets |= collectCodesOfDatasetsAttachedToSamples(s.getChildren(), nodeCodes, maxDepth - 1); @@ -83,200 +81,6 @@ private void addDataSetCount(Collection summaries) { } } - // long startTime = System.nanoTime(); - // methodToTime(); - // long endTime = System.nanoTime(); - // - // long duration = (endTime - startTime); //divide by 1000000 to get milliseconds. - - // public StructuredExperiment parseAll(List allSamples, List datasets) - // throws JAXBException { - // this.xmlParser = new XMLParser(); - // sampCodeToDS = new HashMap>(); - // sampCodeToSamp = new HashMap(); - // for (DataSet d : datasets) { - // String code = d.getSampleIdentifierOrNull().split("/")[2]; - // if (sampCodeToDS.containsKey(code)) - // sampCodeToDS.get(code).add(d); - // else - // sampCodeToDS.put(code, new ArrayList(Arrays.asList(d))); - // } - // Set knownFactors = new HashSet(); - // List roots = new ArrayList(); - // - // for (Sample s : allSamples) { - // sampCodeToSamp.put(s.getCode(), s); - // Map p = s.getProperties(); - // List factors = xmlParser.getFactors(xmlParser.parseXMLString(p.get("Q_PROPERTIES"))); - // for (Factor f : factors) - // knownFactors.add(f.getLabel()); - // if (s.getParents().isEmpty() && validSamples.contains(s.getSampleTypeCode())) - // roots.add(s); - // } - // knownFactors.add("None"); - // Map> factorsToSamples = new HashMap>(); - // - // // arrays/lists of everything needed, so samples have to be visited only once (speedup) - // int numFactors = knownFactors.size(); - // int[] ids = new int[numFactors]; - // // stores Node Summary, everything that makes a node unique...and the samples that lead to - // // this summary - // List>> summariesList = - // new ArrayList>>(); - // // stores in which summary a sample ends up - // List> sampleToSummaryList = - // new ArrayList>(); - // List> orderList = new ArrayList>(); - // - // for (int i = 0; i < numFactors; i++) { - // summariesList.add(new HashMap>()); - // sampleToSummaryList.add(new HashMap()); - // orderList.add(new HashMap()); - // } - // List factorLabels = new ArrayList(knownFactors); - // - // - // createSummariesRecursive2(roots, sampleToSummaryList, summariesList, factorLabels, ids, - // orderList); - // for (int i = 0; i < ids.length; i++) { - // for (NewNodeSummary sum : summariesList.get(i).keySet()) { - // for (Sample s : summariesList.get(i).get(sum)) { - // for (Sample c : s.getChildren()) { - // if (sampleToSummaryList.get(i).containsKey(c)) - // sum.addChild(sampleToSummaryList.get(i).get(c)); - // } - // } - // } - // // create real graph objects - // List res = convertNodeSummariesToSampleSummaries(summariesList.get(i), - // sampleToSummaryList.get(i), orderList.get(i)); - // addDataSetCount(res); - // factorsToSamples.put(WordUtils.capitalize(factorLabels.get(i)), res); - // } - // // one graph for every experimental factor - // // for (String label : knownFactors) { - // // // stores Node Summary, everything that makes a node unique...and the samples that lead to - // // // this summary - // // Map> summaries = new HashMap>(); - // // // stores in which summary a sample ends up - // // Map sampleToSummary = new HashMap(); - // // - // // int[] id = {0}; - // // Map order = new HashMap(); - // // System.out.println("creating summaries for factor label " + label); - // // startTime = System.nanoTime(); - // // createSummariesRecursive(roots, sampleToSummary, summaries, label, id, order); - // // endTime = System.nanoTime(); - // // System.err.println((endTime - startTime) / 1000000); - // // for (NewNodeSummary sum : summaries.keySet()) { - // // for (Sample s : summaries.get(sum)) { - // // for (Sample c : s.getChildren()) { - // // if (sampleToSummary.containsKey(c)) - // // sum.addChild(sampleToSummary.get(c)); - // // } - // // } - // // } - // // // create real graph objects - // // List res = - // // convertNodeSummariesToSampleSummaries(summaries, sampleToSummary, order); - // // addDataSetCount(res); - // // factorsToSamples.put(WordUtils.capitalize(label), res); - // // } - // return new StructuredExperiment(factorsToSamples); - // } - - // private void createSummariesRecursive2(List roots, - // List> sampleToSummaryList, - // List>> summariesList, List factorLabels, int[] ids, - // List> orderList) throws JAXBException { - // // System.out.println("recurse"); - // // List nextLvl = new ArrayList(); - // for (Sample s : roots) { - // String type = s.getSampleTypeCode(); - // List nextLvl = new ArrayList(); - // // if sample type should be shown in graph...TODO intermediate samples should never be - // // hidden for obvious reasons - // if (validSamples.contains(type)) { - // nextLvl.addAll(s.getChildren()); - // - // for (int i = 0; i < ids.length; i++) { - // // fill maps - // Map> summaries = summariesList.get(i); - // Map order = orderList.get(i); - // Map sampleToSummary = sampleToSummaryList.get(i); - // String label = factorLabels.get(i); - // NewNodeSummary node = sampleToBucket(s, label); - // if (summaries.containsKey(node)) { - // summaries.get(node).add(s); - // node = sampleToSummary.get(summaries.get(node).get(0));// for ids - // } else { - // summaries.put(node, new ArrayList(Arrays.asList(s))); - // node.setID(ids[i]); - // order.put(ids[i], node); - // ids[i] = ids[i] + 1; - // } - // sampleToSummaryList.get(i).put(s, node); - // - // } - // } - // createSummariesRecursive2(nextLvl, sampleToSummaryList, summariesList, factorLabels, ids, - // orderList); - // } - // // if (!nextLvl.isEmpty()) - // // createSummariesRecursive(nextLvl, sampleToSummary, summaries, label, id, order); - // } - // - // private void createSummariesRecursive(List roots, - // Map sampleToSummary, Map> summaries, - // String label, int[] id, Map order) throws JAXBException { - // // System.out.println("recurse"); - // // List nextLvl = new ArrayList(); - // for (Sample s : roots) { - // String type = s.getSampleTypeCode(); - // List nextLvl = new ArrayList(); - // // if sample type should be shown in graph...TODO intermediate samples should never be - // // hidden for obvious reasons - // if (validSamples.contains(type)) { - // nextLvl.addAll(s.getChildren()); - // // fill maps - // NewNodeSummary node = sampleToBucket(s, label); - // if (summaries.containsKey(node)) { - // summaries.get(node).add(s); - // node = sampleToSummary.get(summaries.get(node).get(0));// for ids - // } else { - // summaries.put(node, new ArrayList(Arrays.asList(s))); - // node.setID(id[0]); - // order.put(id[0], node); - // id[0] = id[0] + 1; - // } - // sampleToSummary.put(s, node); - // } - // createSummariesRecursive(nextLvl, sampleToSummary, summaries, label, id, order); - // } - // // if (!nextLvl.isEmpty()) - // // createSummariesRecursive(nextLvl, sampleToSummary, summaries, label, id, order); - // } - // - // // create list of real nodes for the graph - // private List convertNodeSummariesToSampleSummaries( - // Map> summaries, Map sampleToSummary, - // Map order) { - // List res = new ArrayList(); - // for (int i = 0; i < order.size(); i++) { - // NewNodeSummary node = order.get(i); - // Set children = node.getChildren(); - // SampleSummary sum = - // new SampleSummary(node.getID(), summaries.get(node), node.getName(), children.isEmpty()); - // List childIDs = new ArrayList(); - // for (NewNodeSummary childNode : children) { - // childIDs.add(childNode.getID()); - // } - // sum.setChildIDs(childIDs); - // res.add(sum); - // } - // return res; - // } - private Property getFactorOfSampleOrNull(Sample s, String factorLabel) throws JAXBException { Map props = s.getProperties(); List factors = new ArrayList(); @@ -331,7 +135,7 @@ public StructuredExperiment parseSamplesBreadthFirst(List samples, List< } } } - // TODO maybe fill stack (then copy stack) and map to parents outside this loop + // TODO maybe fill queue (then copy queue) and map to parents outside this loop Map idCounterPerLabel = new HashMap(); Map>> sampleToParentNodesPerLabel = new HashMap>>(); @@ -342,14 +146,9 @@ public StructuredExperiment parseSamplesBreadthFirst(List samples, List< sampleToParentNodesPerLabel.put(label, new HashMap>()); nodesForFactorPerLabel.put(label, new LinkedHashSet()); } - - // Set nodesForFactor = new HashSet(); - // Map> sampleToParentNodes = - // new HashMap>(); - // breadth first stack loop + // breadth first queue loop while (!samplesBreadthFirst.isEmpty()) { Sample s = samplesBreadthFirst.poll(); - // System.out.println(nodesForFactor); String type = s.getSampleTypeCode(); if (validSamples.contains(type) && !visited.contains(s)) { visited.add(s); @@ -375,18 +174,14 @@ public StructuredExperiment parseSamplesBreadthFirst(List samples, List< } if (!exists) idCounterPerLabel.put(label, idCounterPerLabel.get(label) + 1); - // idCounter++; // adds node if not already contained in set Set theseNodes = nodesForFactorPerLabel.get(label); theseNodes.add(node); nodesForFactorPerLabel.put(label, theseNodes); // add this id to parents' child ids for (SampleSummary parentSummary : parentSummaries) { - // System.out.println("adding " + node.getId() + " as child of " + parentSummary); parentSummary.addChildID(node.getId()); - // System.out.println(parentSummary); } - // System.out.println(node); for (Sample c : children) { samplesBreadthFirst.add(c); if (!sampleToParentNodes.containsKey(c)) { @@ -444,14 +239,6 @@ private SampleSummary createSummary(Sample s, Set parents, String String value = ""; if (newFactor) value = factor.getValue(); - // while (!parents.isEmpty()) { - // depth += 1; - // List gramps = new ArrayList(); - // for (Sample p : parents) { - // gramps.addAll(p.getParents()); - // } - // parents = gramps; - // } Map props = s.getProperties(); switch (type) { case "Q_BIOLOGICAL_ENTITY": @@ -470,7 +257,7 @@ private SampleSummary createSummary(Sample s, Set parents, String } } if (!newFactor || source.equals(value)) { - value = source;// test + value = source; } else { value = source + " " + value; } @@ -484,77 +271,16 @@ private SampleSummary createSummary(Sample s, Set parents, String value = source; break; } - // String code = s.getCode(); - // int measured = 0; - // if (sampCodeToDS.containsKey(code)) - // measured = sampCodeToDS.get(code).size(); - // System.out.println(type); - // System.out.println(measured);// TODO connect to datasets - return new SampleSummary(currentID, parentIDs, new ArrayList(Arrays.asList(s)), factor.getValue(), - tryShortenName(value, s), type, s.getChildren().isEmpty()); + boolean leaf = true; + for (Sample c : s.getChildren()) { + if (validSamples.contains(c.getSampleTypeCode())) { + leaf = false; + break; + } + } + return new SampleSummary(currentID, parentIDs, new ArrayList(Arrays.asList(s)), + factor.getValue(), tryShortenName(value, s), type, leaf); } - // - // - // private NewNodeSummary sampleToBucket(Sample s, String factorLabel) throws JAXBException { - // String type = s.getSampleTypeCode(); - // String source = "unknown"; - // Factor factor = getFactorOfSampleOrNull(s, factorLabel); - // int depth = 0; - // boolean factorInherited = false; - // List parents = s.getParents(); - // Set parentSources = new HashSet(); - // for (Sample p : parents) { - // if (getFactorOfSampleOrNull(p, factorLabel) != null) { - // factorInherited = true; - // } - // parentSources.add(sampleToBucket(p, factorLabel).getSource()); - // } - // if (factor == null) { - // factor = new Factor("parents", StringUtils.join(parentSources, "+")); - // } - // while (!parents.isEmpty()) { - // depth += 1; - // List gramps = new ArrayList(); - // for (Sample p : parents) { - // gramps.addAll(p.getParents()); - // } - // parents = gramps; - // } - // Map props = s.getProperties(); - // String name = factor.getValue(); - // switch (type) { - // case "Q_BIOLOGICAL_ENTITY": - // source = taxMap.get(props.get("Q_NCBI_ORGANISM")); - // name = source + " " + name; - // break; - // case "Q_BIOLOGICAL_SAMPLE": - // source = tissueMap.get(props.get("Q_PRIMARY_TISSUE")); - // boolean isCellLine = source.equals("Cell Line"); - // if (source.equals("Other") || isCellLine) { - // String detail = props.get("Q_TISSUE_DETAILED"); - // if (detail != null && !detail.isEmpty()) { - // source = detail; - // if (isCellLine) - // source = "Cell Line " + source; - // } - // } - // if (factorInherited || source.equals(name)) - // name = source;// test - // else { - // name = source + " " + name; - // } - // break; - // case "Q_TEST_SAMPLE": - // source = props.get("Q_SAMPLE_TYPE"); - // name = source + factor.getValue(); - // break; - // case "Q_MHC_LIGAND_EXTRACT": - // source = props.get("Q_MHC_CLASS"); - // name = source; - // break; - // } - // return new NewNodeSummary(source, factor, depth, tryShortenName(name, s)); - // } private String tryShortenName(String key, Sample s) { switch (s.getSampleTypeCode()) { diff --git a/QBiCMainPortlet/src/samplegraph/SampleSummary.java b/QBiCMainPortlet/src/samplegraph/SampleSummary.java index 5b0b686..5842c2b 100644 --- a/QBiCMainPortlet/src/samplegraph/SampleSummary.java +++ b/QBiCMainPortlet/src/samplegraph/SampleSummary.java @@ -23,29 +23,8 @@ public class SampleSummary { private int amount; private boolean leaf; - public SampleSummary(List samples, String name, int measured, int amount, String sampleType) { - super(); - this.samples = samples; - this.name = name; - this.measuredPercent = measured; - this.amount = amount; - this.sampleType = sampleType; - childIDs = new HashSet(); - addCodes(samples); - } - - public SampleSummary(List samples, String name, String sampleType, boolean isLeaf) { - super(); - this.samples = samples; - this.name = name; - childIDs = new HashSet(); - this.leaf = isLeaf; - this.amount = samples.size(); - this.sampleType = sampleType; - addCodes(samples); - } - - public SampleSummary(int id, Set parentIDs, List samples, String factorValue, String name, String sampleType, boolean isLeaf) { + public SampleSummary(int id, Set parentIDs, List samples, String factorValue, + String name, String sampleType, boolean isLeaf) { this.samples = samples; this.parentIDs = parentIDs; this.name = name; @@ -65,7 +44,11 @@ private void addCodes(List samples) { codes.add(s.getCode()); } - public boolean isLeaf() { + public void setLeaf(boolean isLeaf) { + this.leaf = isLeaf; + } + + public boolean getLeaf() { return leaf; } @@ -132,7 +115,7 @@ public void setMeasuredPercent(int measured) { public int getAmount() { return amount; } - + public String getSampleType() { return sampleType; } @@ -164,7 +147,7 @@ public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((factorValue == null) ? 0 : factorValue.hashCode()); -// result = prime * result + (leaf ? 1231 : 1237); + // result = prime * result + (leaf ? 1231 : 1237); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((parentIDs == null) ? 0 : parentIDs.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); @@ -185,8 +168,8 @@ public boolean equals(Object obj) { return false; } else if (!factorValue.equals(other.factorValue)) return false; -// if (leaf != other.leaf) -// return false; + // if (leaf != other.leaf) + // return false; if (name == null) { if (other.name != null) return false; diff --git a/QBiCMainPortlet/src/samplegraph/graph_connector.js b/QBiCMainPortlet/src/samplegraph/graph_connector.js index 4903ec7..fbc89e9 100644 --- a/QBiCMainPortlet/src/samplegraph/graph_connector.js +++ b/QBiCMainPortlet/src/samplegraph/graph_connector.js @@ -1,6 +1,5 @@ window.samplegraph_ProjectGraph = function() { var diagramElement = this.getElement(); - // d3.select(diagramElement).append("svg"); var rpcProxy = this.getRpcProxy(); this.onStateChange = function() { @@ -29,11 +28,6 @@ window.samplegraph_ProjectGraph = function() { return getTextWidth(label, "12px arial") + 5; } - /* - * var tooltip = d3.select("body") .append("div") .style("position", - * "absolute") .style("z-index", "10") .style("visibility", "hidden") - * .text("a simple tooltip"); - */ var icons = { "dna" : "dna.svg", "rna" : "rna.svg", @@ -56,13 +50,14 @@ window.samplegraph_ProjectGraph = function() { } function init_graph_circles(samples) { - var circ_rad = 20; - var margin = 15; + var factor = 1; + var circ_rad = 20 * factor; + var margin = 15 * factor; // distance from top and left var max_Y = 0, max_X = 0;// maximal node positions var g = new dagre.graphlib.Graph() // Set an object for the graph label - g.setGraph({}); + g.setGraph({marginx:margin,marginy:margin}); // Default to assigning a new object as a label for each new edge. g.setDefaultEdgeLabel(function() { @@ -121,8 +116,6 @@ window.samplegraph_ProjectGraph = function() { if (typeof n != 'undefined') { if (n.label != "") { label = n.label.toLowerCase().replace(" ", ""); - n["y"] = n["y"] + margin; // spacing from top - n["x"] = n["x"] + margin; // spacing from left var x = n["x"]; var y = n["y"]; max_X = Math.max(max_X, x); @@ -130,9 +123,6 @@ window.samplegraph_ProjectGraph = function() { } } }); - factor = 1; - circ_rad = circ_rad * factor; - margin = 15 * factor; // distance from top and left var legend_entry_height = circ_rad + 5; // guess needed width of graph using 4-digit sample label var box_width = factor * max_X + circ_rad + getTextWidth("9999") + 20; @@ -158,53 +148,33 @@ window.samplegraph_ProjectGraph = function() { addBGImages(svg, Object.keys(icons), "", circ_rad * 2); addBGImages(svg, Object.keys(icons), "legend_", circ_rad); -// console.log(samples); -// g.edges().forEach( -// function(e) { -// console.log(e) -// var from = e.v; -// if (samples[from] == "undefined") { // case: empty node (added -// // to make graph look -// // better) -// line = g.edge(e)["points"][0] // first line, coming -// // out of the bottom of -// // the node -// target_x = line["x"]; -// target_y = line["y"]; -// d3.select("svg").append("line").attr("x1", -// target_x * factor + margin).attr("y1", -// target_y * factor + margin).attr("x2", -// target_x * factor + margin).attr("y2", -// target_y * factor + margin - circ_rad * 2) // invisible -// // node -// // is -// // spanned -// // by -// // this -// // line -// .attr("stroke-width", 2).attr("stroke", "black"); -// } -// }); g.edges().forEach( function(e) { var points = g.edge(e)["points"]; - for (var i = 1; i < points.length; i++) { - var one = points[i - 1]; - var two = points[i]; - d3.select("svg").append("line").attr("x1", - one["x"] * factor + margin).attr("y1", - one["y"] * factor + margin).attr("x2", - two["x"] * factor + margin).attr("y2", - two["y"] * factor + margin).attr( - "stroke-width", 2).attr("stroke", "black"); - } + var start = g.node(e.v); + var end = g.node(e.w); + var mid = points[1]; + var top_x = start["x"] * factor; + var top_y = start["y"] * factor; + var mid_x = mid["x"] * factor; + var mid_y = mid["y"] * factor; + var bot_x = end["x"] * factor; + var bot_y = end["y"] * factor; + d3.select("svg").append("line").attr("x1", + top_x).attr("y1", + top_y).attr("x2", + mid_x).attr("y2", + mid_y).attr("stroke-width", 2).attr("stroke", "black"); + d3.select("svg").append("line").attr("x1", + mid_x).attr("y1", + mid_y).attr("x2", + bot_x).attr("y2", + bot_y).attr("stroke-width", 2).attr("stroke", "black"); }); g.nodes().forEach( function(v) { - // if (typeof n != 'undefined') { - // alert(v); var n = g.node(v); var data = idToSample[v]; var label = n.label; @@ -214,11 +184,10 @@ window.samplegraph_ProjectGraph = function() { var y = n["y"] * factor; var rad = circ_rad; - // var w_label = width_label(label); - // var x_label = x + rad*2 - w_label; // main circles d3.select("svg").append("circle").attr("cx", x).attr( - "cy", y).attr("r", rad).style("fill", + "cy", y).attr("r", rad).attr( + "stroke", "black").style("fill", function() { if (usedSymbols.has(label)) { return "#3494F8"; @@ -226,56 +195,81 @@ window.samplegraph_ProjectGraph = function() { return color(label); } }) - // .on("mouseover", function(){ - // d3.select(this).style("fill","blue"); - // return tooltip.style("visibility", - // "visible").text(n["label"]+": ...samples");}) - // .on("mouseout", function(){ - // d3.select(this).style("fill",color(n.label)); - // return tooltip.style("visibility", "hidden");}) - ; + .on('click', function() { + rpcProxy.onCircleClick(label, data.codes); + }) + .on("mouseover", function(){ + d3.select(this).attr("opacity",0.9); + }) + .on("mouseout", function(){ + d3.select(this).attr("opacity",1); + }); // circles containing symbols if (usedSymbols.has(label)) { d3.select("svg").append("circle").attr("cx", x) .attr("cy", y).attr("r", rad).attr( "stroke", "black").attr("fill", "url(#" + lowerLabel + ")") - // .on("mouseover", function(){ - // d3.select(this).attr("opacity",0.3); - // return tooltip.style("visibility", - // "visible").text(n["label"]+": ...samples");}) - // .on("mouseout", function(){ - // d3.select(this).attr("opacity",1); - // return tooltip.style("visibility", "hidden");}) + .on('click', function() { + rpcProxy.onCircleClick(label, data.codes); + }) + .on("mouseover", function(){ + d3.select(this).attr("opacity",0.3); + }) + .on("mouseout", function(){ + d3.select(this).attr("opacity",1); + }) ; } + if(data.leaf) { // done and missing datasets (angles) var angle_done = 360 * data.measuredPercent / 100 + if(angle_done != 0) { var arc_done = d3.arc().innerRadius(rad).outerRadius( rad + rad / 4).startAngle(0).endAngle( angle_done * (pi / 180)) // converting from // degrees to // radians - var arc_missing = d3.arc().innerRadius(rad) - .outerRadius(rad + rad / 4).startAngle( - angle_done * (pi / 180)).endAngle( - 360 * (pi / 180)) d3.select("svg").append("path").attr("d", arc_done) .attr("fill", "green") .attr("stroke","black") .attr("transform", - "translate(" + x + "," + y + ")") + "translate(" + x + "," + y + ")") .on('click', function() { rpcProxy.onCircleClick(label, data.codes); + }) + .on("mouseover", function(){ + d3.select(this).attr("opacity",0.6); + return tooltip.style("visibility", "visible").text("Click for more information"); + }) + .on("mouseout", function(){ + d3.select(this).attr("opacity",1); + return tooltip.style("visibility", "hidden"); }); + } + if(angle_done != 360) { + var arc_missing = d3.arc().innerRadius(rad) + .outerRadius(rad + rad / 4).startAngle( + angle_done * (pi / 180)).endAngle( + 360 * (pi / 180)) d3.select("svg").append("path").attr("d", arc_missing) - .attr("fill", "transparent") - .attr("stroke","black") + .attr("fill", "grey") + .attr("stroke","black") .attr("transform", - "translate(" + x + "," + y + ")") + "translate(" + x + "," + y + ")") .on('click', function() { - rpcProxy.onCircleClick(label, data.codes); + rpcProxy.onCircleClick(label, data.codes); + }) + .on("mouseover", function(){ + d3.select(this).attr("opacity",0.6); + return tooltip.style("visibility", "visible").text("Click for more information"); + }) + .on("mouseout", function(){ + d3.select(this).attr("opacity",1); + return tooltip.style("visibility", "hidden"); }); + } + } // amount d3.select("svg").append("text").text(data.amount).attr( "font-family", "sans-serif").attr("font-size", diff --git a/QBiCMainPortlet/src/upload/UploadComponent.java b/QBiCMainPortlet/src/upload/UploadComponent.java index fbc9e3a..49da121 100644 --- a/QBiCMainPortlet/src/upload/UploadComponent.java +++ b/QBiCMainPortlet/src/upload/UploadComponent.java @@ -6,9 +6,6 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.io.StringWriter; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.Date; import org.apache.commons.io.FilenameUtils; @@ -91,9 +88,7 @@ public OutputStream receiveUpload(String filename, String MIMEType) { upload.interruptUpload(); } FileOutputStream fos = null; - Date date = new java.util.Date(); - String timeStamp = new SimpleDateFormat("HHmmssS").format(new Timestamp(date.getTime())); - file = new File(directory, user + "_" + timeStamp + "_" + filename); + file = new File(directory, filename); try { fos = new FileOutputStream(file); } catch (final java.io.FileNotFoundException e) {