List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:com.romraider.logger.ecu.ui.tab.DynoChartPanel.java
private void configurePlot(JFreeChart chart) { plot = chart.getXYPlot(); plot.setOutlinePaint(DARK_GREY);/* ww w.ja v a 2 s.c om*/ plot.setBackgroundPaint(BLACK); // X axis settings plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.getDomainAxis().setLabelPaint(WHITE); plot.getDomainAxis().setTickLabelPaint(LIGHT_GREY); plot.setDomainGridlinePaint(DARK_GREY); // Y1 axis (left) settings hpAxis.setLabel(labelY1); hpAxis.setLabelPaint(BLUE); hpAxis.setTickLabelPaint(LIGHT_GREY); hpAxis.setAutoRangeIncludesZero(false); hpAxis.setAutoRange(true); plot.setRangeAxis(0, hpAxis); plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToRangeAxis(2, 0); // Y2 axis (right) settings tqAxis.setLabel(labelY2); tqAxis.setLabelPaint(YELLOW); tqAxis.setTickLabelPaint(LIGHT_GREY); tqAxis.setAutoRangeIncludesZero(false); tqAxis.setAutoRange(true); plot.setRangeAxis(1, tqAxis); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.mapDatasetToRangeAxis(1, 1); plot.mapDatasetToRangeAxis(3, 1); plot.setRangeGridlinePaint(DARK_GREY); refStat.setPaint(WHITE); refStat.setTextAnchor(TextAnchor.TOP_LEFT); refStat.setFont(new Font("SansSerif", Font.BOLD, 12)); }
From source file:edu.ucla.stat.SOCR.chart.demo.XYBarChartDemo1.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, true, rangeLabel, dataset, PlotOrientation.VERTICAL, !legendPanelOn, true, false); // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); renderer.setBaseToolTipGenerator(generator); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setLowerMargin(0.01);/*from w ww . j a va2 s. c o m*/ axis.setUpperMargin(0.01); // setXSummary(dataset); X is time return chart; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.explore.EnclosingBallController.java
public void plotXYBalls(TrackDataHolder trackDataHolder) { int selectedIndexRadius = exploreTrackController.getExploreTrackPanel().getEnclosingBallRadiusCombobox() .getSelectedIndex();// ww w . j av a 2 s .com List<List<EnclosingBall>> enclosingBallsList = trackDataHolder.getStepCentricDataHolder() .getxYEnclosingBalls(); List<EnclosingBall> enclosingBalls = enclosingBallsList.get(selectedIndexRadius); // get the coordinates matrix Double[][] coordinatesMatrix = trackDataHolder.getStepCentricDataHolder().getCoordinatesMatrix(); XYSeries xYSeries = JFreeChartUtils.generateXYSeries(coordinatesMatrix); String seriesKey = "track " + trackDataHolder.getTrack().getTrackNumber() + ", well " + trackDataHolder.getTrack().getWellHasImagingType().getWell(); xYSeries.setKey(seriesKey); XYSeriesCollection ySeriesCollection = new XYSeriesCollection(xYSeries); JFreeChart chart = ChartFactory.createXYLineChart(seriesKey + " - enclosing balls", "x (m)", "y (m)", ySeriesCollection, PlotOrientation.VERTICAL, false, true, false); XYPlot xyPlot = chart.getXYPlot(); JFreeChartUtils.setupXYPlot(xyPlot); JFreeChartUtils.setupSingleTrackPlot(chart, exploreTrackController.getExploreTrackPanel().getTracksList().getSelectedIndex(), true); XYSeriesCollection dataset = (XYSeriesCollection) xyPlot.getDataset(0); double minY = dataset.getSeries(0).getMinY(); double maxY = dataset.getSeries(0).getMaxY(); xyPlot.getRangeAxis().setRange(minY - 10, maxY + 10); xYBallsChartPanel.setChart(chart); enclosingBalls.stream().forEach((ball) -> { xyPlot.addAnnotation(new XYShapeAnnotation(ball.getShape(), JFreeChartUtils.getDashedLine(), GuiUtils.getDefaultColor())); }); }
From source file:clientv2.GUI.java
/** * Creates a chart//from ww w .j a v a 2 s. c o m * * @param TS * @param GraphName * @return */ public JFreeChart createChart(TimeSeriesCollection TS, String GraphName, double minRange, double maxRange) { JFreeChart chart = ChartFactory.createTimeSeriesChart(GraphName, "Time", "Value", TS, true, true, false); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); plot.getRangeAxis().setRange(minRange, maxRange); plot.setBackgroundPaint(WHITE); plot.setDomainMinorGridlinePaint(BLACK); plot.setDomainGridlinePaint(BLACK); plot.setRangeMinorGridlinePaint(BLACK); plot.setRangeGridlinesVisible(true); axis.setFixedAutoRange(20000.0); return chart; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.explore.EnclosingBallController.java
public void plotXTBalls(TrackDataHolder trackDataHolder) { int selectedIndexEpsilon = exploreTrackController.getExploreTrackPanel().getEnclosingBallEpsCombobox() .getSelectedIndex();//from w w w . j a va 2 s.c o m List<List<EnclosingBall>> xtEnclosingBallList = trackDataHolder.getStepCentricDataHolder() .getxTEnclosingBalls(); List<EnclosingBall> xTempBalls = xtEnclosingBallList.get(selectedIndexEpsilon); // get the track coordinates matrix and transpose it Double[][] transpose2DArray = AnalysisUtils .transpose2DArray(trackDataHolder.getStepCentricDataHolder().getCoordinatesMatrix()); // we get the x coordinates and the time information double[] xCoordinates = ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(transpose2DArray[0])); double[] timeIndexes = trackDataHolder.getStepCentricDataHolder().getTimeIndexes(); // we create the series and set its key XYSeries xtSeries = JFreeChartUtils.generateXYSeries(timeIndexes, xCoordinates); String seriesKey = "track " + trackDataHolder.getTrack().getTrackNumber() + ", well " + trackDataHolder.getTrack().getWellHasImagingType().getWell(); xtSeries.setKey(seriesKey); // we then create the XYSeriesCollection and use it to make a new line chart XYSeriesCollection xtSeriesCollection = new XYSeriesCollection(xtSeries); JFreeChart chart = ChartFactory.createXYLineChart(seriesKey + " - enclosing balls", "time", "x (m)", xtSeriesCollection, PlotOrientation.VERTICAL, false, true, false); XYPlot xyPlot = chart.getXYPlot(); xyPlot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis yaxis = (NumberAxis) xyPlot.getRangeAxis(); yaxis.setAutoRangeIncludesZero(false); JFreeChartUtils.setupXYPlot(xyPlot); JFreeChartUtils.setupSingleTrackPlot(chart, exploreTrackController.getExploreTrackPanel().getTracksList().getSelectedIndex(), true); xTBallsChartPanel.setChart(chart); xTempBalls.stream().forEach((ball) -> { xyPlot.addAnnotation(new XYShapeAnnotation(ball.getShape(), JFreeChartUtils.getDashedLine(), GuiUtils.getDefaultColor())); }); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.explore.EnclosingBallController.java
public void plotYTBalls(TrackDataHolder trackDataHolder) { int selectedIndexEpsilon = exploreTrackController.getExploreTrackPanel().getEnclosingBallEpsCombobox() .getSelectedIndex();/*from w w w. ja v a 2 s . c om*/ List<List<EnclosingBall>> ytEnclosingBallList = trackDataHolder.getStepCentricDataHolder() .getyTEnclosingBalls(); List<EnclosingBall> yTempBalls = ytEnclosingBallList.get(selectedIndexEpsilon); // get the track coordinates matrix and transpose it Double[][] transpose2DArray = AnalysisUtils .transpose2DArray(trackDataHolder.getStepCentricDataHolder().getCoordinatesMatrix()); // we get the y coordinates and the time information double[] yCoordinates = ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(transpose2DArray[1])); double[] timeIndexes = trackDataHolder.getStepCentricDataHolder().getTimeIndexes(); // we create the series and set its key XYSeries ytSeries = JFreeChartUtils.generateXYSeries(timeIndexes, yCoordinates); String seriesKey = "track " + trackDataHolder.getTrack().getTrackNumber() + ", well " + trackDataHolder.getTrack().getWellHasImagingType().getWell(); ytSeries.setKey(seriesKey); // we then create the XYSeriesCollection and use it to make a new line chart XYSeriesCollection ytSeriesCollection = new XYSeriesCollection(ytSeries); JFreeChart chart = ChartFactory.createXYLineChart(seriesKey + " - enclosing balls", "time", "y (m)", ytSeriesCollection, PlotOrientation.VERTICAL, false, true, false); XYPlot xyPlot = chart.getXYPlot(); xyPlot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis yaxis = (NumberAxis) xyPlot.getRangeAxis(); yaxis.setAutoRangeIncludesZero(false); JFreeChartUtils.setupXYPlot(xyPlot); JFreeChartUtils.setupSingleTrackPlot(chart, exploreTrackController.getExploreTrackPanel().getTracksList().getSelectedIndex(), true); yTBallsChartPanel.setChart(chart); yTempBalls.stream().forEach((ball) -> { xyPlot.addAnnotation(new XYShapeAnnotation(ball.getShape(), JFreeChartUtils.getDashedLine(), GuiUtils.getDefaultColor())); }); }
From source file:playground.dgrether.analysis.categoryhistogram.CategoryHistogramWriter.java
public JFreeChart getGraphic(final CategoryHistogram histo, final String modeName) { this.checkIndex(histo); final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries departuresSerie = new XYSeries(this.departuresName, false, true); final XYSeries arrivalsSerie = new XYSeries(this.arrivalsName, false, true); final XYSeries onRouteSerie = new XYSeries(this.enRouteName, false, true); Integer enRoute = 0;//ww w. j a v a 2 s . co m for (int i = histo.getFirstIndex() - 2; i <= histo.getLastIndex() + 2; i++) { int departures = histo.getDepartures(modeName, i); int arrivals = histo.getArrivals(modeName, i); int stuck = histo.getAbort(modeName, i); enRoute = enRoute + departures - arrivals - stuck; double hour = i * histo.getBinSizeSeconds() / 60.0 / 60.0; departuresSerie.add(hour, departures); arrivalsSerie.add(hour, arrivals); onRouteSerie.add(hour, enRoute); } xyData.addSeries(departuresSerie); xyData.addSeries(arrivalsSerie); xyData.addSeries(onRouteSerie); final JFreeChart chart = ChartFactory.createXYStepChart( this.title + ", " + modeName + ", " + "it." + histo.getIteration(), "time [h]", yTitle, 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(1.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(1.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); return chart; }
From source file:playground.christoph.evacuation.analysis.AgentsInEvacuationAreaActivityWriter.java
/** * @return a graphic showing the number of agents in the evacuated area *//*w w w.j a v a2 s . c o m*/ private JFreeChart getGraphic(int[] activities, int[] activitiesParticipatingAtHome, int[] activitiesParticipatingNotAtHome, int[] activitiesNotParticipatingAtHome, int[] activitiesNotParticipatingNotAtHome) { final XYSeriesCollection xyData = new XYSeriesCollection(); XYSeries dataSerie; dataSerie = new XYSeries("total activity performing agents in evacuated area", false, true); for (int i = 0; i < activities.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activities[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("participating agents performing a home activity in evacuated area", false, true); for (int i = 0; i < activitiesParticipatingAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesParticipatingAtHome[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("participating agents performing an other activity in evacuated area", false, true); for (int i = 0; i < activitiesParticipatingNotAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesParticipatingNotAtHome[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("not participating agents performing a home activity in evacuated area", false, true); for (int i = 0; i < activitiesNotParticipatingAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesNotParticipatingAtHome[i]); } xyData.addSeries(dataSerie); dataSerie = new XYSeries("not participating agents performing an other activity in evacuated area", false, true); for (int i = 0; i < activitiesNotParticipatingNotAtHome.length; i++) { double hour = i * this.binSize / 60.0 / 60.0; dataSerie.add(hour, activitiesNotParticipatingNotAtHome[i]); } xyData.addSeries(dataSerie); final JFreeChart chart = ChartFactory.createXYStepChart( "activity performing agents in evacuated area, it." + this.iteration, "time", "# agents", 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")); return chart; }
From source file:se.six.jmeter.visualizer.statagg.StatAggVisualizer.java
private JFreeChart createChart() { setupDatasets();// w w w.ja va 2s . c o m final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "ThroughPut", _dataSet1, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); //axis.setFixedAutoRange(12 * 3600 * 1000); // 12 Hours XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.BLACK); final NumberAxis axis2 = new NumberAxis("Response Time"); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, _dataSet2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, new Color(0, 153, 255)); plot.setRenderer(1, renderer2); chart.setBackgroundPaint(Color.white); return chart; }
From source file:chart.JChart.java
/** * Creates a sample chart./*from w w w.ja va 2 s . co m*/ * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset, List<NSubsequence> anomalies) { final JFreeChart chart = ChartFactory.createXYLineChart("Test", "Time", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); // plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // final XYItemRenderer renderer = plot.getRenderer(); MyRender renderer = new MyRender(dataset, anomalies); plot.setRenderer(renderer); renderer.setSeriesShapesVisible(0, false); chart.setBackgroundPaint(Color.white); // DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("S")); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); return chart; }