use of org.baderlab.csplugins.enrichmentmap.style.ColorScheme in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method createStyleOptions.
private EMStyleOptions createStyleOptions(EnrichmentMap map, EMViewControlPanel viewPanel) {
if (map == null || viewPanel == null)
return null;
Set<AbstractDataSet> dataSets = viewPanel.getDataSetSelector().getCheckedItems();
boolean publicationReady = viewPanel.getPublicationReadyCheck().isSelected();
boolean postAnalysis = map.hasSignatureDataSets();
ChartData data = (ChartData) viewPanel.getChartDataCombo().getSelectedItem();
ChartType type = getChartType(viewPanel);
ColorScheme colorScheme = (ColorScheme) viewPanel.getChartColorsCombo().getSelectedItem();
boolean showLabels = viewPanel.getShowChartLabelsCheck().isSelected();
ChartOptions chartOptions = new ChartOptions(data, type, colorScheme, showLabels);
return new EMStyleOptions(viewPanel.getNetworkView(), map, dataSets::contains, chartOptions, postAnalysis, publicationReady);
}
use of org.baderlab.csplugins.enrichmentmap.style.ColorScheme in project EnrichmentMapApp by BaderLab.
the class ChartUtil method createHeatStripsLegend.
@SuppressWarnings("serial")
public static JFreeChart createHeatStripsLegend(List<EMDataSet> dataSets, ChartOptions options) {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
int total = dataSets.size();
int v = total / -2;
for (int i = 0; i < total; i++) {
// Just to make sure there is always a bar for each data set name
if (v == 0.0)
v = 1;
dataset.addValue(v++, options.getData().toString(), dataSets.get(i).getName());
}
final JFreeChart chart = ChartFactory.createBarChart(// chart title
null, // domain axis label
null, // range axis label
null, // data
dataset, PlotOrientation.VERTICAL, // include legend
false, // tooltips
true, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(UIManager.getColor("Table.background"));
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
final CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setOutlineVisible(false);
plot.setBackgroundPaint(UIManager.getColor("Table.background"));
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
final CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis();
domainAxis.setVisible(true);
domainAxis.setAxisLineVisible(false);
domainAxis.setTickMarksVisible(false);
domainAxis.setTickLabelFont(UIManager.getFont("Label.font").deriveFont(LookAndFeelUtil.getSmallFontSize()));
domainAxis.setLabelPaint(UIManager.getColor("Label.foreground"));
domainAxis.setMaximumCategoryLabelLines(1);
domainAxis.setCategoryMargin(0.0);
if (total > 4) {
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
domainAxis.setMaximumCategoryLabelWidthRatio(0.5f);
} else {
domainAxis.setMaximumCategoryLabelLines(2);
}
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setVisible(false);
ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
if (// UP, ZERO, DOWN:
colors == null || colors.size() < 3)
colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
List<Color> itemColors = new ArrayList<>();
for (int i = 0; i < total; i++) {
Number n = dataset.getValue(options.getData().toString(), dataSets.get(i).getName());
itemColors.add(ColorUtil.getColor(n.doubleValue(), -total, total, colors.get(2), colors.get(1), colors.get(0)));
}
final BarRenderer renderer = new BarRenderer() {
@Override
public Paint getItemPaint(int row, int column) {
return column < itemColors.size() ? itemColors.get(column) : Color.LIGHT_GRAY;
}
};
plot.setRenderer(renderer);
renderer.setBarPainter(new StandardBarPainter());
renderer.setDrawBarOutline(true);
renderer.setShadowVisible(false);
renderer.setItemMargin(0.0);
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{1}", NumberFormat.getInstance()));
return chart;
}
use of org.baderlab.csplugins.enrichmentmap.style.ColorScheme in project EnrichmentMapApp by BaderLab.
the class ChartUtil method createRadialHeatMapLegend.
public static JFreeChart createRadialHeatMapLegend(List<EMDataSet> dataSets, ChartOptions options) {
// All the slices must have the same size
final DefaultPieDataset pieDataset = new DefaultPieDataset();
for (EMDataSet ds : dataSets) pieDataset.setValue(ds.getName(), 1);
JFreeChart chart = ChartFactory.createPieChart(// chart title
null, // data
pieDataset, // include legend
false, // tooltips
true, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(UIManager.getColor("Table.background"));
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
final PiePlot plot = (PiePlot) chart.getPlot();
plot.setCircular(true);
plot.setOutlineVisible(false);
plot.setBackgroundPaint(UIManager.getColor("Table.background"));
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setShadowPaint(TRANSPARENT_COLOR);
plot.setShadowXOffset(0.0);
plot.setShadowYOffset(0.0);
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
plot.setLabelFont(UIManager.getFont("Label.font").deriveFont(LookAndFeelUtil.getSmallFontSize()));
plot.setLabelPaint(UIManager.getColor("Label.foreground"));
plot.setLabelBackgroundPaint(TRANSPARENT_COLOR);
plot.setLabelOutlinePaint(TRANSPARENT_COLOR);
plot.setLabelShadowPaint(TRANSPARENT_COLOR);
plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0}"));
ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
if (// UP, ZERO, DOWN:
colors == null || colors.size() < 3)
colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
int total = dataSets.size();
int v = total / -2;
for (EMDataSet ds : dataSets) {
plot.setSectionPaint(ds.getName(), ColorUtil.getColor(v, -total, total, colors.get(2), colors.get(1), colors.get(0)));
v++;
}
return chart;
}
use of org.baderlab.csplugins.enrichmentmap.style.ColorScheme in project EnrichmentMapApp by BaderLab.
the class ChartUtil method createHeatMapLegend.
@SuppressWarnings("serial")
public static JFreeChart createHeatMapLegend(List<EMDataSet> dataSets, ChartOptions options) {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (EMDataSet ds : dataSets) dataset.addValue(1, options.getData().toString(), ds.getName());
final JFreeChart chart = ChartFactory.createBarChart(// chart title
null, // domain axis label
null, // range axis label
null, // data
dataset, PlotOrientation.HORIZONTAL, // include legend
false, // tooltips
true, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(UIManager.getColor("Table.background"));
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 20.0));
final CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setOutlineVisible(false);
plot.setBackgroundPaint(UIManager.getColor("Table.background"));
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
final CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis();
domainAxis.setVisible(true);
domainAxis.setAxisLineVisible(false);
domainAxis.setTickMarksVisible(false);
domainAxis.setTickLabelFont(UIManager.getFont("Label.font").deriveFont(LookAndFeelUtil.getSmallFontSize()));
domainAxis.setTickLabelPaint(UIManager.getColor("Label.foreground"));
domainAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 15.0));
domainAxis.setCategoryMargin(0.0);
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setVisible(false);
ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
if (// UP, ZERO, DOWN:
colors == null || colors.size() < 3)
colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
List<Color> itemColors = new ArrayList<>();
int total = dataSets.size();
int v = total / 2;
for (int i = 0; i < total; i++) itemColors.add(ColorUtil.getColor(v--, -total, total, colors.get(2), colors.get(1), colors.get(0)));
final BarRenderer renderer = new BarRenderer() {
@Override
public Paint getItemPaint(int row, int column) {
return column < itemColors.size() ? itemColors.get(column) : Color.LIGHT_GRAY;
}
};
plot.setRenderer(renderer);
renderer.setBarPainter(new StandardBarPainter());
renderer.setDrawBarOutline(true);
renderer.setShadowVisible(false);
renderer.setItemMargin(0.0);
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{1}", NumberFormat.getInstance()));
return chart;
}
Aggregations