List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(String title, Font titleFont, Plot plot, boolean createLegend)
From source file:playground.anhorni.counts.StdDevBoxPlot.java
public JFreeChart createChart() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); ArrayList<Double>[] lists = this.createArrayLists(); // add the collected values to the graph / dataset for (int i = 0; i < 24; i++) { dataset.add(lists[i], "hour", Integer.toString(i + 1)); }/*from w w w .j a va 2s . c o m*/ final CategoryAxis xAxis = new CategoryAxis(xlabel); xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10)); //xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final NumberAxis yAxis = new NumberAxis(ylabel); yAxis.setAutoRangeIncludesZero(true); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); this.chart_ = new JFreeChart(chartTitle, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java
public static JFreeChart createWhiskerChart(SuccessfulAttack sa) { BoxAndWhiskerCategoryDataset boxandwhiskercategorydataset = createDataset(sa); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setMaximumBarWidth(0.05);// w w w . j a v a 2 s . c o m renderer.setMeanVisible(false); renderer.setSeriesPaint(0, Color.GREEN); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesPaint(2, Color.BLUE); NumberAxis numberAxis = new NumberAxis("duration in ms"); CategoryPlot categoryplot = new CategoryPlot(boxandwhiskercategorydataset, new CategoryAxis(""), numberAxis, renderer); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangePannable(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart jFreeChart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 14), categoryplot, true); jFreeChart.removeLegend(); return jFreeChart; }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createPieChart(PieDataset dataset) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); }//from w w w .j a va 2s .c o m if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart("Pie Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java
private static JFreeChart createTsChart() { XYPlot plot = new XYPlot(); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); DateAxis domainAxis = new DateAxis(); domainAxis.setTickLabelsVisible(false); domainAxis.setLowerMargin(0.02);//from w ww.j a v a2s . co m domainAxis.setUpperMargin(0.02); plot.setDomainAxis(domainAxis); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setTickLabelsVisible(false); rangeAxis.setLowerMargin(0.02); rangeAxis.setUpperMargin(0.02); plot.setRangeAxis(rangeAxis); JFreeChart result = new JFreeChart("", null, plot, true); result.setPadding(new RectangleInsets(5, 5, 5, 5)); result.getLegend().setFrame(BlockBorder.NONE); result.getLegend().setBackgroundPaint(null); return result; }
From source file:com.jbombardier.console.charts.XYTimeChartPanel.java
public XYTimeChartPanel() { DateAxis numberaxis = new DateAxis("Time"); yAxis = new NumberAxis("Count"); yAxis.setAutoRangeIncludesZero(true); XYSplineRenderer renderer = new XYSplineRenderer(); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); xyplot = new XYPlot(xyseriescollection, numberaxis, yAxis, renderer); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.lightGray); // xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); // XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) // xyplot.getRenderer(); // xylineandshaperenderer.setBaseShapesVisible(false); // xylineandshaperenderer.setBaseShapesFilled(false); chart = new JFreeChart("Running threads", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); /*/*from ww w . j a v a 2 s . com*/ * ValueMarker valuemarker1 = new ValueMarker(175D); * valuemarker1.setLabelOffsetType(LengthAdjustmentType.EXPAND); * valuemarker1.setPaint(Color.red); valuemarker1.setLabel("Target Price"); * valuemarker1.setLabelAnchor(RectangleAnchor.TOP_RIGHT); * valuemarker1.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); * xyplot.addRangeMarker(valuemarker1); */ LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); // ChartUtilities.applyCurrentTheme(chart); setLayout(new BorderLayout()); jFreeChartPanel = new ChartPanel(chart); jFreeChartPanel.setMinimumDrawHeight(0); jFreeChartPanel.setMinimumDrawWidth(0); jFreeChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); jFreeChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); add(jFreeChartPanel, BorderLayout.CENTER); JPanel controls = new JPanel(new MigLayout("gap 0, ins 0", "[grow,center,fill]", "[grow,center]")); final JCheckBox checkbox = new JCheckBox("Auto-scale"); checkbox.setSelected(true); checkbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleAutoscroll(checkbox.isSelected()); } }); checkbox.setHorizontalAlignment(SwingConstants.RIGHT); controls.add(checkbox, "cell 0 0,alignx center"); add(controls, BorderLayout.SOUTH); }
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.RealisierungLineChart.java
private JFreeChart createProgressChart(Object dataset) { final double plotGap = 10.0; final int axisUpperBoundPadding = 50; final int labelFontSize = 10; XYDataset data1 = (XYDataset) dataset; XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis(Messages.RealisierungLineChart_1); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis(Messages.RealisierungLineChart_2)); plot.setGap(plotGap);/*from w w w . ja v a 2 s . c om*/ plot.add(subplot1, 1); plot.setOrientation(PlotOrientation.VERTICAL); CountMassnahmen command = new CountMassnahmen(); try { command = ServiceFactory.lookupCommandService().executeCommand(command); } catch (CommandException e) { ExceptionUtil.log(e, Messages.RealisierungLineChart_3); } int totalNum = command.getTotalCount(); NumberAxis axis = (NumberAxis) subplot1.getRangeAxis(); axis.setUpperBound(totalNum + axisUpperBoundPadding); ValueMarker bst = new ValueMarker(totalNum); bst.setPaint(Color.GREEN); bst.setLabel(Messages.RealisierungLineChart_4); bst.setLabelAnchor(RectangleAnchor.LEFT); bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, labelFontSize)); //$NON-NLS-1$ bst.setLabelTextAnchor(TextAnchor.CENTER_LEFT); subplot1.addRangeMarker(bst, Layer.BACKGROUND); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart(Messages.RealisierungLineChart_6, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.spantus.exp.segment.exec.DrawSegmentComparision.java
/** * initialize/* w ww. j av a 2 s .co m*/ */ public void init() { final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time")); plot.setGap(10.0); plot.setOrientation(PlotOrientation.VERTICAL); XYSeries[] seriesArr = createSeries(getWavName(), getMarkerName()); for (XYSeries series : seriesArr) { final XYSeriesCollection data1 = new XYSeriesCollection(series); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis(series.getDescription()); final XYPlot subplot = new XYPlot(data1, null, rangeAxis1, renderer1); plot.add(subplot, 1); } final JFreeChart chart = new JFreeChart("Segmentation Result", JFreeChart.DEFAULT_TITLE_FONT, plot, false); final ChartPanel chartPanel = new ChartPanel(chart); setContentPane(chartPanel); chartPanel.setPreferredSize(new Dimension(500, 270)); }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.EICPlot.java
public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info, List<NavigableMap<Double, Double>> modelPeaks) { super(null, true); setBackground(Color.white);//from w ww .ja va 2 s .c o m setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberAxis xAxis = new NumberAxis("Retention Time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); NumberAxis yAxis = new NumberAxis("Intensity"); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new XYSeriesCollection(); colorDataset = new ArrayList<>(); toolTips = new ArrayList<>(); int seriesID = 0; for (int i = 0; i < clusters.size(); ++i) { List<NavigableMap<Double, Double>> cluster = clusters.get(i); double color = colors.get(i); for (int j = 0; j < cluster.size(); ++j) { XYSeries series = new XYSeries(seriesID++); for (Entry<Double, Double> e : cluster.get(j).entrySet()) series.add(e.getKey(), e.getValue()); xyDataset.addSeries(series); colorDataset.add(color); toolTips.add(info.get(i).get(j)); } } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() { @Override public Paint getItemPaint(int row, int col) { double c = colorDataset.get(row); return Color.getHSBColor((float) c, 1.0f, 1.0f); } }; renderer.setDefaultShapesVisible(false); renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { try { return toolTips.get(series); } catch (NullPointerException | IndexOutOfBoundsException e) { return ""; } } }); XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); }
From source file:com.bt.aloha.batchtest.Chart.java
private JFreeChart createCombinedChart(XYDataset xydataset1, String titleX1, String labelX1, String labelY1, XYDataset xydataset2, String titleX2, String labelX2, String labelY2) { CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("threads")); combineddomainxyplot.setGap(10D);/*from w w w . j a v a 2 s . co m*/ combineddomainxyplot.add(createChart(xydataset1, titleX1, labelX1, labelY1).getXYPlot(), 1); combineddomainxyplot.add(createChart(xydataset2, titleX2, labelX2, labelY2).getXYPlot(), 1); combineddomainxyplot.setOrientation(PlotOrientation.VERTICAL); return new JFreeChart("Historical", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true); }
From source file:playground.dgrether.analysis.charts.DgModalSplitQuantilesChart.java
public JFreeChart createChart() { CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel); valueAxis.setRange(0.0, 102.0);/*from w w w.ja v a2s.c om*/ DgColorScheme colorScheme = new DgColorScheme(); CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(categoryAxis); plot.setRangeAxis(valueAxis); plot.setDataset(0, this.dataset); BarRenderer carRenderer = new BarRenderer(); carRenderer.setSeriesPaint(0, colorScheme.COLOR1A); carRenderer.setSeriesPaint(1, colorScheme.COLOR3A); carRenderer.setItemMargin(0.10); plot.setRenderer(0, carRenderer); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.removeLegend(); return chart; }