List of usage examples for org.jfree.chart.plot XYPlot setDomainAxis
public void setDomainAxis(ValueAxis axis)
From source file:playground.dgrether.linkanalysis.DgCountPerIterationGraph.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Iteration"); xAxis.setRange(this.controllerConfig.getFirstIteration(), this.controllerConfig.getLastIteration() + 2); ValueAxis yAxis = this.axisBuilder.createValueAxis("Trips"); // yAxis.setRange(-0.05, 0.3); // xAxis.setVisible(false); // xAxis.setFixedAutoRange(1.0); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis);/*www .j av a 2 s .c om*/ plot.setDataset(0, this.dataset); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); for (int i = 0; i < this.dataset.getSeriesCount(); i++) { renderer2.setSeriesItemLabelsVisible(i, true); renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f)); renderer2.setSeriesStroke(i, new BasicStroke(2.0f)); renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a")); } // renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator); // renderer2.setSeriesStroke(1, new BasicStroke(2.0f)); // renderer2.setSeriesOutlineStroke(1, new BasicStroke(3.0f)); // renderer2.setSeriesPaint(1, colorScheme.getColor(2, "a")); plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); // chart.removeLegend(); return chart; }
From source file:org.codehaus.mojo.chronos.chart.HistoryChartGenerator.java
public final void createThroughputChart(HistoricSamples samples, String dataId) throws IOException { XYPlot xyplot = newPlot(samples.getThroughput(dataId), "chronos.label.throughput.requests", true); xyplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); xyplot.getRenderer().setSeriesPaint(0, Color.GREEN); String timeLabel = bundle.getString("chronos.label.throughput.historytime"); DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat()); xyplot.setDomainAxis(timeAxis); JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.throughput"), xyplot); renderer.renderChart("history-throughput-" + dataId, chart); }
From source file:org.gvsig.remotesensing.profiles.gui.ZProfileOptionsPanel.java
public GraphicChartPanel getJPanelChart() { jPanelChart.cleanChart();/*from w w w . j a va 2 s. com*/ XYPlot plot = jPanelChart.getChart().getChart().getXYPlot(); NumberAxis domainAxis = new NumberAxis(PluginServices.getText(this, "bandas")); domainAxis.setRange(1, getGrid().getBandCount()); domainAxis.setTickUnit(new NumberTickUnit(1.0)); plot.setDomainAxis(domainAxis); return jPanelChart; }
From source file:org.jfree.chart.demo.MarkerDemo1.java
/** * Creates a sample chart.//from w ww .j a va 2s.c o m * * @param data the sample data. * * @return A configured chart. */ private JFreeChart createChart(final XYDataset data) { final JFreeChart chart = ChartFactory.createScatterPlot("Marker Demo 1", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); // chart.getLegend().setAnchor(Legend.EAST); // customise... final XYPlot plot = chart.getXYPlot(); plot.getRenderer().setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); // set axis margins to allow space for marker labels... final DateAxis domainAxis = new DateAxis("Time"); domainAxis.setUpperMargin(0.50); plot.setDomainAxis(domainAxis); final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.30); rangeAxis.setLowerMargin(0.50); // add a labelled marker for the bid start price... final Marker start = new ValueMarker(200.0); start.setPaint(Color.green); start.setLabel("Bid Start Price"); start.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); start.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addRangeMarker(start); // add a labelled marker for the target price... final Marker target = new ValueMarker(175.0); target.setPaint(Color.red); target.setLabel("Target Price"); target.setLabelAnchor(RectangleAnchor.TOP_RIGHT); target.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); plot.addRangeMarker(target); // add a labelled marker for the original closing time... final Hour hour = new Hour(2, new Day(22, 5, 2003)); double millis = hour.getFirstMillisecond(); final Marker originalEnd = new ValueMarker(millis); originalEnd.setPaint(Color.orange); originalEnd.setLabel("Original Close (02:00)"); originalEnd.setLabelAnchor(RectangleAnchor.TOP_LEFT); originalEnd.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(originalEnd); // add a labelled marker for the current closing time... final Minute min = new Minute(15, hour); millis = min.getFirstMillisecond(); final Marker currentEnd = new ValueMarker(millis); currentEnd.setPaint(Color.red); currentEnd.setLabel("Close Date (02:15)"); currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT); currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT); plot.addDomainMarker(currentEnd); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // label the best bid with an arrow and label... final Hour h = new Hour(2, new Day(22, 5, 2003)); final Minute m = new Minute(10, h); millis = m.getFirstMillisecond(); final CircleDrawer cd = new CircleDrawer(Color.red, new BasicStroke(1.0f), null); final XYAnnotation bestBid = new XYDrawableAnnotation(millis, 163.0, 11, 11, cd); plot.addAnnotation(bestBid); final XYPointerAnnotation pointer = new XYPointerAnnotation("Best Bid", millis, 163.0, 3.0 * Math.PI / 4.0); pointer.setBaseRadius(35.0); pointer.setTipRadius(10.0); pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); pointer.setPaint(Color.blue); pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); plot.addAnnotation(pointer); return chart; }
From source file:playground.dgrether.signalsystems.analysis.DgGreenSplitPerIterationGraph.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Iteration"); xAxis.setRange(this.controllerConfig.getFirstIteration(), this.controllerConfig.getLastIteration() + 2); ValueAxis yAxis = this.axisBuilder.createValueAxis("GreenTime"); // yAxis.setRange(-0.05, 0.3); // xAxis.setVisible(false); // xAxis.setFixedAutoRange(1.0); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis);//w w w .jav a 2 s . c om DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); renderer2.setSeriesItemLabelsVisible(0, true); // renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator); plot.setDataset(0, this.getDataset()); renderer2.setSeriesStroke(0, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f)); renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a")); renderer2.setSeriesStroke(1, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(1, new BasicStroke(3.0f)); renderer2.setSeriesPaint(1, colorScheme.getColor(2, "a")); renderer2.setSeriesStroke(2, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(2, new BasicStroke(3.0f)); renderer2.setSeriesPaint(2, colorScheme.getColor(3, "a")); renderer2.setSeriesStroke(3, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(3, new BasicStroke(3.0f)); renderer2.setSeriesPaint(3, colorScheme.getColor(4, "a")); plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); // chart.removeLegend(); return chart; }
From source file:org.jfree.chart.demo.DifferenceChartDemo.java
/** * Creates a chart./*from w w w. j a v a2s .c o m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Difference Chart Demo", "Time", "Value", dataset, true, // legend true, // tool tips false // URLs ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setRenderer(new XYDifferenceRenderer(Color.green, Color.red, false)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final ValueAxis domainAxis = new DateAxis("Time"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); plot.setForegroundAlpha(0.5f); return chart; }
From source file:com.marvelution.jira.plugins.hudson.charts.BuildResultsRatioChartGenerator.java
/** * {@inheritDoc}//from w ww . j a v a 2s. co m */ @Override public ChartHelper generateChart() { final Map<Integer, Build> buildMap = new HashMap<Integer, Build>(); final CategoryTableXYDataset dataSet = new CategoryTableXYDataset(); for (Build build : builds) { buildMap.put(Integer.valueOf(build.getBuildNumber()), build); dataSet.add(Double.valueOf(build.getBuildNumber()), Double.valueOf(build.getDuration()), getI18n().getText("hudson.charts.duration")); } final JFreeChart chart = ChartFactory.createXYBarChart("", "", false, getI18n().getText("hudson.charts.duration"), dataSet, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); final BuildResultRenderer renderer = new BuildResultRenderer(server, buildMap); renderer.setBaseItemLabelFont(ChartDefaults.defaultFont); renderer.setBaseItemLabelsVisible(false); renderer.setMargin(0.0D); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBaseToolTipGenerator(renderer); renderer.setURLGenerator(renderer); final XYPlot xyPlot = chart.getXYPlot(); xyPlot.setAxisOffset(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D)); xyPlot.setRenderer(renderer); final NumberAxis domainAxis = new NumberAxis(); domainAxis.setLowerBound(Collections.min(buildMap.keySet())); domainAxis.setUpperBound(Collections.max(buildMap.keySet())); final TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); domainAxis.setStandardTickUnits(ticks); xyPlot.setDomainAxis(domainAxis); final DateAxis rangeAxis = new DateAxis(); final DurationFormat durationFormat = new DurationFormat(); rangeAxis.setDateFormatOverride(durationFormat); rangeAxis.setLabel(getI18n().getText("hudson.charts.duration")); xyPlot.setRangeAxis(rangeAxis); ChartUtil.setupPlot(xyPlot); return new ChartHelper(chart); }
From source file:org.matsim.contrib.freight.usecases.analysis.LegHistogram.java
private JFreeChart getGraphic(final ModeData modeData, final String modeName) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries departuresSerie = new XYSeries("departures", false, true); final XYSeries arrivalsSerie = new XYSeries("arrivals", false, true); final XYSeries onRouteSerie = new XYSeries("en route", false, true); int onRoute = 0; for (int i = 0; i < modeData.countsDep.length; i++) { onRoute = onRoute + modeData.countsDep[i] - modeData.countsArr[i] - modeData.countsStuck[i]; double hour = i * this.binSize / 60.0 / 60.0; departuresSerie.add(hour, modeData.countsDep[i]); arrivalsSerie.add(hour, modeData.countsArr[i]); onRouteSerie.add(hour, onRoute); }//w w w .jav a 2 s . co m xyData.addSeries(departuresSerie); xyData.addSeries(arrivalsSerie); xyData.addSeries(onRouteSerie); final JFreeChart chart = ChartFactory.createXYStepChart( "Leg Histogram, " + modeName + ", it." + this.iteration, "time", "# vehicles", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); return chart; }
From source file:juicebox.windowui.QCDialog.java
public QCDialog(MainWindow mainWindow, HiC hic, String title) { super(mainWindow); Dataset dataset = hic.getDataset();//from w w w . ja v a 2s . c o m String text = dataset.getStatistics(); String textDescription = null; String textStatistics = null; String graphs = dataset.getGraphs(); JTextPane description = null; JTabbedPane tabbedPane = new JTabbedPane(); HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("table { border-collapse: collapse;}"); styleSheet.addRule("body {font-family: Sans-Serif; font-size: 12;}"); styleSheet.addRule("td { padding: 2px; }"); styleSheet.addRule( "th {border-bottom: 1px solid #000; text-align: left; background-color: #D8D8D8; font-weight: normal;}"); if (text != null) { int split = text.indexOf("</table>") + 8; textDescription = text.substring(0, split); textStatistics = text.substring(split); description = new JTextPane(); description.setEditable(false); description.setContentType("text/html"); description.setEditorKit(kit); description.setText(textDescription); tabbedPane.addTab("About Library", description); JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setContentType("text/html"); textPane.setEditorKit(kit); textPane.setText(textStatistics); JScrollPane pane = new JScrollPane(textPane); tabbedPane.addTab("Statistics", pane); } boolean success = true; if (graphs != null) { long[] A = new long[2000]; long sumA = 0; long[] mapq1 = new long[201]; long[] mapq2 = new long[201]; long[] mapq3 = new long[201]; long[] intraCount = new long[100]; final XYSeries intra = new XYSeries("Intra Count"); final XYSeries leftRead = new XYSeries("Left"); final XYSeries rightRead = new XYSeries("Right"); final XYSeries innerRead = new XYSeries("Inner"); final XYSeries outerRead = new XYSeries("Outer"); final XYSeries allMapq = new XYSeries("All MapQ"); final XYSeries intraMapq = new XYSeries("Intra MapQ"); final XYSeries interMapq = new XYSeries("Inter MapQ"); Scanner scanner = new Scanner(graphs); try { while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 2000; idx++) { A[idx] = scanner.nextLong(); sumA += A[idx]; } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 201; idx++) { mapq1[idx] = scanner.nextInt(); mapq2[idx] = scanner.nextInt(); mapq3[idx] = scanner.nextInt(); } for (int idx = 199; idx >= 0; idx--) { mapq1[idx] = mapq1[idx] + mapq1[idx + 1]; mapq2[idx] = mapq2[idx] + mapq2[idx + 1]; mapq3[idx] = mapq3[idx] + mapq3[idx + 1]; allMapq.add(idx, mapq1[idx]); intraMapq.add(idx, mapq2[idx]); interMapq.add(idx, mapq3[idx]); } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 100; idx++) { int tmp = scanner.nextInt(); if (tmp != 0) innerRead.add(logXAxis[idx], tmp); intraCount[idx] = tmp; tmp = scanner.nextInt(); if (tmp != 0) outerRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) rightRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) leftRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; if (idx > 0) intraCount[idx] += intraCount[idx - 1]; if (intraCount[idx] != 0) intra.add(logXAxis[idx], intraCount[idx]); } } catch (NoSuchElementException exception) { JOptionPane.showMessageDialog(getParent(), "Graphing file improperly formatted", "Error", JOptionPane.ERROR_MESSAGE); success = false; } if (success) { final XYSeriesCollection readTypeCollection = new XYSeriesCollection(); readTypeCollection.addSeries(innerRead); readTypeCollection.addSeries(outerRead); readTypeCollection.addSeries(leftRead); readTypeCollection.addSeries(rightRead); final JFreeChart readTypeChart = ChartFactory.createXYLineChart("Types of reads vs distance", // chart title "Distance (log)", // domain axis label "Binned Reads (log)", // range axis label readTypeCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Binned Reads (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel = new ChartPanel(readTypeChart); final XYSeriesCollection reCollection = new XYSeriesCollection(); final XYSeries reDistance = new XYSeries("Distance"); for (int i = 0; i < A.length; i++) { if (A[i] != 0) reDistance.add(i, A[i] / (float) sumA); } reCollection.addSeries(reDistance); final JFreeChart reChart = ChartFactory.createXYLineChart( "Distance from closest restriction enzyme site", // chart title "Distance (bp)", // domain axis label "Fraction of Reads (log)", // range axis label reCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot rePlot = reChart.getXYPlot(); rePlot.setDomainAxis(new NumberAxis("Distance (bp)")); rePlot.setRangeAxis(new LogarithmicAxis("Fraction of Reads (log)")); rePlot.setBackgroundPaint(Color.white); rePlot.setRangeGridlinePaint(Color.lightGray); rePlot.setDomainGridlinePaint(Color.lightGray); reChart.setBackgroundPaint(Color.white); rePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel2 = new ChartPanel(reChart); final XYSeriesCollection intraCollection = new XYSeriesCollection(); intraCollection.addSeries(intra); final JFreeChart intraChart = ChartFactory.createXYLineChart("Intra reads vs distance", // chart title "Distance (log)", // domain axis label "Cumulative Sum of Binned Reads (log)", // range axis label intraCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot intraPlot = intraChart.getXYPlot(); intraPlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); intraPlot.setRangeAxis(new NumberAxis("Cumulative Sum of Binned Reads (log)")); intraPlot.setBackgroundPaint(Color.white); intraPlot.setRangeGridlinePaint(Color.lightGray); intraPlot.setDomainGridlinePaint(Color.lightGray); intraChart.setBackgroundPaint(Color.white); intraPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel3 = new ChartPanel(intraChart); final XYSeriesCollection mapqCollection = new XYSeriesCollection(); mapqCollection.addSeries(allMapq); mapqCollection.addSeries(intraMapq); mapqCollection.addSeries(interMapq); final JFreeChart mapqChart = ChartFactory.createXYLineChart("MapQ Threshold Count", // chart title "MapQ threshold", // domain axis label "Count", // range axis label mapqCollection, // data PlotOrientation.VERTICAL, true, // include legend true, // include tooltips false); final XYPlot mapqPlot = mapqChart.getXYPlot(); mapqPlot.setBackgroundPaint(Color.white); mapqPlot.setRangeGridlinePaint(Color.lightGray); mapqPlot.setDomainGridlinePaint(Color.lightGray); mapqChart.setBackgroundPaint(Color.white); mapqPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel4 = new ChartPanel(mapqChart); tabbedPane.addTab("Pair Type", chartPanel); tabbedPane.addTab("Restriction", chartPanel2); tabbedPane.addTab("Intra vs Distance", chartPanel3); tabbedPane.addTab("MapQ", chartPanel4); } } final ExpectedValueFunction df = hic.getDataset().getExpectedValues(hic.getZoom(), hic.getNormalizationType()); if (df != null) { double[] expected = df.getExpectedValues(); final XYSeriesCollection collection = new XYSeriesCollection(); final XYSeries expectedValues = new XYSeries("Expected"); for (int i = 0; i < expected.length; i++) { if (expected[i] > 0) expectedValues.add(i + 1, expected[i]); } collection.addSeries(expectedValues); String title1 = "Expected at " + hic.getZoom() + " norm " + hic.getNormalizationType(); final JFreeChart readTypeChart = ChartFactory.createXYLineChart(title1, // chart title "Distance between reads (log)", // domain axis label "Genome-wide expected (log)", // range axis label collection, // data PlotOrientation.VERTICAL, false, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance between reads (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Genome-wide expected (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel5 = new ChartPanel(readTypeChart); tabbedPane.addTab("Expected", chartPanel5); } if (text == null && graphs == null) { JOptionPane.showMessageDialog(this, "Sorry, no metrics are available for this dataset", "Error", JOptionPane.ERROR_MESSAGE); setVisible(false); dispose(); } else { getContentPane().add(tabbedPane); pack(); setModal(false); setLocation(100, 100); setTitle(title); setVisible(true); } }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createXYAreaChart(String xAxisLabel, String yAxisLabel, XYDataset dataset, boolean includeLegend) { JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true);/* w w w .j a va2 s . c om*/ xyplot.setBackgroundPaint(null); xyplot.setOutlinePaint(null); xyplot.setForegroundAlpha(0.8F); xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY); DateAxis dateaxis = new DateAxis(xAxisLabel); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); rangeAxis.setRangeType(RangeType.POSITIVE); rangeAxis.setLabelFont(UIConstants.H5_FONT); rangeAxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0)); if (includeLegend) { LegendTitle legendtitle = new LegendTitle(xyplot); legendtitle.setItemFont(UIConstants.H5_FONT); legendtitle.setBackgroundPaint(UIConstants.INTEL_WHITE); legendtitle.setFrame(new BlockBorder(UIConstants.INTEL_BLUE)); legendtitle.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.99999999999999998D, legendtitle, RectangleAnchor.TOP_RIGHT); // xytitleannotation.setMaxWidth(0.47999999999999998D); xyplot.addAnnotation(xytitleannotation); } XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(1, UIConstants.INTEL_DARK_GRAY); xyitemrenderer.setSeriesPaint(0, NodeTypeViz.SWITCH.getColor()); xyitemrenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator("<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>", Util.getHHMMSS(), new DecimalFormat("#,##0.00"))); return jfreechart; }