Example usage for org.jfree.chart.renderer.xy XYSplineRenderer setStroke

List of usage examples for org.jfree.chart.renderer.xy XYSplineRenderer setStroke

Introduction

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

Prototype

public void setStroke(Stroke stroke) 

Source Link

Document

Sets the stroke for ALL series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:br.ufrgs.enq.jcosmo.test.VLEdiagrams.java

@SuppressWarnings("deprecation")
public JPanel calcMethanolMethilAcetate() throws Exception {
    super.setTitle("P vs x1");
    double T = 25;

    COSMOSACDataBase db = COSMOSACDataBase.getInstance();

    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    comps[0] = db.getComp("methanol");
    comps[1] = db.getComp("methyl-acetate");

    COSMOSAC cosmosac = new COSMOSAC();
    cosmosac.setComponents(comps);//from   w w w .  j ava 2  s  .  c  o m

    cosmosac.setTemperature(T + 273.15);

    double[] x1 = new double[n];
    double[] x2 = new double[n];
    double[] gamma1 = new double[n];
    double[] gamma2 = new double[n];
    double[] z = new double[2];
    double[] lnGamma = new double[2];
    z[0] = 0.00;
    int j = 0;
    while (z[0] < 1.0001) {
        z[1] = 1 - z[0];
        x1[j] = z[0];
        x2[j] = z[1];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);
        gamma1[j] = Math.exp(lnGamma[0]);
        gamma2[j] = Math.exp(lnGamma[1]);
        z[0] += 0.05;
        j++;
    }

    double[][] parAntoine = new double[3][3];
    parAntoine[0][0] = 16.5785;
    parAntoine[0][1] = 3638.27;
    parAntoine[0][2] = 239.500;
    parAntoine[1][0] = 14.2456;
    parAntoine[1][1] = 2662.78;
    parAntoine[1][2] = 219.690;

    double[] Psat = pSat(parAntoine, T);
    double[] P = calcPx(x1, x2, gamma1, gamma2, Psat);
    double[] y1 = calcY(x1, gamma1, Psat, P);

    XYPlot plot2;
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries liq = new XYSeries("liquid");
    XYSeries vap = new XYSeries("vapor");
    XYSeries raoult = new XYSeries("Raoult's Law");
    for (int i = 0; i < n; i++) {
        liq.add(x1[i], P[i]);
        vap.add(y1[i], P[i]);
    }
    raoult.add(0, Psat[1]);
    raoult.add(1, Psat[0]);
    dataset.addSeries(liq);
    dataset.addSeries(vap);
    dataset.addSeries(raoult);

    JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction: x1, y1", "P/KPa", null,
            PlotOrientation.VERTICAL, true, true, false);
    plot2 = (XYPlot) chart.getPlot();
    plot2.getDomainAxis().setRange(new Range(0.0, 1.0));
    plot2.getRangeAxis().setRange(new Range(15.0, 30.0));

    plot2.setDataset(dataset);

    XYSplineRenderer r = new XYSplineRenderer();
    BasicStroke stroke = new BasicStroke(2f);
    r.setStroke(stroke);
    plot2.setRenderer(r);
    r.setBaseShapesVisible(false);

    ChartPanel chartPanel = new ChartPanel(chart);
    JPanel jp = new JPanel(new BorderLayout());
    jp.add(chartPanel, BorderLayout.CENTER);

    add(jp);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 500);

    return jp;
}

From source file:br.ufrgs.enq.jcosmo.test.VLEdiagrams.java

@SuppressWarnings("deprecation")
public JPanel calcMethanolMethilAcetateMOPAC() throws Exception {
    super.setTitle("P vs x1");
    double T = 25;

    COSMOSACDataBase db = COSMOSACDataBase.getInstance();

    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    comps[0] = db.getComp("methanol");
    comps[1] = db.getComp("methyl-acetate");

    COSMOSAC cosmosac = new COSMOPAC();
    cosmosac.setComponents(comps);// w  ww .j  av  a 2s .  c  o m

    cosmosac.setTemperature(T + 273.15);

    double[] x1 = new double[n];
    double[] x2 = new double[n];
    double[] gamma1 = new double[n];
    double[] gamma2 = new double[n];
    double[] z = new double[2];
    double[] lnGamma = new double[2];
    z[0] = 0.00;
    int j = 0;
    while (z[0] < 1.0001) {
        z[1] = 1 - z[0];
        x1[j] = z[0];
        x2[j] = z[1];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);
        gamma1[j] = Math.exp(lnGamma[0]);
        gamma2[j] = Math.exp(lnGamma[1]);
        z[0] += 0.05;
        j++;
    }

    double[][] parAntoine = new double[3][3];
    parAntoine[0][0] = 16.5785;
    parAntoine[0][1] = 3638.27;
    parAntoine[0][2] = 239.500;
    parAntoine[1][0] = 14.2456;
    parAntoine[1][1] = 2662.78;
    parAntoine[1][2] = 219.690;

    double[] Psat = pSat(parAntoine, T);
    double[] P = calcPx(x1, x2, gamma1, gamma2, Psat);
    double[] y1 = calcY(x1, gamma1, Psat, P);

    XYPlot plot2;
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries liq = new XYSeries("liquid");
    XYSeries vap = new XYSeries("vapor");
    XYSeries raoult = new XYSeries("Raoult's Law");
    for (int i = 0; i < n; i++) {
        liq.add(x1[i], P[i]);
        vap.add(y1[i], P[i]);
    }
    raoult.add(0, Psat[1]);
    raoult.add(1, Psat[0]);
    dataset.addSeries(liq);
    dataset.addSeries(vap);
    dataset.addSeries(raoult);

    JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction: x1, y1", "P/KPa", null,
            PlotOrientation.VERTICAL, true, true, false);
    plot2 = (XYPlot) chart.getPlot();
    plot2.getDomainAxis().setRange(new Range(0.0, 1.0));
    plot2.getRangeAxis().setRange(new Range(15.0, 30.0));

    plot2.setDataset(dataset);

    XYSplineRenderer r = new XYSplineRenderer();
    BasicStroke stroke = new BasicStroke(2f);
    r.setStroke(stroke);
    plot2.setRenderer(r);
    r.setBaseShapesVisible(false);

    ChartPanel chartPanel = new ChartPanel(chart);
    JPanel jp = new JPanel(new BorderLayout());
    jp.add(chartPanel, BorderLayout.CENTER);

    add(jp);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 500);

    return jp;
}

From source file:br.ufrgs.enq.jcosmo.test.VLEdiagrams.java

@SuppressWarnings("deprecation")
public JPanel calcEthTol() throws Exception {
    super.setTitle("P vs x1");
    double T = 60;
    setLayout(new BorderLayout());

    COSMOSACDataBase db = COSMOSACDataBase.getInstance();

    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    comps[0] = db.getComp("ethanol");
    comps[1] = db.getComp("toluene");

    COSMOSAC cosmosac = new COSMOSAC();
    cosmosac.setComponents(comps);//from  w  ww. jav  a 2  s  .  com

    cosmosac.setTemperature(T + 273.15);

    double[] x1 = new double[n];
    double[] x2 = new double[n];
    double[] gamma1 = new double[n];
    double[] gamma2 = new double[n];
    double[] z = new double[2];
    double[] lnGamma = new double[2];
    z[0] = 0.00;
    int j = 0;
    while (z[0] < 1.0001) {
        z[1] = 1 - z[0];
        x1[j] = z[0];
        x2[j] = z[1];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);
        gamma1[j] = Math.exp(lnGamma[0]);
        gamma2[j] = Math.exp(lnGamma[1]);
        z[0] += 0.05;
        j++;
    }

    double[][] parAntoine = new double[3][3];
    parAntoine[0][0] = 16.8958;
    parAntoine[0][1] = 3795.17;
    parAntoine[0][2] = 230.918;
    parAntoine[1][0] = 13.9320;
    parAntoine[1][1] = 3056.96;
    parAntoine[1][2] = 217.625;

    double[] Psat = pSat(parAntoine, T);
    double[] P = calcPx(x1, x2, gamma1, gamma2, Psat);
    double[] y1 = calcY(x1, gamma1, Psat, P);

    XYPlot plot1;
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries liq = new XYSeries("liquid");
    XYSeries vap = new XYSeries("vapor");
    XYSeries raoult = new XYSeries("Raoult's Law");
    for (int i = 0; i < n; i++) {
        liq.add(x1[i], P[i]);
        vap.add(y1[i], P[i]);
    }
    raoult.add(0, Psat[1]);
    raoult.add(1, Psat[0]);
    dataset.addSeries(liq);
    dataset.addSeries(vap);
    dataset.addSeries(raoult);

    JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction: x1, y1", "P/KPa", null,
            PlotOrientation.VERTICAL, true, true, false);
    plot1 = (XYPlot) chart.getPlot();
    plot1.getDomainAxis().setRange(new Range(0.0, 1.0));
    plot1.getRangeAxis().setRange(new Range(15.0, 50.0));

    plot1.setDataset(dataset);

    XYSplineRenderer r = new XYSplineRenderer();
    BasicStroke stroke = new BasicStroke(2f);
    r.setStroke(stroke);
    plot1.setRenderer(r);
    r.setBaseShapesVisible(false);

    ChartPanel chartPanel = new ChartPanel(chart);
    JPanel jp = new JPanel(new BorderLayout());
    jp.add(chartPanel);

    add(jp, BorderLayout.CENTER);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 500);

    return jp;
}

From source file:br.ufrgs.enq.jcosmo.test.VLEdiagrams.java

/**
 * VLE diagrams using sigma profile by MOPAC
 * // ww  w  .  j a  va2  s. co m
 * @return
 * @throws Exception 
 */
@SuppressWarnings("deprecation")
public JPanel calcEthTolMOPAC() throws Exception {
    super.setTitle("P vs x1");
    double T = 60;
    setLayout(new BorderLayout());

    COSMOSACDataBase db = COSMOSACDataBase.getInstance();

    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    comps[0] = db.getComp("ethanol");
    comps[1] = db.getComp("toluene");

    COSMOSAC cosmosac = new COSMOPAC();
    cosmosac.setComponents(comps);

    cosmosac.setTemperature(T + 273.15);

    double[] x1 = new double[n];
    double[] x2 = new double[n];
    double[] gamma1 = new double[n];
    double[] gamma2 = new double[n];
    double[] z = new double[2];
    double[] lnGamma = new double[2];
    z[0] = 0.00;
    int j = 0;
    while (z[0] < 1.0001) {
        z[1] = 1 - z[0];
        x1[j] = z[0];
        x2[j] = z[1];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);
        gamma1[j] = Math.exp(lnGamma[0]);
        gamma2[j] = Math.exp(lnGamma[1]);
        z[0] += 0.05;
        j++;
    }

    double[][] parAntoine = new double[3][3];
    parAntoine[0][0] = 16.8958;
    parAntoine[0][1] = 3795.17;
    parAntoine[0][2] = 230.918;
    parAntoine[1][0] = 13.9320;
    parAntoine[1][1] = 3056.96;
    parAntoine[1][2] = 217.625;

    double[] Psat = pSat(parAntoine, T);
    double[] P = calcPx(x1, x2, gamma1, gamma2, Psat);
    double[] y1 = calcY(x1, gamma1, Psat, P);

    XYPlot plot1;
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries liq = new XYSeries("liquid");
    XYSeries vap = new XYSeries("vapor");
    XYSeries raoult = new XYSeries("Raoult's Law");
    for (int i = 0; i < n; i++) {
        liq.add(x1[i], P[i]);
        vap.add(y1[i], P[i]);
    }
    ;
    raoult.add(0, Psat[1]);
    raoult.add(1, Psat[0]);
    dataset.addSeries(liq);
    dataset.addSeries(vap);
    dataset.addSeries(raoult);

    JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction: x1, y1", "P/KPa", null,
            PlotOrientation.VERTICAL, true, true, false);
    plot1 = (XYPlot) chart.getPlot();
    plot1.getDomainAxis().setRange(new Range(0.0, 1.0));
    plot1.getRangeAxis().setRange(new Range(15.0, 50.0));

    plot1.setDataset(dataset);

    XYSplineRenderer r = new XYSplineRenderer();
    BasicStroke stroke = new BasicStroke(2f);
    r.setStroke(stroke);
    plot1.setRenderer(r);
    r.setBaseShapesVisible(false);

    ChartPanel chartPanel = new ChartPanel(chart);
    JPanel jp = new JPanel(new BorderLayout());
    jp.add(chartPanel);

    add(jp, BorderLayout.CENTER);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 500);

    return jp;
}