use of org.jfree.chart.axis.ValueAxis in project nimbus by nimbus-org.
the class CombinedDomainXYPlotFactoryService method createPlot.
// PlotFactoryのJavaDoc
public Plot createPlot(PlotCondition[] plotConditions) throws PlotCreateException {
CombinedDomainXYPlot combinedPlot = (CombinedDomainXYPlot) copyXYPlot();
if (plotConditions == null || plotConditions.length == 0) {
return combinedPlot;
}
for (int i = 0; i < subPlotFactoryServices.size(); i++) {
PlotFactory plotFactory = (PlotFactory) subPlotFactoryServices.get(i);
Plot plot = plotFactory.createPlot(plotConditions);
if (plot != null && plot instanceof XYPlot) {
XYPlot xyPlot = (XYPlot) plot;
combinedPlot.add(xyPlot, xyPlot.getWeight());
}
}
XYPlotConditionImpl xyPlotCondition = mergeXYPlotCondition(plotConditions);
if (domainAxisServiceNames != null && domainAxisServiceNames.length > 0) {
for (int i = 0; i < domainAxisServiceNames.length; i++) {
ValueAxis domainAxis = (ValueAxis) ServiceManagerFactory.getServiceObject(domainAxisServiceNames[i]);
if (xyPlotCondition != null) {
// 横軸ラベルフォント
if (xyPlotCondition.getDefaultDomainAxisLabelFontName() != null || xyPlotCondition.getDefaultDomainAxisLabelFontStyle() != Integer.MIN_VALUE || xyPlotCondition.getDefaultDomainAxisLabelFontSize() != Integer.MIN_VALUE) {
domainAxis.setLabelFont(mergeFont(domainAxis.getLabelFont(), xyPlotCondition.getDefaultDomainAxisLabelFontName(), xyPlotCondition.getDefaultDomainAxisLabelFontStyle(), xyPlotCondition.getDefaultDomainAxisLabelFontSize()));
} else if (xyPlotCondition.getDomainAxisLabelFontName(i) != null || xyPlotCondition.getDomainAxisLabelFontStyle(i) != Integer.MIN_VALUE || xyPlotCondition.getDomainAxisLabelFontSize(i) != Integer.MIN_VALUE) {
domainAxis.setLabelFont(mergeFont(domainAxis.getLabelFont(), xyPlotCondition.getDomainAxisLabelFontName(i), xyPlotCondition.getDomainAxisLabelFontStyle(i), xyPlotCondition.getDomainAxisLabelFontSize(i)));
}
// 横軸Tickラベルフォント
if (xyPlotCondition.getDefaultDomainAxisTickLabelFontName() != null || xyPlotCondition.getDefaultDomainAxisTickLabelFontStyle() != Integer.MIN_VALUE || xyPlotCondition.getDefaultDomainAxisTickLabelFontSize() != Integer.MIN_VALUE) {
domainAxis.setTickLabelFont(mergeFont(domainAxis.getTickLabelFont(), xyPlotCondition.getDefaultDomainAxisTickLabelFontName(), xyPlotCondition.getDefaultDomainAxisTickLabelFontStyle(), xyPlotCondition.getDefaultDomainAxisTickLabelFontSize()));
} else if (xyPlotCondition.getDomainAxisTickLabelFontName(i) != null || xyPlotCondition.getDomainAxisTickLabelFontStyle(i) != Integer.MIN_VALUE || xyPlotCondition.getDomainAxisTickLabelFontSize(i) != Integer.MIN_VALUE) {
domainAxis.setTickLabelFont(mergeFont(domainAxis.getTickLabelFont(), xyPlotCondition.getDomainAxisTickLabelFontName(i), xyPlotCondition.getDomainAxisTickLabelFontStyle(i), xyPlotCondition.getDomainAxisTickLabelFontSize(i)));
}
}
combinedPlot.setDomainAxis(i, domainAxis);
}
}
if (getTickUnitAdjusters() != null) {
// 目盛り調節
TickUnitAdjuster[] adjusters = getTickUnitAdjusters();
for (int i = 0; i < adjusters.length; i++) {
adjusters[i].adjust(combinedPlot);
}
}
return combinedPlot;
}
use of org.jfree.chart.axis.ValueAxis in project mafscaling by vimsh.
the class MafRescale method createGraghPanel.
private void createGraghPanel(JPanel dataPanel) {
JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);
chart.setBorderVisible(true);
mafChartPanel = new MafChartPanel(chart, this);
GridBagConstraints gbl_chartPanel = new GridBagConstraints();
gbl_chartPanel.anchor = GridBagConstraints.PAGE_START;
gbl_chartPanel.insets = insets0;
gbl_chartPanel.fill = GridBagConstraints.BOTH;
gbl_chartPanel.weightx = 1.0;
gbl_chartPanel.weighty = 1.0;
gbl_chartPanel.gridx = 0;
gbl_chartPanel.gridy = 2;
dataPanel.add(mafChartPanel.getChartPanel(), gbl_chartPanel);
XYSplineRenderer lineRenderer = new XYSplineRenderer(3);
lineRenderer.setUseFillPaint(true);
lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00")));
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f);
lineRenderer.setSeriesStroke(0, stroke);
lineRenderer.setSeriesStroke(1, stroke);
lineRenderer.setSeriesPaint(0, new Color(201, 0, 0));
lineRenderer.setSeriesPaint(1, new Color(0, 0, 255));
lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5));
lineRenderer.setSeriesShape(1, ShapeUtilities.createUpTriangle((float) 2.5));
ValueAxis mafvDomain = new NumberAxis(XAxisName);
ValueAxis mafgsRange = new NumberAxis(YAxisName);
XYSeriesCollection lineDataset = new XYSeriesCollection();
lineDataset.addSeries(currMafData);
lineDataset.addSeries(corrMafData);
XYPlot plot = chart.getXYPlot();
plot.setRangePannable(true);
plot.setDomainPannable(true);
plot.setDomainGridlinePaint(Color.DARK_GRAY);
plot.setRangeGridlinePaint(Color.DARK_GRAY);
plot.setBackgroundPaint(new Color(224, 224, 224));
plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
plot.setDataset(0, lineDataset);
plot.setRenderer(0, lineRenderer);
plot.setDomainAxis(0, mafvDomain);
plot.setRangeAxis(0, mafgsRange);
plot.mapDatasetToDomainAxis(0, 0);
plot.mapDatasetToRangeAxis(0, 0);
LegendTitle legend = new LegendTitle(plot.getRenderer());
legend.setItemFont(new Font("Arial", 0, 10));
legend.setPosition(RectangleEdge.TOP);
chart.addLegend(legend);
}
use of org.jfree.chart.axis.ValueAxis in project mafscaling by vimsh.
the class LogView method createGraghPanel.
private void createGraghPanel() {
JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);
chartPanel = new ChartPanel(chart, true, true, true, true, true);
chartPanel.setFocusable(true);
chartPanel.setAutoscrolls(true);
chartPanel.setPopupMenu(null);
chart.setBackgroundPaint(chartColor);
rpmDataset = new XYSeriesCollection();
rpmPlotRenderer = new XYLineAndShapeRenderer();
dataset = new XYSeriesCollection();
plotRenderer = new XYLineAndShapeRenderer();
NumberAxis xAxis = new NumberAxis();
xAxis.setTickLabelsVisible(false);
xAxis.setTickLabelPaint(Color.WHITE);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis();
yAxis.setTickLabelsVisible(false);
yAxis.setTickLabelPaint(Color.WHITE);
yAxis.setAutoRangeIncludesZero(false);
NumberAxis y2Axis = new NumberAxis();
y2Axis.setTickLabelsVisible(false);
y2Axis.setTickLabelPaint(Color.WHITE);
y2Axis.setAutoRangeIncludesZero(false);
plot = chartPanel.getChart().getXYPlot();
plot.setRangePannable(true);
plot.setDomainPannable(true);
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
plot.setBackgroundPaint(chartBgColor);
plot.setDataset(0, rpmDataset);
plot.setRenderer(0, rpmPlotRenderer);
plot.setDomainAxis(0, xAxis);
plot.setRangeAxis(0, yAxis);
plot.mapDatasetToDomainAxis(0, 0);
plot.mapDatasetToRangeAxis(0, 0);
plot.setDataset(1, dataset);
plot.setRenderer(1, plotRenderer);
plot.setRangeAxis(1, y2Axis);
plot.mapDatasetToDomainAxis(1, 0);
plot.mapDatasetToRangeAxis(1, 1);
LegendTitle legend = new LegendTitle(plot);
legend.setItemFont(new Font("Arial", 0, 10));
legend.setPosition(RectangleEdge.TOP);
legend.setItemPaint(Color.WHITE);
chart.addLegend(legend);
xMarker = new XYDomainMutilineAnnotation();
xMarker.setDefaultPaint(Color.WHITE);
plot.addAnnotation(xMarker);
chartMouseListener = new ChartMouseListener() {
@Override
public void chartMouseMoved(ChartMouseEvent event) {
try {
Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
Point2D p = chartPanel.translateScreenToJava2D(event.getTrigger().getPoint());
double x = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge());
boolean isLeft = (p.getX() < (dataArea.getMaxX() - dataArea.getMinX()) / 2) ? true : false;
if (setMarkers(x, isLeft)) {
try {
int selectedCol = logDataTable.getTable().getSelectedColumn();
if (selectedCol < 0)
selectedCol = 0;
if (logPlayWindow == null || startMarker != null || endMarker != null) {
logDataTable.getTable().setRowSelectionInterval((int) x, (int) x);
logDataTable.getTable().changeSelection((int) x, selectedCol, false, false);
} else {
logPlayWindow.setProgressBar((int) x);
}
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void chartMouseClicked(ChartMouseEvent event) {
chartPanel.requestFocusInWindow();
if (logPlayWindow == null)
return;
if (xMarker.count() == 0)
return;
Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
Point2D p = chartPanel.translateScreenToJava2D(event.getTrigger().getPoint());
double x = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge());
if (x < 0 || (int) x >= logDataTable.getRowCount())
return;
if (SwingUtilities.isLeftMouseButton(event.getTrigger())) {
if (startMarker == null) {
startMarker = new ValueMarker(x);
startMarker.setPaint(Color.GREEN);
startMarker.setStroke(new BasicStroke(1.5f));
plot.addDomainMarker(startMarker);
} else {
plot.removeDomainMarker(startMarker);
startMarker = null;
}
} else if (SwingUtilities.isRightMouseButton(event.getTrigger())) {
if (endMarker == null) {
endMarker = new ValueMarker(x);
endMarker.setPaint(Color.GREEN);
endMarker.setStroke(new BasicStroke(1.5f));
plot.addDomainMarker(endMarker);
} else {
plot.removeDomainMarker(endMarker);
endMarker = null;
}
}
chartPanel.repaint();
logPlayWindow.setStartEndArea(startMarker, endMarker);
}
};
chartPanel.addChartMouseListener(chartMouseListener);
chartPanel.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (!chartPanel.hasFocus())
return;
int keyCode = e.getKeyCode();
if (keyCode < KeyEvent.VK_LEFT || keyCode > KeyEvent.VK_DOWN)
return;
ValueAxis axis = null;
if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT)
axis = ((XYPlot) chartPanel.getChart().getXYPlot()).getDomainAxis();
else
axis = ((XYPlot) chartPanel.getChart().getXYPlot()).getRangeAxis();
if (axis != null) {
double delta = (axis.getUpperBound() - axis.getLowerBound()) / 100.0;
if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_DOWN)
axis.setRange(axis.getLowerBound() - delta, axis.getUpperBound() - delta);
else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_RIGHT)
axis.setRange(axis.getLowerBound() + delta, axis.getUpperBound() + delta);
}
}
public void keyReleased(KeyEvent arg0) {
}
public void keyTyped(KeyEvent arg0) {
}
});
}
use of org.jfree.chart.axis.ValueAxis in project Gemma by PavlidisLab.
the class ExpressionExperimentQCController method writeDetailedFactorAnalysis.
private boolean writeDetailedFactorAnalysis(ExpressionExperiment ee, OutputStream os) throws Exception {
SVDValueObject svdo = svdService.getSvdFactorAnalysis(ee.getId());
if (svdo == null)
return false;
if (svdo.getFactors().isEmpty() && svdo.getDates().isEmpty()) {
return false;
}
Map<Integer, Map<Long, Double>> factorCorrelations = svdo.getFactorCorrelations();
// Map<Integer, Map<Long, Double>> factorPvalues = svdo.getFactorPvalues();
Map<Integer, Double> dateCorrelations = svdo.getDateCorrelations();
assert ee.getId().equals(svdo.getId());
// need the experimental design
ee = expressionExperimentService.thawLite(ee);
int maxWidth = 30;
Map<Long, String> efs = this.getFactorNames(ee, maxWidth);
Map<Long, ExperimentalFactor> efIdMap = EntityUtils.getIdMap(ee.getExperimentalDesign().getExperimentalFactors());
Collection<Long> continuousFactors = new HashSet<>();
for (ExperimentalFactor ef : ee.getExperimentalDesign().getExperimentalFactors()) {
boolean isContinous = ExperimentalDesignUtils.isContinuous(ef);
if (isContinous) {
continuousFactors.add(ef.getId());
}
}
/*
* Make plots of the dates vs. PCs, factors vs. PCs.
*/
int MAX_COMP = 3;
Map<Long, List<JFreeChart>> charts = new LinkedHashMap<>();
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
/*
* FACTORS
*/
String componentShorthand = "PC";
for (Integer component : factorCorrelations.keySet()) {
if (component >= MAX_COMP)
break;
String xaxisLabel = componentShorthand + (component + 1);
for (Long efId : factorCorrelations.get(component).keySet()) {
/*
* Should not happen.
*/
if (!efs.containsKey(efId)) {
log.warn("No experimental factor with id " + efId);
continue;
}
if (!svdo.getFactors().containsKey(efId)) {
// this should not happen.
continue;
}
boolean isCategorical = !continuousFactors.contains(efId);
Map<Long, String> categories = new HashMap<>();
if (isCategorical) {
this.getCategories(efIdMap, efId, categories);
}
if (!charts.containsKey(efId)) {
charts.put(efId, new ArrayList<JFreeChart>());
}
Double a = factorCorrelations.get(component).get(efId);
// unique?
String plotname = (efs.get(efId) == null ? "?" : efs.get(efId)) + " " + xaxisLabel;
if (a != null && !Double.isNaN(a)) {
String title = plotname + " " + String.format("%.2f", a);
List<Double> values = svdo.getFactors().get(efId);
Double[] eigenGene = this.getEigenGene(svdo, component);
assert values.size() == eigenGene.length;
/*
* Plot eigengene vs values, add correlation to the plot
*/
JFreeChart chart;
if (isCategorical) {
/*
* Categorical factor
*/
// use the absolute value of the correlation, since direction is arbitrary.
title = plotname + " " + String.format("r=%.2f", Math.abs(a));
DefaultMultiValueCategoryDataset dataset = new DefaultMultiValueCategoryDataset();
/*
* What this code does is organize the factor values by the groups.
*/
Map<String, List<Double>> groupedValues = new TreeMap<>();
for (int i = 0; i < values.size(); i++) {
Long fvId = values.get(i).longValue();
String fvValue = categories.get(fvId);
if (fvValue == null) {
// is this all we need to do?
continue;
}
if (!groupedValues.containsKey(fvValue)) {
groupedValues.put(fvValue, new ArrayList<Double>());
}
groupedValues.get(fvValue).add(eigenGene[i]);
if (log.isDebugEnabled())
log.debug(fvValue + " " + values.get(i));
}
for (String key : groupedValues.keySet()) {
dataset.add(groupedValues.get(key), plotname, key);
}
// don't show the name of the X axis: it's redundant with the title.
NumberAxis rangeAxis = new NumberAxis(xaxisLabel);
rangeAxis.setAutoRangeIncludesZero(false);
// rangeAxis.setAutoRange( false );
rangeAxis.setAutoRangeMinimumSize(4.0);
// rangeAxis.setRange( new Range( -2, 2 ) );
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis(null), rangeAxis, new ScatterRenderer());
plot.setRangeGridlinesVisible(false);
plot.setDomainGridlinesVisible(false);
chart = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 12), plot, false);
ScatterRenderer renderer = (ScatterRenderer) plot.getRenderer();
float saturationDrop = (float) Math.min(1.0, component * 0.8f / MAX_COMP);
renderer.setSeriesFillPaint(0, Color.getHSBColor(0.0f, 1.0f - saturationDrop, 0.7f));
renderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3));
renderer.setUseOutlinePaint(false);
renderer.setUseFillPaint(true);
renderer.setBaseFillPaint(Color.white);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
} else {
/*
* Continuous value factor
*/
DefaultXYDataset series = new DefaultXYDataset();
series.addSeries(plotname, new double[][] { ArrayUtils.toPrimitive(values.toArray(new Double[] {})), ArrayUtils.toPrimitive(eigenGene) });
// don't show x-axis label, which would otherwise be efs.get( efId )
chart = ChartFactory.createScatterPlot(title, null, xaxisLabel, series, PlotOrientation.VERTICAL, false, false, false);
XYPlot plot = chart.getXYPlot();
plot.setRangeGridlinesVisible(false);
plot.setDomainGridlinesVisible(false);
XYItemRenderer renderer = plot.getRenderer();
renderer.setBasePaint(Color.white);
renderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3));
float saturationDrop = (float) Math.min(1.0, component * 0.8f / MAX_COMP);
renderer.setSeriesPaint(0, Color.getHSBColor(0.0f, 1.0f - saturationDrop, 0.7f));
plot.setRenderer(renderer);
}
chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 12));
charts.get(efId).add(chart);
}
}
}
/*
* DATES
*/
charts.put(-1L, new ArrayList<JFreeChart>());
for (Integer component : dateCorrelations.keySet()) {
String xaxisLabel = componentShorthand + (component + 1);
List<Date> dates = svdo.getDates();
if (dates.isEmpty())
break;
long secspan = ubic.basecode.util.DateUtil.numberOfSecondsBetweenDates(dates);
if (component >= MAX_COMP)
break;
Double a = dateCorrelations.get(component);
if (a != null && !Double.isNaN(a)) {
Double[] eigenGene = svdo.getvMatrix().getColObj(component);
/*
* Plot eigengene vs values, add correlation to the plot
*/
TimeSeries series = new TimeSeries("Dates vs. eigen" + (component + 1));
int i = 0;
for (Date d : dates) {
// if span is less than an hour, retain the minute.
if (secspan < 60 * 60) {
series.addOrUpdate(new Minute(d), eigenGene[i++]);
} else {
series.addOrUpdate(new Hour(d), eigenGene[i++]);
}
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
JFreeChart chart = ChartFactory.createTimeSeriesChart("Dates: " + xaxisLabel + " " + String.format("r=%.2f", a), null, xaxisLabel, dataset, false, false, false);
XYPlot xyPlot = chart.getXYPlot();
chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 12));
// standard renderer makes lines.
XYDotRenderer renderer = new XYDotRenderer();
renderer.setBaseFillPaint(Color.white);
renderer.setDotHeight(3);
renderer.setDotWidth(3);
// has no effect, need dotheight.
renderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3));
float saturationDrop = (float) Math.min(1.0, component * 0.8f / MAX_COMP);
renderer.setSeriesPaint(0, Color.getHSBColor(0.0f, 1.0f - saturationDrop, 0.7f));
ValueAxis domainAxis = xyPlot.getDomainAxis();
domainAxis.setVerticalTickLabels(true);
xyPlot.setRenderer(renderer);
xyPlot.setRangeGridlinesVisible(false);
xyPlot.setDomainGridlinesVisible(false);
charts.get(-1L).add(chart);
}
}
/*
* Plot in a grid, with each factor as a column. FIXME What if we have too many factors to fit on the screen?
*/
int columns = (int) Math.ceil(charts.size());
int perChartSize = ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX;
BufferedImage image = new BufferedImage(columns * perChartSize, MAX_COMP * perChartSize, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
int currentX = 0;
int currentY = 0;
for (Long id : charts.keySet()) {
for (JFreeChart chart : charts.get(id)) {
this.addChartToGraphics(chart, g2, currentX, currentY, perChartSize, perChartSize);
if (currentY + perChartSize < MAX_COMP * perChartSize) {
currentY += perChartSize;
} else {
currentY = 0;
currentX += perChartSize;
}
}
}
os.write(ChartUtilities.encodeAsPNG(image));
return true;
}
use of org.jfree.chart.axis.ValueAxis in project Gemma by PavlidisLab.
the class ExpressionExperimentQCController method writeMeanVariance.
/**
* @param os response output stream
* @param mvr MeanVarianceRelation object to plot
* @return true if mvr data points were plotted
*/
private boolean writeMeanVariance(OutputStream os, MeanVarianceRelation mvr, Double size) throws Exception {
// if number of datapoints > THRESHOLD then alpha = TRANSLUCENT, else alpha = OPAQUE
final int THRESHOLD = 1000;
final int TRANSLUCENT = 50;
final int OPAQUE = 255;
// Set maximum plot range to Y_MAX + YRANGE * OFFSET to leave some extra white space
final double OFFSET_FACTOR = 0.05f;
// set the final image size to be the minimum of MAX_IMAGE_SIZE_PX or size
final int MAX_IMAGE_SIZE_PX = 5;
if (mvr == null) {
return false;
}
// get data points
XYSeriesCollection collection = this.getMeanVariance(mvr);
if (collection.getSeries().size() == 0) {
return false;
}
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart chart = ChartFactory.createScatterPlot("", "mean (log2)", "variance (log2)", collection, PlotOrientation.VERTICAL, false, false, false);
// adjust colors and shapes
XYRegressionRenderer renderer = new XYRegressionRenderer();
renderer.setBasePaint(Color.white);
int alpha = collection.getSeries(0).getItemCount() > THRESHOLD ? TRANSLUCENT : OPAQUE;
renderer.setSeriesPaint(0, new Color(0, 0, 0, alpha));
renderer.setSeriesPaint(1, Color.red);
renderer.setSeriesStroke(1, new BasicStroke(1));
renderer.setSeriesShape(0, new Ellipse2D.Double(4, 4, 4, 4));
renderer.setSeriesShapesFilled(0, false);
renderer.setSeriesLinesVisible(0, false);
renderer.setSeriesLinesVisible(1, true);
renderer.setSeriesShapesVisible(1, false);
XYPlot plot = chart.getXYPlot();
plot.setRenderer(renderer);
plot.setRangeGridlinesVisible(false);
plot.setDomainGridlinesVisible(false);
// adjust the chart domain and ranges
double yRange = collection.getSeries(0).getMaxY() - collection.getSeries(0).getMinY();
double xRange = collection.getSeries(0).getMaxX() - collection.getSeries(0).getMinX();
double ybuffer = (yRange) * OFFSET_FACTOR;
double xbuffer = (xRange) * OFFSET_FACTOR;
double newYMin = collection.getSeries(0).getMinY() - ybuffer;
double newYMax = collection.getSeries(0).getMaxY() + ybuffer;
double newXMin = collection.getSeries(0).getMinX() - xbuffer;
double newXMax = collection.getSeries(0).getMaxX() + xbuffer;
ValueAxis yAxis = new NumberAxis("Variance");
yAxis.setRange(newYMin, newYMax);
ValueAxis xAxis = new NumberAxis("Mean");
xAxis.setRange(newXMin, newXMax);
chart.getXYPlot().setRangeAxis(yAxis);
chart.getXYPlot().setDomainAxis(xAxis);
int finalSize = (int) Math.min(MAX_IMAGE_SIZE_PX * ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX, size * ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX);
ChartUtilities.writeChartAsPNG(os, chart, finalSize, finalSize);
return true;
}
Aggregations