diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetReportColumnDefinition.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetReportColumnDefinition.java index 296b9ac0906c36c83b283b40bfea57ddf7f5ebe0..93825630e8fdae8b0bdd85cfbd16a97cb68c42a3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetReportColumnDefinition.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetReportColumnDefinition.java @@ -22,6 +22,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DateTableCell; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GeneratedImageTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ImageTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader; @@ -72,13 +73,17 @@ public class DataSetReportColumnDefinition implements IColumnDefinition<TableMod int width = imageCell.getMaxThumbnailWidth(); int height = imageCell.getMaxThumbnailHeight(); String imagePath = imageCell.getPath(); - return SimpleImageHtmlRenderer.createEmbededDatastoreImageHtml(imagePath, width, height, - downloadURL, sessionID); + return SimpleImageHtmlRenderer.createEmbededDatastoreImageHtml(imagePath, width, + height, downloadURL, sessionID); } if (cell instanceof DateTableCell) { return SimpleDateRenderer.renderDate(((DateTableCell) cell).getDateTime()); } + if (cell instanceof GeneratedImageTableCell) + { + return ((GeneratedImageTableCell) cell).getHTMLString(downloadURL, sessionID); + } return cell.toString(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/GeneratedImageTableCell.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/GeneratedImageTableCell.java new file mode 100644 index 0000000000000000000000000000000000000000..92b3088fd6d0f65d5c15d812cc7e11a8ddd9c854 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/GeneratedImageTableCell.java @@ -0,0 +1,161 @@ +/* + * Copyright 2009 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +import java.util.HashMap; +import java.util.Map; + +import ch.systemsx.cisd.openbis.generic.shared.basic.URLMethodWithParameters; + +/** + * A Table Cell that is used for generated images. + * + * @author Chandrasekhar Ramakrishnan + */ +public class GeneratedImageTableCell implements ISerializableComparable +{ + // Servlet parameters + public final static String IMAGE_WIDTH_PARAM = "w"; + + public final static String IMAGE_HEIGHT_PARAM = "h"; + + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + + private String path; + + private int imageWidth; + + private int imageHeight; + + private int thumbnailWidth; + + private int thumbnailHeight; + + private HashMap<String, Object> parameters; + + public GeneratedImageTableCell(String path, int imageWidth, int imageHeight, + int thumbnailWidth, int thumbnailHeight) + { + this.path = path; + this.imageWidth = imageWidth; + this.imageHeight = imageHeight; + this.thumbnailWidth = thumbnailWidth; + this.thumbnailHeight = thumbnailHeight; + this.parameters = new HashMap<String, Object>(); + } + + // For GWT + @SuppressWarnings("unused") + private GeneratedImageTableCell() + { + } + + public String getPath() + { + return path; + } + + int getImageWidth() + { + return imageWidth; + } + + int getImageHeight() + { + return imageHeight; + } + + public int getMaxThumbnailWidth() + { + return thumbnailWidth; + } + + public int getMaxThumbnailHeight() + { + return thumbnailHeight; + } + + public void addParameter(String name, Object value) + { + parameters.put(name, value); + } + + public int compareTo(ISerializableComparable o) + { + return toString().compareTo(String.valueOf(o)); + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + + if (!(obj instanceof GeneratedImageTableCell)) + return false; + + GeneratedImageTableCell other = (GeneratedImageTableCell) obj; + + return other.toString().equals(toString()); + } + + @Override + public int hashCode() + { + return toString().hashCode(); + } + + @Override + public String toString() + { + return getHTMLString("url/", "sessionToken"); + } + + /** + * Get a string containing HTML that shows a thumbnail image with a link to the larger image + */ + public String getHTMLString(String downloadURL, String sessionID) + { + String urlRoot = downloadURL + "/" + path; + // Need to do everything doubly, since we need urls for the images and the thumbnails + URLMethodWithParameters urlMethodImage = new URLMethodWithParameters(urlRoot); + URLMethodWithParameters urlMethodThumb = new URLMethodWithParameters(urlRoot); + urlMethodImage.addParameter("sessionID", sessionID); + urlMethodThumb.addParameter("sessionID", sessionID); + + for (Map.Entry<String, Object> entry : parameters.entrySet()) + { + urlMethodImage.addParameter(entry.getKey(), entry.getValue()); + urlMethodThumb.addParameter(entry.getKey(), entry.getValue()); + } + + // Add dimension parameters for the full image and thumbnail + urlMethodImage.addParameter(IMAGE_WIDTH_PARAM, imageWidth); + urlMethodImage.addParameter(IMAGE_HEIGHT_PARAM, imageHeight); + + urlMethodThumb.addParameter(IMAGE_WIDTH_PARAM, thumbnailWidth); + urlMethodThumb.addParameter(IMAGE_HEIGHT_PARAM, thumbnailHeight); + + return getEmbededImageHtml(urlMethodThumb.toString(), urlMethodImage.toString()); + } + + private String getEmbededImageHtml(String thumbURL, String imageURL) + { + return "<div align='center'><a class='link-style' href='" + imageURL + + "' target='_blank'><img src='" + thumbURL + "' alt='" + "image" + "'/></a></div>"; + } +} diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/eicml/EICMLChromatogramImagesReporter.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/eicml/EICMLChromatogramImagesReporter.java index 3a367d16cb10c49c63a066da0ec75f535a45feb9..61d62820d220428a63b77093cd567a50a4584e0d 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/eicml/EICMLChromatogramImagesReporter.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/eicml/EICMLChromatogramImagesReporter.java @@ -33,8 +33,9 @@ import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractData import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IReportingPluginTask; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.SimpleTableModelBuilder; import ch.systemsx.cisd.openbis.dss.yeastx.server.EICMLChromatogramGeneratorServlet; +import ch.systemsx.cisd.openbis.generic.shared.GenericSharedConstants; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GeneratedImageTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ImageTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; import ch.systemsx.cisd.yeastx.db.DBUtils; @@ -49,7 +50,9 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp { private static final String CHROMATOGRAM_SERVLET = "chromatogram"; - private static final int THUMBNAIL_SIZE = 60; + private static final int THUMBNAIL_SIZE = 150; + + private static final int IMAGE_SIZE = 600; private static final long serialVersionUID = 1L; @@ -156,31 +159,17 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp row.add(asText(chromatogram.getLabel())); - StringBuffer imageURL = new StringBuffer(); - - imageURL.append(CHROMATOGRAM_SERVLET); - - imageURL.append("?"); - imageURL.append(EICMLChromatogramGeneratorServlet.DATASET_CODE_PARAM); - imageURL.append("="); - imageURL.append(datasetCode); - - imageURL.append("&"); - imageURL.append(EICMLChromatogramGeneratorServlet.CHROMATOGRAM_CODE_PARAM); - imageURL.append("="); - imageURL.append(chromatogram.getId()); - - imageURL.append("&"); - imageURL.append(EICMLChromatogramGeneratorServlet.IMAGE_WIDTH_PARAM); - imageURL.append("="); - imageURL.append(THUMBNAIL_SIZE); + GeneratedImageTableCell imageCell = + new GeneratedImageTableCell( + GenericSharedConstants.DATA_STORE_SERVER_WEB_APPLICATION_NAME + "/" + + CHROMATOGRAM_SERVLET, IMAGE_SIZE, IMAGE_SIZE, THUMBNAIL_SIZE, + THUMBNAIL_SIZE); - imageURL.append("&"); - imageURL.append(EICMLChromatogramGeneratorServlet.IMAGE_HEIGHT_PARAM); - imageURL.append("="); - imageURL.append(THUMBNAIL_SIZE); + imageCell.addParameter(EICMLChromatogramGeneratorServlet.DATASET_CODE_PARAM, datasetCode); + imageCell.addParameter(EICMLChromatogramGeneratorServlet.CHROMATOGRAM_CODE_PARAM, + chromatogram.getId()); - row.add(new ImageTableCell(imageURL.toString(), THUMBNAIL_SIZE, THUMBNAIL_SIZE)); + row.add(imageCell); return row; }