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;
}
Aggregations