Example usage for java.awt BasicStroke JOIN_BEVEL

List of usage examples for java.awt BasicStroke JOIN_BEVEL

Introduction

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

Prototype

int JOIN_BEVEL

To view the source code for java.awt BasicStroke JOIN_BEVEL.

Click Source Link

Document

Joins path segments by connecting the outer corners of their wide outlines with a straight segment.

Usage

From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java

public JVMMemoryProfilerPanel() {
    initComponents();//  w  ww.j a  v a  2 s.c  o  m
    profiler = new JVMMemoryProfiler(frequency);
    profiler.addListener(new JVMMemoryProfilerListener() {

        @Override
        public void addScore(long t, long f) {
            total.add(new Millisecond(), t);
            free.add(new Millisecond(), f);
        }
    });

    total = new TimeSeries("Total Memory");
    total.setMaximumItemCount(historyCount);
    free = new TimeSeries("Free Memory");
    free.setMaximumItemCount(historyCount);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(total);
    dataset.addSeries(free);

    final DateAxis domain = new DateAxis("Time");
    final NumberAxis range = new NumberAxis("Memory");
    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYItemRenderer renderer = new DefaultXYItemRenderer();
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.green);
    renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));

    final XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);

    final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot,
            true);
    chart.setBackgroundPaint(Color.white);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12));

    add(chartPanel, BorderLayout.CENTER);
}

From source file:com.orsonpdf.demo.PDFTimeSeriesChartDemo1.java

/**
 * Creates a chart./* w  w w  . j  a  v  a  2 s.  c om*/
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices",
            null, "US cents/lb", dataset, true, false, false);

    String fontName = "Palatino";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf",
            new Font(fontName, Font.PLAIN, 14)));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(false);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.setRangeGridlinePaint(Color.red);
    plot.setDomainGridlinePaint(Color.red);
    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);
    chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setDrawSeriesLineAsPath(true);
        // set the default stroke for all series
        renderer.setAutoPopulateSeriesStroke(false);
        renderer.setBaseStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false);
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesPaint(1, new Color(24, 123, 58));
        renderer.setSeriesPaint(2, new Color(149, 201, 136));
        renderer.setSeriesPaint(3, new Color(1, 62, 29));
        renderer.setSeriesPaint(4, new Color(81, 176, 86));
        renderer.setSeriesPaint(5, new Color(0, 55, 122));
        renderer.setSeriesPaint(6, new Color(0, 92, 165));
    }
    return chart;
}

From source file:org.jfree.graphics2d.demo.SVGTimeSeriesChartDemo1.java

/**
 * Creates a chart.//from   ww  w . ja va2s.co  m
 *
 * @param dataset  a dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices",
            null, "US cents/lb", dataset);

    String fontName = "Palatino";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf",
            new Font(fontName, Font.PLAIN, 14)));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(false);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.setRangeGridlinePaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.GRAY);
    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);
    chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setDrawSeriesLineAsPath(true);
        // set the default stroke for all series
        renderer.setAutoPopulateSeriesStroke(false);
        renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false);
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesPaint(1, new Color(24, 123, 58));
        renderer.setSeriesPaint(2, new Color(149, 201, 136));
        renderer.setSeriesPaint(3, new Color(1, 62, 29));
        renderer.setSeriesPaint(4, new Color(81, 176, 86));
        renderer.setSeriesPaint(5, new Color(0, 55, 122));
        renderer.setSeriesPaint(6, new Color(0, 92, 165));
    }

    return chart;

}

From source file:org.fhaes.jsea.JSEABarChart.java

/**
 * Creates a demo chart.//from w  ww. j  av  a  2s.com
 * 
 * @return A chart.
 */
@SuppressWarnings("deprecation")
public static JFreeChart createChart(String title, double[] meanByWindow, int lengthOfWindow,
        int yearsPriorOfEvent, int yearsAfterEvent, double[][] leftEndPointSim, double[][] rightEndPointSim,
        String outputFilePrefix, int alphaLevel, int segmentIndex) {

    JSEABarChart.meanByWindow = meanByWindow;
    JSEABarChart.lengthOfWindow = lengthOfWindow;
    JSEABarChart.yearsPriorOfEvent = yearsPriorOfEvent;
    JSEABarChart.leftEndPointSim = leftEndPointSim;
    JSEABarChart.rightEndPointSim = rightEndPointSim;
    JSEABarChart.alphaLevel = alphaLevel;

    CategoryPlot plot = new CategoryPlot();
    plot.setDataset(0, createDataset());
    plot.setOrientation(PlotOrientation.VERTICAL);

    CustomBarRenderer renderer = new CustomBarRenderer(createPaint(lengthOfWindow, Color.gray));
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setDrawBarOutline(false);
    renderer.setOutlinePaint(Color.yellow);
    renderer.setOutlineStroke(new BasicStroke(1.1f, BasicStroke.JOIN_ROUND, BasicStroke.JOIN_BEVEL));
    renderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    plot.setRenderer(0, renderer);
    Color allcolors[] = { Color.red, Color.green, Color.blue };

    System.out.println("here is the alphlevel " + alphaLevel);
    // for (int k = 0; k <= 5; k++) {
    // if (k <= 2) {
    // / plot.setDataset(k + 1, createEndDataset(k, true));
    // plot.setRenderer(k + 1, createCategoryItemRenderer(allcolors[k], k));
    // } else {
    // plot.setDataset(k + 1, createEndDataset(k - 3, false));
    // plot.setRenderer(k + 1, createCategoryItemRenderer(allcolors[k - 3], k - 3));
    // }
    // }
    // for (int k = 0; k <1; k++) {
    // if (k <= 2) {
    plot.setDataset(1, createEndDataset(alphaLevel, true));
    plot.setRenderer(1, createCategoryItemRenderer(allcolors[alphaLevel], alphaLevel));
    // } else {
    plot.setDataset(4, createEndDataset(alphaLevel, false));
    plot.setRenderer(4, createCategoryItemRenderer(allcolors[alphaLevel], alphaLevel));
    // }
    // }
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    // plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainAxis(new CategoryAxis("LAG"));

    plot.addRangeMarker(new ValueMarker(0));

    plot.setRangeAxis(new NumberAxis(outputFilePrefix));
    plot.setRangeGridlinesVisible(true);

    JFreeChart chart = new JFreeChart(plot);
    chart.setTitle(title);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.WHITE);

    return chart;
}

From source file:eu.choreos.vv.chart.XYChart.java

private static JFreeChart createChart(XYDataset dataset, String chartTitle, String xLabel, String yLabel) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // initial series
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from w w  w .  j  a v  a2 s . co  m

    // set chart background
    chart.setBackgroundPaint(Color.white);

    // set a few custom plot features
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(0xffffe0));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // set the plot's axes to display integers
    TickUnitSource ticks = NumberAxis.createIntegerTickUnits();
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setStandardTickUnits(ticks);
    domain.resizeRange(1.1);
    domain.setLowerBound(0.5);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setStandardTickUnits(ticks);
    range.setUpperBound(range.getUpperBound() * 1.1);

    // render shapes and lines
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true);
    plot.setRenderer(renderer);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // set the renderer's stroke
    Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
    renderer.setBaseOutlineStroke(stroke);

    // label the points
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(2);
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator(
            StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format);
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelsVisible(true);

    return chart;
}

From source file:edu.scripps.fl.curves.plot.CurvePlotDrawingSupplier.java

public void setLineWidth(double width) {
    this.strokeSequence = new Stroke[] {
            new BasicStroke((float) width, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL) };
}

From source file:eu.choreos.vv.chart.YIntervalChart.java

private static JFreeChart createChart(XYDataset dataset, String chartTitle, String xLabel, String yLabel) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // initial series
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from   w ww.j a v  a  2 s .  co m*/

    // set chart background
    chart.setBackgroundPaint(Color.white);

    // set a few custom plot features
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(0xffffe0));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // set the plot's axes to display integers
    TickUnitSource ticks = NumberAxis.createIntegerTickUnits();
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setStandardTickUnits(ticks);
    domain.resizeRange(1.1);
    domain.setLowerBound(0.5);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setStandardTickUnits(ticks);
    range.setUpperBound(range.getUpperBound() * 1.1);

    // render shapes and lines
    DeviationRenderer renderer = new DeviationRenderer(true, true);
    plot.setRenderer(renderer);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // set the renderer's stroke
    Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
    renderer.setBaseOutlineStroke(stroke);

    //TODO: render the deviation with the same color as the line
    //        renderer.setBaseFillPaint(new Color(255, 200, 200));
    //        renderer.setUseOutlinePaint(flag);
    //        renderer.setUseFillPaint(flag);

    // label the points
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(2);
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator(
            StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format);
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelsVisible(true);

    //TODO: fix the visible area to show the deviation

    return chart;
}

From source file:eu.choreos.chart.XYChart.java

private JFreeChart createChart(XYDataset dataset, String chartTitle) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            "Execution size", // domain axis label
            "Range", // range axis label
            dataset, // initial series
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from  www  .  j  a va  2s  .  c  om

    // set chart background
    chart.setBackgroundPaint(Color.white);

    // set a few custom plot features
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(0xffffe0));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // set the plot's axes to display integers
    TickUnitSource ticks = NumberAxis.createIntegerTickUnits();
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setStandardTickUnits(ticks);
    domain.resizeRange(1.1);
    domain.setLowerBound(0.5);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setStandardTickUnits(ticks);
    range.setUpperBound(range.getUpperBound() * 1.1);

    // render shapes and lines
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true);
    plot.setRenderer(renderer);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // set the renderer's stroke
    Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
    renderer.setBaseOutlineStroke(stroke);

    // label the points
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(2);
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator(
            StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format);
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelsVisible(true);

    return chart;
}

From source file:com.bdb.weather.display.freeplot.FreePlot.java

/**
 * Build the Stroke objects that will be used for each series collection.
 *///from   w  w w.  ja v a  2  s . c  om
private void buildStrokes() {
    strokes = new BasicStroke[STROKE_DASH.length + 1];
    //
    // The zeroith series is a solid line
    //
    strokes[0] = new BasicStroke(STROKE_WEIGHT);

    //
    // The rest of the strokes are build from the STROKE_DASH array
    //
    for (int i = 1; i < strokes.length; i++) {
        strokes[i] = new BasicStroke(STROKE_WEIGHT, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f,
                STROKE_DASH[i - 1], 0.0f);
    }
}

From source file:ca.nengo.plot.impl.DefaultPlotter.java

/**
 * @see ca.nengo.plot.Plotter#doPlot(ca.nengo.util.TimeSeries, ca.nengo.util.TimeSeries, java.lang.String)
 *//*from   www  . jav  a  2 s  .  co  m*/
public void doPlot(TimeSeries ideal, TimeSeries actual, String title) {
    XYSeriesCollection idealDataset = getDataset(ideal);
    XYSeriesCollection actualDataset = getDataset(actual);

    JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (s)", "", idealDataset,
            PlotOrientation.VERTICAL, false, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDataset(1, actualDataset);

    XYLineAndShapeRenderer idealRenderer = new XYLineAndShapeRenderer(true, false);
    idealRenderer.setDrawSeriesLineAsPath(true);
    idealRenderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10f,
            new float[] { 10f, 10f }, 0f));
    plot.setRenderer(plot.indexOf(idealDataset), idealRenderer);

    XYLineAndShapeRenderer actualRenderer = new XYLineAndShapeRenderer(true, false);
    actualRenderer.setDrawSeriesLineAsPath(true);
    //idealRenderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10f, new float[]{10f, 10f}, 0f));
    plot.setRenderer(plot.indexOf(actualDataset), actualRenderer);

    showChart(chart, "Time Series Plot");
}