Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setUseFillPaint

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setUseFillPaint

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setUseFillPaint.

Prototype

public void setUseFillPaint(boolean flag) 

Source Link

Document

Sets the flag that controls whether the fill paint is used to fill shapes, and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates a line chart.// w w w. j av a  2 s  . com
 * 
 * @param title
 * @param categoryAxisLabel
 *            (X-Axis label)
 * @param valueAxisLabel
 *            (Y-Axis label)
 * @param dataset
 * @param includeZero
 *            True when zero shall be included to the axis range.
 * @return JfreeChart instance.
 */
public JFreeChart createXYLineChart(String title, String categoryAxisLabel, String valueAxisLabel,
        XYDataset dataset, boolean includeZero, boolean drawShapes) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            this.orientation, this.drawLegend, false, false);
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = chart.getXYPlot();
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.025);
    domainAxis.setUpperMargin(0.025);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(includeZero);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.green);
    renderer.setSeriesPaint(3, Color.darkGray);
    renderer.setSeriesPaint(4, Color.yellow);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseShapesVisible(drawShapes);
    renderer.setBaseShapesFilled(true);
    return chart;
}

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;/*www .j av a  2 s  . com*/
    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 &gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(lnGammaInf1Label = new JLabel());
    south.add(new JLabel("<html>ln &gamma;<sup>&infin;</sup><sub>2</sub>:</html>"));
    south.add(lnGammaInf2Label = new JLabel());
    south.add(Box.createHorizontalStrut(20));
    south.add(new JLabel("<html>&gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(gammaInf1Label = new JLabel());
    south.add(new JLabel("<html>&gamma;<sup>&infin;</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   ww  w  .  j a va 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:mil.tatrc.physiology.biogears.verification.ScenarioPlotTool.java

public void createGraph(String toDir, Paint color, String title, String XAxisLabel, String YAxisLabel,
        XYSeries... xyData) {//ww w.  ja  va 2 s . co m
    new File(toDir).mkdir();

    Log.info("Creating Graph " + toDir + title);
    double resMin0 = 1.e6;
    double resMax0 = -1.e6;
    double resMin1 = 1.e6;
    double resMax1 = -1.e6;

    XYSeriesCollection dataSet = new XYSeriesCollection();
    for (XYSeries data : xyData)
        dataSet.addSeries(data);

    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            XAxisLabel, // x axis label
            YAxisLabel, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();

    if (title.contains("Residual")) {
        // Make plot symmetric about x axis
        resMax0 = xyData[0].getMaxY();
        resMin0 = xyData[0].getMinY();
        if (Math.abs(xyData[0].getMinY()) > Math.abs(xyData[0].getMaxY()))
            resMax0 = Math.abs(resMin0);
        if (Math.abs(xyData[0].getMaxY()) > Math.abs(xyData[0].getMinY()))
            resMin0 = -1.0 * Math.abs(resMax0);
        if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
            resMin0 = -0.00001;
            resMax0 = 0.00001;
        }
        ValueAxis yAxis = plot.getRangeAxis();
        yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly
    } else if (title.contains("Error")) {
        // Make plot symmetric about x axis
        resMax0 = xyData[0].getMaxY();
        resMin0 = xyData[0].getMinY();
        if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
            resMin0 = -0.00001;
            resMax0 = 0.00001;
        }
        if (resMin0 >= 0.0)
            resMin0 = -0.01;
        ValueAxis yAxis = plot.getRangeAxis();
        yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly

        /*
         yAxis.setTickLabelPaint(new Color(1,0,0));
         yAxis.setTickMarkPaint(new Color(1,0,0));
         yAxis.setAxisLinePaint(new Color(1,0,0));
         yAxis.setLabelPaint(new Color(1,0,0));
                
         ValueAxis xAxis = plot.getDomainAxis();
         xAxis.setTickLabelPaint(new Color(1,0,0));
         xAxis.setTickMarkPaint(new Color(1,0,0));
         yAxis.setAxisLinePaint(new Color(1,0,0));
         yAxis.setLabelPaint(new Color(1,0,0));
         */
    } else {
        if (xyData.length > 1) {
            // Make plot symmetric about x axis
            resMax0 = xyData[0].getMaxY();
            resMin0 = xyData[0].getMinY();
            resMax1 = xyData[1].getMaxY();
            resMin1 = xyData[1].getMinY();
            if (resMin1 < resMin0)
                resMin0 = resMin1;
            if (resMax1 > resMax0)
                resMax0 = resMax1;
            if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
                resMin0 = -0.00001;
                resMax0 = 0.00001;
            }
            if (resMin0 >= 0.0)
                resMin0 = -0.01;
            if (YAxisLabel.indexOf("PlasmaConcentration") > -1)
                plot.setRangeAxis(new LogarithmicAxis("Log(" + YAxisLabel + ")"));
            else {
                ValueAxis yAxis = plot.getRangeAxis();
                yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly
            }
        } else {
            // Make plot symmetric about x axis
            resMax0 = xyData[0].getMaxY();
            resMin0 = xyData[0].getMinY();
            if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
                resMin0 = -0.00001;
                resMax0 = 0.00001;
            }
            if (resMin0 >= 0.0)
                resMin0 = -0.01;
            if (YAxisLabel.indexOf("PlasmaConcentration") > -1)
                plot.setRangeAxis(new LogarithmicAxis("Log(" + YAxisLabel + ")"));
            else {
                ValueAxis yAxis = plot.getRangeAxis();
                yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly
            }
        }
    }

    formatXYPlot(chart, color);
    //Changing line widths and colors
    XYItemRenderer r = plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(lineWidth);
    r.setSeriesStroke(0, wideLine);
    r.setSeriesStroke(1, wideLine);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    if (xyData.length > 1) {
        renderer.setSeriesStroke(//makes a dashed line
                0, //argument below float[]{I,K} -> alternates between solid and opaque (solid for I, opaque for K)
                new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                        new float[] { 15.0f, 30.0f }, 0.0f));
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setUseFillPaint(true);
    }
    renderer.setBaseShapesVisible(false);
    renderer.setSeriesFillPaint(0, expectedLineColor);
    renderer.setSeriesFillPaint(1, computedLineColor);
    renderer.setSeriesPaint(0, expectedLineColor);
    renderer.setSeriesPaint(1, computedLineColor);

    try {
        if (toDir == null || toDir.isEmpty())
            toDir = ".";
        File JPGFile = new File(toDir + "/" + StringUtils.removeParens(title) + ".jpg");
        ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, 800);
    } catch (IOException e) {
        Log.error(e.getMessage());
    }
}

From source file:mil.tatrc.physiology.utilities.csv.plots.CSVPlotTool.java

public void createGraph(String toDir, Paint color, String title, String XAxisLabel, String YAxisLabel,
        XYSeries... xyData) {//from w w w. j ava2  s.  c  o  m
    new File(toDir).mkdir();

    Log.info("Creating Graph " + toDir + "/" + title);
    double resMin0 = 1.e6;
    double resMax0 = -1.e6;
    double resMin1 = 1.e6;
    double resMax1 = -1.e6;

    XYSeriesCollection dataSet = new XYSeriesCollection();
    for (XYSeries data : xyData) {
        if (data != null && !data.isEmpty())
            dataSet.addSeries(data);
    }

    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            XAxisLabel, // x axis label
            YAxisLabel, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    /* I have residual and error plots turned off, there are some plots that contain these names in their title, and I don't want this code running, need a better way to see if we are doing a special plot rather than title contents
        if(title.contains("Residual"))
        {
          // Make plot symmetric about x axis
          resMax0 = xyData[0].getMaxY();
          resMin0 = xyData[0].getMinY();
          if (Math.abs(xyData[0].getMinY()) > Math.abs(xyData[0].getMaxY()))  resMax0 = Math.abs(resMin0);
          if (Math.abs(xyData[0].getMaxY()) > Math.abs(xyData[0].getMinY()))  resMin0 = -1.0*Math.abs(resMax0);
          if((resMin0==0.0) && (resMax0==0.0))
          {
            resMin0 = -0.00001;
            resMax0 =  0.00001;
          }       
          ValueAxis yAxis = plot.getRangeAxis();
          yAxis.setRange(resMin0 + 0.05*resMin0, resMax0 + 0.05*resMax0);//5% buffer so we can see top and bottom clearly
        }
        else if(title.contains("Error"))
        {
          // Make plot symmetric about x axis
          resMax0 = xyData[0].getMaxY();
          resMin0 = xyData[0].getMinY();
          if((resMin0==0.0) && (resMax0==0.0))
          {
            resMin0 = -0.00001;
            resMax0 =  0.00001;
          }
          if(resMin0>=0.0) resMin0 = -0.01;
          ValueAxis yAxis = plot.getRangeAxis();
          yAxis.setRange(resMin0 + 0.05*resMin0, resMax0 + 0.05*resMax0);//5% buffer so we can see top and bottom clearly
            
          /*
           yAxis.setTickLabelPaint(new Color(1,0,0));
           yAxis.setTickMarkPaint(new Color(1,0,0));
           yAxis.setAxisLinePaint(new Color(1,0,0));
           yAxis.setLabelPaint(new Color(1,0,0));
            
           ValueAxis xAxis = plot.getDomainAxis();
           xAxis.setTickLabelPaint(new Color(1,0,0));
           xAxis.setTickMarkPaint(new Color(1,0,0));
           yAxis.setAxisLinePaint(new Color(1,0,0));
           yAxis.setLabelPaint(new Color(1,0,0));
           *
        }
        else
    */
    {
        if (title.indexOf("Hemoglobin-GlomerularFilterability") > -1)
            System.out.println("stop");
        if (xyData.length > 1) {
            // Make plot symmetric about x axis
            resMax0 = xyData[0].getMaxY();
            resMin0 = xyData[0].getMinY();
            resMax1 = xyData[1].getMaxY();
            resMin1 = xyData[1].getMinY();
            if (resMin1 < resMin0)
                resMin0 = resMin1;
            if (resMax1 > resMax0)
                resMax0 = resMax1;
            if (DoubleUtils.isZero(resMin0))
                resMin0 = -0.001;
            if (DoubleUtils.isZero(resMax0))
                resMax0 = 0.001;
            if (resMin0 >= 0.0)
                resMin0 = -0.01;
            if (YAxisLabel.indexOf("PlasmaConcentration") > -1)
                plot.setRangeAxis(new LogarithmicAxis("Log(" + YAxisLabel + ")"));
            else {
                ValueAxis yAxis = plot.getRangeAxis();
                yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.15 * Math.abs(resMax0));//5% buffer so we can see top and bottom clearly
            }
            String NaNCheck = "";
            if (Double.isNaN(resMax0) || Double.isNaN(resMin0))
                NaNCheck += "Expected is NaN ";
            if (Double.isNaN(resMax1) || Double.isNaN(resMin1))
                NaNCheck += "Computed is NaN ";
            if (!NaNCheck.isEmpty())
                plot.getDomainAxis().setLabel(NaNCheck);
        } else {
            // Make plot symmetric about x axis
            resMax0 = xyData[0].getMaxY();
            resMin0 = xyData[0].getMinY();
            if (Double.isNaN(resMax0) || Double.isNaN(resMin0))
                plot.getDomainAxis().setLabel("Computed is NaN");
            if (DoubleUtils.isZero(resMin0))
                resMin0 = -0.001;
            if (DoubleUtils.isZero(resMax0))
                resMax0 = 0.001;
            if (resMin0 >= 0.0)
                resMin0 = -0.01;
            if (YAxisLabel.indexOf("PlasmaConcentration") > -1)
                plot.setRangeAxis(new LogarithmicAxis("Log(" + YAxisLabel + ")"));
            else {
                ValueAxis yAxis = plot.getRangeAxis();
                yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.15 * Math.abs(resMax0));//5% buffer so we can see top and bottom clearly
            }
        }
    }

    formatXYPlot(chart, color);
    //Changing line widths and colors
    XYItemRenderer r = plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(lineWidth);
    r.setSeriesStroke(0, wideLine);
    r.setSeriesStroke(1, wideLine);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    if (xyData.length > 1) {
        renderer.setSeriesStroke(//makes a dashed line
                0, //argument below float[]{I,K} -> alternates between solid and opaque (solid for I, opaque for K)
                new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                        new float[] { 15.0f, 30.0f }, 0.0f));
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setUseFillPaint(true);
    }
    renderer.setBaseShapesVisible(false);
    renderer.setSeriesFillPaint(0, expectedLineColor);
    renderer.setSeriesFillPaint(1, computedLineColor);
    renderer.setSeriesPaint(0, expectedLineColor);
    renderer.setSeriesPaint(1, computedLineColor);

    try {
        if (toDir == null || toDir.isEmpty())
            toDir = ".";
        File JPGFile = new File(toDir + "/" + MakeFileName(title) + ".jpg");
        ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, 800);
    } catch (IOException e) {
        Log.error(e.getMessage());
    }
}

From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java

private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset,
        String other) {/*from   w  w w .j  a  v  a  2 s  . c om*/

    // 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  w w  .j a v a  2  s.c om*/

    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;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java

private void addMarker(int index, double value, final Color color, float stoke, XYPlot plot) {
    logger.debug("IN");
    TimeSeries markerSeries = new TimeSeries("Marker" + index, Month.class);
    for (Iterator iterator = yearsDefined.iterator(); iterator.hasNext();) {
        String currentYear = (String) iterator.next();
        boolean stop = false;
        for (int i = 1; i < 13 && stop == false; i++) {
            if (!(currentYear.equalsIgnoreCase(yearsDefined.first()) && i < firstMonth.getMonth())) {
                markerSeries.add(new Month(i, Integer.valueOf(currentYear).intValue()), value);
            }/* ww  w. j  a va 2  s .  com*/
            if (currentYear.equalsIgnoreCase(lastYear) && i >= lastMonth.getMonth()) {
                stop = true;
            }
        }
    }

    final TimeSeriesCollection dataset = new TimeSeriesCollection(markerSeries);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) {
        public boolean getItemShapeVisible(int _series, int item) {
            return (false);
        }

        public Paint getItemPaint(int row, int column) {
            return color;
        }
    };

    renderer.setBaseStroke(new BasicStroke(stoke, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.GRAY);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setUseOutlinePaint(true);

    plot.setDataset(index, dataset);
    plot.setRenderer(index, renderer);
    logger.debug("OUT");
}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

protected JFreeChart createScatterChart() throws JRException {
    JFreeChart jfreeChart = super.createScatterChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();

    xyPlot.setRangeGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setRangeGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setDomainGridlinesVisible(true);
    xyPlot.setDomainGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setDomainGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setRangeZeroBaselinePaint(ChartThemesConstants.GRAY_PAINT_134);

    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    lineRenderer.setUseFillPaint(true);
    JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
    boolean isShowLines = scatterPlot.getShowLines() == null ? false
            : scatterPlot.getShowLines().booleanValue();
    lineRenderer.setBaseLinesVisible(isShowLines);
    XYDataset xyDataset = xyPlot.getDataset();
    if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
            lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            lineRenderer.setSeriesFillPaint(i,
                    (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
            lineRenderer.setSeriesPaint(i, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            //lineRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
        }//from  w  w  w  . ja  v  a  2  s .  c o  m
    }
    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java

@Override
protected JFreeChart createScatterChart() throws JRException {
    JFreeChart jfreeChart = super.createScatterChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();

    xyPlot.setRangeGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setRangeGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setDomainGridlinesVisible(true);
    xyPlot.setDomainGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setDomainGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setRangeZeroBaselinePaint(ChartThemesConstants.GRAY_PAINT_134);

    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    lineRenderer.setUseFillPaint(true);
    JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
    boolean isShowLines = scatterPlot.getShowLines() == null ? false : scatterPlot.getShowLines();
    lineRenderer.setBaseLinesVisible(isShowLines);
    XYDataset xyDataset = xyPlot.getDataset();
    if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
            lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            lineRenderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
            lineRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            //lineRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
        }/*from   w  w w .j  a  va2 s.c o  m*/
    }
    return jfreeChart;
}