use of org.jfree.chart.plot.XYPlot in project s1tbx by senbox-org.
the class MultiMasterInSAROpUI method getPairsAndDrawChart.
private JFreeChart getPairsAndDrawChart(final int[] sliderValue, final boolean showLogoInPlot) {
// Get metadata of acquisitions
final double[][] metadata = getAcquisitionsMetadata();
if (metadata != null) {
// Get arcs corresponding to pairs
final List<int[]> arcs = getPairs(sliderValue, metadata);
// Generate series
final XYSeries acquisitionsSeries = new XYSeries("Acquisitions");
final XYLineAnnotation[] interferogramArcsAnnotations = new XYLineAnnotation[arcs.size()];
final String yAxisLabel = yAxisForPlot;
int metadata_index = yAxisLabel.contains("Doppler") ? 1 : 2;
for (int i = 0; i < metadata.length; i++) {
acquisitionsSeries.add(metadata[i][0], metadata[i][metadata_index]);
}
for (int i = 0; i < arcs.size(); i++) {
final int[] arc = arcs.get(i);
interferogramArcsAnnotations[i] = new XYLineAnnotation(metadata[arc[0]][0], metadata[arc[0]][metadata_index], metadata[arc[1]][0], metadata[arc[1]][metadata_index], new BasicStroke(1.0f), Color.WHITE);
}
// Add series to dataset
final XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(acquisitionsSeries);
// Generate graph
final JFreeChart chart = ChartFactory.createXYLineChart("Reference-Secondaries Plot", "Time [days]", yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false);
chart.addSubtitle(new TextTitle(String.format("(Number of pairs: %d)", pairs.length)));
final XYPlot plot = (XYPlot) chart.getPlot();
for (XYLineAnnotation annotation : interferogramArcsAnnotations) {
plot.addAnnotation(annotation);
}
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesPaint(0, Color.BLUE);
renderer.setSeriesLinesVisible(0, false);
renderer.setSeriesShapesVisible(0, true);
plot.setBackgroundPaint(Color.gray);
plot.setDomainGridlinePaint(Color.white);
plot.setRenderer(renderer);
if (showLogoInPlot) {
Image image = null;
final String homePath = SystemUtils.getApplicationHomeDir().getAbsolutePath();
final String internalPath = "snap-desktop/snap-application/target/snap";
final String pathUser = homePath.substring(0, homePath.length() - internalPath.length());
try {
image = ImageIO.read(new File(pathUser + "s1tbx/s1tbx-rcp/src/main/resources/org/esa/s1tbx/dat/icons/SNAP_icon_128.jpg"));
} catch (IOException e) {
}
plot.setBackgroundImage(image);
plot.setBackgroundImageAlignment(25);
plot.setBackgroundAlpha(0.9f);
}
return chart;
}
return null;
}
use of org.jfree.chart.plot.XYPlot in project scriptmanager by CEGRcode.
the class HeatMap method createCorrelationHeatmap.
public static ChartPanel createCorrelationHeatmap(String[] labels, double[][] MATRIX, File output) {
// create a paint-scale and a legend showing it
LookupPaintScale paintScale = new LookupPaintScale(0, 1, Color.black);
paintScale.add(0.0, new Color(0, 0, 255));
paintScale.add(0.11, new Color(63, 63, 255));
paintScale.add(0.22, new Color(126, 126, 255));
paintScale.add(0.33, new Color(189, 189, 255));
paintScale.add(0.44, new Color(255, 255, 255));
paintScale.add(0.55, new Color(255, 189, 189));
paintScale.add(0.66, new Color(255, 126, 126));
paintScale.add(0.77, new Color(255, 63, 63));
paintScale.add(0.88, new Color(255, 0, 0));
NumberAxis xAxis = new NumberAxis(null);
xAxis.setVisible(false);
String[] reverselabels = new String[labels.length];
for (int x = 0; x < labels.length; x++) {
reverselabels[labels.length - x - 1] = labels[x];
}
SymbolAxis yAxis = new SymbolAxis("Experiments", reverselabels);
XYPlot plot = new XYPlot(createDataset(MATRIX), xAxis, yAxis, null);
XYBlockRenderer r = new XYBlockRenderer();
r.setPaintScale(paintScale);
r.setBlockHeight(1.0f);
r.setBlockWidth(1.0f);
plot.setRenderer(r);
JFreeChart chart = new JFreeChart("Correlation Matrix", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
NumberAxis scaleAxis = new NumberAxis("Scale");
scaleAxis.setAxisLinePaint(Color.white);
scaleAxis.setTickMarkPaint(Color.white);
PaintScaleLegend legend = new PaintScaleLegend(paintScale, scaleAxis);
legend.setSubdivisionCount(128);
legend.setAxisLocation(AxisLocation.TOP_OR_RIGHT);
legend.setPadding(new RectangleInsets(10, 10, 10, 10));
legend.setStripWidth(20);
legend.setPosition(RectangleEdge.RIGHT);
legend.setBackgroundPaint(Color.WHITE);
chart.addSubtitle(legend);
chart.setBackgroundPaint(Color.white);
if (output != null) {
int width = 640;
int height = 480;
try {
ChartUtils.saveChartAsPNG(output, chart, width, height);
} catch (IOException e) {
e.printStackTrace();
}
}
return new ChartPanel(chart);
}
use of org.jfree.chart.plot.XYPlot in project scriptmanager by CEGRcode.
the class Histogram method createChart.
private static JFreeChart createChart(IntervalXYDataset dataset) throws IOException {
final JFreeChart chart = ChartFactory.createXYBarChart(// chart title
"Paired-End Insert Size Frequency Histogram", // domain axis label
"Insert Size (bp)", false, // range axis label
"Frequency", // data
dataset, // orientation
PlotOrientation.VERTICAL, // include legend
true, // tooltips
true, // urls
false);
XYPlot plot = (XYPlot) chart.getPlot();
// Set Histogram Color to Red
plot.getRenderer().setSeriesPaint(0, new Color(51, 51, 51));
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.black);
plot.setDomainGridlinePaint(Color.black);
// Turn off Glossy 3D on bar chart
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setBarPainter(new StandardXYBarPainter());
return chart;
}
use of org.jfree.chart.plot.XYPlot in project zaproxy by zaproxy.
the class ScanProgressDialog method createChart.
private JFreeChart createChart(final XYDataset dataset) {
JFreeChart result = ChartFactory.createTimeSeriesChart(// No title - it just takes up space
null, Constant.messages.getString("ascan.progress.chart.time"), Constant.messages.getString("ascan.progress.chart.responses"), dataset, true, true, false);
XYPlot plot = result.getXYPlot();
ValueAxis daxis = plot.getDomainAxis();
daxis.setAutoRange(true);
daxis.setAutoRangeMinimumSize(60000.0);
plot.getRangeAxis().setAutoRangeMinimumSize(20);
return result;
}
use of org.jfree.chart.plot.XYPlot in project mastodon-tracking by mastodon-sc.
the class WizardUtils method createQualityHistogram.
public static final ChartPanel createQualityHistogram(final Model model) {
final DetectionQualityFeature qFeature = DetectionQualityFeature.getOrRegister(model.getFeatureModel(), model.getGraph().vertices().getRefPool());
final double[] values = qFeature.values();
if (values.length == 0)
return null;
final ChartPanel chartPanel = HistogramUtil.createHistogramPlot(values, false);
chartPanel.getChart().setTitle(new TextTitle("Quality histogram", chartPanel.getFont()));
// Disable zoom.
for (final MouseListener ml : chartPanel.getMouseListeners()) chartPanel.removeMouseListener(ml);
// Re enable the X axis.
final XYPlot plot = chartPanel.getChart().getXYPlot();
plot.getDomainAxis().setVisible(true);
final TickUnitSource source = new NumberTickUnitSource(false, FORMAT);
plot.getDomainAxis().setStandardTickUnits(source);
final Font smallFont = chartPanel.getFont().deriveFont(chartPanel.getFont().getSize2D() - 2f);
plot.getDomainAxis().setTickLabelFont(smallFont);
// Transparent background.
chartPanel.getChart().setBackgroundPaint(null);
return chartPanel;
}
Aggregations