Skip to content
Snippets Groups Projects
Commit 26101461 authored by cramakri's avatar cramakri
Browse files

SE-186 Modifications to reporting to improve the chromatogram report display.

SVN: 14658
parent 95652262
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; ...@@ -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.IColumnDefinition;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; 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.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.ISerializableComparable;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ImageTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ImageTableCell;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader;
...@@ -72,13 +73,17 @@ public class DataSetReportColumnDefinition implements IColumnDefinition<TableMod ...@@ -72,13 +73,17 @@ public class DataSetReportColumnDefinition implements IColumnDefinition<TableMod
int width = imageCell.getMaxThumbnailWidth(); int width = imageCell.getMaxThumbnailWidth();
int height = imageCell.getMaxThumbnailHeight(); int height = imageCell.getMaxThumbnailHeight();
String imagePath = imageCell.getPath(); String imagePath = imageCell.getPath();
return SimpleImageHtmlRenderer.createEmbededDatastoreImageHtml(imagePath, width, height, return SimpleImageHtmlRenderer.createEmbededDatastoreImageHtml(imagePath, width,
downloadURL, sessionID); height, downloadURL, sessionID);
} }
if (cell instanceof DateTableCell) if (cell instanceof DateTableCell)
{ {
return SimpleDateRenderer.renderDate(((DateTableCell) cell).getDateTime()); return SimpleDateRenderer.renderDate(((DateTableCell) cell).getDateTime());
} }
if (cell instanceof GeneratedImageTableCell)
{
return ((GeneratedImageTableCell) cell).getHTMLString(downloadURL, sessionID);
}
return cell.toString(); return cell.toString();
} }
......
/*
* 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>";
}
}
...@@ -33,8 +33,9 @@ import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractData ...@@ -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.IReportingPluginTask;
import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.SimpleTableModelBuilder; 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.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.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.basic.dto.TableModel;
import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
import ch.systemsx.cisd.yeastx.db.DBUtils; import ch.systemsx.cisd.yeastx.db.DBUtils;
...@@ -49,7 +50,9 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp ...@@ -49,7 +50,9 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp
{ {
private static final String CHROMATOGRAM_SERVLET = "chromatogram"; 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; private static final long serialVersionUID = 1L;
...@@ -156,31 +159,17 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp ...@@ -156,31 +159,17 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp
row.add(asText(chromatogram.getLabel())); row.add(asText(chromatogram.getLabel()));
StringBuffer imageURL = new StringBuffer(); GeneratedImageTableCell imageCell =
new GeneratedImageTableCell(
imageURL.append(CHROMATOGRAM_SERVLET); GenericSharedConstants.DATA_STORE_SERVER_WEB_APPLICATION_NAME + "/"
+ CHROMATOGRAM_SERVLET, IMAGE_SIZE, IMAGE_SIZE, THUMBNAIL_SIZE,
imageURL.append("?"); THUMBNAIL_SIZE);
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);
imageURL.append("&"); imageCell.addParameter(EICMLChromatogramGeneratorServlet.DATASET_CODE_PARAM, datasetCode);
imageURL.append(EICMLChromatogramGeneratorServlet.IMAGE_HEIGHT_PARAM); imageCell.addParameter(EICMLChromatogramGeneratorServlet.CHROMATOGRAM_CODE_PARAM,
imageURL.append("="); chromatogram.getId());
imageURL.append(THUMBNAIL_SIZE);
row.add(new ImageTableCell(imageURL.toString(), THUMBNAIL_SIZE, THUMBNAIL_SIZE)); row.add(imageCell);
return row; return row;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment