Example usage for java.awt BasicStroke CAP_ROUND

List of usage examples for java.awt BasicStroke CAP_ROUND

Introduction

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

Prototype

int CAP_ROUND

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

Click Source Link

Document

Ends unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen.

Usage

From source file:org.n52.io.type.quantity.handler.img.LineRenderer.java

private BasicStroke getDashedLineDefinition(LineStyle lineStyle) {
    int width = lineStyle.getDashGapWidth();
    float[] dashSequence = new float[] { 4.0f * width, 4.0f * width };
    return new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, dashSequence, 0.0f);
}

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

/**
 * Creates a chart./*from  w w  w .  j  a  v  a  2 s  .c  o 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.encog.workbench.dialogs.activation.EquationPanel.java

/**
 * Creates a line chart using the data from the supplied dataset.
 *
 * @param dataset  the dataset.//w  w w  .  j av a  2 s  . c o m
 *
 * @return The chart.
 */
public static JFreeChart createChart(XYDataset dataset, ActivationFunction activation, boolean normal) {

    String title;

    if (normal) {
        title = activation.getClass().getSimpleName();
    } else {
        if (activation.hasDerivative()) {
            title = "Derv of " + activation.getClass().getSimpleName();
        } else {
            title = "NO Derv of " + activation.getClass().getSimpleName();
        }
    }

    JFreeChart chart = ChartFactory.createXYLineChart(title, "input (x)", "output (y)", dataset,
            PlotOrientation.VERTICAL, true, true, false);

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

    if (normal) {

        plot.setDomainZeroBaselineVisible(true);
        plot.setRangeZeroBaselineVisible(true);
        plot.setDomainPannable(true);
        plot.setRangePannable(true);
        ValueAxis xAxis = plot.getDomainAxis();
        xAxis.setLowerMargin(0.0);
        xAxis.setUpperMargin(0.0);
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
        r.setDrawSeriesLineAsPath(true);
        r.setSeriesStroke(0, new BasicStroke(1.5f));
        r.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 6.0f, 4.0f }, 0.0f));
        r.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 6.0f, 4.0f, 3.0f, 3.0f }, 0.0f));
        r.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                new float[] { 4.0f, 4.0f }, 0.0f));
    }

    return chart;
}

From source file:net.imglib2.script.analysis.BarChart.java

static private void setBackgroundDefault(final JFreeChart chart) {
    BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 1.0f }, 0.0f);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeGridlineStroke(gridStroke);
    plot.setDomainGridlineStroke(gridStroke);
    plot.setBackgroundPaint(new Color(235, 235, 235));
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setOutlineVisible(false);//from ww w .j  ava2 s .  c  om
    plot.getDomainAxis().setAxisLineVisible(false);
    plot.getRangeAxis().setAxisLineVisible(false);
    plot.getDomainAxis().setLabelPaint(Color.gray);
    plot.getRangeAxis().setLabelPaint(Color.gray);
    plot.getDomainAxis().setTickLabelPaint(Color.gray);
    plot.getRangeAxis().setTickLabelPaint(Color.gray);
    chart.getTitle().setPaint(Color.gray);
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.TimeChartRenderer.java

public void createChart() {
    XYDataset dataset = (XYDataset) this.datasetStrategy.getDataset();
    report = ChartFactory.createTimeSeriesChart(this.datasetStrategy.getTitle(), // title
            this.datasetStrategy.getXAxisLabel(), // x-axis label
            this.datasetStrategy.getYAxisLabel(), // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );/*www  . ja  v  a2s.  c  o m*/

    // report.setBackgroundPaint( Color.lightGray );
    XYPlot plot = report.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    XYItemRenderer xyitemrenderer = plot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyitemrenderer;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);

        renderer.setBaseShapesVisible(true);
        renderer.setDrawOutlines(true);
        renderer.setBaseItemLabelGenerator(
                ((AbstractTimeChartStrategy) this.datasetStrategy).getLabelGenerator());
        renderer.setBaseItemLabelFont(new Font("SansSerif", Font.BOLD, 10));
        renderer.setBaseItemLabelsVisible(true);
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BASELINE_RIGHT));
    }

    Paint[] paints = this.datasetStrategy.getPaintColor();
    for (int i = 0; i < dataset.getSeriesCount() && i < paints.length; i++) {
        xyitemrenderer.setSeriesPaint(i, paints[i]);
        xyitemrenderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    }
    plot.setRangeAxis(((AbstractTimeChartStrategy) this.datasetStrategy).getRangeAxis());
    DashDateAxis axisDate = new DashDateAxis();
    axisDate.setDateFormatOverride(
            ((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod().getDateFormat());
    axisDate.setLabel(this.datasetStrategy.getXAxisLabel());
    axisDate.setTickUnit(getTickUnit(((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod()));
    axisDate.setUpperMargin(0.0D);
    axisDate.setDateTickLabelAngle(-0.6);

    if (((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate() != null
            && ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate() != null) {
        axisDate.setRangeWithMargins(
                new DateRange(((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate(),
                        ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate()));

    }
    plot.setDomainAxis(axisDate);

    Date[] dates = DateUtils.getAllDates(((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate(),
            ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate(),
            ((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod());
    int width = (dates.length * ChartUtils.STANDARD_TIME_ENTRY_WIDTH)
            + ChartUtils.STANDARD_TIME_ADDITIONAL_WIDTH;
    if (width > ChartUtils.MINIMUM_WIDTH) {
        this.setWidth(width);
    } else {
        this.setWidth(ChartUtils.MINIMUM_WIDTH);
    }
}

From source file:view.FuzzySetView.java

/**
 *
 *///from ww  w .j ava  2 s  . c  o m
public void showFuzzyValues() {
    clearMarkers();

    BasicStroke dashedStroke = new BasicStroke(1.7f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 6f,
            new float[] { 6f }, 0);
    double crispValue = 0;
    FuzzySet fuzzySet = getFuzzySet();
    for (int i = 0; i < fuzzySet.getMembershipValuesLength(); i++) {
        MembershipValue value = fuzzySet.getMembershipValueAt(i);
        if (value != null) {
            ValueMarker marker = new ValueMarker(value.getValue(), colors[i], dashedStroke);
            plot.addRangeMarker(marker);

            crispValue = value.getCrispValue();
        }
    }
    plot.addDomainMarker(new ValueMarker(crispValue, Color.BLACK, dashedStroke));
}

From source file:application.BrokersMouseListener.java

@Override
public void graphClicked(Object arg0, MouseEvent arg1) {

    //Reset the selected variable for all the broker
    ListIterator<Broker> it = state.getBrokersList();
    while (it.hasNext()) {
        it.next().resetSelected();/*ww w .j  a v  a2s  .  c  o  m*/
    }

    Broker broker = (Broker) arg0;

    //SET the selected variable for THE SPECIFIC broker
    broker.setSelected();
    Transformer<Broker, Paint> vertexPaint = new Transformer<Broker, Paint>() {
        public Paint transform(Broker b) {
            if (b.selected()) {
                return Color.GREEN;
            }
            return Color.GRAY;
        }
    };

    //Reset the selected variable for all the link
    it = state.getBrokersList();
    while (it.hasNext()) {
        Broker b = it.next();
        ListIterator<Interface> intit = b.getInterfaces();
        while (intit.hasNext()) {
            Interface ix = intit.next();
            ix.getLink().resetSelected();
        }
    }

    //SET the selected variable for THE SPECIFIC links
    it = state.getBrokersList();
    while (it.hasNext()) {
        Broker b = it.next();
        ListIterator<Interface> intit = b.getInterfaces();
        if (b.equals(broker)) {
            while (intit.hasNext()) {
                Interface ix = intit.next();
                ix.getLink().setSelected();
            }
        } else {
            while (intit.hasNext()) {
                Interface ix = intit.next();
                ix.getLink().setSelectedBcastFunction(state.getBrokerPosition(broker));
            }
        }
    }

    Transformer<Link, Stroke> edgeStrokeTransformer = new Transformer<Link, Stroke>() {
        public Stroke transform(Link link) {

            if (link.selected()) {
                final Stroke edgeStroke = new BasicStroke(2);
                return edgeStroke;
            } else {
                float[] dot = { 1.0f, 3.0f };
                final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                        1.0f, dot, 0f);
                return edgeStroke;
            }
        }
    };

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);

    //((FRLayout)layout).initialize();
    //((FRLayout)layout).step();
    vv.repaint();
}

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 www  . j  a v  a 2s .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: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?
    );/* ww  w. j ava2s . com*/

    // 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:edu.coeia.charts.LineChartPanel.java

/**
 * Creates a sample chart.//from w  w w .ja  v a2 s  .c  o  m
 *
 * @param dataset  a dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createLineChart("Frequency of Messages", // chart title
            "Time of Messages", // domain axis label
            "Number of Messages", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    // customise the renderer...
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 10.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 6.0f }, 0.0f));

    return chart;
}