Changeset 3444
- Timestamp:
- Oct 14, 2009, 2:58:09 PM (14 years ago)
- Location:
- branches/testing
- Files:
-
- 14 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/testing/api/core/src/org/proteios/core/Application.java
r3381 r3444 65 65 * The minor version. 66 66 */ 67 private static final int MINOR_VERSION = 9;67 private static final int MINOR_VERSION = 10; 68 68 /** 69 69 * The micro version. -
branches/testing/api/waf/src/se/lu/thep/waf/dom/html/Img.java
r1916 r3444 40 40 return this; 41 41 } 42 43 44 public Img setUsemap(String usemap) 45 { 46 this.setAttribute(new Attribute("usemap", usemap)); 47 return this; 48 } 42 49 } -
branches/testing/client/servlet/src/org/proteios/Service.java
r3419 r3444 49 49 import org.proteios.core.Directory; 50 50 import org.proteios.core.File; 51 import org.proteios.core.Identifiable; 51 52 import org.proteios.core.ItemAlreadyExistsException; 52 53 import org.proteios.core.ItemFactory; … … 54 55 import org.proteios.core.ItemQuery; 55 56 import org.proteios.core.ItemResultIterator; 57 import org.proteios.core.Nameable; 56 58 import org.proteios.core.Operator; 57 59 import org.proteios.core.Project; … … 89 91 90 92 /** 91 * Web service that enables clients to fetch and upload data ina tab separated93 * Web service that enables clients to read and write data through a tab separated 92 94 * format. Exposing items to the service is done in your web.xml. NOTE!!! This 93 95 * service is still under heavy development. Use this feature only in … … 128 130 { 129 131 RequestData data = startRequest(request, response); 130 131 // Define 132 Removable itemToRemove; 133 134 // Use 135 if (data.item != null) 136 137 { 138 if (data.item instanceof Removable) 139 { 140 itemToRemove = (Removable) data.item; 141 itemToRemove.setRemoved(true); 142 data.dc.commit(); 143 } 144 else 145 { 146 response.setStatus(HttpServletResponse.SC_FORBIDDEN); 147 } 148 } 149 else 150 { 151 response.setStatus(HttpServletResponse.SC_NOT_FOUND); 152 } 153 132 RequestHandler remover = new RemoveRequestHandler(); 133 remover.handle(data); 154 134 endRequest(data); 155 135 } … … 317 297 private void applyWhereToQuery(ItemQuery<?> query, List<AttributeDefinition> show, HttpServletRequest request) 318 298 { 319 String paramName,filterString,opStr, valueStr;299 String subParamName, paramName,filterString,opStr, valueStr, name, key; 320 300 Filter filter; 321 301 Operator operator; … … 324 304 Class<?> type; 325 305 typeUtil = new TypeUtil(); 306 Enumeration en; 307 Map<String,Boolean> whereParams; 308 309 whereParams = new HashMap<String,Boolean>(); 310 311 /* 312 Find all where* parameters 313 */ 314 en = request.getParameterNames(); 315 while (en.hasMoreElements()) 316 { 317 name = (String) en.nextElement(); 318 if(name.startsWith("where")) 319 { 320 whereParams.put(name, new Boolean(true)); 321 } 322 } 326 323 327 324 for (AttributeDefinition ad : show) … … 329 326 paramName = "where" + ad.getKey(); 330 327 // The filterString is what the user entered 331 filterString = request.getParameter(paramName); 332 log.debug(paramName + "=" + filterString); 333 if (filterString != null && filterString.length() > 1) 334 { 335 // Parse the string for operator 336 filter = null; 337 opStr = filterString.substring(0, 2); 338 valueStr = filterString.substring(2); 339 if (operatorMap.get(opStr) == null) 340 { 341 opStr = filterString.substring(0, 1); 342 valueStr = filterString.substring(1); 343 } 344 if (operatorMap.get(opStr) != null) 345 { 346 if (valueStr != null && valueStr.length() > 0) 347 { 348 // The filter string must be at least 349 // one character long Now convert the string 350 // to the proper type 351 type = ad.getAttributeType(); 352 Object value = null; 353 try 354 { 355 value = typeUtil.parse(type, valueStr); 356 log 357 .debug("Value " + valueStr + " is of type " + type + " and typeUtil returned " + value); 358 } 359 catch (Exception e) 360 { 361 log.debug(e.getMessage(), e); 362 } 363 if (value != null) 364 { 365 operator = operatorMap.get(opStr); 366 coreType = typeUtil.getType(type); 367 if (operator.equals(EQ) && typeUtil 368 .isString(type)) 369 { 370 // LIKE matching 371 if (((String) value).contains("%")) 372 operator = LIKE; 373 } 374 filter = new Filter(operator, value, 375 coreType); 376 applyFilter(query, filter, ad); 377 } 378 } 379 } 380 } 381 } 328 filter = createFilter(request, ad.getAttributeType(), paramName); 329 if(filter != null) 330 { 331 applyFilter(query, filter, ad.getKey()); 332 } 333 } 334 } 335 336 private Filter createFilter(HttpServletRequest request, Class<?> type, String paramName) 337 { 338 339 Object value = null; 340 Operator operator; 341 Type coreType; 342 TypeUtil typeUtil; 343 String filterString, opStr, valueStr; 344 boolean createFilter; 345 createFilter = false; 346 opStr = null; 347 valueStr = null; 348 349 filterString = request.getParameter(paramName); 350 log.debug(paramName + "=" + filterString); 351 if (filterString != null && filterString.length() > 1) 352 { 353 // Parse the string for operator 354 opStr = filterString.substring(0, 2); 355 valueStr = filterString.substring(2); 356 if (operatorMap.get(opStr) == null) 357 { 358 opStr = filterString.substring(0, 1); 359 valueStr = filterString.substring(1); 360 } 361 if (operatorMap.get(opStr) != null && valueStr != null && valueStr.length() > 0) 362 { 363 createFilter = true; 364 } 365 } 366 if(createFilter) 367 { 368 typeUtil = new TypeUtil(); 369 try 370 { 371 value = typeUtil.parse(type, valueStr); 372 log.debug("Value " + valueStr + " is of type " + type + " and typeUtil returned " + value); 373 } 374 catch (Exception e) 375 { 376 log.debug(e.getMessage(), e); 377 } 378 if (value != null) 379 { 380 operator = operatorMap.get(opStr); 381 coreType = typeUtil.getType(type); 382 if (operator.equals(EQ) && typeUtil.isString(type)) 383 { 384 // LIKE matching 385 if (((String) value).contains("%")) 386 { 387 operator = LIKE; 388 } 389 } 390 return new Filter(operator, value, coreType); 391 } 392 } 393 return null; 382 394 } 383 395 … … 642 654 logHeaders(request); 643 655 logParameters(request); 644 data = new RequestData(request );656 data = new RequestData(request, response); 645 657 parsePath(data); 646 658 data.sc = authenticate(request); … … 823 835 824 836 private void applyFilter(ItemQuery<?> query, Filter filter, 825 AttributeDefinition attributeDefinition) 826 { 827 String key = attributeDefinition.getKey(); 837 String key) 838 { 828 839 String property = key.substring(0, 1).toLowerCase() + key.substring(1); 829 840 Operator operator = filter.getOperator(); … … 987 998 988 999 989 /** 990 * @author gregory 991 */ 992 private class RequestData 993 { 994 Class<BasicItem> itemClass = null; 995 BasicItem<?> item = null; 996 int itemId = 0; 997 int projectContextId = 0; 998 String context = null; 999 String resource = null; 1000 Boolean isValidResource = false; 1001 User user = null; 1002 SessionControl sc = null; 1003 DbControl dc = null; 1004 ItemFactory factory = null; 1005 ClassDescriptor cd = null; 1006 Project activeProject = null; 1007 Directory home = null; 1008 HttpServletRequest request; 1009 BufferedReader reader = null; 1010 InputStream stream = null; 1011 InputStreamReader streamReader = null; 1012 1013 public RequestData(HttpServletRequest request) 1014 { 1015 this.request = request; 1016 } 1017 1018 1019 1020 @Override 1021 public String toString() 1022 { 1023 StringBuilder sb = new StringBuilder(); 1024 append(sb, "itemClass", itemClass); 1025 append(sb, "itemId", itemId); 1026 append(sb, "projectContextId", projectContextId); 1027 append(sb, "resource", resource); 1028 append(sb, "context", context); 1029 return sb.toString(); 1030 } 1031 1032 1033 private void append(StringBuilder sb, String name, Object value) 1034 { 1035 sb.append(name); 1036 sb.append("="); 1037 sb.append(value == null ? null : value.toString()); 1038 sb.append(","); 1039 } 1040 1041 } 1000 1042 1001 } -
branches/testing/client/servlet/src/org/proteios/action/file/InspectActiveSpectrumFile.java
r3428 r3444 27 27 import org.proteios.action.ProteiosAction; 28 28 import org.proteios.action.peakList.PlotFileSpectrum; 29 import org.proteios.action.read.ScrollTo; 29 30 import org.proteios.core.DbControl; 30 31 import org.proteios.core.File; … … 32 33 import org.proteios.gui.ColumnContainer; 33 34 import org.proteios.gui.Image; 35 import org.proteios.gui.ImageMap; 36 import org.proteios.gui.ImageMapArea; 34 37 import org.proteios.gui.RowContainer; 38 import org.proteios.gui.Scroller; 35 39 import org.proteios.gui.Title; 36 40 import org.proteios.gui.Toolbar; … … 38 42 import org.proteios.gui.form.Form; 39 43 import org.proteios.gui.form.FormFactory; 44 import org.proteios.gui.form.TextField; 40 45 import org.proteios.gui.layout.RowLayout; 41 46 import org.proteios.gui.table.Cell; … … 77 82 "keepOriginalSpectrum", false); 78 83 84 private int maxResults = 20; 85 private int itemsFrom = 0; 86 private boolean pageSelectedFromScroller = false; 87 88 89 /** 90 * Get the max number of results to show in list. 91 * 92 * @return int The max number of results to show in list. 93 */ 94 public int getMaxResults() 95 { 96 return this.maxResults; 97 } 98 99 100 /** 101 * Set the max number of results to show in list. 102 * 103 * @param maxResults int The value to set for the max number of results to show in list. 104 */ 105 public void setMaxResults(int maxResults) 106 { 107 this.maxResults = maxResults; 108 } 109 110 111 /** 112 * Get the item number to start from in the list. 113 * 114 * @return int The item number to start from in the list. 115 */ 116 public int getItemsFrom() 117 { 118 return this.itemsFrom; 119 } 120 121 122 /** 123 * Set the item number to start from in the list. 124 * 125 * @param itemsFrom int The value to set for the item number to start from in the list. 126 */ 127 public void setItemsFrom(int itemsFrom) 128 { 129 this.itemsFrom = itemsFrom; 130 } 131 132 133 /** 134 * Get flag indicating that page is selected from scroller. 135 * 136 * @return boolean The flag indicating that page is selected from scroller. 137 */ 138 public boolean isPageSelectedFromScroller() 139 { 140 return this.pageSelectedFromScroller; 141 } 142 143 144 /** 145 * Set flag indicating that page is selected from scroller. 146 * 147 * @param pageSelectedFromScroller boolean The value to set for flag indicating that page is selected from scroller. 148 */ 149 public void setPageSelectedFromScroller(boolean pageSelectedFromScroller) 150 { 151 this.pageSelectedFromScroller = pageSelectedFromScroller; 152 } 153 154 79 155 @Override 80 156 protected void runMe() … … 90 166 // Check alternative input 91 167 if (files == null) 92 { 93 168 { 94 169 Integer fileIdFromSessionAttribute = getSessionAttribute(VSPECTRUMFILEID); 95 170 log.debug("fileIdFromSessionAttribute = " + fileIdFromSessionAttribute ); … … 165 240 */ 166 241 Table peakListTable = new Table("peaklists"); 242 // Add tool-bar to table to make GUIConverter set 243 // form id for action in hidden field. 244 Toolbar peakListTableToolbar = new Toolbar(); 245 peakListTable.setToolbar(peakListTableToolbar); 167 246 if (spectrumIdReader != null) 168 247 { … … 179 258 { 180 259 log.debug("spectrumIds.size() = " + spectrumIds.size()); 181 for (int i = 0; i < spectrumIds.size(); i++) 260 // Fetch scroller page selected 261 restoreScrollerState(); 262 log.debug("getItemsFrom() = " + getItemsFrom() + " isPageSelectedFromScroller() = " + isPageSelectedFromScroller()); 263 if (!isPageSelectedFromScroller()) 264 { 265 // Adjust scroller page to include selected spectrum 266 if (spectrumId != null && !spectrumId.equals("")) 267 { 268 // find start of scroller page including selected spectrum 269 Integer currentIndex = fetchStringListItemIndex(spectrumId, spectrumIds); 270 log.debug("currentIndex = " + currentIndex); 271 if (currentIndex != null && currentIndex >= 0) 272 { 273 int pageNo = currentIndex/getMaxResults(); 274 int tempStart = pageNo*getMaxResults(); 275 log.debug("currentIndex = " + currentIndex + " pageNo = " + pageNo + " tempStart = " + tempStart); 276 // Set start index for displayed list 277 setItemsFrom(tempStart); 278 } 279 } 280 } 281 // Add scroller 282 int count = spectrumIds.size(); 283 if (count > getMaxResults()) 284 { 285 Scroller scroller = new Scroller(); 286 scroller.setFrom(getItemsFrom()); 287 scroller.setMax(getMaxResults()); 288 scroller.setTotalCount(count); 289 scroller.setScrollActionId(getActionFactory().getId(ScrollTo.class)); 290 scroller.setTableConfActionId(getActionFactory().getId(InspectActiveSpectrumFile.class)); 291 scroller.setDisplayActionId(getActionFactory().getId(InspectActiveSpectrumFile.class)); 292 //scroller.put(FormFactory.VCLASSNAME, itemClass.getName()); 293 log.debug("scroller ScrollActionId = \"" + getActionFactory().getId(ScrollTo.class) + "\""); 294 log.debug("scroller TableConfActionId = \"" + getActionFactory().getId(InspectActiveSpectrumFile.class) + "\""); 295 log.debug("scroller.getDisplayActionId() = \"" + scroller.getDisplayActionId() + "\""); 296 // Add scroller to table 297 peakListTable.setScroller(scroller); 298 } 299 // Add scroller data 300 log.debug("getItemsFrom() = " + getItemsFrom()); 301 log.debug("getMaxResults() = " + getMaxResults()); 302 int scrollFrom = getItemsFrom(); 303 int scrollMaxResults = getMaxResults(); 304 TextField<Integer> scrollFromField = new TextField<Integer>( 305 Scroller.VFROM); 306 TextField<Integer> scrollMaxResultsField = new TextField<Integer>( 307 Scroller.VMAXRESULT); 308 scrollFromField.setValue(scrollFrom); 309 scrollMaxResultsField.setValue(scrollMaxResults); 310 peakListTable.add(scrollFromField); 311 peakListTable.add(scrollMaxResultsField); 312 // 313 // Add spectrum id field 314 TextField<String> spectrumIdField = new TextField<String>( 315 PlotFileSpectrum.VSPECTRUMID); 316 spectrumIdField.setHidden(true); 317 spectrumIdField.setValue(spectrumId); 318 peakListTable.add(spectrumIdField); 319 // 320 // Add mass cut-off low string field 321 TextField<String> massCutOffLowStrField = new TextField<String>( 322 PlotFileSpectrum.VMASSCUTOFFLOWSTR); 323 massCutOffLowStrField.setHidden(true); 324 massCutOffLowStrField.setValue(massCutoffLowStr); 325 peakListTable.add(massCutOffLowStrField); 326 // 327 // Add mass cut-off high string field 328 TextField<String> massCutOffHighStrField = new TextField<String>( 329 PlotFileSpectrum.VMASSCUTOFFHIGHSTR); 330 massCutOffHighStrField.setHidden(true); 331 massCutOffHighStrField.setValue(massCutoffHighStr); 332 peakListTable.add(massCutOffHighStrField); 333 // 334 // Add keep original spectrum flag field 335 TextField<Boolean> keepOriginalSpectrumField = new TextField<Boolean>( 336 VKEEPORIGINALSPECTRUM); 337 keepOriginalSpectrumField.setHidden(true); 338 keepOriginalSpectrumField.setValue(keepOriginalSpectrum); 339 peakListTable.add(keepOriginalSpectrumField); 340 // 341 // Create spectrum list to display 342 int itemStart = getItemsFrom(); 343 int itemStop = getItemsFrom() + getMaxResults(); 344 for (int i = itemStart; (i < spectrumIds.size() && i < itemStop); i++) 182 345 { 183 346 //log.debug("spectrumIds.get(" + i + ") = \"" + spectrumIds.get(i) + "\""); … … 206 369 * Spectrum plot 207 370 */ 371 PlotFileSpectrum plotFileSpectrum = new PlotFileSpectrum(); 372 ImageMap imageMap; 208 373 Image plotOriginal = null; 209 374 if (keepOriginalSpectrum) … … 217 382 plotOriginal.setHeight(PlotFileSpectrum.HEIGHT); 218 383 plotOriginal.setWidth(PlotFileSpectrum.WIDTH); 384 // Add mass annotation image map 385 imageMap = plotFileSpectrum.fetchMassPeakAnnotationToolTips(dc, fileId, spectrumId, 386 (String) null, (String) null); 387 plotOriginal.setImageMap(imageMap); 388 log.debug("plotOriginal imagMap = " + imageMap); 219 389 } 220 390 Image plot = new Image(); … … 228 398 plot.setHeight(PlotFileSpectrum.HEIGHT); 229 399 plot.setWidth(PlotFileSpectrum.WIDTH); 400 // Add mass annotation image map 401 imageMap = plotFileSpectrum.fetchMassPeakAnnotationToolTips(dc, fileId, spectrumId, 402 massCutoffLowStr, massCutoffHighStr); 403 plot.setImageMap(imageMap); 404 log.debug("plot imagMap = " + imageMap); 230 405 /*********************************************************************** 231 406 * Spectrum iteration buttons … … 367 542 // 368 543 setLayout(layout); 369 } 370 371 372 /** 373 * Fetch previous list item from string list. 544 log.debug("End"); 545 } 546 547 548 /** 549 * Fetch index for item from from string list. 374 550 * 375 551 * @param currentItem String The current item. 376 552 * @param inList List<String> The string list to use. 377 * @return String The previousitem, or null if none.378 */ 379 public String fetchPreviousListItem(String currentItem, List<String> inList)553 * @return Integer The index for the item, or null if none. 554 */ 555 public Integer fetchStringListItemIndex(String currentItem, List<String> inList) 380 556 { 381 557 log.debug("currentItem = \"" + currentItem + "\""); … … 386 562 log.debug("inList.size() = " + inList.size()); 387 563 // Find current index 388 int currentIndex = -1;564 Integer currentIndex = null; 389 565 for (int i = 0; i < inList.size(); i++) 390 566 { … … 400 576 } 401 577 log.debug("currentIndex = " + currentIndex); 402 // Find previous item 403 String previousItem = null; 404 if (currentIndex > 0) 405 { 406 previousItem = (String) inList.get(currentIndex - 1); 407 } 408 log.debug("previousItem = \"" + previousItem + "\""); 409 return previousItem; 578 return currentIndex; 410 579 } 411 580 412 581 413 582 /** 414 * Fetch nextlist item from string list.583 * Fetch previous list item from string list. 415 584 * 416 585 * @param currentItem String The current item. 417 586 * @param inList List<String> The string list to use. 418 * @return String The nextitem, or null if none.419 */ 420 public String fetch NextListItem(String currentItem, List<String> inList)587 * @return String The previous item, or null if none. 588 */ 589 public String fetchPreviousListItem(String currentItem, List<String> inList) 421 590 { 422 591 log.debug("currentItem = \"" + currentItem + "\""); … … 441 610 } 442 611 log.debug("currentIndex = " + currentIndex); 612 // Find previous item 613 String previousItem = null; 614 if (currentIndex > 0) 615 { 616 previousItem = (String) inList.get(currentIndex - 1); 617 } 618 log.debug("previousItem = \"" + previousItem + "\""); 619 return previousItem; 620 } 621 622 623 /** 624 * Fetch next list item from string list. 625 * 626 * @param currentItem String The current item. 627 * @param inList List<String> The string list to use. 628 * @return String The next item, or null if none. 629 */ 630 public String fetchNextListItem(String currentItem, List<String> inList) 631 { 632 log.debug("currentItem = \"" + currentItem + "\""); 633 if (currentItem == null || inList == null) 634 { 635 return null; 636 } 637 log.debug("inList.size() = " + inList.size()); 638 // Find current index 639 int currentIndex = -1; 640 for (int i = 0; i < inList.size(); i++) 641 { 642 String item = (String) inList.get(i); 643 if (item != null) 644 { 645 if (item.equals(currentItem)) 646 { 647 currentIndex = i; 648 break; 649 } 650 } 651 } 652 log.debug("currentIndex = " + currentIndex); 443 653 // Find next item 444 654 String nextItem = null; … … 450 660 return nextItem; 451 661 } 662 663 664 /** 665 * Restores table scroller settings (stored as valid parameters). 666 */ 667 private void restoreScrollerState() 668 throws InvalidParameterValue 669 { 670 // Get scroller data from valid parameters set to table 671 Integer scrollFrom = getValidInteger(Scroller.VFROM); 672 Integer scrollMaxResults = getValidInteger(Scroller.VMAXRESULT); 673 // Update scroller settings 674 if (scrollFrom != null) 675 { 676 setItemsFrom(scrollFrom); 677 setPageSelectedFromScroller(true); 678 } 679 if (scrollMaxResults != null) 680 { 681 setMaxResults(scrollMaxResults); 682 } 683 log.debug("scrollFrom = " + scrollFrom + " isPageSelectedFromScroller() = " + isPageSelectedFromScroller()); 684 log.debug("scrollMaxResults = " + scrollMaxResults); 685 } 452 686 } -
branches/testing/client/servlet/src/org/proteios/action/hit/ViewActiveHitPDBFile.java
r3375 r3444 281 281 } 282 282 log.debug("gene3DUrl = \"" + gene3DUrl + "\""); 283 // ... Gene3D; <a href=http://cathwww.biochem.ucl.ac.uk/cgi-bin/cath/GotoCath.pl?cath=G3DSA:3.40.605.10>G3DSA:3.40.605.10</a>; 284 // gene3DUrl = "http://cathwww.biochem.ucl.ac.uk/cgi-bin/cath/GotoCath.pl?cath=G3DSA:3.40.605.10" 285 // 286 // Update 2009-10-07 287 // ... Gene3D; <a href=http://www.cathdb.info/cathnode/G3DSA:3.40.605.10>G3DSA:3.40.605.10</a>; Aldehyde_dehydrogenase_N; 1. 288 // gene3DUrl = "http://www.cathdb.info/cathnode/G3DSA:3.40.605.10" 289 // 283 290 // Get Gene3D server URL string (URL part before /cgi-bin 284 291 String gene3DServerUrlStr = null; … … 290 297 { 291 298 gene3DServerUrlStr = gene3DUrlStr.substring(0, cgibinIndex); 299 } 300 else 301 { 302 int serverSearchIndex = gene3DUrlStr.indexOf("cathnode/"); 303 if (serverSearchIndex > -1) 304 { 305 gene3DServerUrlStr = gene3DUrlStr.substring(0, serverSearchIndex); 306 } 292 307 } 293 308 // Get Gene3D URL title … … 297 312 { 298 313 gene3DUrlTitleStr = gene3DUrlStr.substring(titleIndex + titlePrecursor.length()); 314 } 315 else 316 { 317 titlePrecursor = new String("cathnode/"); 318 titleIndex = gene3DUrlStr.indexOf(titlePrecursor); 319 if (titleIndex > -1) 320 { 321 gene3DUrlTitleStr = gene3DUrlStr.substring(titleIndex + titlePrecursor.length()); 322 } 299 323 } 300 324 } … … 503 527 { 504 528 // ... Gene3D; <a href=http://cathwww.biochem.ucl.ac.uk/cgi-bin/cath/GotoCath.pl?cath=G3DSA:3.40.605.10>G3DSA:3.40.605.10</a>; 529 // gene3DUrl = "http://cathwww.biochem.ucl.ac.uk/cgi-bin/cath/GotoCath.pl?cath=G3DSA:3.40.605.10" 530 // 531 // Update 2009-10-07 532 // ... Gene3D; <a href=http://www.cathdb.info/cathnode/G3DSA:3.40.605.10>G3DSA:3.40.605.10</a>; Aldehyde_dehydrogenase_N; 1. 533 // gene3DUrl = "http://www.cathdb.info/cathnode/G3DSA:3.40.605.10" 534 // 505 535 String linePattern = new String(".*[Gg][Ee][Nn][Ee]3[Dd];.*"); 506 536 // Delimiters for URL string -
branches/testing/client/servlet/src/org/proteios/action/peakList/PeakAnnotationUtil.java
r3428 r3444 28 28 package org.proteios.action.peakList; 29 29 30 import org.proteios.gui.ImageMap; 31 import org.proteios.gui.ImageMapArea; 30 32 import org.proteios.io.SpectrumInterface; 31 33 … … 199 201 int ySpectrumOffsetBottom = yInnerAreaOffsetBottom + yInnerAreaPeakBottomOffset; 200 202 int ySpectrumOffsetTop = yInnerAreaOffsetTop + yInnerAreaPeakTopOffset; 201 int spectrumAreaWidth = width - xSpectrumOffsetLeft - xSpectrumOffsetRight;203 int spectrumAreaWidth = width - xSpectrumOffsetLeft - xSpectrumOffsetRight; 202 204 int spectrumAreaHeight = height - ySpectrumOffsetBottom - ySpectrumOffsetTop; 203 205 log.debug("width = " + width + " height = " + height); … … 220 222 graphics.drawString("x", (width - xSpectrumOffsetRight), (height - ySpectrumOffsetBottom)); 221 223 */ 222 // Annotate peaks224 // Annotate selected peaks 223 225 for (int i = 0; i < topPeaks.size(); i++) 224 226 { … … 256 258 yCoord = height; 257 259 } 258 log.debug("mass = " + mass + " spectrum offset = " + (xCoord - xSpectrumOffsetLeft) + " xCoord = " + xCoord );260 log.debug("mass = " + mass + " spectrum offset = " + (xCoord - xSpectrumOffsetLeft) + " xCoord = " + xCoord + " yCoord = " + yCoord); 259 261 // Draw mass value over peak 260 262 graphics.drawString(massStr, xCoord, (height - yCoord)); … … 402 404 return topPeakIndex; 403 405 } 406 407 408 /** 409 * Create mass peak annotation tool-tips for HTML. 410 * Note that y-coordinates for drawing purposes 411 * increases upwards, while tool-tip y-coordinates 412 * in HTML increases downwards. 413 * 414 * @param spectrum SpectrumInterface Input mass spectrum data. 415 * @param imageWidth int Image width in pixels. 416 * @param imageHeight int Image height in pixels. 417 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 418 */ 419 public ImageMap fetchMassPeakAnnotationToolTips(SpectrumInterface spectrum, int imageWidth, int imageHeight) 420 { 421 log.debug("spectrum = " + spectrum); 422 log.debug("imageWidth = " + imageWidth); 423 log.debug("imageHeight = " + imageHeight); 424 // If no spectrum, return directly 425 if (spectrum == null) 426 { 427 return null; 428 } 429 // 430 double[] massArray = spectrum.listMass(); 431 double[] intensityArray = spectrum.listIntensities(); 432 if (massArray == null) 433 { 434 return null; 435 } 436 int size = massArray.length; 437 if (size == 0) 438 { 439 return null; 440 } 441 // Analyze spectrum 442 double massMin = massArray[0]; 443 double massMax = massArray[massArray.length - 1]; 444 double massRange = 1.0; 445 if (massMin < massMax) 446 { 447 massRange = massMax - massMin; 448 } 449 log.debug("size = " + size + " massMin = " + massMin + " massMax = " + massMax + " massRange = " + massRange); 450 /* 451 * The positioning of mass value markers above (or near) 452 * the top of a mass spectrum peak is determined by 453 * a type of dead reckoning, as use of the JFreeChart 454 * package to draw the mass spectra itself does not 455 * give any feedback for the position of the top of 456 * a mass peak, which depends on the offsets of the 457 * spectrum drawing area in the image, when space for 458 * scales and labels have been allocated. The available 459 * input are the width and height of the image, plus 460 * the mass and intensity values of the spectra. 461 * Based on the graphical output for typical standard 462 * choices of spectra, the needed offsets have been 463 * determined by trial and error to a degree that 464 * hopefully is sufficient for an adequate placement 465 * of the markers. 466 */ 467 /* 468 * The following offsets are based on the following input: 469 * width = 400 470 * height = 300 471 * min mass = 110 472 * max mass = 1022 473 * max intensity = 3361 474 */ 475 int maxPeakIndex = findMaxValueIndex(intensityArray); 476 double maxIntensity = intensityArray[maxPeakIndex]; 477 log.debug("maxPeakIndex = " + maxPeakIndex + " mass = " + massArray[maxPeakIndex] + " intensity = " + maxIntensity); 478 // Use coordinate system with origin at lower left corner 479 // Offsets in pixels for inner drawing area without scales and labels 480 int xInnerAreaOffsetLeft = 58; 481 int xInnerAreaOffsetRight = 12; 482 int yInnerAreaOffsetBottom = 36; 483 int yInnerAreaOffsetTop = 30; 484 // Corrections for intensity scale numbers outside range [1000, 9999] 485 int offsetLeftCorrStep = 7; 486 if (maxIntensity < 1000) 487 { 488 xInnerAreaOffsetLeft -= offsetLeftCorrStep; 489 } 490 if (maxIntensity > 10000) 491 { 492 xInnerAreaOffsetLeft += offsetLeftCorrStep; 493 } 494 if (maxIntensity > 100000) 495 { 496 xInnerAreaOffsetLeft += offsetLeftCorrStep; 497 } 498 if (maxIntensity > 1000000) 499 { 500 xInnerAreaOffsetLeft += offsetLeftCorrStep; 501 } 502 // Offsets in pixels for mass spectrum area relative to inner drawing area 503 int xInnerAreaFirstPeakOffset = 18; 504 int xInnerAreaLastPeakOffset = 13; 505 int yInnerAreaPeakBottomOffset = 0; 506 int yInnerAreaPeakTopOffset = 10; 507 // Offsets in pixels for mass spectrum area relative to full drawing area 508 int xSpectrumOffsetLeft = xInnerAreaOffsetLeft + xInnerAreaFirstPeakOffset; 509 int xSpectrumOffsetRight = xInnerAreaOffsetRight + xInnerAreaLastPeakOffset; 510 int ySpectrumOffsetBottom = yInnerAreaOffsetBottom + yInnerAreaPeakBottomOffset; 511 int ySpectrumOffsetTop = yInnerAreaOffsetTop + yInnerAreaPeakTopOffset; 512 int spectrumAreaWidth = imageWidth - xSpectrumOffsetLeft - xSpectrumOffsetRight; 513 int spectrumAreaHeight = imageHeight - ySpectrumOffsetBottom - ySpectrumOffsetTop; 514 log.debug("imageWidth = " + imageWidth + " imageHeight = " + imageHeight); 515 log.debug("spectrumAreaWidth = " + spectrumAreaWidth + " spectrumAreaHeight = " + spectrumAreaHeight); 516 // 517 // Create mass value annotation tool-tips for all peaks 518 int numberOfDecimalsForTooltips = 4; 519 ImageMap imageMap = fetchMassPeakAnnotationToolTips(massArray, intensityArray, 520 imageWidth, imageHeight, spectrumAreaWidth, spectrumAreaHeight, 521 xSpectrumOffsetLeft, ySpectrumOffsetBottom, yInnerAreaOffsetBottom, 522 massMin, massRange, maxIntensity, numberOfDecimalsForTooltips); 523 return imageMap; 524 } 525 526 527 /** 528 * Create mass peak annotation tool-tips for HTML. 529 * Note that y-coordinates for drawing purposes 530 * increases upwards, while tool-tip y-coordinates 531 * in HTML increases downwards. Input y-coordinates 532 * are expected to to be increasing upwards. 533 * 534 * @param massArray double[] Array with mass values. 535 * @param intensityArray double[] Array with intensities. 536 * @param width int Width of image area in pixels. 537 * @param height int Height of image area in pixels. 538 * @param spectrumAreaWidth int Width of spectrum area in pixels. 539 * @param spectrumAreaHeight int Height of spectrum area in pixels. 540 * @param xSpectrumOffsetLeft int Left offset in x of spectrum area in pixels. 541 * @param ySpectrumOffsetBottom int Bottom offset in y of spectrum area in pixels. 542 * @param yInnerAreaOffsetBottom int Bottom offset in y of inner area in pixels. 543 * @param massMin double Minimum mass value. 544 * @param massRange double The range of mass values, i.e. maximum - minimum mass value. 545 * @param maxIntensity double Maximum intensity value. 546 * @param numberOfDecimals int The number of decimals to use for mass values in tool-tips. 547 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 548 */ 549 public ImageMap fetchMassPeakAnnotationToolTips(double[] massArray, double[] intensityArray, 550 int width, int height, int spectrumAreaWidth, int spectrumAreaHeight, 551 int xSpectrumOffsetLeft, int ySpectrumOffsetBottom, int yInnerAreaOffsetBottom, 552 double massMin, double massRange, double maxIntensity, int numberOfDecimals) 553 { 554 ImageMap imageMap = new ImageMap(); 555 ImageMapArea imageMapArea; 556 // Annotate peaks 557 if (numberOfDecimals < 0) 558 { 559 numberOfDecimals = 4; 560 } 561 // 562 // Select peaks for annotation 563 int tempXCoord = -1; 564 double tempMaxIntensity = 0; 565 int tempMaxIntensityIndex = -1; 566 List<Integer> annotationIndexList = new ArrayList<Integer>(); 567 int size = massArray.length; 568 for (int i = 0; i < size; i++) 569 { 570 double mass = massArray[i]; 571 double intensity = intensityArray[i]; 572 int xCoord = xSpectrumOffsetLeft + (int) (spectrumAreaWidth*((mass - massMin)/massRange)); 573 // Check if peak has same x-coordinate in pixels as previous peaks 574 if (xCoord == tempXCoord) 575 { 576 // Check if peak is larger than previous peaks with same x-coordinate in pixels 577 if (intensity > tempMaxIntensity) 578 { 579 // Set current peak as annotation candidate for x-coordinate in pixels 580 tempMaxIntensity = intensity; 581 tempMaxIntensityIndex = i; 582 } 583 } 584 else 585 { 586 if (tempXCoord >= 0) 587 { 588 // Add stored peak for previous x-coordinate in pixels to annotation list 589 annotationIndexList.add(tempMaxIntensityIndex); 590 } 591 // Reset stored peak data to new peak 592 tempXCoord = xCoord; 593 tempMaxIntensity = intensity; 594 tempMaxIntensityIndex = i; 595 } 596 } 597 // Add last stored index to list 598 if (tempXCoord >= 0) 599 { 600 // Add stored peak for previous x-coordinate in pixels to annotation list 601 annotationIndexList.add(tempMaxIntensityIndex); 602 } 603 log.debug("mass array size = " + size + " annotationIndexList.size() = " + annotationIndexList.size()); 604 // 605 // Annotate selected mass peaks 606 for (int j = 0; j < annotationIndexList.size(); j++) 607 { 608 int i = (Integer) annotationIndexList.get(j); 609 double mass = massArray[i]; 610 double intensity = intensityArray[i]; 611 int xCoord = xSpectrumOffsetLeft + (int) (spectrumAreaWidth*((mass - massMin)/massRange)); 612 int yCoord = ySpectrumOffsetBottom + (int) (spectrumAreaHeight*(intensity/maxIntensity)); 613 // Get mass value marker with desired number of decimals 614 //String massStr = Integer.toString((int) mass); 615 //NumberFormat fixedNumberOfDecimals = NumberFormat.getInstance(); 616 NumberFormat fixedNumberOfDecimals = new DecimalFormat("#########.######"); 617 fixedNumberOfDecimals.setMinimumFractionDigits(numberOfDecimals); 618 fixedNumberOfDecimals.setMaximumFractionDigits(numberOfDecimals); 619 String massStr = fixedNumberOfDecimals.format(mass).toString(); 620 String hrefStr = null; 621 // 622 // Log output for test of tool-tip creation 623 int yCoordFromImageBottom = height - yCoord; 624 int ySpectrumImageBottom = height - yInnerAreaOffsetBottom - 1; 625 // Create image map area with mass annotation tool-tip 626 //log.debug(" <AREA SHAPE=\"RECT\" COORDS=\"" + xCoord + ", " + yCoordFromImageBottom + ", " + (xCoord + 1) + ", " + ySpectrumImageBottom + "\" HREF=\"http://www.proteios.org\" onMouseover=\"showtip(this,event,'" + massStr + "')\" onMouseout=\"hidetip()\">"); 627 //log.debug(" <AREA SHAPE=\"RECT\" COORDS=\"" + xCoord + ", " + yCoordFromImageBottom + ", " + (xCoord + 1) + ", " + ySpectrumImageBottom + "\" onMouseover=\"showtip(this,event,'" + massStr + "')\" onMouseout=\"hidetip()\">"); 628 imageMapArea = new ImageMapArea(xCoord, yCoordFromImageBottom, (xCoord + 1), ySpectrumImageBottom, hrefStr, massStr); 629 imageMap.addImageMapArea(imageMapArea); 630 } 631 return imageMap; 632 } 404 633 } -
branches/testing/client/servlet/src/org/proteios/action/peakList/PlotFileSpectrum.java
r3428 r3444 37 37 import org.proteios.core.File; 38 38 import org.proteios.core.ItemFactory; 39 import org.proteios.gui.ImageMap; 39 40 import org.proteios.gui.form.FormFactory; 40 41 import org.proteios.io.PeakListFileInterface; … … 250 251 { 251 252 // Trim plot header to fit on one line 252 int maxNumChars = 40;253 int maxNumChars = 35; 253 254 if (plotHeader.length() > maxNumChars) 254 255 { … … 286 287 throw new ActionException(e); 287 288 } 289 } 290 291 292 /** 293 * Create mass peak annotation tool-tips for HTML. 294 * Note that y-coordinates for drawing purposes 295 * increases upwards, while tool-tip y-coordinates 296 * in HTML increases downwards. 297 * 298 * @param dc DbControl The DbControl to use. 299 * @param spectrumFileId Integer The spectrum file id. 300 * @param spectrumId String The spectrum id. 301 * @param massCutoffLowStr String The lower cutoff mass value string. 302 * @param massCutoffHighStr String The upper cutoff mass value string. 303 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 304 */ 305 public ImageMap fetchMassPeakAnnotationToolTips(DbControl dc, Integer spectrumFileId, String spectrumId, 306 String massCutoffLowStr, String massCutoffHighStr) 307 { 308 Float massCutoffLow = null; 309 if (massCutoffLowStr != null) 310 { 311 try 312 { 313 massCutoffLow = Float.parseFloat(massCutoffLowStr); 314 } 315 catch (Exception e) 316 { 317 log.debug("Exception when parsing string \"" + massCutoffLowStr + "\" to Float: " + e); 318 } 319 } 320 Float massCutoffHigh = null; 321 if (massCutoffHighStr != null) 322 { 323 try 324 { 325 massCutoffHigh = Float.parseFloat(massCutoffHighStr); 326 } 327 catch (Exception e) 328 { 329 log.debug("Exception when parsing string \"" + massCutoffHighStr + "\" to Float: " + e); 330 } 331 } 332 log.debug("spectrumFileId = " + spectrumFileId); 333 log.debug("spectrumId = \"" + spectrumId + "\""); 334 log.debug("massCutoffLowStr = \"" + massCutoffLowStr + "\""); 335 log.debug("massCutoffHighStr = \"" + massCutoffHighStr + "\""); 336 log.debug("massCutoffLow = " + massCutoffLow); 337 log.debug("massCutoffHigh = " + massCutoffHigh); 338 // 339 SpectrumInterface spectrum = fetchSpectrum(dc, spectrumFileId, spectrumId, massCutoffLow, massCutoffHigh); 340 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 341 ImageMap imageMap = peakAnnotationUtil.fetchMassPeakAnnotationToolTips(spectrum, WIDTH, HEIGHT); 342 return imageMap; 343 } 344 345 346 /** 347 * Create mass peak annotation tool-tips for HTML. 348 * Note that y-coordinates for drawing purposes 349 * increases upwards, while tool-tip y-coordinates 350 * in HTML increases downwards. 351 * 352 * @param dc DbControl The DbControl to use. 353 * @param spectrumFileId Integer The spectrum file id. 354 * @param spectrumId String The spectrum id. 355 * @param massCutoffLow Float The lower cutoff mass value. 356 * @param massCutoffHigh Float The upper cutoff mass value. 357 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 358 */ 359 public ImageMap fetchMassPeakAnnotationToolTips(DbControl dc, Integer spectrumFileId, String spectrumId, 360 Float massCutoffLow, Float massCutoffHigh) 361 { 362 log.debug("spectrumFileId = " + spectrumFileId); 363 log.debug("spectrumId = \"" + spectrumId + "\""); 364 log.debug("massCutoffLow = " + massCutoffLow); 365 log.debug("massCutoffHigh = " + massCutoffHigh); 366 SpectrumInterface spectrum = fetchSpectrum(dc, spectrumFileId, spectrumId, massCutoffLow, massCutoffHigh); 367 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 368 ImageMap imageMap = peakAnnotationUtil.fetchMassPeakAnnotationToolTips(spectrum, WIDTH, HEIGHT); 369 return imageMap; 370 } 371 372 373 /** 374 * Create mass peak annotation tool-tips for HTML. 375 * Note that y-coordinates for drawing purposes 376 * increases upwards, while tool-tip y-coordinates 377 * in HTML increases downwards. 378 * 379 * @param dc DbControl The DbControl to use. 380 * @param spectrumFileId Integer The spectrum file id. 381 * @param spectrumId String The spectrum id. 382 * @param massCutoffLow Float The lower cutoff mass value. 383 * @param massCutoffHigh Float The upper cutoff mass value. 384 * @param imageWidth int Image width in pixels. 385 * @param imageHeight int Image height in pixels. 386 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 387 */ 388 public ImageMap fetchMassPeakAnnotationToolTips(DbControl dc, Integer spectrumFileId, String spectrumId, 389 Float massCutoffLow, Float massCutoffHigh, int imageWidth, int imageHeight) 390 { 391 SpectrumInterface spectrum = fetchSpectrum(dc, spectrumFileId, spectrumId, massCutoffLow, massCutoffHigh); 392 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 393 ImageMap imageMap = peakAnnotationUtil.fetchMassPeakAnnotationToolTips(spectrum, imageWidth, imageHeight); 394 return imageMap; 395 } 396 397 398 /** 399 * Fetches spectrum given spectrum file id, spectrum id, 400 * and zoom limit parameters. 401 * 402 * @param dc DbControl The DbControl to use. 403 * @param spectrumFileId Integer The spectrum file id. 404 * @param spectrumId String The spectrum id. 405 * @param massCutoffLow Float The lower cutoff mass value. 406 * @param massCutoffHigh Float The upper cutoff mass value. 407 * @return SpectrumInterface The possibly pruned spectrum. 408 */ 409 public SpectrumInterface fetchSpectrum(DbControl dc, Integer spectrumFileId, String spectrumId, Float massCutoffLow, Float massCutoffHigh) 410 { 411 log.debug("spectrumFileId = " + spectrumFileId); 412 log.debug("spectrumId = \"" + spectrumId + "\""); 413 log.debug("massCutoffLow = " + massCutoffLow); 414 log.debug("massCutoffHigh = " + massCutoffHigh); 415 /*********************************************************************** 416 * Get peakListFile data 417 */ 418 ItemFactory factory = new ItemFactory(dc); 419 // Get peak list file 420 File spectrumFile = null; 421 if (spectrumFileId != null && spectrumFileId > 0) 422 { 423 spectrumFile = factory.getById(File.class, spectrumFileId); 424 } 425 // Get peak list file reader 426 boolean useTitle = true; 427 // Use string id if it exists 428 if (spectrumId != null) 429 { 430 // If the stringId is just a number, it could have been parsed, 431 // so use the int instead... 432 try 433 { 434 Integer titleNumber = Integer.parseInt(spectrumId); 435 if (titleNumber != null) 436 { 437 useTitle = false; 438 log.debug("spectrumId is a number, useTitle = " + useTitle); 439 } 440 } 441 catch (NumberFormatException e) 442 {} 443 // Special case: A spectrum id starting with a number should be treated as a number 444 String stringId = null; 445 int strIndex = spectrumId.indexOf(" "); 446 if (strIndex >= 0) 447 { 448 // Remove part beginning with first blank 449 stringId = spectrumId.substring(0, strIndex); 450 } 451 if (stringId != null) 452 { 453 try 454 { 455 Integer titleNumber = Integer.parseInt(stringId); 456 if (titleNumber != null) 457 { 458 useTitle = false; 459 log.debug("spectrumId begins with a number, useTitle = " + useTitle); 460 } 461 } 462 catch (NumberFormatException e) 463 {} 464 } 465 } 466 SpectrumFileReaderFactory spectrumFileReaderFactory = new SpectrumFileReaderFactory(); 467 PeakListFileInterface peakListFileReader = spectrumFileReaderFactory.fetchPeakListFileReader(spectrumFile, useTitle); 468 SpectrumInterface spectrum = null; 469 if (peakListFileReader != null && spectrumId != null) 470 { 471 // Get spectrum 472 int size = 0; 473 log.debug("useTitle = " + useTitle + " spectrumId = \"" + spectrumId + "\""); 474 spectrum = peakListFileReader.getSpectrum(spectrumId); 475 // Restrict spectrum to specified mass range, if defined 476 spectrum = zoomSpectrum(spectrum, massCutoffLow, massCutoffHigh); 477 } 478 else 479 { 480 log.warn("Couldn't find peak list (Peaklist file: " + spectrumFile + " Spectrum Id: " + spectrumId + ")"); 481 } 482 return spectrum; 288 483 } 289 484 -
branches/testing/client/servlet/src/org/proteios/action/peakList/PlotSpectrum.java
r3428 r3444 39 39 import org.proteios.core.Peak; 40 40 import org.proteios.core.PeakList; 41 import org.proteios.gui.ImageMap; 41 42 import org.proteios.io.SpectrumImpl; 42 43 import org.proteios.io.SpectrumInterface; … … 245 246 throw new ActionException(e); 246 247 } 248 } 249 250 251 /** 252 * Create mass peak annotation tool-tips for HTML. 253 * Note that y-coordinates for drawing purposes 254 * increases upwards, while tool-tip y-coordinates 255 * in HTML increases downwards. 256 * 257 * @param dc DbControl The DbControl to use. 258 * @param peakListId Integer The peak list id. 259 * @param massCutoffLowStr String The lower cutoff mass value string. 260 * @param massCutoffHighStr String The upper cutoff mass value string. 261 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 262 */ 263 public ImageMap fetchMassPeakAnnotationToolTips(DbControl dc, Integer peakListId, 264 String massCutoffLowStr, String massCutoffHighStr) 265 { 266 Float massCutoffLow = null; 267 if (massCutoffLowStr != null) 268 { 269 try 270 { 271 massCutoffLow = Float.parseFloat(massCutoffLowStr); 272 } 273 catch (Exception e) 274 { 275 log.debug("Exception when parsing string \"" + massCutoffLowStr + "\" to Float: " + e); 276 } 277 } 278 Float massCutoffHigh = null; 279 if (massCutoffHighStr != null) 280 { 281 try 282 { 283 massCutoffHigh = Float.parseFloat(massCutoffHighStr); 284 } 285 catch (Exception e) 286 { 287 log.debug("Exception when parsing string \"" + massCutoffHighStr + "\" to Float: " + e); 288 } 289 } 290 log.debug("peakListId = " + peakListId); 291 log.debug("massCutoffLowStr = \"" + massCutoffLowStr + "\""); 292 log.debug("massCutoffHighStr = \"" + massCutoffHighStr + "\""); 293 log.debug("massCutoffLow = " + massCutoffLow); 294 log.debug("massCutoffHigh = " + massCutoffHigh); 295 // 296 SpectrumInterface spectrum = fetchSpectrum(dc, peakListId, massCutoffLow, massCutoffHigh); 297 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 298 ImageMap imageMap = peakAnnotationUtil.fetchMassPeakAnnotationToolTips(spectrum, WIDTH, HEIGHT); 299 return imageMap; 300 } 301 302 303 /** 304 * Create mass peak annotation tool-tips for HTML. 305 * Note that y-coordinates for drawing purposes 306 * increases upwards, while tool-tip y-coordinates 307 * in HTML increases downwards. 308 * 309 * @param dc DbControl The DbControl to use. 310 * @param peakListId Integer The peak list id. 311 * @param massCutoffLow Float The lower cutoff mass value. 312 * @param massCutoffHigh Float The upper cutoff mass value. 313 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 314 */ 315 public ImageMap fetchMassPeakAnnotationToolTips(DbControl dc, Integer peakListId, 316 Float massCutoffLow, Float massCutoffHigh) 317 { 318 log.debug("peakListId = " + peakListId); 319 log.debug("massCutoffLow = " + massCutoffLow); 320 log.debug("massCutoffHigh = " + massCutoffHigh); 321 SpectrumInterface spectrum = fetchSpectrum(dc, peakListId, massCutoffLow, massCutoffHigh); 322 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 323 ImageMap imageMap = peakAnnotationUtil.fetchMassPeakAnnotationToolTips(spectrum, WIDTH, HEIGHT); 324 return imageMap; 325 } 326 327 328 /** 329 * Create mass peak annotation tool-tips for HTML. 330 * Note that y-coordinates for drawing purposes 331 * increases upwards, while tool-tip y-coordinates 332 * in HTML increases downwards. 333 * 334 * @param dc DbControl The DbControl to use. 335 * @param peakListId Integer The peak list id. 336 * @param massCutoffLow Float The lower cutoff mass value. 337 * @param massCutoffHigh Float The upper cutoff mass value. 338 * @param imageWidth int Image width in pixels. 339 * @param imageHeight int Image height in pixels. 340 * @return ImageMap An HTML image map with mass value annotations for mass peaks as tool-tips. 341 */ 342 public ImageMap fetchMassPeakAnnotationToolTips(DbControl dc, Integer peakListId, 343 Float massCutoffLow, Float massCutoffHigh, int imageWidth, int imageHeight) 344 { 345 SpectrumInterface spectrum = fetchSpectrum(dc, peakListId, massCutoffLow, massCutoffHigh); 346 PeakAnnotationUtil peakAnnotationUtil = new PeakAnnotationUtil(); 347 ImageMap imageMap = peakAnnotationUtil.fetchMassPeakAnnotationToolTips(spectrum, imageWidth, imageHeight); 348 return imageMap; 349 } 350 351 352 /** 353 * Fetches spectrum given peak list id, 354 * and zoom limit parameters. 355 * 356 * @param dc DbControl The DbControl to use. 357 * @param peakListId Integer The peak list id. 358 * @param massCutoffLow Float The lower cutoff mass value. 359 * @param massCutoffHigh Float The upper cutoff mass value. 360 * @return SpectrumInterface The possibly pruned spectrum. 361 */ 362 public SpectrumInterface fetchSpectrum(DbControl dc, Integer peakListId, Float massCutoffLow, Float massCutoffHigh) 363 { 364 log.debug("peakListId = " + peakListId); 365 log.debug("massCutoffLow = " + massCutoffLow); 366 log.debug("massCutoffHigh = " + massCutoffHigh); 367 /*********************************************************************** 368 * Get peakList data 369 */ 370 PeakList pl = PeakList.getById(dc, peakListId); 371 ItemQuery<Peak> query = pl.getPeaksQuery(); 372 // query.include(Include.MINE); 373 ItemResultList<Peak> peaksList = query.list(dc); 374 int size = 0; 375 if (!peaksList.isEmpty()) 376 { 377 size = peaksList.size(); 378 } 379 // Store mass and intensity values in arrays for peak annotation 380 double[] massArray = null; 381 double[] intensityArray = null; 382 if (size > 0) 383 { 384 massArray = new double[size]; 385 intensityArray = new double[size]; 386 } 387 // Load peak values 388 for (int i = 0; i < size; i++) 389 { 390 Peak p = peaksList.get(i); 391 double x = p.getMassToChargeRatio(); 392 double y = p.getIntensity(); 393 massArray[i] = x; 394 intensityArray[i] = y; 395 } 396 SpectrumImpl spectrumOrig = null; 397 if (size > 0) 398 { 399 spectrumOrig = new SpectrumImpl(); 400 spectrumOrig.setMass(massArray); 401 spectrumOrig.setIntensities(intensityArray); 402 } 403 // Restrict spectrum to specified mass range, if defined 404 SpectrumInterface spectrum = zoomSpectrum(spectrumOrig, massCutoffLow, massCutoffHigh); 405 return spectrum; 247 406 } 248 407 -
branches/testing/client/servlet/src/org/proteios/action/peakList/ViewActivePeakList.java
r3370 r3444 38 38 import org.proteios.gui.ColumnContainer; 39 39 import org.proteios.gui.Image; 40 import org.proteios.gui.ImageMap; 41 import org.proteios.gui.ImageMapArea; 40 42 import org.proteios.gui.RowContainer; 41 43 import org.proteios.gui.Toolbar; … … 120 122 * Spectrum plot 121 123 */ 124 PlotSpectrum plotSpectrum = new PlotSpectrum(); 125 ImageMap imageMap; 122 126 Image plotOriginal = null; 123 127 if (keepOriginalSpectrum) … … 130 134 plotOriginal.setHeight(PlotSpectrum.HEIGHT); 131 135 plotOriginal.setWidth(PlotSpectrum.WIDTH); 136 // Add mass annotation image map 137 imageMap = plotSpectrum.fetchMassPeakAnnotationToolTips(dc, peakListId, 138 (String) null, (String) null); 139 plotOriginal.setImageMap(imageMap); 140 log.debug("plotOriginal imagMap = " + imageMap); 132 141 } 133 142 Image plot = new Image(); … … 140 149 plot.setHeight(PlotSpectrum.HEIGHT); 141 150 plot.setWidth(PlotSpectrum.WIDTH); 151 // Add mass annotation image map 152 imageMap = plotSpectrum.fetchMassPeakAnnotationToolTips(dc, peakListId, 153 massCutoffLowStr, massCutoffHighStr); 154 plot.setImageMap(imageMap); 155 log.debug("plot imagMap = " + imageMap); 142 156 /*********************************************************************** 143 157 * Spectrum mass range selection form -
branches/testing/client/servlet/src/org/proteios/gui/Image.java
r2651 r3444 39 39 private Integer width = 0; 40 40 private Integer height = 0; 41 private ImageMap imageMap = null; 41 42 /** 42 43 * If true draw a kind of frame around this image … … 107 108 this.framed = framed; 108 109 } 110 111 112 public ImageMap getImageMap() 113 { 114 return this.imageMap; 115 } 116 117 118 public void setImageMap(ImageMap imageMap) 119 { 120 this.imageMap = imageMap; 121 } 109 122 } -
branches/testing/client/servlet/src/org/proteios/gui/web/GUIConverter.java
r3217 r3444 45 45 import org.proteios.gui.IFrame; 46 46 import org.proteios.gui.Image; 47 import org.proteios.gui.ImageMap; 48 import org.proteios.gui.ImageMapArea; 47 49 import org.proteios.gui.ListItem; 48 50 import org.proteios.gui.Listing; … … 72 74 73 75 import se.lu.thep.waf.dom.html.A; 76 import se.lu.thep.waf.dom.html.Area; 74 77 import se.lu.thep.waf.dom.html.Attribute; 75 78 import se.lu.thep.waf.dom.html.CData; … … 83 86 import se.lu.thep.waf.dom.html.Input; 84 87 import se.lu.thep.waf.dom.html.Li; 88 import se.lu.thep.waf.dom.html.Map; 85 89 import se.lu.thep.waf.dom.html.Option; 86 90 import se.lu.thep.waf.dom.html.Select; … … 187 191 // First we show the loading img 188 192 imgT.setSrc(loadingImgSrc); 193 // 194 if (img.getImageMap() != null && img.getImageMap().getImageMapAreaList() != null) 195 { 196 String imageMapStr = "ImageMap" + imgId; 197 imgT.setUsemap("#" + imageMapStr); 198 // Create image map 199 Map map = new Map(); 200 map.setParent(div); 201 div.add(map); 202 map.setName(imageMapStr); 203 List<ImageMapArea> imageMapAreaList = img.getImageMap().getImageMapAreaList(); 204 for (int i = 0; i < imageMapAreaList.size(); i++) 205 { 206 // Get image map area data from image object 207 ImageMapArea imageMapArea = (ImageMapArea) imageMapAreaList .get(i); 208 int xTopLeft = imageMapArea.getXTopLeft(); 209 int yTopLeft = imageMapArea.getYTopLeft(); 210 int xBottomRight = imageMapArea.getXBottomRight(); 211 int yBottomRight = imageMapArea.getYBottomRight(); 212 String hrefStr = imageMapArea.getHrefStr(); 213 String toolTipStr = imageMapArea.getToolTipStr(); 214 String onMouseoverStr = null; 215 String onMouseoutStr = null; 216 if (toolTipStr != null && !toolTipStr.equals("")) 217 { 218 onMouseoverStr = new String("showtip(this,event,'" + toolTipStr + "')"); 219 onMouseoutStr = new String("hidetip()"); 220 } 221 // Create new image map area 222 Area area = new Area(); 223 area.setParent(map); 224 map.add(area); 225 area.setShape("RECT"); 226 area.setCoords(xTopLeft, yTopLeft, xBottomRight, yBottomRight); 227 if (hrefStr != null && !hrefStr.equals("")) 228 { 229 area.setHref(hrefStr); 230 } 231 if (onMouseoverStr != null && !onMouseoverStr.equals("")) 232 { 233 area.setOnMousover(onMouseoverStr); 234 } 235 if (onMouseoutStr != null && !onMouseoutStr.equals("")) 236 { 237 area.setOnMousout(onMouseoutStr); 238 } 239 } 240 } 189 241 script = div.newScript(); 190 242 script.newCData("var " + imgId + " = new Image();"); -
branches/testing/client/servlet/test/test_webservice.sh
r3416 r3444 49 49 } 50 50 51 DELETE() 52 { 53 url=$1 54 curlit "-X DELETE" $url 55 } 56 57 51 58 PUT() 52 59 { … … 71 78 fail() 72 79 { 73 echo "Failed[$test_no]: $1" 74 echo "Message: $2" 80 date >> /dev/stderr 81 echo "Failed[$test_no]: $1" >> /dev/stderr 82 echo "Message: $2" >> /dev/stderr 83 echo "" >> /dev/stderr 75 84 exit 76 85 } … … 84 93 case $1 in 85 94 9) 86 test "Cross table search" 87 GET "$A" "$resource/extracts?$auth" 95 test "Mark file for deletion" 96 generate_name 97 echo -e "Name\tDescription" > $A 98 echo -e "${i}_$name\tThis is the ${i}:th file" >> $A 99 PUT "$A" "$resource/files?$auth" 100 GET "$B" "$resource/files?$auth&select=Id&whereName==${i}_$name" 101 lastid=`tail -n 1 $B | perl -ane '/(\d+)/; print \$1;'` 102 DELETE "$resource/files/$lastid?$auth" 103 GET "$C" "$resource/files?$auth&select=Name,Removed&whereName==${i}_$name" 104 removed=`grep $name $C` 105 if [ "$removed" != "" ]; then 106 fail "$test" "File should have been marked as removed, but was not." 107 fi 88 108 ;; 89 109 8) -
branches/testing/client/servlet/www/static/js/script.js
r3409 r3444 378 378 } 379 379 380 /* http://www.dynamicdrive.com/dynamicindex5/texttool.htm */ 381 function showtip(current,e,text) 382 { 383 if (document.all || document.getElementById) 384 { 385 thetitle = text.split('<br>'); 386 if (thetitle.length > 1) 387 { 388 thetitles = ''; 389 for (i=0; i < thetitle.length; i++) 390 { 391 thetitles += thetitle[i]; 392 } 393 current.title = thetitles; 394 } 395 else 396 { 397 current.title = text; 398 } 399 } 400 else if (document.layers) 401 { 402 document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>'); 403 document.tooltip.document.close(); 404 document.tooltip.left = e.pageX + 5; 405 document.tooltip.top = e.pageY + 5; 406 document.tooltip.visibility = "show"; 407 } 408 } 409 410 function hidetip() 411 { 412 if (document.layers) 413 { 414 document.tooltip.visibility = "hidden"; 415 } 416 } 417 380 418 // this will resize all iframes every 381 419 // time you change the size of the window. -
branches/testing/recipe
r3263 r3444 9 9 # Run 'bake web' to generate and copy web related files 10 10 WEB_PATH=/home/tom/wwwroot/proteios 11 VERSION=2. 7.011 VERSION=2.9.0 12 12 MD5_GZ=`cat /home/tom/trac/proteios/htdocs/downloads/$VERSION/ProteiosSE-$VERSION.tar.gz.MD5` 13 13 MD5_ZIP=`cat /home/tom/trac/proteios/htdocs/downloads/$VERSION/ProteiosSE-$VERSION.zip.MD5`
Note: See TracChangeset
for help on using the changeset viewer.