Example usage for org.jfree.chart.renderer.category StatisticalLineAndShapeRenderer setBaseStroke

List of usage examples for org.jfree.chart.renderer.category StatisticalLineAndShapeRenderer setBaseStroke

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category StatisticalLineAndShapeRenderer setBaseStroke.

Prototype

public void setBaseStroke(Stroke stroke) 

Source Link

Document

Sets the base stroke and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:guineu.modules.visualization.intensityplot.IntensityPlotFrame.java

public IntensityPlotFrame(ParameterSet parameters) {
    super("", true, true, true, true);

    String title = "Intensity plot [" + GuineuCore.getDesktop().getSelectedDataFiles()[0].getDatasetName()
            + "]";
    String xAxisLabel = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue().toString();

    // create dataset
    dataset = new IntensityPlotDataset(parameters);

    // create new JFreeChart
    logger.finest("Creating new chart instance");

    chart = ChartFactory.createLineChart(title, xAxisLabel, "Height", dataset, PlotOrientation.VERTICAL, true,
            true, false);//from w w  w  .j  a  v a2  s .c o m

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

    // set renderer
    StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(false, true);
    renderer.setBaseStroke(new BasicStroke(2));
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);

    // set tooltip generator
    CategoryToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator();
    renderer.setBaseToolTipGenerator(toolTipGenerator);

    CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    chart.setBackgroundPaint(Color.white);

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

    IntensityPlotToolBar toolBar = new IntensityPlotToolBar(this);
    add(toolBar, BorderLayout.EAST);

    // disable maximum size (we don't want scaling)
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    // set title properties
    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    LegendTitle legend = chart.getLegend();
    legend.setItemFont(legendFont);
    legend.setBorder(0, 0, 0, 0);

    Plot dplot = chart.getPlot();

    // set shape provider
    IntensityPlotDrawingSupplier shapeSupplier = new IntensityPlotDrawingSupplier();
    dplot.setDrawingSupplier(shapeSupplier);

    // set y axis properties
    NumberAxis yAxis;

    yAxis = (NumberAxis) ((CategoryPlot) dplot).getRangeAxis();

    NumberFormat yAxisFormat = new DecimalFormat("0.0E0");
    yAxis.setNumberFormatOverride(yAxisFormat);

    setTitle(title);
    setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
    setBackground(Color.white);
    pack();

}

From source file:net.sf.mzmine.modules.visualization.intensityplot.IntensityPlotFrame.java

public IntensityPlotFrame(ParameterSet parameters) {

    PeakList peakList = parameters.getParameter(IntensityPlotParameters.peakList).getValue()[0];

    String title = "Intensity plot [" + peakList + "]";
    String xAxisLabel = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue().toString();
    String yAxisLabel = parameters.getParameter(IntensityPlotParameters.yAxisValueSource).getValue().toString();

    // create dataset
    dataset = new IntensityPlotDataset(parameters);

    // create new JFreeChart
    logger.finest("Creating new chart instance");
    Object xAxisValueSource = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue();
    boolean isCombo = (xAxisValueSource instanceof ParameterWrapper)
            && (((ParameterWrapper) xAxisValueSource).getParameter() instanceof ComboParameter);
    if ((xAxisValueSource == IntensityPlotParameters.rawDataFilesOption) || isCombo) {

        chart = ChartFactory.createLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL,
                true, true, false);//  w ww.  ja  v  a  2  s .co  m

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

        // set renderer
        StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(false, true);
        renderer.setBaseStroke(new BasicStroke(2));
        plot.setRenderer(renderer);
        plot.setBackgroundPaint(Color.white);

        // set tooltip generator
        CategoryToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator();
        renderer.setBaseToolTipGenerator(toolTipGenerator);

        CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
        xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    } else {

        chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL,
                true, true, false);

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

        XYErrorRenderer renderer = new XYErrorRenderer();
        renderer.setBaseStroke(new BasicStroke(2));
        plot.setRenderer(renderer);
        plot.setBackgroundPaint(Color.white);

        // set tooltip generator
        XYToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator();
        renderer.setBaseToolTipGenerator(toolTipGenerator);

    }

    chart.setBackgroundPaint(Color.white);

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

    IntensityPlotToolBar toolBar = new IntensityPlotToolBar(this);
    add(toolBar, BorderLayout.EAST);

    // disable maximum size (we don't want scaling)
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    // set title properties
    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    LegendTitle legend = chart.getLegend();
    legend.setItemFont(legendFont);
    legend.setBorder(0, 0, 0, 0);

    Plot plot = chart.getPlot();

    // set shape provider
    IntensityPlotDrawingSupplier shapeSupplier = new IntensityPlotDrawingSupplier();
    plot.setDrawingSupplier(shapeSupplier);

    // set y axis properties
    NumberAxis yAxis;
    if (plot instanceof CategoryPlot)
        yAxis = (NumberAxis) ((CategoryPlot) plot).getRangeAxis();
    else
        yAxis = (NumberAxis) ((XYPlot) plot).getRangeAxis();
    NumberFormat yAxisFormat = MZmineCore.getConfiguration().getIntensityFormat();
    if (parameters.getParameter(IntensityPlotParameters.yAxisValueSource).getValue() == YAxisValueSource.RT)
        yAxisFormat = MZmineCore.getConfiguration().getRTFormat();
    yAxis.setNumberFormatOverride(yAxisFormat);

    setTitle(title);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBackground(Color.white);
    pack();

}

From source file:net.sf.mzmine.modules.visualization.intensityplot.IntensityPlotWindow.java

public IntensityPlotWindow(ParameterSet parameters) {

    PeakList peakList = parameters.getParameter(IntensityPlotParameters.peakList).getValue()
            .getMatchingPeakLists()[0];/*from   w  w w.  j a  v a  2 s .c om*/

    String title = "Intensity plot [" + peakList + "]";
    String xAxisLabel = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue().toString();
    String yAxisLabel = parameters.getParameter(IntensityPlotParameters.yAxisValueSource).getValue().toString();

    // create dataset
    dataset = new IntensityPlotDataset(parameters);

    // create new JFreeChart
    logger.finest("Creating new chart instance");
    Object xAxisValueSource = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue();
    boolean isCombo = (xAxisValueSource instanceof ParameterWrapper)
            && (!(((ParameterWrapper) xAxisValueSource).getParameter() instanceof DoubleParameter));
    if ((xAxisValueSource == IntensityPlotParameters.rawDataFilesOption) || isCombo) {

        chart = ChartFactory.createLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL,
                true, true, false);

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

        // set renderer
        StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(false, true);
        renderer.setBaseStroke(new BasicStroke(2));
        plot.setRenderer(renderer);
        plot.setBackgroundPaint(Color.white);

        // set tooltip generator
        CategoryToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator();
        renderer.setBaseToolTipGenerator(toolTipGenerator);

        CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
        xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    } else {

        chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL,
                true, true, false);

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

        XYErrorRenderer renderer = new XYErrorRenderer();
        renderer.setBaseStroke(new BasicStroke(2));
        plot.setRenderer(renderer);
        plot.setBackgroundPaint(Color.white);

        // set tooltip generator
        XYToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator();
        renderer.setBaseToolTipGenerator(toolTipGenerator);

    }

    chart.setBackgroundPaint(Color.white);

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

    IntensityPlotToolBar toolBar = new IntensityPlotToolBar(this);
    add(toolBar, BorderLayout.EAST);

    // disable maximum size (we don't want scaling)
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    // set title properties
    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    LegendTitle legend = chart.getLegend();
    legend.setItemFont(legendFont);
    legend.setBorder(0, 0, 0, 0);

    Plot plot = chart.getPlot();

    // set shape provider
    IntensityPlotDrawingSupplier shapeSupplier = new IntensityPlotDrawingSupplier();
    plot.setDrawingSupplier(shapeSupplier);

    // set y axis properties
    NumberAxis yAxis;
    if (plot instanceof CategoryPlot)
        yAxis = (NumberAxis) ((CategoryPlot) plot).getRangeAxis();
    else
        yAxis = (NumberAxis) ((XYPlot) plot).getRangeAxis();
    NumberFormat yAxisFormat = MZmineCore.getConfiguration().getIntensityFormat();
    if (parameters.getParameter(IntensityPlotParameters.yAxisValueSource).getValue() == YAxisValueSource.RT)
        yAxisFormat = MZmineCore.getConfiguration().getRTFormat();
    yAxis.setNumberFormatOverride(yAxisFormat);

    setTitle(title);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBackground(Color.white);

    // Add the Windows menu
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(new WindowsMenu());
    setJMenuBar(menuBar);

    pack();

    // get the window settings parameter
    ParameterSet paramSet = MZmineCore.getConfiguration().getModuleParameters(IntensityPlotModule.class);
    WindowSettingsParameter settings = paramSet.getParameter(IntensityPlotParameters.windowSettings);

    // update the window and listen for changes
    settings.applySettingsToWindow(this);
    this.addComponentListener(settings);

}