List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(String title, Font titleFont, Plot plot, boolean createLegend)
From source file:de.berlios.statcvs.xml.report.ActivityProgressionChart.java
private JFreeChart createContourPlot() { Grouper grouper = settings.getGrouper(new ModuleGrouper(settings.getModules(content))); ContourDataset data = createDataset(grouper); if (data == null) { return null; }//from w w w . ja va 2 s . c om ValueAxis xAxis = new DateAxis(I18n.tr("Date")); SymbolicAxis yAxis = new SymbolicAxis(grouper.getName(), (String[]) groupNames.toArray(new String[0])); yAxis.setInverted(true); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); ColorBar zAxis = new ColorBar(I18n.tr("Commit Activity (%)")); zAxis.getAxis(); ContourPlot plot = new ContourPlot(data, xAxis, yAxis, zAxis); //plot.setRenderAsPoints(true); // don't use plot units for ratios when x axis is date plot.setDataAreaRatio(0.0); plot.setColorBarLocation(RectangleEdge.BOTTOM); return new JFreeChart(settings.getProjectName(), null, plot, false); }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.TimeSeriesUnkownFailuresChart.java
@Override protected JFreeChart createGraph() { TimeTableXYDataset dataset = createDataset(); ValueAxis xAxis = new DateAxis(); xAxis.setLowerMargin(0.0);//from w w w . ja v a 2 s . co m xAxis.setUpperMargin(0.0); Calendar lowerBound = getLowerGraphBound(); xAxis.setRange(lowerBound.getTimeInMillis(), Calendar.getInstance().getTimeInMillis()); NumberAxis yAxis = new NumberAxis(Y_AXIS_LABEL); yAxis.setRange(0, HUNDRED_PERCENT); XYItemRenderer renderer = new XYBarRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(graphTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.removeLegend(); return chart; }
From source file:Visuals.RingChart.java
public ChartPanel drawRingChart() { DefaultPieDataset dataset = new DefaultPieDataset(); if (riskCount == 0) { dataset.setValue(noVulnerabilities, new Integer(1)); } else {//from w w w .j a v a2 s . c om if (critical > 0) dataset.setValue(criticalValue, new Integer(critical)); if (low > 0) dataset.setValue(lowValue, new Integer(low)); if (medium > 0) dataset.setValue(mediumValue, new Integer(medium)); if (high > 0) dataset.setValue(highValue, new Integer(high)); } RingPlot plot = new RingPlot(dataset); //plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); // if (tooltips) { // plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); // } if (riskCount == 0) { plot.setSectionPaint(noVulnerabilities, new Color(47, 196, 6)); } else { plot.setSectionPaint(criticalValue, new Color(230, 27, 27)); plot.setSectionPaint(highValue, new Color(230, 90, 27)); plot.setSectionPaint(mediumValue, new Color(85, 144, 176)); if (lowValue.equals("Updated (" + low + ")")) { plot.setSectionPaint(lowValue, new Color(47, 196, 6)); } else plot.setSectionPaint(lowValue, new Color(230, 219, 27)); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); CategoryItemRenderer renderer = new CustomRenderer(); renderer.setItemLabelsVisible(false); plot.setLabelLinksVisible(false); plot.setLabelGenerator(null); plot.setBackgroundPaint(new Color(210, 234, 243)); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; // if(isMain) // { // piechart.removeLegend(); // } }
From source file:be.ac.ua.comp.scarletnebula.gui.DecoratedGraph.java
/** * @see Graph/* ww w.j a v a 2 s .co m*/ */ @Override public ChartPanel getChartPanel() { final XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.darkGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setInsets(new RectangleInsets(0, 0, 0, 0)); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); if (stream.getMax() != null) { log.info("Getting chart panel for stream with maximum."); range.setAutoRange(false); range.setTickUnit(new NumberTickUnit(stream.getMax() / 10, new DecimalFormat(), 1)); range.setRange(0, stream.getMax()); } else if (stream.getType() == Type.RELATIVE) { range.setAutoRange(false); range.setTickUnit(new NumberTickUnit(0.1, new DecimalFormat(), 1)); range.setRange(0, 1); } else { double sum = 0; final List<TimedDatapoint> datapoints = stream.getRecentlyProcessedDatapoints(); range.setTickUnit( new NumberTickUnit((int) (Utils.max(datapoints).getValue() / 5) + 1, new DecimalFormat(), 1)); } final JFreeChart chart = new JFreeChart(stream.getStreamname(), new Font("SansSerif", Font.PLAIN, 20), plot, true); chart.setBackgroundPaint(Color.white); chart.removeLegend(); final ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setBorder(BorderFactory // .createBevelBorder(BevelBorder.LOWERED)); return chartPanel; }
From source file:org.spantus.exp.segment.draw.DrawDtw.java
protected JFreeChart createXYZChart() { NumberAxis xAxis = new NumberAxis("Sample"); NumberAxis yAxis = new NumberAxis("target"); List<List<Double>> data = info.getDistanceMatrix(); XYZDataset xyzset = new XYZArrayDataset(data); XYPlot plot = new XYPlot(xyzset, xAxis, yAxis, null); XYBlockRenderer r = new XYBlockRenderer(); PaintScale ps = new GrayPaintScale(min, max); // LookupPaintScale ps = new LookupPaintScale(0.0, 4.0, Color.WHITE); // ps.add(1, Color.red); // ps.add(2, Color.green); // ps.add(3, Color.gray); r.setPaintScale(ps);//from w ww . j a va 2 s .co m r.setBlockHeight(1.0f); r.setBlockWidth(1.0f); plot.setRenderer(r); JFreeChart chart = new JFreeChart("Chart Title", JFreeChart.DEFAULT_TITLE_FONT, plot, false); NumberAxis scaleAxis = new NumberAxis("Scale"); scaleAxis.setUpperBound(100); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); // PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis); // legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // legend.setPadding(new RectangleInsets(5, 5, 5, 5)); // legend.setStripWidth(50); // legend.setPosition(RectangleEdge.RIGHT); // legend.setBackgroundPaint(Color.WHITE); // chart.addSubtitle(legend); chart.setBackgroundPaint(Color.white); return chart; }
From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java
public JVMMemoryProfilerPanel() { initComponents();//from www.j av a2s .c o m profiler = new JVMMemoryProfiler(frequency); profiler.addListener(new JVMMemoryProfilerListener() { @Override public void addScore(long t, long f) { total.add(new Millisecond(), t); free.add(new Millisecond(), f); } }); total = new TimeSeries("Total Memory"); total.setMaximumItemCount(historyCount); free = new TimeSeries("Free Memory"); free.setMaximumItemCount(historyCount); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(total); dataset.addSeries(free); final DateAxis domain = new DateAxis("Time"); final NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12)); add(chartPanel, BorderLayout.CENTER); }
From source file:org.apache.qpid.disttest.charting.chartbuilder.StatisticalBarChartBuilder.java
@Override public JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { CategoryAxis xAxis = new CategoryAxis(xAxisTitle); ValueAxis yAxis = new NumberAxis(yAxisTitle); CategoryItemRenderer renderer = new StatisticalBarRenderer(); CategoryPlot plot = new CategoryPlot((StatisticalCategoryDataset) dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, new Font("Arial", Font.PLAIN, 10), plot, true); chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); return chart; }
From source file:com.googlecode.jchav.chart.MinMeanMaxChart.java
/** * Construct a new chart to display the given data. * * @param title The page id, used for the title of the chart. * @param data the data to plot.//from w w w . java 2s.com */ public MinMeanMaxChart(final String title, final SortedSet<Measurement> data) { // The renderer that does all the real work here: final MinMaxCategoryRenderer minMaxRenderer = new MinMaxCategoryRenderer(); minMaxRenderer.setObjectIcon(new FilledCircle()); // Munge the data into form JFreeChart can use: DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Measurement m : data) { // This ordering gives max=red, min=green, mean=blue dataset.addValue(m.getMaximumTime(), "max", m.getBuildId().getBuildName()); dataset.addValue(m.getAverageTime(), "mean", m.getBuildId().getBuildName()); dataset.addValue(m.getMinimumTime(), "min", m.getBuildId().getBuildName()); } // Create the plot area: final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset); plot.setRenderer(minMaxRenderer); plot.setDomainAxis(new CategoryAxis("Build")); // TO DO: i18n plot.setRangeAxis(new NumberAxis("RT")); // Build labels running diagonally under the bars of the chart. plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(false); // the legend here would be the "min", "max", "mean" strings used when created int category data set. boolean showLegend = true; // Render the chart: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); chart.setTitle(title); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); if (showLegend) { chart.getLegend().setBorder(BlockBorder.NONE); } this.setChart(chart); }
From source file:playground.yu.utils.charts.TimeScatterChart.java
private JFreeChart createChart(String title, String timeAxisLabel, String valueAxisLabel, final TimeTableXYDataset dataset) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02);/*from ww w . ja v a2 s . co m*/ NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = null; boolean tooltips = false; if (tooltips) { toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); } XYURLGenerator urlGenerator = null; boolean urls = false; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); boolean legend = true; JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; // return ChartFactory.createTimeSeriesChart(title, timeAxisLabel, // valueAxisLabel, dataset, true, // legend? // false, // tooltips? // false // URLs? // ); }
From source file:org.btrg.df.betterologist.swingui.ProjectJobSchedulingPanel.java
private JFreeChart createChart(Schedule schedule) { YIntervalSeriesCollection seriesCollection = new YIntervalSeriesCollection(); Map<Project, YIntervalSeries> projectSeriesMap = new LinkedHashMap<Project, YIntervalSeries>( schedule.getProjectList().size()); YIntervalRenderer renderer = new YIntervalRenderer(); int maximumEndDate = 0; int seriesIndex = 0; for (Project project : schedule.getProjectList()) { YIntervalSeries projectSeries = new YIntervalSeries(project.getLabel()); seriesCollection.addSeries(projectSeries); projectSeriesMap.put(project, projectSeries); renderer.setSeriesShape(seriesIndex, new Rectangle()); renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f)); seriesIndex++;/*from w w w . j a va2 s . co m*/ } for (Allocation allocation : schedule.getAllocationList()) { int startDate = allocation.getStartDate(); int endDate = allocation.getEndDate(); YIntervalSeries projectSeries = projectSeriesMap.get(allocation.getProject()); projectSeries.add(allocation.getId(), (startDate + endDate) / 2.0, startDate, endDate); maximumEndDate = Math.max(maximumEndDate, endDate); } NumberAxis domainAxis = new NumberAxis("Job"); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-0.5, schedule.getAllocationList().size() - 0.5); domainAxis.setInverted(true); NumberAxis rangeAxis = new NumberAxis("Day (start to end date)"); rangeAxis.setRange(-0.5, maximumEndDate + 0.5); XYPlot plot = new XYPlot(seriesCollection, domainAxis, rangeAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); return new JFreeChart("Project Job Scheduling", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }