Java Code Examples for org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setSeriesPaint()
The following examples show how to use
org.jfree.chart.renderer.xy.XYLineAndShapeRenderer#setSeriesPaint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseIndicatorBox.java From TAcharting with GNU Lesser General Public License v2.1 | 6 votes |
public void loadMVWAPIndicator(String key) throws XPathException{ int timeFrameMVWAP = Integer.parseInt(parameter.getParameter(key, "Time Frame VWAP")); int timeFrameVWAP = Integer.parseInt(parameter.getParameter(key, "Time Frame MVWAP")); VWAPIndicator vwap = new VWAPIndicator(series.get(),timeFrameVWAP); MVWAPIndicator mvwap = new MVWAPIndicator(vwap,timeFrameMVWAP); List<Indicator> ilVwap = new ArrayList<>(); List<String> nlVwap = new ArrayList<>(); XYLineAndShapeRenderer wapRenderer = createRenderer(key, "Color MVWAP", "Shape MVWAP", "Stroke MVWAP"); Color vwapColor = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color VWAP")); StrokeType vwapStroke = StrokeType.valueOf(parameter.getParameter(key, "Stroke VWAP")); ShapeType vwapShape = ShapeType.valueOf(parameter.getParameter(key, "Shape VWAP")); wapRenderer.setSeriesPaint(1, vwapColor); wapRenderer.setSeriesStroke(1, vwapStroke.stroke); wapRenderer.setSeriesShape(1, vwapShape.shape); IndicatorCategory category = parameter.getCategory(key); ChartType chartType = parameter.getChartType(key); ilVwap.add(mvwap); ilVwap.add(vwap); nlVwap.add(String.format("%s [%s] (%s)",getIdentifier(key), getID(key), timeFrameMVWAP)); nlVwap.add(String.format("%s [%s] (%s)","VWAP", getID(key), timeFrameVWAP)); addChartIndicator(key, ilVwap, nlVwap,"MVWAP/VWAP ",wapRenderer, chartType.toBoolean(), category); }
Example 2
Source File: DomLineChart.java From DominionSim with MIT License | 5 votes |
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart( myType.equals("VP")? "Average Victory Points gained/turn" : "Average $ generated/turn", // chart title "turns", // x axis label myType.equals("VP")? "VP gained" : "available money", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // chart.setBackgroundPaint(Color.darkGray); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0,Color.black); renderer.setSeriesPaint(1,Color.blue); renderer.setSeriesPaint(2,Color.red); renderer.setSeriesPaint(3,Color.cyan); renderer.setBaseShapesVisible(true); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // domainAxis.setTickUnit( new NumberTickUnit( 1 ) ); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // rangeAxis.setTickUnit( new NumberTickUnit( 1 ) ); return chart; }
Example 3
Source File: BaseIndicatorBox.java From TAcharting with GNU Lesser General Public License v2.1 | 5 votes |
public void loadAverageDirectionalMovementUP_DOWN(String key) throws XPathExpressionException { Color color1 = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Up")); StrokeType stroke1 = StrokeType.valueOf(parameter.getParameter(key, "Stroke Up")); ShapeType shape1 = ShapeType.valueOf(parameter.getParameter(key,"Shape Up")); Color color2 = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Down")); StrokeType stroke2 = StrokeType.valueOf(parameter.getParameter(key, "Stroke Down")); ShapeType shape2 = ShapeType.valueOf(parameter.getParameter(key,"Shape Down")); ChartType chartType = ChartType.valueOf(parameter.getParameter(key, "Chart Type")); IndicatorCategory category = parameter.getCategory(key); int timeFrameUp = Integer.parseInt(parameter.getParameter(key, "Time Frame Up")); int timeFrameDown = Integer.parseInt(parameter.getParameter(key, "Time Frame Up")); List<Indicator> ilAdx = new ArrayList<>(); List<String> nlAdx = new ArrayList<>(); ilAdx.add(new ADXIndicator(series.get(), timeFrameDown)); ilAdx.add(new ADXIndicator(series.get(), timeFrameDown)); nlAdx.add("ADX UP "+timeFrameUp); nlAdx.add("ADX Down "+timeFrameUp); XYLineAndShapeRenderer adxRenderer = new XYLineAndShapeRenderer(); adxRenderer.setSeriesPaint(0, color1); adxRenderer.setSeriesStroke(0, stroke1.stroke); adxRenderer.setSeriesShape(0, shape1.shape); adxRenderer.setSeriesPaint(1, color2); adxRenderer.setSeriesStroke(1, stroke2.stroke); adxRenderer.setSeriesShape(1, shape2.shape); addChartIndicator(key, ilAdx, nlAdx, String.format("%s [%s] (%s, %s)", getIdentifier(key), getID(key), timeFrameUp, timeFrameDown ), adxRenderer, chartType.toBoolean(), category); }
Example 4
Source File: LiquidityChartBuilder.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
/** * @param forecast * @param settings (next days) * @return */ public JFreeChart createXYPlot(final LiquidityForecast forecast, final LiquidityForecastSettings settings) { Validate.isTrue(settings.getNextDays() > 0 && settings.getNextDays() < 500); final LiquidityForecastCashFlow cashFlow = new LiquidityForecastCashFlow(forecast, settings.getNextDays()); final TimeSeries accumulatedSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.forecast.dueDate")); final TimeSeries accumulatedSeriesExpected = new TimeSeries( PFUserContext.getLocalizedString("plugins.liquidityplanning.forecast.expected")); final TimeSeries worstCaseSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.forecast.worstCase")); double accumulatedExpected = settings.getStartAmount().doubleValue(); double accumulated = accumulatedExpected; double worstCase = accumulated; final DayHolder dh = new DayHolder(); final Date lower = dh.getDate(); for (int i = 0; i < settings.getNextDays(); i++) { if (log.isDebugEnabled() == true) { log.debug("day: " + i + ", credits=" + cashFlow.getCredits()[i] + ", debits=" + cashFlow.getDebits()[i]); } final Day day = new Day(dh.getDayOfMonth(), dh.getMonth() + 1, dh.getYear()); if (i > 0) { accumulated += cashFlow.getDebits()[i - 1].doubleValue() + cashFlow.getCredits()[i - 1].doubleValue(); accumulatedExpected += cashFlow.getDebitsExpected()[i - 1].doubleValue() + cashFlow.getCreditsExpected()[i - 1].doubleValue(); worstCase += cashFlow.getCredits()[i - 1].doubleValue(); } accumulatedSeries.add(day, accumulated); accumulatedSeriesExpected.add(day, accumulatedExpected); worstCaseSeries.add(day, worstCase); dh.add(Calendar.DATE, 1); } dh.add(Calendar.DATE, -1); final XYChartBuilder cb = new XYChartBuilder(null, null, null, null, true); int counter = 0; final TimeSeriesCollection xyDataSeries = new TimeSeriesCollection(); xyDataSeries.addSeries(accumulatedSeries); xyDataSeries.addSeries(worstCaseSeries); final XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); lineRenderer.setSeriesPaint(0, Color.BLACK); lineRenderer.setSeriesVisibleInLegend(0, true); lineRenderer.setSeriesPaint(1, cb.getGrayMarker()); lineRenderer.setSeriesStroke(1, cb.getDashedStroke()); lineRenderer.setSeriesVisibleInLegend(1, true); cb.setRenderer(counter, lineRenderer).setDataset(counter++, xyDataSeries); final TimeSeriesCollection accumulatedSet = new TimeSeriesCollection(); accumulatedSet.addSeries(accumulatedSeriesExpected); final XYDifferenceRenderer diffRenderer = new XYDifferenceRenderer(cb.getGreenFill(), cb.getRedFill(), true); diffRenderer.setSeriesPaint(0, cb.getRedMarker()); cb.setRenderer(counter, diffRenderer).setDataset(counter++, accumulatedSet) .setStrongStyle(diffRenderer, false, accumulatedSeriesExpected); diffRenderer.setSeriesVisibleInLegend(0, true); cb.setDateXAxis(true).setDateXAxisRange(lower, dh.getDate()).setYAxis(true, null); return cb.getChart(); }
Example 5
Source File: Scatterplot.java From chipster with MIT License | 4 votes |
@Override public JComponent getVisualisation(DataBean data) throws Exception { this.data = data; refreshAxisBoxes(data); List<Variable> vars = getFrame().getVariables(); if (vars == null || vars.size() < 2) { if (xBox.getItemCount() >= 1) { xBox.setSelectedIndex(0); } if (yBox.getItemCount() >= 2) { yBox.setSelectedIndex(1); } else { yBox.setSelectedIndex(0); } } else { xBox.setSelectedItem(vars.get(0)); yBox.setSelectedItem(vars.get(1)); } xVar = (Variable) xBox.getSelectedItem(); yVar = (Variable) yBox.getSelectedItem(); PlotDescription description = new PlotDescription(data.getName(), xVar.getName(), yVar.getName()); NumberAxis domainAxis = new NumberAxis(description.xTitle); domainAxis.setAutoRangeIncludesZero(false); NumberAxis rangeAxis = new NumberAxis(description.yTitle); rangeAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLinesVisible(false); renderer.setShapesVisible(true); renderer.setShape(new Ellipse2D.Float(-2, -2, 4, 4)); renderer.setSeriesPaint(1, Color.black); plot = new XYPlot(new XYSeriesCollection(), domainAxis, rangeAxis, renderer); this.updateSelectionsFromApplication(false); //Calls also updateXYSerieses(); JFreeChart chart = new JFreeChart(description.plotTitle, plot); application.addClientEventListener(this); selectableChartPanel = new SelectableChartPanel(chart, this); return selectableChartPanel; }
Example 6
Source File: AdminJFreeChartController.java From Spring-MVC-Blueprints with MIT License | 4 votes |
private String createXYLineChart(HttpSession session, String title, String xtitle, String ytitle, int width, int height, String useMap, PrintWriter pw) { XYDataset xydataset = getXYDataset(); String filename = ""; JFreeChart chart = ChartFactory.createXYLineChart(title, xtitle, ytitle, xydataset, PlotOrientation.VERTICAL, true, true, true); chart.setTitle(new TextTitle(title, new Font("Calibri", Font.ITALIC, 12))); chart.getTitle().setFont(new Font("Calibri", Font.PLAIN, 12)); chart.setBackgroundPaint(Color.white); /* final XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); final ValueAxis categoryAxis = xyplot.getDomainAxis(); // categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); categoryAxis.setLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12)); categoryAxis.setTickLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12)); NumberAxis numberAxis = (NumberAxis) xyplot.getRangeAxis(); numberAxis.setLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12)); numberAxis.setTickLabelFont(new Font("Calibri", Font.TYPE1_FONT, 12)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberAxis.setAutoRangeIncludesZero(true); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot .getRenderer(); xylineandshaperenderer.setShapesVisible(true); xylineandshaperenderer.setShapesFilled(true); xylineandshaperenderer.setSeriesLinesVisible(0, false); xylineandshaperenderer.setSeriesShapesVisible(1, false); xyplot.setRenderer(xylineandshaperenderer); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 10F, 6F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 6F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 2.0F, 6F }, 0.0F)); xylineandshaperenderer .setBaseItemLabelGenerator(new IntervalXYItemLabelGenerator( "({1},{2})", NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance())); xylineandshaperenderer.setURLGenerator(new StandardXYURLGenerator( "/hrms/admin_charts", "seriesName", "itemName")); xylineandshaperenderer.setLegendTextFont(0, new Font("Calibri", Font.TYPE1_FONT, 12)); xylineandshaperenderer.setLegendTextFont(1, new Font("Calibri", Font.TYPE1_FONT, 12)); xylineandshaperenderer.setLegendTextFont(2, new Font("Calibri", Font.TYPE1_FONT, 12)); */ final XYPlot plot = chart.getXYPlot( ); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( ); renderer.setSeriesPaint( 0 , Color.RED ); renderer.setSeriesPaint( 1 , Color.GREEN ); renderer.setSeriesPaint( 2 , Color.YELLOW ); renderer.setSeriesStroke( 0 , new BasicStroke( 4.0f ) ); renderer.setSeriesStroke( 1 , new BasicStroke( 3.0f ) ); renderer.setSeriesStroke( 2 , new BasicStroke( 2.0f ) ); plot.setRenderer( renderer ); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); try { filename = ServletUtilities.saveChartAsPNG(chart, width, height, info, session); ChartUtilities.writeImageMap(pw, useMap, info, false); pw.flush(); } catch (IOException e) { e.printStackTrace(); } return filename; }
Example 7
Source File: BaseIndicatorBox.java From TAcharting with GNU Lesser General Public License v2.1 | 4 votes |
public void loadKeltner(String key) throws XPathException{ int timeFrame = Integer.parseInt(parameter.getParameter(key, "Time Frame")); double ratio = Double.valueOf(parameter.getParameter(key, "Ratio")); int atr = Integer.parseInt(parameter.getParameter(key, "Time Frame ATR")); Color colorU = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Upper")); StrokeType strokeU = StrokeType.valueOf(parameter.getParameter(key, "Stroke Upper")); ShapeType shapeU = ShapeType.valueOf(parameter.getParameter(key,"Shape Upper")); Color colorL = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Lower")); StrokeType strokeL = StrokeType.valueOf(parameter.getParameter(key, "Stroke Lower")); ShapeType shapeL = ShapeType.valueOf(parameter.getParameter(key,"Shape Lower")); ChartType chartType = ChartType.valueOf(parameter.getParameter(key, "Chart Type")); IndicatorCategory category = parameter.getCategory(key); XYLineAndShapeRenderer renderer = createRenderer(key, "Color Middle", "Shape Middle", "Stroke Middle"); renderer.setSeriesStroke(1, strokeU.stroke); renderer.setSeriesStroke(2, strokeL.stroke); renderer.setSeriesShape(1, shapeU.shape); renderer.setSeriesShape(2, shapeL.shape); renderer.setSeriesPaint(1, colorU); renderer.setSeriesPaint(2, colorL); KeltnerChannelMiddleIndicator kcM = new KeltnerChannelMiddleIndicator(series.get(), timeFrame); KeltnerChannelUpperIndicator kcU = new KeltnerChannelUpperIndicator(kcM,ratio,atr); KeltnerChannelLowerIndicator kcL = new KeltnerChannelLowerIndicator(kcM,ratio,atr); List<Indicator> ilKelt = new ArrayList<>(); List<String> nlKelt = new ArrayList<>(); ilKelt.add(kcM); ilKelt.add(kcU); ilKelt.add(kcL); nlKelt.add("Keltner Middle"); nlKelt.add("Keltner Upper"); nlKelt.add("Keltner Lower"); addChartIndicator(key, ilKelt, nlKelt, String.format("%s [%s] (%s, %s, %S)", getIdentifier(key), getID(key), timeFrame, ratio, atr), renderer, chartType.toBoolean(), category); }
Example 8
Source File: BaseIndicatorBox.java From TAcharting with GNU Lesser General Public License v2.1 | 4 votes |
public void loadMACDIndicator(String key) throws XPathExpressionException { int timeFrameShort = Integer.parseInt(parameter.getParameter(key, "Time Frame Short")); int timeFrameLong = Integer.parseInt(parameter.getParameter(key, "Time Frame Long")); IndicatorCategory category = parameter.getCategory(key); ChartType chartType = parameter.getChartType(key); boolean signalLine = Boolean.valueOf(parameter.getParameter(key, "Add Signal Line")); XYLineAndShapeRenderer renderer = createRenderer(key, "Color", "Shape", "Stroke"); MACDIndicator mcd = new MACDIndicator(closePriceIndicator.get(), timeFrameShort, timeFrameLong); if(!signalLine){ addChartIndicator(key, mcd, String.format("%s [%s] (%s, %s)",getIdentifier(key), getID(key), timeFrameShort,timeFrameLong), renderer, chartType.toBoolean(), category); } else{ int timeFrameSignal = Integer.parseInt(parameter.getParameter(key, "Time Frame Signal Line")); List<String> names = new ArrayList<>(); List<Indicator> indicators = new ArrayList<>(); indicators.add(mcd); indicators.add(new EMAIndicator(mcd, timeFrameSignal)); names.add(String.format("%s [%s] (%s, %s)",getIdentifier(key), getID(key), timeFrameShort,timeFrameLong)); names.add(String.format("Signal Line [%s] (%s)",getID(key),timeFrameSignal)); Color color = ConverterUtils.ColorAWTConverter.fromString(parameter.getParameter(key, "Color Signal Line")); ShapeType shape = ShapeType.valueOf(parameter.getParameter(key, "Shape Signal Line")); StrokeType stroke = StrokeType.valueOf(parameter.getParameter(key, "Stroke Signal Line")); renderer.setSeriesPaint(1,color); renderer.setSeriesShape(1,shape.shape); renderer.setSeriesStroke(1, stroke.stroke); addChartIndicator(key, indicators, names, String.format("%s [%s] (%s, %s)",getIdentifier(key), getID(key), timeFrameShort,timeFrameLong), renderer, chartType.toBoolean(), category); } }
Example 9
Source File: LiquidityChartBuilder.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
/** * @param forecast * @param settings (next days) * @return */ public JFreeChart createBarChart(final LiquidityForecast forecast, final LiquidityForecastSettings settings) { Validate.isTrue(settings.getNextDays() > 0 && settings.getNextDays() < 500); final LiquidityForecastCashFlow cashFlow = new LiquidityForecastCashFlow(forecast, settings.getNextDays()); final TimeSeries accumulatedSeriesExpected = new TimeSeries(I18n.getString("plugins.liquidityplanning.forecast.expected")); final TimeSeries creditSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.common.credit")); final TimeSeries debitSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.common.debit")); double accumulatedExpected = settings.getStartAmount().doubleValue(); final DayHolder dh = new DayHolder(); final Date lower = dh.getDate(); for (int i = 0; i < settings.getNextDays(); i++) { final Day day = new Day(dh.getDayOfMonth(), dh.getMonth() + 1, dh.getYear()); if (i > 0) { accumulatedExpected += cashFlow.getDebitsExpected()[i - 1].doubleValue() + cashFlow.getCreditsExpected()[i - 1].doubleValue(); } accumulatedSeriesExpected.add(day, accumulatedExpected); creditSeries.add(day, cashFlow.getCreditsExpected()[i].doubleValue()); debitSeries.add(day, cashFlow.getDebitsExpected()[i].doubleValue()); dh.add(Calendar.DATE, 1); } dh.add(Calendar.DATE, -1); final XYChartBuilder cb = new XYChartBuilder(ChartFactory.createXYBarChart(null, null, false, null, null, PlotOrientation.VERTICAL, false, false, false)); int counter = 0; final TimeSeriesCollection xyDataSeries = new TimeSeriesCollection(); xyDataSeries.addSeries(accumulatedSeriesExpected); final XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, true); lineRenderer.setSeriesPaint(0, cb.getRedMarker()); lineRenderer.setSeriesVisibleInLegend(0, true); cb.setRenderer(counter, lineRenderer).setDataset(counter++, xyDataSeries) .setStrongStyle(lineRenderer, false, accumulatedSeriesExpected); final TimeSeriesCollection cashflowSet = new TimeSeriesCollection(); cashflowSet.addSeries(debitSeries); cashflowSet.addSeries(creditSeries); final XYBarRenderer barRenderer = new XYBarRenderer(.2); barRenderer.setSeriesPaint(0, cb.getGreenFill()); barRenderer.setSeriesPaint(1, cb.getRedFill()); barRenderer.setShadowVisible(false); cb.setRenderer(counter, barRenderer).setDataset(counter++, cashflowSet); cb.setDateXAxis(true).setDateXAxisRange(lower, dh.getDate()).setYAxis(true, null); return cb.getChart(); }
Example 10
Source File: Volcanoplot.java From chipster with MIT License | 4 votes |
@Override public JComponent getVisualisation(DataBean data) throws Exception { this.data = data; refreshAxisBoxes(data); List<Variable> vars = getFrame().getVariables(); // If this a redraw from the settings panel, use asked columns if (vars != null && vars.size() == 2) { xBox.setSelectedItem(vars.get(0)); yBox.setSelectedItem(vars.get(1)); } xVar = (Variable) xBox.getSelectedItem(); yVar = (Variable) yBox.getSelectedItem(); PlotDescription description = new PlotDescription(data.getName(), "fold change (log2)", "-log(p)"); NumberAxis domainAxis = new NumberAxis(description.xTitle); NumberAxis rangeAxis = new NumberAxis(description.yTitle); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLinesVisible(false); renderer.setShapesVisible(true); renderer.setSeriesPaint(0, Color.green); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesPaint(2, Color.black); renderer.setSeriesPaint(3, Color.lightGray); renderer.setShape(new Ellipse2D.Float(-2, -2, 4, 4)); plot = new XYPlot(new XYSeriesCollection(), domainAxis, rangeAxis, renderer); this.updateSelectionsFromApplication(false); // rounding limit is calculated in updateSelectionsFromApplication plot.getRangeAxis().setRange(new Range(0, -Math.log10(ROUNDING_LIMIT))); JFreeChart chart = new JFreeChart(description.plotTitle, plot); chart.removeLegend(); application.addClientEventListener(this); selectableChartPanel = new SelectableChartPanel(chart, this); return selectableChartPanel; }
Example 11
Source File: AnomalyGraphGenerator.java From incubator-pinot with Apache License 2.0 | 4 votes |
/** * Creates a chart containing the current/baseline data (in that order) as well as markers for * each anomaly interval. timeGranularity and windowMillis are used to determine the date format * and spacing for tick marks on the domain (x) axis. */ public JFreeChart createChart(final XYDataset dataset, final String metric, final TimeGranularity timeGranularity, final long windowMillis, final Map<MergedAnomalyResultDTO, String> anomaliesWithLabels) { // create the chart... final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // no chart title for email // image "Date (" + DEFAULT_TIME_ZONE.getID() + ")", // x axis label metric, // y axis label dataset, // data true, // include legend false, // tooltips - n/a if the chart will be saved as an img false // urls - n/a if the chart will be saved as an img ); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // dashboard webapp currently uses solid blue for current and dashed blue for baseline // (5/2/2016) final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesPaint(0, Color.BLUE); renderer.setSeriesPaint(1, Color.BLUE); // http://www.java2s.com/Code/Java/Chart/JFreeChartLineChartDemo5showingtheuseofacustomdrawingsupplier.htm // set baseline to be dashed renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); plot.setRenderer(renderer); DateAxis axis = (DateAxis) plot.getDomainAxis(); DateTickUnit dateTickUnit = getDateTickUnit(timeGranularity, windowMillis); SimpleDateFormat dateFormat = getDateFormat(timeGranularity); axis.setDateFormatOverride(dateFormat); axis.setTickUnit(dateTickUnit); axis.setVerticalTickLabels(true); List<Marker> anomalyIntervals = getAnomalyIntervals(anomaliesWithLabels); for (Marker marker : anomalyIntervals) { plot.addDomainMarker(marker); } return chart; }
Example 12
Source File: TimeSeriesChartFXDemo1.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "International Coffee Organisation : Coffee Prices", // title null, // x-axis label "US cents/lb", // y-axis label dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setDefaultShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setDefaultStroke(new BasicStroke(3.0f)); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
Example 13
Source File: FXGraphics2DDemo1.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "International Coffee Organisation : Coffee Prices", // title null, // x-axis label "US cents/lb", // y-axis label dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setDefaultShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); renderer.setDefaultLegendTextFont(new Font(fontName, Font.PLAIN, 14)); } return chart; }
Example 14
Source File: AlignmentRansacPlot.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public AlignmentRansacPlot() { super(null, true); dataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart("", null, null, dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // legend constructed by ChartFactory legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // set default renderer properties XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setDefaultLinesVisible(false); renderer.setDefaultShapesVisible(true); renderer.setSeriesShape(0, dataPointsShape); renderer.setSeriesShape(1, dataPointsShape); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GRAY); renderer.setSeriesPaint(2, Color.BLUE); renderer.setDefaultItemLabelPaint(labelsColor); renderer.setDrawSeriesLineAsPath(true); plot.setRenderer(renderer); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 15
Source File: GraphPlot.java From NSGA-II with MIT License | 4 votes |
public void configurePlotter(final String x_axis, final String y_axis) { JFreeChart xyLineChart = ChartFactory.createXYLineChart(GraphPlot.GRAPH_TITLE, x_axis, y_axis, GraphPlot.DATASET, PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(xyLineChart); chartPanel.setPreferredSize(new java.awt.Dimension(GraphPlot.DIMENSION_X, GraphPlot.DIMENSION_Y)); final XYPlot plot = xyLineChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, GraphPlot.COLOR); renderer.setSeriesStroke(0, new BasicStroke(GraphPlot.STROKE_THICKNESS)); plot.setRenderer(renderer); setContentPane(chartPanel); }
Example 16
Source File: GrammarvizRuleChartPanel.java From grammarviz2_src with GNU General Public License v2.0 | 4 votes |
/** * Create the chart for the original time series. * * @return a JFreeChart object of the chart * @throws TSException */ private void chartIntervals(ArrayList<double[]> intervals) throws Exception { // making the data // XYSeriesCollection collection = new XYSeriesCollection(); int counter = 0; for (double[] series : intervals) { collection.addSeries(toSeries(counter++, series)); } // set the renderer // XYLineAndShapeRenderer xyRenderer = new XYLineAndShapeRenderer(true, false); xyRenderer.setSeriesPaint(0, new Color(0, 0, 0)); xyRenderer.setBaseStroke(new BasicStroke(3)); // X - the time axis // NumberAxis timeAxis = new NumberAxis(); // Y axis // NumberAxis valueAxis = new NumberAxis(); // put these into collection of dots // this.plot = new XYPlot(collection, timeAxis, valueAxis, xyRenderer); // enable panning // this.plot.setDomainPannable(true); this.plot.setRangePannable(true); // finally, create the chart this.chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); // and put it on the show ChartPanel chartPanel = new ChartPanel(this.chart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawWidth(1920); chartPanel.setMaximumDrawHeight(1200); chartPanel.setMouseWheelEnabled(true); // cleanup all the content // this.removeAll(); // put the chart on show // this.add(chartPanel); // not sure if I need this // this.validate(); this.repaint(); }
Example 17
Source File: TrafficLoadLineChart.java From EdgeSim with MIT License | 4 votes |
public TrafficLoadLineChart() { this.collection = this.getCollection(); initial(); this.chart = ChartFactory.createXYLineChart( null, "Time Slice", "Traffic Load(100GB)", collection, PlotOrientation.VERTICAL, true, true, false ); this.chart.getPlot().setBackgroundPaint(SystemColor.white); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis(); numberAxisX.setAutoRangeIncludesZero(false); numberAxisX.setAutoRangeMinimumSize(0.1); numberAxisX.setAxisLineVisible(false); numberAxisX.setTickMarkInsideLength(4f); numberAxisX.setTickMarkOutsideLength(0); NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis(); numberAxisY.setTickUnit(new NumberTickUnit(5)); numberAxisY.setRangeWithMargins(0,40); numberAxisY.setAutoRangeIncludesZero(true); numberAxisY.setAxisLineVisible(false); numberAxisY.setTickMarkInsideLength(4f); numberAxisY.setTickMarkOutsideLength(0); numberAxisY.setNumberFormatOverride(NumberFormat.getNumberInstance()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer)plot.getRenderer(); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultShapesVisible(true); renderer.setDrawOutlines(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(1, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(2, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(3, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(4, new BasicStroke(5F)); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesPaint(2, new Color(53,101,253)); renderer.setSeriesPaint(3, new Color(0,161,59));//����ɫ renderer.setSeriesPaint(4, new Color(148,103,189));//��ɫ renderer.setSeriesPaint(0, new Color(255,125,11));//�ٻ�ɫ renderer.setSeriesStroke(0, new BasicStroke(4.0F)); renderer.setSeriesStroke(1, new BasicStroke(4.0F)); renderer.setSeriesStroke(2, new BasicStroke(4.0F)); renderer.setSeriesStroke(3, new BasicStroke(4.0F)); renderer.setSeriesStroke(4, new BasicStroke(2.0F)); renderer.setSeriesStroke(5, new BasicStroke(2.0F)); // renderer.setUseFillPaint(true); this.chartFrame = new ChartFrame("Line Chart", chart); chartFrame.pack(); chartFrame.setSize(1600,1200); chartFrame.setLocation(300,200); chartFrame.setVisible(true); }
Example 18
Source File: BaseLineChart.java From EdgeSim with MIT License | 4 votes |
protected void generateLineChart(String xAisTitle, String yAisTitle, NumberTickUnit xAisSpace, NumberTickUnit yAisSpace, double yaisMinValue, double yAisMaxValue, XYSeriesCollection collection) { this.chart = ChartFactory.createXYLineChart(null, xAisTitle, yAisTitle, collection, PlotOrientation.VERTICAL, true, true, false); this.chart.getPlot().setBackgroundPaint(SystemColor.white); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis(); numberAxisX.setAutoRangeIncludesZero(false); numberAxisX.setTickUnit(xAisSpace); numberAxisX.setAxisLineVisible(false); numberAxisX.setTickMarkInsideLength(4f); numberAxisX.setTickMarkOutsideLength(0); NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis(); numberAxisY.setTickUnit(yAisSpace); numberAxisY.setRangeWithMargins(yaisMinValue, yAisMaxValue); numberAxisY.setAutoRangeIncludesZero(true); numberAxisY.setAxisLineVisible(false); numberAxisY.setTickMarkInsideLength(4f); numberAxisY.setTickMarkOutsideLength(0); numberAxisY.setNumberFormatOverride(NumberFormat.getNumberInstance()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot .getRenderer(); // renderer.setBaseItemLabelsVisible(true); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultShapesVisible(true); // renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(1, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(2, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(3, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(4, new BasicStroke(5F)); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesPaint(2, new Color(255, 125, 11)); renderer.setSeriesPaint(3, new Color(0, 161, 59)); renderer.setSeriesPaint(4, new Color(148, 103, 189)); renderer.setSeriesStroke(0, new BasicStroke(4.0F)); renderer.setSeriesStroke(1, new BasicStroke(4.0F)); renderer.setSeriesStroke(2, new BasicStroke(4.0F)); renderer.setSeriesStroke(3, new BasicStroke(4.0F)); renderer.setSeriesStroke(4, new BasicStroke(2.0F)); renderer.setSeriesStroke(5, new BasicStroke(2.0F)); // renderer.setUseFillPaint(true); this.chartFrame = new ChartFrame("Line Chart", chart); chartFrame.pack(); chartFrame.setSize(800, 600); chartFrame.setLocation(300, 200); chartFrame.setVisible(true); }
Example 19
Source File: TimeSeriesChartFXDemo1.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "International Coffee Organisation : Coffee Prices", // title null, // x-axis label "US cents/lb", // y-axis label dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
Example 20
Source File: AlignmentRansacPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public AlignmentRansacPlot() { super(ChartFactory.createXYLineChart("", null, null, new XYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false)); chart = this.getChart(); chart.setBackgroundPaint(Color.white); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // legend constructed by ChartFactory legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); dataset = (XYSeriesCollection) plot.getDataset(); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // set default renderer properties XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setDefaultLinesVisible(false); renderer.setDefaultShapesVisible(true); renderer.setSeriesShape(0, dataPointsShape); renderer.setSeriesShape(1, dataPointsShape); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GRAY); renderer.setSeriesPaint(2, Color.BLUE); renderer.setDefaultItemLabelPaint(labelsColor); renderer.setDrawSeriesLineAsPath(true); plot.setRenderer(renderer); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }