- Timestamp:
- Dec 11, 2006, 12:35:36 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/servlet/PlotServlet.java
r2993 r3015 42 42 import net.sf.basedb.core.query.Orders; 43 43 import net.sf.basedb.core.query.Restriction; 44 import net.sf.basedb.core.query.Select; 44 45 import net.sf.basedb.core.query.Selects; 45 46 import net.sf.basedb.core.query.SqlResult; 46 47 import net.sf.basedb.core.query.SqlResultIterator; 48 import net.sf.basedb.core.query.WhenStatement; 47 49 import net.sf.basedb.clients.web.formatter.FormatterFactory; 48 50 import net.sf.basedb.clients.web.util.HTML; … … 65 67 66 68 import org.jfree.chart.JFreeChart; 69 import org.jfree.chart.renderer.xy.XYStepRenderer; 67 70 import org.jfree.chart.title.TextTitle; 68 71 … … 341 344 final String annotation = Values.getStringOrNull(request.getParameter("annotation")); 342 345 final boolean hasAnnotation = annotation != null; 346 Select annotationSelect = null; 343 347 344 348 // Scatter plot specified parameters … … 405 409 annotations = new TreeSet<PlotAnnotation>(); 406 410 List<BioAssay> bioAssays = bas.getBioAssays().list(dc); 411 annotationSelect = Dynamic.select(VirtualColumn.COLUMN); 407 412 if ("bioassay".equals(annotation)) 408 413 { … … 434 439 annotations.add(new PlotAnnotation(name, entry.getValue())); 435 440 } 441 } 442 else if (annotation.startsWith("=")) 443 { 444 // JEP restriction 445 Restriction r = 446 BioAssaySetUtil.createJepRestriction(dc, bas, annotation.substring(1), false); 447 Expression e = Expressions.caseWhen(Expressions.integer(0), 448 new WhenStatement(r, Expressions.integer(1))); 449 annotationSelect = Selects.expression(e, "ann"); 450 annotations.add(new PlotAnnotation("", 0)); 451 annotations.add(new PlotAnnotation(annotation.substring(1), 1)); 436 452 } 437 453 else … … 466 482 { 467 483 query.reset(); 468 if ( hasAnnotation)469 { 470 query.select( Dynamic.select(VirtualColumn.COLUMN));484 if (annotationSelect != null) 485 { 486 query.select(annotationSelect); 471 487 } 472 488 query.select(Selects.expression(x[i], "x")); … … 485 501 else 486 502 { 487 HistogramPlot plot = new HistogramPlot(xLabel, yLabel); 503 HistogramPlot plot = new HistogramPlot(xLabel, yLabel, 504 hasAnnotation ? new XYStepRenderer() : null); 488 505 query.setReturnTotalCount(true); 489 506 for (int i = 0; i < x.length; ++i) 490 507 { 491 508 query.reset(); 492 if ( hasAnnotation)493 { 494 query.select( Dynamic.select(VirtualColumn.COLUMN));509 if (annotationSelect != null) 510 { 511 query.select(annotationSelect); 495 512 } 496 513 query.select(Selects.expression(x[i], "x")); -
trunk/src/core/net/sf/basedb/util/plot/HistogramPlot.java
r2474 r3015 34 34 import org.jfree.chart.plot.XYPlot; 35 35 import org.jfree.chart.renderer.xy.XYBarRenderer; 36 import org.jfree.chart.renderer.xy.XY StepRenderer;36 import org.jfree.chart.renderer.xy.XYItemRenderer; 37 37 import org.jfree.chart.renderer.xy.YIntervalRenderer; 38 38 import org.jfree.data.DomainOrder; … … 48 48 import java.util.List; 49 49 import java.util.Map; 50 50 51 51 52 /** … … 72 73 @param nameX The label on the X-axis 73 74 @param nameY The label on the Y-axis 74 */ 75 public HistogramPlot(String nameX, String nameY) 75 @param renderer The renderer to use or null for the default (XYBarRenderer) 76 */ 77 public HistogramPlot(String nameX, String nameY, XYItemRenderer renderer) 76 78 { 77 79 … … 85 87 NumberAxis rangeAxis = new NumberAxis(nameY); 86 88 rangeAxis.setAutoRangeIncludesZero(true); 87 88 plot = new XYPlot(histogram, domainAxis, rangeAxis, new XYBarRenderer());89 if (renderer == null) renderer = new XYBarRenderer(); 90 plot = new XYPlot(histogram, domainAxis, rangeAxis, renderer); 89 91 plot.setDataset(1, hilo); 90 92 YIntervalRenderer yRenderer = new YIntervalRenderer(); … … 179 181 List<TempSeries> tempSeries = new ArrayList<TempSeries>(annotations.size()); 180 182 int meanCount = (int)(data.getTotalCount() / annotations.size()); 183 plot.getRenderer().setSeriesVisibleInLegend(null); 181 184 for (PlotAnnotation pa : annotations) 182 185 { … … 213 216 hilo.addSeries(new HistogramSeries(ts.name, main, hiloAggregate)); 214 217 } 218 plot.getRenderer().setSeriesVisibleInLegend(histogram.getSeriesCount()-1, !ts.name.equals("")); 215 219 } 216 220 adjustRanges(); 217 plot.setRenderer(new XYStepRenderer());218 221 } 219 222 -
trunk/src/core/net/sf/basedb/util/plot/PlotAnnotation.java
r2704 r3015 24 24 package net.sf.basedb.util.plot; 25 25 26 import java.util.Arrays; 26 27 import java.util.Collection; 27 28 … … 43 44 private final String name; 44 45 private final Collection<Integer> values; 46 47 /** 48 Create a new PlotAnnotation. 49 @param name The name of the annotation, which will be used as a label in the image 50 @param values The value that belongs to this annotation 51 @since 2.2 52 */ 53 public PlotAnnotation(String name, int value) 54 { 55 this(name, Arrays.asList(value)); 56 } 45 57 46 58 /** -
trunk/src/core/net/sf/basedb/util/plot/ScatterPlot.java
r2327 r3015 137 137 Map<Integer, XYSeries> series = new HashMap<Integer, XYSeries>(annotations.size()); 138 138 List<XYSeries> newSeries = new ArrayList<XYSeries>(annotations.size()); 139 plot.getRenderer().setSeriesVisibleInLegend(null); 139 140 for (PlotAnnotation pa : annotations) 140 141 { … … 160 161 { 161 162 allSeries.addSeries(s); 163 plot.getRenderer().setSeriesVisibleInLegend(allSeries.getSeriesCount()-1, !s.getKey().equals("")); 162 164 } 163 165 } -
trunk/www/views/experiments/plotter/index.jsp
r2993 r3015 196 196 function switchTab(tabControlId, tabId) 197 197 { 198 if (tabId != 'filter')198 if (tabId == 'scatter' || tabId == 'histogram') 199 199 { 200 200 plotType = tabId; … … 240 240 var frm = document.forms['plot']; 241 241 var selected = list[list.selectedIndex]; 242 var value = selected.value ? selected.text : '';242 var value = selected.value && selected.value != '$' ? selected.text : ''; 243 243 value = value.replace('\[A\] ', ''); 244 244 frm.subTitle.value = value; 245 } 246 245 246 var annotationFrm = document.forms['annotation']; 247 if (selected.value.substring(0, 1) == '$') 248 { 249 annotationFrm.annotationExp.disabled = true; 250 } 251 else 252 { 253 if (selected.value) 254 { 255 annotationFrm.annotationExp.value = selected.value; 256 } 257 annotationFrm.annotationExp.disabled = false; 258 annotationFrm.annotationExp.focus(); 259 } 260 } 261 262 function annotationExpressionOnChange() 263 { 264 var annotationFrm = document.forms['annotation']; 265 annotationFrm.annotationPresets.selectedIndex = annotationFrm.annotationPresets.length-1; 266 } 247 267 248 268 function generatePlotUrl(fullSize) … … 264 284 { 265 285 url += '&filter='+Main.encodeURI(filterFrm.filter.value); 286 } 287 288 var annotationFrm = document.forms['annotation']; 289 var annotation = ''; 290 if (!annotationFrm.annotationExp.disabled) 291 { 292 if (annotationFrm.annotationExp.value) 293 { 294 annotation = '=' + annotationFrm.annotationExp.value; 295 } 296 } 297 else 298 { 299 annotation = annotationFrm.annotationPresets[annotationFrm.annotationPresets.selectedIndex].value.substring(1); 300 } 301 if (annotation) 302 { 303 url += '&annotation='+Main.encodeURI(annotation); 266 304 } 267 305 … … 277 315 url += '&yLog='+(frm.yLog.checked ? 1 : 0); 278 316 url += '&yLabel='+Main.encodeURI(frm.yLabel.value); 279 if (frm.annotation)280 {281 url += '&annotation='+frm.annotation[frm.annotation.selectedIndex].value;282 }283 317 } 284 318 else … … 299 333 } 300 334 url += '&yLabel='+Main.encodeURI(frm.yLabel.value); 301 if (frm.annotation)302 {303 url += '&annotation='+frm.annotation[frm.annotation.selectedIndex].value;304 }305 335 } 306 336 return url; … … 419 449 <t:tabcontrol id="plotType" style="<%="width: "+(int)(scale*340)+"px;"%>" contentstyle="<%="height: "+(int)(scale*340)+"px;"%>" 420 450 switch="switchTab"> 421 <t:tab id="scatter" title="Scatter plot" helpid="plotter.scatterplot"> 451 <t:tab id="scatter" title="Scatter plot" helpid="plotter.scatterplot" 452 tooltip="Create a scatter plot"> 422 453 <form name="scatter"> 423 454 <table border="0" cellspacing="0" cellpadding="2" class="form"> … … 490 521 <td colspan="2"><input type="checkbox" name="xLog" value="1"></td> 491 522 </tr> 492 <%493 if (ba == null)494 {495 %>496 <tr>497 <td class="prompt">Annotation</td>498 <td colspan="2">499 <select name="annotation" onchange="annotationOnChange(this)">500 <option value="">- none -501 <option value="bioassay">Bioassay502 <option value="spots">Spots503 <option value="arrayDesign.name">Array design504 <option value="software.name">Software505 <option value="protocol.name">Protocol506 <option value="scan.scanner.name">Scanner507 <option value="scan.protocol.name">Scanning protocol508 <option value="scan.hybridization.protocol.name">Hybridization protocol509 <option value="scan.hybridization.creationEvent.eventDate">Hybridization date510 <%511 for (AnnotationType at : experimentalFactors)512 {513 %>514 <option value="<%=at.getId()%>">[A] <%=HTML.encodeTags(at.getName())%>515 <%516 }517 %>518 </select>519 </td>520 </tr>521 <%522 }523 %>524 523 </table> 525 524 </form> 526 525 </t:tab> 527 526 528 <t:tab id="histogram" title="Histogram plot" helpid="plotter.histogram"> 527 <t:tab id="histogram" title="Histogram plot" helpid="plotter.histogram" 528 tooltip="Create a histogram plot"> 529 529 <form name="histogram"> 530 530 <table border="0" cellspacing="0" cellpadding="2" class="form"> … … 617 617 <td colspan="2"><input type="text" class="text" name="binSize" value="1"></td> 618 618 </tr> 619 <%620 if (ba == null)621 {622 %>623 <tr>624 <td class="prompt">Annotation</td>625 <td colspan="2">626 <select name="annotation" onchange="annotationOnChange(this)">627 <option value="">- none -628 <option value="bioassay">Bioassay629 <option value="spots">Spots630 <option value="arrayDesign.name">Array design631 <option value="software.name">Software632 <option value="protocol.name">Protocol633 <option value="scan.scanner.name">Scanner634 <option value="scan.protocol.name">Scanning protocol635 <option value="scan.hybridization.protocol.name">Hybridization protocol636 <option value="scan.hybridization.creationEvent.eventDate">Hybridization date637 <%638 for (AnnotationType at : experimentalFactors)639 {640 %>641 <option value="<%=at.getId()%>">[A] <%=HTML.encodeTags(at.getName())%>642 <%643 }644 %>645 </select>646 </td>647 </tr>648 <%649 }650 %>651 619 </table> 652 620 </form> 653 621 </t:tab> 654 622 655 <t:tab id="filter" title="Filter" helpid="plotter.filter"> 623 <t:tab id="filter" title="Filter" helpid="plotter.filter" 624 tooltip="Specify a filter for spots that should be included in the plot"> 656 625 <form name="filter"> 657 626 <table border="0" cellspacing="0" cellpadding="2" class="form"> … … 683 652 </tr> 684 653 </table> 654 </form> 685 655 </t:tab> 656 657 <t:tab id="annotation" title="Annotation" helpid="plotter.annotation" 658 tooltip="Specify a property or expression for sub-grouping the plotted values"> 659 <form name="annotation"> 660 661 <table border="0" cellspacing="0" cellpadding="2" class="form"> 662 <tr> 663 <td class="prompt" colspan="2">Annotation</td> 664 </tr> 665 <tr> 666 <td> Presets</td> 667 <td colspan="2"> 668 <select name="annotationPresets" onchange="annotationOnChange(this)"> 669 <option value="$">- none - 670 <% 671 if (ba == null) 672 { 673 %> 674 <option value="$bioassay">Bioassay 675 <option value="$spots">Spots 676 <option value="$arrayDesign.name">Array design 677 <option value="$software.name">Software 678 <option value="$protocol.name">Protocol 679 <option value="$scan.scanner.name">Scanner 680 <option value="$scan.protocol.name">Scanning protocol 681 <option value="$scan.hybridization.protocol.name">Hybridization protocol 682 <option value="$scan.hybridization.creationEvent.eventDate">Hybridization date 683 <option value="" disabled>- annotations - 684 <% 685 for (AnnotationType at : experimentalFactors) 686 { 687 %> 688 <option value="$<%=at.getId()%>">[A] <%=HTML.encodeTags(at.getName())%> 689 <% 690 } 691 } 692 %> 693 <option value="" disabled>- expressions - 694 <%=filterOptions.toString()%> 695 <option value="">Other... 696 </select> 697 </td> 698 </tr> 699 <tr> 700 <td> Expression</td> 701 <td><input type="text" class="text" size="30" maxlength="255" name="annotationExp" 702 onchange="annotationExpressionOnChange()" disabled></td> 703 <td> 704 <base:button 705 title="" 706 image="expression_builder.gif" 707 tooltip="Use the Expression builder" 708 onclick="openExpressionBuilder('Annotation filter', 'annotation', 'annotationExp', 'COLUMN_RESTRICTION')" 709 /> 710 </td> 711 </tr> 712 </table> 713 </form> 714 </t:tab> 686 715 687 716 </t:tabcontrol>
Note: See TracChangeset
for help on using the changeset viewer.