Example usage for java.awt BasicStroke BasicStroke

List of usage examples for java.awt BasicStroke BasicStroke

Introduction

In this page you can find the example usage for java.awt BasicStroke BasicStroke.

Prototype

public BasicStroke(float width) 

Source Link

Document

Constructs a solid BasicStroke with the specified line width and with default values for the cap and join styles.

Usage

From source file:org.tsho.dmc2.core.chart.TrajectoryMultiRenderer.java

public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) {

    ValueAxis domainAxis = plot.getDomainAxis();
    ValueAxis rangeAxis = plot.getRangeAxis();

    /* transients */
    if (!continua) {
        state = STATE_TRANSIENTS;//from  w w  w.j  av  a  2  s.co  m

        for (int i = 0; i < stepperList.length; i++) {
            stepperList[i].initialize();
            prevX[i] = 0;
            prevY[i] = 0;
        }

        for (index = 0; index < transients; index++) {
            for (int i = 0; i < stepperList.length; i++) {
                stepperList[i].step();
            }
            if (stopped) {
                state = STATE_STOPPED;
                return;
            }
        }

        //            for (int i = 0; i < stepperList.length; i++) {
        //                stepperList[i].initialize();
        //                for (index = 0; index < transients; index++) {
        //                    stepperList[i].step();
        //                    if (stopped) {
        //                        state = STATE_STOPPED;
        //                        return;
        //                    }
        //                }
        //                prevX[i] = 0;
        //                prevY[i] = 0;
        //            }

        index = 0;
    }

    state = STATE_POINTS;

    Stepper.Point2D point;
    int x, y;
    int start = index;
    int end = 0;
    if (index == 0) {
        end = start + iterations + 1;
    } else {
        end = start + iterations;
    }

    Stroke stroke = new BasicStroke(7f);
    Stroke origStroke = g2.getStroke();
    Color color = Color.BLACK;

    for (; index < end; index++) {

        for (int i = 0; i < stepperList.length; i++) {
            point = stepperList[i].getCurrentPoint2D();

            if (!timePlot) {
                x = (int) domainAxis.valueToJava2D(point.getX(), dataArea, RectangleEdge.BOTTOM);
            } else {
                x = (int) domainAxis.valueToJava2D(index + transients, dataArea, RectangleEdge.BOTTOM);
            }

            y = (int) rangeAxis.valueToJava2D(point.getY(), dataArea, RectangleEdge.LEFT);

            g2.setPaint(paintList[i]);

            if (connectWithLines) {
                if (index > 0) {
                    g2.drawLine(x, y, prevX[i], prevY[i]);
                }

                prevX[i] = x;
                prevY[i] = y;
            }

            if (bigDots) {
                g2.fillRect(x - 1, y - 1, 3, 3);
            } else {
                g2.fillRect(x, y, 1, 1);
            }

            stepperList[i].step();
        }

        if (stopped) {
            state = STATE_STOPPED;
            return;
        }

        if (delay > 0) {
            try {
                Thread.sleep(delay);
            } catch (final InterruptedException e) {
            } finally {
            }
        }

    }
    state = STATE_FINISHED;
}

From source file:playground.dgrether.analysis.charts.DgTravelTimeCalculatorChart.java

@Override
public JFreeChart createChart() {
    XYSeriesCollection dataset = this.createDataSet();
    XYPlot plot = new XYPlot();
    DgAxisBuilder axisBuilder = new DgDefaultAxisBuilder();
    ValueAxis xAxis = axisBuilder.createValueAxis("Simulation Time");
    //    xAxis.setRange(this.controllerConfig.getFirstIteration(), this.controllerConfig.getLastIteration() + 2);
    ValueAxis yAxis = axisBuilder.createValueAxis("Travel Time");
    //    yAxis.setRange(-0.05, 0.3);
    //    xAxis.setVisible(false);
    //    xAxis.setFixedAutoRange(1.0);
    plot.setDomainAxis(xAxis);/*from  ww  w . j  a  v a  2s .c o m*/
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesItemLabelsVisible(0, true);
    //    renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    renderer2.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(1, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(1, colorScheme.getColor(2, "a"));
    renderer2.setSeriesStroke(2, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(2, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(2, colorScheme.getColor(3, "a"));
    renderer2.setSeriesStroke(3, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(3, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(3, colorScheme.getColor(4, "a"));

    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    //    chart.removeLegend();
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo9.java

/**
 * Creates a sample chart./*from w w w .j  a v  a  2 s.  co  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            !legendPanelOn, // include legend
            true, false);

    TextTitle title = chart.getTitle();
    title.setBorder(0, 0, 1, 0);
    title.setBackgroundPaint(new GradientPaint(0f, 0f, Color.red, 350f, 0f, Color.white, true));
    title.setExpandToFitSpace(true);

    chart.setBackgroundPaint(new GradientPaint(0f, 0f, Color.yellow, 350f, 0f, Color.white, true));

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA!");
    plot.setBackgroundPaint(null);
    plot.setInsets(new RectangleInsets(10, 5, 5, 5));
    plot.setOutlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlineStroke(new BasicStroke(1.0f));
    Paint[] colors = createPaint();
    CustomBarRenderer renderer = new CustomBarRenderer(colors);
    renderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    plot.setRenderer(renderer);

    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    // change the margin at the top of the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //   rangeAxis.setRange(0.0, 800.0);
    rangeAxis.setTickMarkPaint(Color.black);

    setCategorySummary(dataset);
    return chart;

}

From source file:com.tencent.wstt.apt.chart.AbstractRealTimeLineChart.java

/**
 * ?????//from w w w.j  av a2 s .co  m
 * ?????????
* @Title: addOneDataset  
* @Description:   
* @param pkgNames
* @param dataName
* @return 
* int ??-1
* @throws
 */
public int addOneDataset(String[] objects, String dataName) {
    if (objects == null || objects.length == 0 || dataName == null) {
        return -1;
    }

    objectNum = objects.length;
    dataNum++;
    for (int i = 0; i < objectNum; i++) {
        int index = i * dataNum + (dataNum - 1);
        chart.getXYPlot().getRenderer().setSeriesStroke(index, new BasicStroke(Constant.LINE_WIDTH));
        tsList.add(index, new TimeSeries(objects[i] + "_" + dataName));
        tsEnableList.add(index, true);
        dataset.addSeries(tsList.get(index));
    }
    return dataNum - 1;
}

From source file:com.att.aro.ui.view.diagnostictab.plot.BufferOccupancyPlot.java

@Override
public void populate(XYPlot plot, AROTraceData analysis) {

    if (analysis != null) {

        bufferFillDataCollection.removeAllSeries();
        seriesBufferFill = new XYSeries("Buffer Fill");
        seriesDataSets = new TreeMap<>();

        seriesDataSets = bufferOccupancyCalculatorImpl.populateBufferOccupancyDataSet(
                analysis.getAnalyzerResult().getVideoUsage(), chunkPlayTimeList);
        bufferSizeList.clear();//from w w w. j a  v  a2 s  .  c  o m

        double xCoordinate, yCoordinate;
        String ptCoordinate[] = new String[2]; // to hold x & y values
        if (!seriesDataSets.isEmpty()) {

            for (int key : seriesDataSets.keySet()) {
                ptCoordinate = seriesDataSets.get(key).trim().split(",");
                xCoordinate = Double.parseDouble(ptCoordinate[0]);
                yCoordinate = Double.parseDouble(ptCoordinate[1]);
                yCoordinate = yCoordinate / 1024; //Converting Buffer size measurement unit to KB
                bufferSizeList.add(yCoordinate);
                seriesBufferFill.add(xCoordinate, yCoordinate);
            }
        }
        Collections.sort(bufferSizeList);
        BufferOccupancyBPResult bufferOccupancyResult = bufferOccupancyCalculatorImpl
                .setMaxBuffer(bufferSizeList.get(bufferSizeList.size() - 1));
        bufferOccupancyResult.setBufferByteDataSet(bufferSizeList);
        analysis.getAnalyzerResult().setBufferOccupancyResult(bufferOccupancyResult);
        // populate collection
        bufferFillDataCollection.addSeries(seriesBufferFill);

        XYItemRenderer renderer = new StandardXYItemRenderer();
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {

                // Tooltip value
                Number timestamp = dataset.getX(series, item);
                Number bufferSize = dataset.getY(series, item);
                StringBuffer tooltipValue = new StringBuffer();
                tooltipValue.append(String.format("%.2f", bufferSize) + "," + String.format("%.2f", timestamp));

                String[] value = tooltipValue.toString().split(",");
                return (MessageFormat.format(BUFFEROCCUPANCY_TOOLTIP, value[0], value[1]));
                //return "BufferSize: " + String.format("%.2f", bufferSize) + "KB \n Timestamp: " + String.format("%.2f", timestamp)+"S";
            }

        });
        renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setSeriesShape(0, shape);

        plot.setRenderer(renderer);

    }
    plot.setDataset(bufferFillDataCollection);
}

From source file:adams.gui.visualization.stats.paintlet.Exponential.java

/**
 * The paint routine of the paintlet.//from  w w w. j a v  a2s .  c  o  m
 *
 * @param g      the graphics context to use for painting
 * @param moment   what {@link PaintMoment} is currently being painted
 */
@Override
protected void doPerformPaint(Graphics g, PaintMoment moment) {
    if ((m_Data != null) && (m_Sorted != null)) {
        GUIHelper.configureAntiAliasing(g, m_AntiAliasingEnabled);

        for (int i = 0; i < m_Sorted.length; i++) {
            Graphics2D g2d = (Graphics2D) g;
            //If data points are to be filled
            if (m_Fill) {
                g2d.setColor(m_FillColor);
                g2d.setStroke(new BasicStroke(0));
                g2d.fillOval(m_AxisBottom.valueToPos(m_Sorted[i]) - m_Size / 2,
                        m_AxisLeft.valueToPos(m_TransformedY[i]) - m_Size / 2, m_Size, m_Size);
            }
            //outline of data point
            g2d.setStroke(new BasicStroke(m_StrokeThickness));
            g2d.setColor(m_Color);
            g2d.drawOval(m_AxisBottom.valueToPos(m_Sorted[i]) - m_Size / 2,
                    m_AxisLeft.valueToPos(m_TransformedY[i]) - m_Size / 2, m_Size, m_Size);
        }
        //if drawing regression fit diagonal
        if (m_RegressionLine) {
            g.setColor(Color.BLACK);
            double[] newData = new double[m_Sorted.length];
            for (int i = 0; i < m_Sorted.length; i++) {
                newData[i] = Math.log(m_Sorted[i]);
            }
            ExponentialDistributionImpl ex = new ExponentialDistributionImpl(StatUtils.mean(newData));
            //draw the expected diagonal line using the exponential distribution
            for (int i = 0; i < m_Sorted.length - 1; i++) {
                double prob1;
                try {
                    prob1 = ex.cumulativeProbability(newData[i]);
                } catch (MathException e) {
                    prob1 = 0;
                }
                double prob2;
                try {
                    prob2 = ex.cumulativeProbability(newData[i + 1]);
                } catch (MathException e) {
                    prob2 = 0;
                }
                double p1 = -Math.log(1 - prob1);
                double p2 = -Math.log(1 - prob2);
                g.drawLine(m_AxisBottom.valueToPos(m_Sorted[i]), m_AxisLeft.valueToPos(p1),
                        m_AxisBottom.valueToPos(m_Sorted[i + 1]), m_AxisLeft.valueToPos(p2));
            }
        }
    }
}

From source file:org.jfree.experimental.chart.swt.editor.SWTPlotAppearanceEditor.java

SWTPlotAppearanceEditor(Composite parent, int style, Plot plot) {
    super(parent, style);
    FillLayout layout = new FillLayout();
    layout.marginHeight = layout.marginWidth = 4;
    this.setLayout(layout);

    Group general = new Group(this, SWT.NONE);
    GridLayout groupLayout = new GridLayout(3, false);
    groupLayout.marginHeight = groupLayout.marginWidth = 4;
    general.setLayout(groupLayout);/*from w  ww. j av  a2  s . c om*/
    general.setText(localizationResources.getString("General"));

    // row 1: stroke
    new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_stroke"));
    this.strokeCanvas = new SWTStrokeCanvas(general, SWT.NONE);
    this.strokeCanvas.setStroke(plot.getOutlineStroke());
    GridData strokeGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    strokeGridData.heightHint = 20;
    this.strokeCanvas.setLayoutData(strokeGridData);
    this.selectStroke = new Spinner(general, SWT.BORDER);
    this.selectStroke.setMinimum(1);
    this.selectStroke.setMaximum(3);
    this.selectStroke.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    this.selectStroke.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            int w = SWTPlotAppearanceEditor.this.selectStroke.getSelection();
            if (w > 0) {
                SWTPlotAppearanceEditor.this.strokeCanvas.setStroke(new BasicStroke(w));
                SWTPlotAppearanceEditor.this.strokeCanvas.redraw();
            }
        }
    });
    // row 2: outline color
    new Label(general, SWT.NONE).setText(localizationResources.getString("Outline_Paint"));
    this.outlinePaintCanvas = new SWTPaintCanvas(general, SWT.NONE,
            SWTUtils.toSwtColor(getDisplay(), plot.getOutlinePaint()));
    GridData outlineGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    outlineGridData.heightHint = 20;
    this.outlinePaintCanvas.setLayoutData(outlineGridData);
    Button selectOutlineColor = new Button(general, SWT.PUSH);
    selectOutlineColor.setText(localizationResources.getString("Select..."));
    selectOutlineColor.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    selectOutlineColor.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Outline_Paint"));
            dlg.setRGB(SWTPlotAppearanceEditor.this.outlinePaintCanvas.getColor().getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                SWTPlotAppearanceEditor.this.outlinePaintCanvas.setColor(new Color(getDisplay(), rgb));
            }
        }
    });
    // row 3: background paint
    new Label(general, SWT.NONE).setText(localizationResources.getString("Background_paint"));
    this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE,
            SWTUtils.toSwtColor(getDisplay(), plot.getBackgroundPaint()));
    GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    bgGridData.heightHint = 20;
    this.backgroundPaintCanvas.setLayoutData(bgGridData);
    Button selectBgPaint = new Button(general, SWT.PUSH);
    selectBgPaint.setText(localizationResources.getString("Select..."));
    selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    selectBgPaint.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Background_paint"));
            dlg.setRGB(SWTPlotAppearanceEditor.this.backgroundPaintCanvas.getColor().getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                SWTPlotAppearanceEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb));
            }
        }
    });
    // row 4: orientation
    if (plot instanceof CategoryPlot) {
        this.plotOrientation = ((CategoryPlot) plot).getOrientation();
    } else if (plot instanceof XYPlot) {
        this.plotOrientation = ((XYPlot) plot).getOrientation();
    }
    if (this.plotOrientation != null) {
        boolean isVertical = this.plotOrientation.equals(PlotOrientation.VERTICAL);
        int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL;
        new Label(general, SWT.NONE).setText(localizationResources.getString("Orientation"));
        this.orientation = new Combo(general, SWT.DROP_DOWN);
        this.orientation.setItems(orientationNames);
        this.orientation.select(index);
        this.orientation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1));
        this.orientation.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent event) {
                switch (SWTPlotAppearanceEditor.this.orientation.getSelectionIndex()) {
                case ORIENTATION_VERTICAL:
                    SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL;
                    break;
                case ORIENTATION_HORIZONTAL:
                    SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.HORIZONTAL;
                    break;
                default:
                    SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL;
                }
            }
        });
    }
}

From source file:tl.lib.dataCollection.gui.TimeSeriesChart.java

public void addPoint(SourceId sourceId, double x, double y) {
    if (default_all && !selected.contains(sourceId))
        selected.add(sourceId);//  ww  w. ja v a 2  s. c  om
    if (selected.contains(sourceId)) {
        if (collection.indexOf(sourceId) < 0) {
            XYSeries series = new XYSeries(sourceId);
            collection.addSeries(series);
            XYItemRenderer renderer = plot.getRenderer();
            renderer.setSeriesPaint(collection.indexOf(sourceId), sourceDescriptor.getColor(sourceId));
            BasicStroke wideLine = new BasicStroke(2.0f);
            renderer.setSeriesStroke(collection.indexOf(sourceId), wideLine);
        }
        collection.getSeries(sourceId).add(x, y);
    }
}

From source file:MSUmpire.DIA.RTAlignedPepIonMapping.java

private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2)
        throws IOException {
    new File(Workfolder + "/RT_Mapping/").mkdir();
    String pngfile = Workfolder + "/RT_Mapping/"
            + FilenameUtils.getBaseName(LCMSA.mzXMLFileName).substring(0,
                    Math.min(120, FilenameUtils.getBaseName(LCMSA.mzXMLFileName).length() - 1))
            + "_" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName).substring(0,
                    Math.min(120, FilenameUtils.getBaseName(LCMSB.mzXMLFileName).length() - 1))
            + "_RT.png";

    XYSeries smoothline = new XYSeries("RT fitting curve");
    for (XYZData data : regression.PredictYList) {
        smoothline.add(data.getX(), data.getY());
    }/*w  ww .jav a2  s.co  m*/
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2,
            "RT:" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName),
            "RT:" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName), xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}

From source file:com.wattzap.view.graphs.SCHRGraph.java

public SCHRGraph(ArrayList<Telemetry> telemetry[]) {
    super();/*  ww  w  .j  av a2s.  c  o m*/
    this.telemetry = telemetry;

    final NumberAxis domainAxis = new NumberAxis("Time (h:m:s)");

    domainAxis.setVerticalTickLabels(true);
    domainAxis.setTickLabelPaint(Color.black);
    domainAxis.setAutoRange(true);

    domainAxis.setNumberFormatOverride(new NumberFormat() {
        @Override
        public StringBuffer format(double millis, StringBuffer toAppendTo, FieldPosition pos) {
            if (millis >= 3600000) {
                // hours, minutes and seconds
                return new StringBuffer(

                        String.format("%d:%d:%d", TimeUnit.MILLISECONDS.toHours((long) millis),
                                TimeUnit.MILLISECONDS.toMinutes(
                                        (long) millis - TimeUnit.MILLISECONDS.toHours((long) millis) * 3600000),
                                TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES
                                        .toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else if (millis >= 60000) {
                // minutes and seconds
                return new StringBuffer(String.format("%d:%d", TimeUnit.MILLISECONDS.toMinutes((long) millis),
                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else {
                return new StringBuffer(String.format("%d", TimeUnit.MILLISECONDS.toSeconds((long) millis)
                        - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            }
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer(String.format("%s", number));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    // create plot ...
    final XYItemRenderer powerRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return orange;
        }
    };
    powerRenderer.setSeriesPaint(0, orange);
    plot = new XYPlot();
    plot.setRenderer(0, powerRenderer);
    plot.setRangeAxis(0, powerAxis);
    plot.setDomainAxis(domainAxis);

    // add a second dataset and renderer...
    final XYItemRenderer cadenceRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return cornflower;
        }

        public Shape lookupLegendShape(int series) {
            return new Rectangle(15, 15);
        }
    };

    final ValueAxis cadenceAxis = new NumberAxis(userPrefs.messages.getString("cDrpm"));
    cadenceAxis.setRange(0, 200);

    // arguments of new XYLineAndShapeRenderer are to activate or deactivate
    // the display of points or line. Set first argument to true if you want
    // to draw lines between the points for e.g.
    plot.setRenderer(1, cadenceRenderer);
    plot.setRangeAxis(1, cadenceAxis);
    plot.mapDatasetToRangeAxis(1, 1);
    cadenceRenderer.setSeriesPaint(0, cornflower);

    // add a third dataset and renderer...
    final XYItemRenderer hrRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return straw;
        }

    };

    // arguments of new XYLineAndShapeRenderer are to activate or deactivate
    // the display of points or line. Set first argument to true if you want
    // to draw lines between the points for e.g.
    final ValueAxis heartRateAxis = new NumberAxis(userPrefs.messages.getString("hrBpm"));
    heartRateAxis.setRange(0, 200);

    plot.setRenderer(2, hrRenderer);
    hrRenderer.setSeriesPaint(0, straw);

    plot.setRangeAxis(2, heartRateAxis);
    plot.mapDatasetToRangeAxis(2, 2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setBackgroundPaint(Color.DARK_GRAY);
    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.getLegend().setBackgroundPaint(Color.gray);

    chartPanel = new ChartPanel(chart);

    // TODO: maybe remember sizes set by user?
    this.setPreferredSize(new Dimension(1200, 500));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setBackground(Color.gray);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);

    SmoothingPanel smoothingPanel = new SmoothingPanel(this);
    add(smoothingPanel, BorderLayout.SOUTH);

    //infoPanel = new InfoPanel();
    //add(infoPanel, BorderLayout.NORTH);
    setVisible(true);
}