diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/HeatmapUtil.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/HeatmapUtil.java deleted file mode 100644 index 738145b4a8f87cb4958ed064d65bdd2c41923bc1..0000000000000000000000000000000000000000 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/HeatmapUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2010 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.plugin.screening.client.web.client.application.detailviewers; - -import java.util.List; - -import com.google.gwt.user.client.ui.Widget; - -import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps.IHeatmapRenderer; -import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps.dto.Color; -import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps.dto.HeatmapScaleRange; - -/** - * @author Tomasz Pylak - */ -public class HeatmapUtil -{ - // --- DTOs - - static class NumberHeatmapRenderer implements IHeatmapRenderer<Float> - { - - public NumberHeatmapRenderer(float min, float max) - { - - } - - public Color getColor(Float value) - { - // TODO Auto-generated method stub - return null; - } - - public List<HeatmapScaleRange> calculateScale() - { - // TODO Auto-generated method stub - return null; - } - - } - - static class ScaleDrawer - { - Widget draw(List<HeatmapScaleRange> ranges, int height) - { - // TODO 2010--, Tomasz Pylak: - return null; - } - } - -} diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/heatmaps/NumberHeatmapRenderer.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/heatmaps/NumberHeatmapRenderer.java new file mode 100644 index 0000000000000000000000000000000000000000..0325579dc7e784eda3fd1355300d691f0d99c022 --- /dev/null +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/heatmaps/NumberHeatmapRenderer.java @@ -0,0 +1,28 @@ +package ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps; + +import java.util.List; + +import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps.dto.Color; +import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps.dto.HeatmapScaleRange; + +public class NumberHeatmapRenderer implements IHeatmapRenderer<Float> +{ + + public NumberHeatmapRenderer(float min, float max) + { + + } + + public Color getColor(Float value) + { + // TODO Auto-generated method stub + return null; + } + + public List<HeatmapScaleRange> calculateScale() + { + // TODO Auto-generated method stub + return null; + } + +} \ No newline at end of file diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/heatmaps/ScaleDrawer.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/heatmaps/ScaleDrawer.java new file mode 100644 index 0000000000000000000000000000000000000000..56121cd1c08f3f03d9d7af0015c083b0897c74b2 --- /dev/null +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/heatmaps/ScaleDrawer.java @@ -0,0 +1,109 @@ +package ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.extjs.gxt.ui.client.Style.HorizontalAlignment; +import com.extjs.gxt.ui.client.Style.Scroll; +import com.extjs.gxt.ui.client.Style.VerticalAlignment; +import com.extjs.gxt.ui.client.widget.Component; +import com.extjs.gxt.ui.client.widget.Dialog; +import com.extjs.gxt.ui.client.widget.LayoutContainer; +import com.extjs.gxt.ui.client.widget.Text; +import com.extjs.gxt.ui.client.widget.layout.TableData; +import com.extjs.gxt.ui.client.widget.layout.TableLayout; +import com.google.gwt.user.client.ui.Widget; + +import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps.dto.Color; +import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers.heatmaps.dto.HeatmapScaleRange; + +public class ScaleDrawer +{ + + static public void example() + { + List<HeatmapScaleRange> ranges = new ArrayList<HeatmapScaleRange>(); + for (String s : Arrays.asList("#67001F", "#B2182B", "#D6604D", "#F4A582", "#FDDBC7", + "#F7F7F7", "#D1E5F0", "#92C5DE", "#4393C3", "#2166AC", "#053061")) + { + ranges.add(new HeatmapScaleRange(s, new Color(s))); + } + Dialog dialog = new Dialog(); + dialog.add(draw(ranges)); + dialog.add(draw("First", ranges)); + dialog.show(); + } + + public static Widget draw(List<HeatmapScaleRange> ranges) + { + return draw(null, ranges); + } + + public static Widget draw(String firstLabelOrNull, List<HeatmapScaleRange> ranges) + { + LayoutContainer container = new LayoutContainer(); + container.setLayout(new TableLayout(2)); + container.setBorders(true); + container.setScrollMode(Scroll.NONE); + boolean isFirstLabel = firstLabelOrNull != null; + if (isFirstLabel) + { + container.add(createLabel(isFirstLabel, firstLabelOrNull), + createLabelData(isFirstLabel)); + container.add(createBox(null), createBoxData()); + } + for (HeatmapScaleRange r : ranges) + { + container.add(createLabel(isFirstLabel, r.getLabel()), createLabelData(isFirstLabel)); + container.add(createBox(r.getColor()), createBoxData()); + } + if (isFirstLabel) + { + container.add(createLabel(isFirstLabel, ""), createLabelData(isFirstLabel)); + container.add(createBox(null), createBoxData()); + } + return container; + } + + private static TableData createBoxData() + { + return new TableData(HorizontalAlignment.LEFT, VerticalAlignment.TOP); + } + + private static TableData createLabelData(boolean isFirstLabel) + { + if (isFirstLabel) + { + return new TableData(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM); + } else + { + return new TableData(HorizontalAlignment.RIGHT, VerticalAlignment.MIDDLE); + } + } + + private static Component createBox(Color color) + { + Text box = new Text(); + box.setStyleAttribute("margin-left", "0.5em"); + if (color != null) + { + box.setStyleAttribute("background-color", color.getHexColor()); + } + box.setWidth("1em"); + box.setHeight("2em"); + return box; + } + + private static Component createLabel(boolean isFirstLabel, String text) + { + Text label = new Text(text); + label.setStyleAttribute("font-size", "0.5em"); + label.setStyleAttribute("position", "relative"); + if (isFirstLabel) + { + label.setStyleAttribute("bottom", "-0.6em"); + } + return label; + } +} \ No newline at end of file