List of usage examples for org.jfree.chart.axis NumberAxis setAxisLinePaint
public void setAxisLinePaint(Paint paint)
From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) {//ww w .ja va2 s.c om NumberAxis xAxis = new NumberAxis("X"); xAxis.setRange(mins[0], maxs[0]); NumberAxis yAxis = new NumberAxis("Y"); yAxis.setRange(mins[1], maxs[1]); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth((maxs[0] - mins[0]) / (nPoints - 1)); renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1)); PaintScale scale = new GrayPaintScale(0, 1.0); renderer.setPaintScale(scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); JFreeChart chart = new JFreeChart("", plot); chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false); NumberAxis scaleAxis = new NumberAxis("Probability (class 0)"); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(), scaleAxis); legend.setStripOutlineVisible(false); legend.setSubdivisionCount(20); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.red)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.LEFT); chart.addSubtitle(legend); ChartUtilities.applyCurrentTheme(chart); plot.setDataset(1, xyData); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setBaseLinesVisible(false); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo1.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setLowerMargin(0.0D);/* w w w . j a v a2s . c om*/ numberaxis.setUpperMargin(0.0D); numberaxis.setAxisLinePaint(Color.white); numberaxis.setTickMarkPaint(Color.white); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis1.setLowerMargin(0.0D); numberaxis1.setUpperMargin(0.0D); numberaxis1.setAxisLinePaint(Color.white); numberaxis1.setTickMarkPaint(Color.white); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); GrayPaintScale graypaintscale = new GrayPaintScale(-2D, 1.0D); xyblockrenderer.setPaintScale(graypaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinesVisible(false); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setOutlinePaint(Color.blue); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo1", xyplot); jfreechart.removeLegend(); NumberAxis numberaxis2 = new NumberAxis("Scale"); numberaxis2.setAxisLinePaint(Color.white); numberaxis2.setTickMarkPaint(Color.white); numberaxis2.setTickLabelFont(new Font("Dialog", 0, 7)); PaintScaleLegend paintscalelegend = new PaintScaleLegend(new GrayPaintScale(), numberaxis2); paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); paintscalelegend.setAxisOffset(5D); paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D)); paintscalelegend.setFrame(new BlockBorder(Color.red)); paintscalelegend.setPadding(new RectangleInsets(10D, 10D, 10D, 10D)); paintscalelegend.setStripWidth(10D); paintscalelegend.setPosition(RectangleEdge.RIGHT); paintscalelegend.setBackgroundPaint(new Color(120, 120, 180)); jfreechart.addSubtitle(paintscalelegend); jfreechart.setBackgroundPaint(new Color(180, 180, 250)); return jfreechart; }
From source file:org.spantus.exp.segment.draw.DrawDtw.java
protected JFreeChart createXYZChart() { NumberAxis xAxis = new NumberAxis("Sample"); NumberAxis yAxis = new NumberAxis("target"); List<List<Double>> data = info.getDistanceMatrix(); XYZDataset xyzset = new XYZArrayDataset(data); XYPlot plot = new XYPlot(xyzset, xAxis, yAxis, null); XYBlockRenderer r = new XYBlockRenderer(); PaintScale ps = new GrayPaintScale(min, max); // LookupPaintScale ps = new LookupPaintScale(0.0, 4.0, Color.WHITE); // ps.add(1, Color.red); // ps.add(2, Color.green); // ps.add(3, Color.gray); r.setPaintScale(ps);// w w w. j a va 2 s . co m r.setBlockHeight(1.0f); r.setBlockWidth(1.0f); plot.setRenderer(r); JFreeChart chart = new JFreeChart("Chart Title", JFreeChart.DEFAULT_TITLE_FONT, plot, false); NumberAxis scaleAxis = new NumberAxis("Scale"); scaleAxis.setUpperBound(100); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); // PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis); // legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // legend.setPadding(new RectangleInsets(5, 5, 5, 5)); // legend.setStripWidth(50); // legend.setPosition(RectangleEdge.RIGHT); // legend.setBackgroundPaint(Color.WHITE); // chart.addSubtitle(legend); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.jls.toolbox.math.chart.XYBarChart.java
/** * Permet de paramtrer le graphique une fois cr. *//*from w w w . j a va2 s . c o m*/ private void setChartStyle() { // Paramtrage des courbes this.plot.setBackgroundAlpha((float) 0.0); this.plot.setDomainCrosshairVisible(this.isGridXVisible); this.plot.setDomainCrosshairLockedOnData(true); this.plot.setRangeCrosshairVisible(this.isGridYVisible); this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); this.plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR); NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis(); NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis(); xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); xAxis.setAutoRange(true); xAxis.setAutoRangeIncludesZero(false); yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(false); this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR); this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR); }
From source file:com.fr3ts0n.ecu.gui.application.ObdDataPlotter.java
/** * add a new series to the graph//from ww w.j a v a 2 s . com * * @param series The new series to be added */ public synchronized void addSeries(TimeSeries series) { if (oneRangePerSeries) { // get paint for current axis/range/... Paint currPaint = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[raIndex % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]; XYPlot plot = (XYPlot) chart.getPlot(); // set dataset plot.setDataset(raIndex, new TimeSeriesCollection(series)); // ** set axis NumberAxis axis = new NumberAxis(); axis.setTickLabelFont(legendFont); axis.setAxisLinePaint(currPaint); axis.setTickLabelPaint(currPaint); axis.setTickMarkPaint(currPaint); // ** set axis in plot plot.setRangeAxis(raIndex, axis); plot.setRangeAxisLocation(raIndex, raIndex % 2 == 0 ? AxisLocation.TOP_OR_LEFT : AxisLocation.BOTTOM_OR_RIGHT); plot.mapDatasetToRangeAxis(raIndex, raIndex); // ** create renderer XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGen); renderer.setSeriesPaint(0, currPaint); // ** set renderer in plot plot.setRenderer(raIndex, renderer); raIndex++; } dataset.addSeries(series); }
From source file:com.thalesgroup.hudson.plugins.cccc.CcccChartBuilder.java
protected JFreeChart createGraph() { JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of modules", buildDataset(action), PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null);/* www .ja va2s . c om*/ plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer(); CcccAreaRenderer renderer = new CcccAreaRenderer(action.getUrlName()); plot.setRenderer(firstRender); //Second NumberAxis axis2 = new NumberAxis("Lines of Code"); axis2.setLabelPaint(Color.BLUE); axis2.setAxisLinePaint(Color.BLUE); axis2.setTickLabelPaint(Color.BLUE); CategoryPlot categoryPlot = chart.getCategoryPlot(); categoryPlot.setRangeAxis(1, axis2); //CategoryAxis categoryAxis = categoryPlot.getDomainAxis(); categoryPlot.setDataset(1, buildDataset2(action)); categoryPlot.mapDatasetToRangeAxis(1, 1); CategoryItemRenderer rendu = new DefaultCategoryItemRenderer(); rendu.setBasePaint(Color.BLUE); categoryPlot.setRenderer(1, rendu); //Third NumberAxis axis3 = new NumberAxis("McCabe's Cyclomatic Number"); axis3.setLabelPaint(Color.GREEN); axis3.setAxisLinePaint(Color.GREEN); axis3.setTickLabelPaint(Color.GREEN); CategoryPlot categoryPlot3 = chart.getCategoryPlot(); categoryPlot3.setRangeAxis(2, axis3); categoryPlot3.setDataset(2, buildDataset3(action)); categoryPlot3.mapDatasetToRangeAxis(2, 2); categoryPlot3.mapDatasetToDomainAxis(2, 0); CategoryItemRenderer rendu3 = new DefaultCategoryItemRenderer(); rendu3.setBasePaint(Color.GREEN); categoryPlot3.setRenderer(2, rendu3); return chart; }
From source file:net.sf.mzmine.chartbasics.chartthemes.EStandardChartTheme.java
@Override public void apply(JFreeChart chart) { // TODO Auto-generated method stub super.apply(chart); ///*from ww w . j a va 2 s. c o m*/ chart.getXYPlot().setDomainGridlinesVisible(showXGrid); chart.getXYPlot().setRangeGridlinesVisible(showYGrid); // all axes for (int i = 0; i < chart.getXYPlot().getDomainAxisCount(); i++) { NumberAxis a = (NumberAxis) chart.getXYPlot().getDomainAxis(i); a.setTickMarkPaint(axisLinePaint); a.setAxisLinePaint(axisLinePaint); // visible? a.setVisible(showXAxis); } for (int i = 0; i < chart.getXYPlot().getRangeAxisCount(); i++) { NumberAxis a = (NumberAxis) chart.getXYPlot().getRangeAxis(i); a.setTickMarkPaint(axisLinePaint); a.setAxisLinePaint(axisLinePaint); // visible? a.setVisible(showYAxis); } // apply bg chart.setBackgroundPaint(this.getChartBackgroundPaint()); chart.getPlot().setBackgroundPaint(this.getPlotBackgroundPaint()); for (int i = 0; i < chart.getSubtitleCount(); i++) { // visible? chart.getSubtitle(i).setVisible(subtitleVisible); // if (PaintScaleLegend.class.isAssignableFrom(chart.getSubtitle(i).getClass())) ((PaintScaleLegend) chart.getSubtitle(i)).setBackgroundPaint(this.getChartBackgroundPaint()); } if (chart.getLegend() != null) chart.getLegend().setBackgroundPaint(this.getChartBackgroundPaint()); // chart.setAntiAlias(isAntiAliased()); chart.getTitle().setVisible(isShowTitle()); chart.getPlot().setBackgroundAlpha(isNoBackground() ? 0 : 1); }
From source file:org.jls.toolbox.math.chart.XYLineChart.java
/** * Permet de paramtrer le graphique une fois cr. *//*w w w. j av a2s.c o m*/ private void setChartStyle() { // Paramtrage des courbes this.plot.setBackgroundAlpha((float) 0.0); this.plot.setDomainCrosshairVisible(this.isGridXVisible); this.plot.setDomainCrosshairLockedOnData(true); this.plot.setRangeCrosshairVisible(this.isGridYVisible); this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); this.plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis(); NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis(); this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR); xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); xAxis.setAutoRange(true); xAxis.setAutoRangeIncludesZero(false); yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(false); this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR); this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) this.plot.getRenderer(); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); }
From source file:org.jls.toolbox.math.chart.XYBlockChart.java
/** * Permet de paramtrer le graphique une fois cr. *//* ww w . jav a2 s .c o m*/ private void setChartStyle() { this.plot.setBackgroundAlpha((float) 0.0); this.plot.setDomainCrosshairLockedOnData(false); this.plot.setRangeCrosshairLockedOnData(false); this.plot.setDomainCrosshairVisible(true); this.plot.setRangeCrosshairVisible(true); this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); this.plot.setDomainGridlinesVisible(true); this.plot.setRangeGridlinesVisible(true); this.plot.setRangeGridlinePaint(Color.white); this.plot.setDomainCrosshairStroke(new BasicStroke(1f)); this.plot.setRangeCrosshairStroke(new BasicStroke(1f)); this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR); NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis(); NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis(); xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); xAxis.setAutoRange(true); xAxis.setAutoRangeIncludesZero(false); yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR); yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR); yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(false); this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR); this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR); this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
protected void resetRenderer(final IScope scope, final String serieid) { final XYBlockRenderer newr = (XYBlockRenderer) this.getOrCreateRenderer(scope, serieid); // newr.setSeriesStroke(0, new BasicStroke(0)); final ChartDataSeries myserie = this.getChartdataset().getDataSeries(scope, serieid); if (myserie.getMycolor() != null) { newr.setSeriesPaint(0, myserie.getMycolor()); }/*from w w w .j ava2 s . c o m*/ if (myserie.getSValues(scope).size() > 0) { final double maxval = Collections.max(myserie.getSValues(scope)); final double minval = Collections.min(myserie.getSValues(scope)); Color cdeb = new Color(0, 0, 0, 0); if (myserie.getMyMincolor() != null) cdeb = myserie.getMyMincolor(); Color cend = new Color(0.9f, 0.9f, 0.9f, 1.0f); if (myserie.getMycolor() != null) cend = myserie.getMycolor(); LookupPaintScale paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, cend); if (myserie.getMyMedcolor() != null) paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, myserie.getMyMedcolor(), cend); newr.setPaintScale(paintscale); final NumberAxis scaleAxis = new NumberAxis(myserie.getName()); scaleAxis.setAxisLinePaint(this.axesColor); scaleAxis.setTickMarkPaint(this.axesColor); scaleAxis.setTickLabelFont(this.getTickFont()); scaleAxis.setRange(minval, maxval); scaleAxis.setAxisLinePaint(axesColor); scaleAxis.setLabelFont(getLabelFont()); if (textColor != null) { scaleAxis.setLabelPaint(textColor); scaleAxis.setTickLabelPaint(textColor); } if (!this.getXTickValueVisible(scope)) { scaleAxis.setTickMarksVisible(false); scaleAxis.setTickLabelsVisible(false); } final PaintScaleLegend legend = new PaintScaleLegend(paintscale, scaleAxis); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); // legend.setMargin(new RectangleInsets(5, 5, 5, 5)); // legend.setFrame(new BlockBorder(Color.red)); // legend.setPadding(new RectangleInsets(10, 10, 10, 10)); // legend.setStripWidth(10); legend.setPosition(RectangleEdge.RIGHT); legend.setBackgroundPaint(this.backgroundColor); // ArrayList<PaintScaleLegend> caxe=new // ArrayList<PaintScaleLegend>(); // caxe.add(legend); // chart.setSubtitles(caxe); if (!this.series_label_position.equals("none")) chart.addSubtitle(legend); } }