List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseFillPaint
public void setBaseFillPaint(Paint paint)
From source file:org.jfree.chart.demo.XYTaskDatasetDemo2.java
private static XYPlot createSubplot1(XYDataset xydataset) { XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); xylineandshaperenderer.setBaseShape(new java.awt.geom.Ellipse2D.Double(-4D, -4D, 8D, 8D)); xylineandshaperenderer.setAutoPopulateSeriesShape(false); NumberAxis numberaxis = new NumberAxis("Y"); numberaxis.setLowerMargin(0.10000000000000001D); numberaxis.setUpperMargin(0.10000000000000001D); XYPlot xyplot = new XYPlot(xydataset, new DateAxis("Time"), numberaxis, xylineandshaperenderer); return xyplot; }
From source file:org.jfree.chart.demo.CompareToPreviousYearDemo.java
private static JFreeChart createChart() { XYDataset xydataset = createDataset2006(); XYDataset xydataset1 = createDataset2007(); DateAxis dateaxis = new DateAxis("Date"); Month month = new Month(1, 2007); Month month1 = new Month(12, 2007); dateaxis.setRange(month.getFirstMillisecond(), month1.getLastMillisecond()); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM")); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}", new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00"))); XYPlot xyplot = new XYPlot(xydataset1, dateaxis, new NumberAxis("Sales"), xylineandshaperenderer); xyplot.setDomainPannable(true);//from ww w .java 2 s . c o m xyplot.setRangePannable(true); DateAxis dateaxis1 = new DateAxis(); dateaxis1.setVisible(false); xyplot.setDomainAxis(1, dateaxis1); xyplot.setDataset(1, xydataset); xyplot.mapDatasetToDomainAxis(1, 1); XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(); xylineandshaperenderer1.setSeriesPaint(0, Color.blue); xylineandshaperenderer1.setUseFillPaint(true); xylineandshaperenderer1.setBaseFillPaint(Color.white); xylineandshaperenderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}", new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00"))); xyplot.setRenderer(1, xylineandshaperenderer1); JFreeChart jfreechart = new JFreeChart("Sales Comparison Chart", xyplot); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); DateAxis dateaxis2 = (DateAxis) xyplot.getDomainAxis(); dateaxis2.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:org.jfree.chart.demo.TimeSeriesDemo14.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Bug Report Submissions for Java", "Date", "Evaluation ID", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); }/* w ww .j a v a 2 s . c o m*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return jfreechart; }
From source file:org.jfree.chart.demo.MovingAverageDemo1.java
public static JFreeChart createChart(XYDataset xydataset) { String s = "Legal & General Unit Trust Prices"; JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(s, "Date", "Price Per Unit", xydataset, true, true, false);/*from w w w. jav a2 s . c o m*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(false); xylineandshaperenderer.setSeriesShapesVisible(0, true); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); } DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return jfreechart; }
From source file:net.nosleep.superanalyzer.analysis.views.LikesView.java
private void createChart() { _chart = ChartFactory.createScatterPlot(Misc.getString("LIKES_VS_PLAYS"), Misc.getString("ALBUM_PLAY_COUNT"), Misc.getString("ALBUM_RATING"), _dataset, PlotOrientation.VERTICAL, false, true, false); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LIKES_VS_PLAYS_SUBTITLE"))); XYPlot plot = (XYPlot) _chart.getPlot(); ChartUtilities.applyCurrentTheme(_chart); plot.setDomainPannable(true);//from ww w . ja v a 2 s . c o m plot.setRangePannable(true); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // get rid of the little line above/next to the axis plot.setDomainZeroBaselinePaint(Color.white); plot.setRangeZeroBaselinePaint(Color.white); /* * NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); * domainAxis.setAutoRangeIncludesZero(false); * * domainAxis.setTickMarkInsideLength(2.0f); * domainAxis.setTickMarkOutsideLength(2.0f); * * domainAxis.setMinorTickCount(2); * domainAxis.setMinorTickMarksVisible(true); */ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); /* * rangeAxis.setTickMarkInsideLength(2.0f); * rangeAxis.setTickMarkOutsideLength(2.0f); * rangeAxis.setMinorTickCount(2); * rangeAxis.setMinorTickMarksVisible(true); */ rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // format the line renderer after applying the theme XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); Misc.formatChart(plot); renderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:org.glotaran.core.datadisplayers.common.ImageSVDPanel.java
public void createSVDPlots() { int maxSpinnerNumberModel = Math.min(MAX_NUMBER_SINGULAR_VALUES, (int) svdResult[1].getRowCount()); jTFtotalNumSV//from w w w. java 2 s. c o m .setText("Max " + maxSpinnerNumberModel + " of " + String.valueOf(svdResult[1].getRowCount())); jSnumSV.setModel(new SpinnerNumberModel((int) 1, (int) 0, maxSpinnerNumberModel, (int) 1)); //creare collection with first 2 LSV XYSeriesCollection lSVCollection = new XYSeriesCollection(); XYSeries seria; seria = new XYSeries("LSV1"); for (int i = 0; i < timeSteps; i++) { seria.add(timeAxe[i], svdResult[0].getAsDouble((long) i, 0)); } lSVCollection.addSeries(seria); //creare chart for 2 LSV leftSVChart = ChartFactory.createXYLineChart("Left singular vectors", "Time (~s)", null, lSVCollection, PlotOrientation.VERTICAL, false, false, false); //leftSVChart.getTitle().setFont(new Font(leftSVChart.getTitle().getFont().getFontName(), Font.PLAIN, 12)); leftSVChart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT); GraphPanel chpan = new GraphPanel(leftSVChart); jPLeftSingVectors.removeAll(); jPLeftSingVectors.add(chpan); //creare collection with first RSV double[] tempRsingVec = null; double minVal = 0; double maxVal = 0; // seria = new XYSeries("RSV" + (j + 1)); tempRsingVec = new double[imageWitdth * imageHeight]; double tempValue; for (int i = 0; i < imageWitdth * imageHeight; i++) { tempValue = svdResult[2].getAsDouble(i, 0); tempRsingVec[i] = tempValue; minVal = minVal > tempValue ? tempValue : minVal; maxVal = maxVal < tempValue ? tempValue : maxVal; } IntensImageDataset rSingVec = new IntensImageDataset(imageWitdth, imageHeight, tempRsingVec); PaintScale ps = new RedGreenPaintScale(minVal, maxVal); JFreeChart rSingVect = CommonDataDispTools .createScatChart(ImageUtilities.createColorCodedImage(rSingVec, ps), ps, imageWitdth, imageHeight); // rSingVect.setTitle("R Singular vector " + String.valueOf(j + 1)); //rSingVect.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12)); ChartPanel rSingVectPanel = new ChartPanel(rSingVect); rSingVectPanel.setFillZoomRectangle(true); rSingVectPanel.setMouseWheelEnabled(true); jPRightSingVectors.removeAll(); jPRightSingVectors.add(rSingVectPanel); //creare collection with singular values XYSeriesCollection sVCollection = new XYSeriesCollection(); seria = new XYSeries("SV"); for (int i = 0; i < maxSpinnerNumberModel; i++) { seria.add(i + 1, svdResult[1].getAsDouble((long) i, (long) i)); } sVCollection.addSeries(seria); //create chart for singular values JFreeChart tracechart = ChartFactory.createXYLineChart("Screeplot", "Singular Value index (n)", null, sVCollection, PlotOrientation.VERTICAL, false, false, false); LogAxis logAxe = new LogAxis("Log(SVn)"); final NumberAxis domainAxis = (NumberAxis) tracechart.getXYPlot().getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); tracechart.getXYPlot().setRangeAxis(logAxe); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) tracechart.getXYPlot().getRenderer(); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(1.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); //tracechart.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12)); tracechart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT); chpan = new GraphPanel(tracechart); //add chart with 2 RSV to JPannel jPSingValues.removeAll(); jPSingValues.add(chpan); }
From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java
public COSMOSACDialog() { super("JCOSMO Simple"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); db = COSMOSACDataBase.getInstance(); COSMOSAC models[] = new COSMOSAC[5]; models[0] = new COSMOSAC(); models[1] = new COSMOPAC(); models[2] = new COSMOSAC_SVP(); models[3] = new COSMOSAC_G(); models[4] = new PCMSAC(); modelBox = new JComboBox(models); modelBox.addActionListener(this); JPanel north = new JPanel(new GridLayout(0, 2)); add(north, BorderLayout.NORTH); JPanel northAba1 = new JPanel(new GridLayout(0, 4)); JPanel northAba2 = new JPanel(new GridLayout(0, 2)); //Where the GUI is created: JMenuBar menuBar;// w ww . j av a 2 s . c om JMenu file, help; JMenuItem menuItem; //Create the menu bar. menuBar = new JMenuBar(); // the file menu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); menuBar.add(file); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); menuItem.setActionCommand(QUIT); menuItem.addActionListener(this); file.add(menuItem); // the help menu help = new JMenu("Help"); file.setMnemonic(KeyEvent.VK_H); menuBar.add(help); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); menuItem.setActionCommand(ABOUT); menuItem.addActionListener(this); help.add(menuItem); setJMenuBar(menuBar); listModel = new DefaultListModel(); list = new JList(listModel); list.setBorder(BorderFactory.createTitledBorder("compounds")); list.setVisibleRowCount(2); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane listScrollPane = new JScrollPane(list); JButton addButton = new JButton("Add"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AddCompoundDialog(COSMOSACDialog.this); } }); removeButton = new JButton("Remove"); removeButton.addActionListener(this); visibRemove(false); JButton calcButton = new JButton("Calculate"); calcButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildChart(); rebuildSigmaProfiles(); } }); JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildSigmaProfiles(); } }); ignoreSGButton = new JCheckBox("Ignore SG"); ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term"); ignoreSGButton.addActionListener(this); JPanel but = new JPanel(new GridLayout(0, 1)); but.add(addButton, BorderLayout.EAST); but.add(removeButton, BorderLayout.EAST); but.add(modelBox); north.add(listScrollPane); north.add(but); northAba1.add(new JLabel("Temperature [K]")); northAba1.add(temperature = new JTextField(10)); temperature.setText("298"); northAba1.add(new JLabel("Sigma HB")); northAba1.add(sigmaHB = new JTextField(10)); northAba1.add(new JLabel("Sigma HB2")); northAba1.add(sigmaHB2 = new JTextField(10)); northAba1.add(new JLabel("Sigma HB3")); northAba1.add(sigmaHB3 = new JTextField(10)); northAba1.add(new JLabel("Charge HB")); northAba1.add(chargeHB = new JTextField(10)); northAba1.add(new JLabel("Sigma Disp")); northAba1.add(sigmaDisp = new JTextField(10)); northAba1.add(new JLabel("Charge Disp")); northAba1.add(chargeDisp = new JTextField(10)); northAba1.add(new JLabel("Beta")); northAba1.add(beta = new JTextField(10)); northAba1.add(new JLabel("fpol")); northAba1.add(fpol = new JTextField(10)); northAba1.add(new JLabel("Anorm")); northAba1.add(anorm = new JTextField(10)); northAba1.add(ignoreSGButton); northAba1.add(calcButton); northAba2.add(new JLabel("")); northAba2.add(refreshButton); // chart = new JLineChart(); // add(chart, BorderLayout.CENTER); // chart.setTitle("Gamma Plot"); // chart.setSubtitle(""); // chart.setXAxisLabel("Mole Fraction, x_1"); // chart.setYAxisLabel("ln gamma, gE/RT"); // chart.setSource(getTitle()); // chart.setLegendPosition(LegendPosition.BOTTOM); // chart.setShapesVisible(true); JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null, PlotOrientation.VERTICAL, true, true, false); plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(new Range(0.0, 1.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setUseFillPaint(true); r.setBaseFillPaint(Color.white); r.setBaseShapesVisible(true); JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null, PlotOrientation.VERTICAL, true, true, false); sigmaProfilePlot = sigmaProfileChart.getXYPlot(); sigmaProfilePlot.getDomainAxis().setAutoRange(false); sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025)); // sigmaProfilePlot.setBackgroundPaint(Color.lightGray); // sigmaProfilePlot.setDomainGridlinePaint(Color.white); // sigmaProfilePlot.setRangeGridlinePaint(Color.white); JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null, PlotOrientation.VERTICAL, true, true, false); plotSegGamma = (XYPlot) chartSegGamma.getPlot(); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(lnGammaInf1Label = new JLabel()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(lnGammaInf2Label = new JLabel()); south.add(Box.createHorizontalStrut(20)); south.add(new JLabel("<html>γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(gammaInf1Label = new JLabel()); south.add(new JLabel("<html>γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(gammaInf2Label = new JLabel()); JPanel aba1 = new JPanel(new BorderLayout()); aba1.add(northAba1, BorderLayout.NORTH); JPanel chartsPanel = new JPanel(new GridLayout(0, 2)); aba1.add(chartsPanel, BorderLayout.CENTER); chartsPanel.add(new ChartPanel(chart)); chartsPanel.add(new ChartPanel(chartSegGamma)); aba1.add(south, BorderLayout.SOUTH); JPanel aba2 = new JPanel(new BorderLayout()); aba2.add(northAba2, BorderLayout.NORTH); aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("gamma", aba1); tabbedPane.addTab("sigma", aba2); add(tabbedPane, BorderLayout.CENTER); // cosmosac.setAEffPrime(6.596176570595075); // cosmosac.setCoord(11.614599507917934); // cosmosac.setVnorm(56.36966406129967); // cosmosac.setAnorm(41.56058649432742); // cosmosac.setCHB(65330.19484947528); // cosmosac.setSigmaHB(0.008292411048046008); //Display the window. setSize(800, 600); setLocationRelativeTo(null); modelBox.setSelectedIndex(0); setVisible(true); // test for a mixture // addList("WATER"); // addList("H3O+1"); // addList("OH-1"); // addList("CL-1"); // addList("OXYGEN"); // addList("sec-butylamine"); // addList("hydrogen-fluoride"); // addList("ACETONE"); // addList("METHANOL"); // addList("ACETONE.opt"); // addList("METHANOL.opt"); // addList("METHYL-ETHYL-KETONE"); // addList("ETHANOL"); // addList("N-HEPTANE"); // addList("PROPIONIC-ACID"); // addList("EMIM"); // addList("NTF2"); // addList("DCA"); // addList("N-OCTANE"); addList("ETHYLENE CARBONATE"); addList("BENZENE"); addList("TOLUENE"); removeButton.setEnabled(true); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java
private void addPointSeries(TimeSeries series, XYPlot plot) { logger.debug("IN"); TimeSeries pointSerie = new TimeSeries("Point", Month.class); for (int i = 0; i < series.getItemCount(); i++) { pointSerie.add(series.getTimePeriod(i), series.getValue(i)); }/*from www . j av a 2 s. c o m*/ final TimeSeriesCollection avgDs = new TimeSeriesCollection(pointSerie); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) { public boolean getItemShapeVisible(int _series, int item) { return (true); } }; renderer.setSeriesPaint(2, Color.LIGHT_GRAY); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.BLACK); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setUseOutlinePaint(true); renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, -2.0, 4.0, 4.0)); plot.setDataset(2, avgDs); plot.setRenderer(2, renderer); logger.debug("OUT"); }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset, String other) {// ww w.ja v a 2s . c o m // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); chart.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinePaint(Color.lightGray); //plot.setNoDataMessage("No data available"); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // customise the renderer... XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(true); renderer.setDrawOutlines(true); renderer.setBaseShapesFilled(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); if (other.toLowerCase().indexOf("noline") != -1) { renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(false); } if (other.toLowerCase().indexOf("noshape") != -1) { renderer.setBaseShapesVisible(false); renderer.setBaseLinesVisible(true); } if (other.toLowerCase().indexOf("excludeszero") != -1) { rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setAutoRangeIncludesZero(false); } return chart; }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset, Color[] colors, String other) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );//from w ww.j a va2 s .c o m XYPlot plot = chart.getXYPlot(); chart.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinePaint(Color.lightGray); //plot.setNoDataMessage("No data available"); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // customise the renderer... XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(true); renderer.setDrawOutlines(true); renderer.setBaseShapesFilled(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); for (int i = 0; i < colors.length; i++) { renderer.setSeriesPaint(i, colors[i]); } if (other.toLowerCase().indexOf("noline") != -1) { renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(false); } if (other.toLowerCase().indexOf("noshape") != -1) { renderer.setBaseShapesVisible(false); renderer.setBaseLinesVisible(true); } if (other.toLowerCase().indexOf("excludeszero") != -1) { rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setAutoRangeIncludesZero(false); } if (other.toLowerCase().indexOf("color") != -1) { renderer.setBaseShapesVisible(false); renderer.setBaseLinesVisible(true); } return chart; }