Search in sources :

Example 1 with ColorScale

use of org.cytoscape.ding.internal.charts.util.ColorScale in project cytoscape-impl by cytoscape.

the class HeatMapLayer method createChart.

@Override
protected JFreeChart createChart(final XYZDataset dataset) {
    final PlotOrientation plotOrientation = orientation == Orientation.HORIZONTAL ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL;
    final SymbolAxis xAxis = new SymbolAxis(null, xLabels);
    xAxis.setVisible(showDomainAxis);
    xAxis.setAxisLineVisible(false);
    xAxis.setTickMarksVisible(false);
    xAxis.setTickLabelFont(xAxis.getLabelFont().deriveFont(axisFontSize));
    xAxis.setTickLabelPaint(axisColor);
    xAxis.setVerticalTickLabels(domainLabelPosition != LabelPosition.STANDARD);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    final SymbolAxis yAxis = new SymbolAxis(null, yLabels);
    yAxis.setVisible(showRangeAxis);
    yAxis.setAxisLineVisible(false);
    yAxis.setTickMarksVisible(false);
    yAxis.setTickLabelFont(yAxis.getLabelFont().deriveFont(axisFontSize));
    yAxis.setTickLabelPaint(axisColor);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setInverted(true);
    final XYBlockRenderer renderer = new XYBlockRenderer();
    if (range != null && range.size() >= 2 && range.get(0) != null && range.get(1) != null) {
        final int colorsSize = colors != null ? colors.size() : 0;
        Color upperColor = colorsSize > 0 ? colors.get(0) : Color.BLUE;
        Color zeroColor = colorsSize > 1 ? colors.get(1) : Color.WHITE;
        Color lowerColor = colorsSize > 2 ? colors.get(2) : Color.RED;
        Color nanColor = colorsSize > 3 ? colors.get(3) : Color.GRAY;
        final ColorScale scale = new ColorScale(range.get(0), range.get(1), lowerColor, zeroColor, upperColor, nanColor);
        renderer.setPaintScale(scale);
    }
    final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setDomainAxis(xAxis);
    plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    plot.setOutlineVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setBackgroundPaint(TRANSPARENT_COLOR);
    plot.setInsets(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    plot.setAxisOffset(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    plot.setOrientation(plotOrientation);
    final JFreeChart chart = new JFreeChart(null, plot);
    chart.removeLegend();
    chart.setBorderVisible(false);
    chart.setBackgroundPaint(TRANSPARENT_COLOR);
    chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    return chart;
}
Also used : PlotOrientation(org.jfree.chart.plot.PlotOrientation) XYPlot(org.jfree.chart.plot.XYPlot) Color(java.awt.Color) XYBlockRenderer(org.jfree.chart.renderer.xy.XYBlockRenderer) ColorScale(org.cytoscape.ding.internal.charts.util.ColorScale) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) SymbolAxis(org.jfree.chart.axis.SymbolAxis)

Aggregations

Color (java.awt.Color)1 ColorScale (org.cytoscape.ding.internal.charts.util.ColorScale)1 JFreeChart (org.jfree.chart.JFreeChart)1 SymbolAxis (org.jfree.chart.axis.SymbolAxis)1 PlotOrientation (org.jfree.chart.plot.PlotOrientation)1 XYPlot (org.jfree.chart.plot.XYPlot)1 XYBlockRenderer (org.jfree.chart.renderer.xy.XYBlockRenderer)1 RectangleInsets (org.jfree.ui.RectangleInsets)1