List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer setSeriesPaint
public void setSeriesPaint(int series, Paint paint);
From source file:greenapi.ui.charts.LineChartPanelSupport.java
public void setSeriesPaint(Color paramColor, BasicStroke paramBasicStroke) { XYItemRenderer localXYItemRenderer = getPlot().getRenderer(); for (int i = 0; i < this.getTimeSeries().getSeriesCount(); i++) { localXYItemRenderer.setSeriesPaint(i, paramColor); localXYItemRenderer.setSeriesStroke(i, paramBasicStroke); }/* ww w .j a v a 2 s .com*/ }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createCultureTagChart() { JFreeChart chart = ChartFactory.createXYLineChart("Culture Tag Time Series", "Time", "Fraction Blue", model.culture_tag_coll, PlotOrientation.VERTICAL, true, true, false); model.culture_tag_chart = chart;/* ww w . ja v a 2 s . co m*/ NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); return chart; }
From source file:classpackage.ChartGalaxy.java
private static JFreeChart createChart(final XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("MDS Galaxy", "X", "Y", createDataset(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new LabelGenerator()); renderer.setBaseItemLabelPaint(Color.WHITE);//label renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); renderer.setBaseItemLabelFont(renderer.getBaseItemLabelFont().deriveFont(15f)); renderer.setBaseItemLabelsVisible(true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); //set false para linhas no grafico xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeGridlinesVisible(false); xyPlot.setRangeMinorGridlinesVisible(false); xyPlot.setRangeCrosshairVisible(false); xyPlot.setRangeCrosshairLockedOnData(false); xyPlot.setRangeZeroBaselineVisible(false); xyPlot.setBackgroundPaint(Color.BLACK); double size = 40.0; double delta = size / 2.0; Shape shape = new Rectangle2D.Double(-delta, -delta, size, size); renderer.setSeriesShape(0, shape);//w w w . j a v a 2s . co m renderer.setSeriesPaint(0, transparent); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(-0.1, 0.1); domain.setTickUnit(new NumberTickUnit(0.1)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setRange(-0.1, 0.1); range.setTickUnit(new NumberTickUnit(0.1)); return jfreechart; }
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);/*from ww w . j a v a 2 s . com*/ 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; }
From source file:org.matsim.pt.analysis.RouteTimeDiagram.java
public void createGraph(final String filename, final TransitRoute route) { HashMap<Id, Integer> stopIndex = new HashMap<Id, Integer>(); int idx = 0;/*w w w .jav a2 s .c o m*/ for (TransitRouteStop stop : route.getStops()) { stopIndex.put(stop.getStopFacility().getId(), idx); idx++; } HashSet<Id> vehicles = new HashSet<Id>(); for (Departure dep : route.getDepartures().values()) { vehicles.add(dep.getVehicleId()); } XYSeriesCollection dataset = new XYSeriesCollection(); int numSeries = 0; double earliestTime = Double.POSITIVE_INFINITY; double latestTime = Double.NEGATIVE_INFINITY; for (Map.Entry<Id, List<Tuple<Id, Double>>> entry : this.positions.entrySet()) { if (vehicles.contains(entry.getKey())) { XYSeries series = new XYSeries("t", false, true); for (Tuple<Id, Double> pos : entry.getValue()) { Integer stopIdx = stopIndex.get(pos.getFirst()); if (stopIdx != null) { double time = pos.getSecond().doubleValue(); series.add(stopIdx.intValue(), time); if (time < earliestTime) { earliestTime = time; } if (time > latestTime) { latestTime = time; } } } dataset.addSeries(series); numSeries++; } } JFreeChart c = ChartFactory.createXYLineChart("Route-Time Diagram, Route = " + route.getId(), "stops", "time", dataset, PlotOrientation.VERTICAL, false, // legend? false, // tooltips? false // URLs? ); c.setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f)); XYPlot p = (XYPlot) c.getPlot(); p.getRangeAxis().setInverted(true); p.getRangeAxis().setRange(earliestTime, latestTime); XYItemRenderer renderer = p.getRenderer(); for (int i = 0; i < numSeries; i++) { renderer.setSeriesPaint(i, Color.black); } try { ChartUtilities.saveChartAsPNG(new File(filename), c, 1024, 768, null, true, 9); } catch (IOException e) { e.printStackTrace(); } }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createEvolution() { JFreeChart chart = ChartFactory.createXYLineChart("Evolution of Mean Agent Vision and Metabolism", "Time", "Level", model.evolution_vision_coll, PlotOrientation.VERTICAL, true, true, false); model.evolution_chart = chart;//from w w w . j a v a 2 s .c o m NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); plot.setDataset(1, model.evolution_metabolism_coll); renderer.setSeriesPaint(1, Color.BLUE); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createTradeChart() { JFreeChart chart = ChartFactory.createXYLineChart("Trading and Population over Time", "Time", "Level", model.agents_series_coll, PlotOrientation.VERTICAL, true, true, false); model.trade_chart = chart;// w w w .j a v a2s. c o m NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLUE); plot.setDataset(1, model.trade_coll); XYItemRenderer rend2 = new StandardXYItemRenderer(); //if (rend2 != null) rend2.setSeriesPaint(1, Color.BLACK); plot.setRenderer(1, rend2); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createAgeHistoChart() { JFreeChart chart = ChartFactory.createHistogram("Age Distribution", "Age", "Count", model.age_hist_dataset, PlotOrientation.VERTICAL, true, true, false); model.age_histo_chart = chart;/*w ww .j ava2 s .co m*/ //CategoryDataset dataset1 = createDataset1(); NumberAxis rangeAxis1 = new NumberAxis("Age"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); xAxis.setRange(0, 100); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.MAGENTA); return chart; }
From source file:org.jfree.chart.demo.CompassFormatDemo.java
/** * Creates a sample chart./*from w w w . j a v a2 s .c o m*/ * * @return a sample chart. */ private JFreeChart createChart() { final XYDataset direction = createDirectionDataset(600); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", direction, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); // configure the range axis to display directions... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); final TickUnits units = new TickUnits(); units.add(new NumberTickUnit(180.0, new CompassFormat())); units.add(new NumberTickUnit(90.0, new CompassFormat())); units.add(new NumberTickUnit(45.0, new CompassFormat())); units.add(new NumberTickUnit(22.5, new CompassFormat())); rangeAxis.setStandardTickUnits(units); // add the wind force with a secondary dataset/renderer/axis plot.setRangeAxis(rangeAxis); final XYItemRenderer renderer2 = new XYAreaRenderer(); final ValueAxis axis2 = new NumberAxis("Force"); axis2.setRange(0.0, 12.0); renderer2.setSeriesPaint(0, new Color(0, 0, 255, 128)); plot.setDataset(1, createForceDataset(600)); plot.setRenderer(1, renderer2); plot.setRangeAxis(1, axis2); plot.mapDatasetToRangeAxis(1, 1); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createChart2() { JFreeChart chart2 = ChartFactory.createXYLineChart("Wealth Distribution", // the title of the chart "Time step", //"% Population", // the label for the X axis "Gini Coefficient", // % Wealththe label for the Y axis new XYSeriesCollection(model.gini_coeff), // the dataset for the chart PlotOrientation.VERTICAL, // the orientation of the chart true, // a flag specifying whether or not a legend is required true, // a flag specifying whether or not tooltips should be generated false); // a flag specifying whether or not the chart should generate URLs XYPlot plot = chart2.getXYPlot();/*from w w w . j a va2s . co m*/ ValueAxis xAxis = plot.getDomainAxis(); xAxis.setFixedDimension(100); //xAxis.setRange(0,100); //yAxis.setRange(0,1); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); //System.out.println("done creating chart"); return chart2; }