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:org.openfaces.component.chart.impl.configuration.PlotSelectionConfigurator.java

private void setupGridChartSelection(Plot plot, GridChartView chartView) {
    if (chartView.getPoint() != null) {
        GridPointInfo point = chartView.getPoint();
        final ChartSelection selection = chartView.getChart().getChartSelection();

        final LineStyle lineStyle = selection.getLineStyle();
        Paint outlinePaint = lineStyle.getColor() != null ? lineStyle.getColor() : Color.BLUE;
        final Stroke outlineStroke = lineStyle.getStroke() != null ? lineStyle.getStroke()
                : new BasicStroke(5.0F, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
        final Paint selectionPaint = selection.getFillPaint();

        Object itemRenderer = null;
        if (plot instanceof XYPlot) {
            itemRenderer = ((XYPlot) plot).getRenderer();
        } else if (plot instanceof CategoryPlot) {
            itemRenderer = ((CategoryPlot) plot).getRenderer();
        }/*from   w  ww  . jav  a  2s.  com*/

        if (itemRenderer != null && itemRenderer instanceof CustomizedRenderer) {
            if (itemRenderer instanceof BarRenderer) {
                ((BarRenderer) itemRenderer).setDrawBarOutline(true);
            } else if (itemRenderer instanceof XYBarRenderer) {
                ((XYBarRenderer) itemRenderer).setDrawBarOutline(true);
            } else if (itemRenderer instanceof XYRendererAdapter) {
                ((XYRendererAdapter) itemRenderer).setDrawOutlines(true);
            } else if (itemRenderer instanceof XYLineAndShapeRenderer) {
                ((XYLineAndShapeRenderer) itemRenderer).setDrawOutlines(true);
            }

            final SeriesInfo series = point.getSeries();
            ((CustomizedRenderer) itemRenderer).setItemOutlinePaint(series.getIndex(), point.getIndex(),
                    outlinePaint);
            ((CustomizedRenderer) itemRenderer).setItemOutlineStroke(series.getIndex(), point.getIndex(),
                    outlineStroke);

            ((CustomizedRenderer) itemRenderer).setItemPaint(series.getIndex(), point.getIndex(),
                    selectionPaint);
        }
    }
}

From source file:ChartUsingJava.CombinedXYPlotDemo1.java

/**
 * Creates an overlaid chart./*  ww w  .j ava  2  s.c  o  m*/
 *
 * @return The chart.
 */
private static JFreeChart createCombinedChart() {

    // create plot ...
    IntervalXYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    renderer1.setSeriesStroke(0, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);

    DateAxis domainAxis = new DateAxis("Year");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.02);
    ValueAxis rangeAxis = new NumberAxis("$billion");
    XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    IntervalXYDataset data2 = createDataset2();
    XYBarRenderer renderer2 = new XYBarRenderer() {
        public Paint getItemPaint(int series, int item) {
            XYDataset dataset = getPlot().getDataset();
            if (dataset.getYValue(series, item) >= 0.0) {
                return Color.red;
            } else {
                return Color.green;
            }
        }
    };
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setDrawBarOutline(false);
    renderer2.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));

    XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"), renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1", JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    chart.setBackgroundPaint(Color.white);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);
    return chart;
}

From source file:StrokeTest.java

public StrokeTestFrame() {
    setTitle("StrokeTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    canvas = new StrokeComponent();
    add(canvas, BorderLayout.CENTER);

    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(3, 3));
    add(buttonPanel, BorderLayout.NORTH);

    ButtonGroup group1 = new ButtonGroup();
    makeCapButton("Butt Cap", BasicStroke.CAP_BUTT, group1);
    makeCapButton("Round Cap", BasicStroke.CAP_ROUND, group1);
    makeCapButton("Square Cap", BasicStroke.CAP_SQUARE, group1);

    ButtonGroup group2 = new ButtonGroup();
    makeJoinButton("Miter Join", BasicStroke.JOIN_MITER, group2);
    makeJoinButton("Bevel Join", BasicStroke.JOIN_BEVEL, group2);
    makeJoinButton("Round Join", BasicStroke.JOIN_ROUND, group2);

    ButtonGroup group3 = new ButtonGroup();
    makeDashButton("Solid Line", false, group3);
    makeDashButton("Dashed Line", true, group3);
}

From source file:TransformTranslation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);/*from www . j  a  va 2  s .  c  om*/

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    g2.transform(AffineTransform.getTranslateInstance(150, 0));

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:TransformersRotation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);//from  w  w  w. j av a 2s.  c om

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6));

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:TransformScale.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);/*from  w  w  w. j  a v a  2  s .c om*/

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    g2.transform(AffineTransform.getScaleInstance(3, 3));

    // Draw the "new" shapes in dashed.
    g2.transform(AffineTransform.getTranslateInstance(75, 75));

    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:TransformTranslatedRotation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);/*from w w w .j a  v a 2s  .co m*/

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    float cm = 72 / 2.54f;
    g2.transform(AffineTransform.getRotateInstance(-Math.PI / 6, 3 * cm, 2 * cm));

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:TransformTransRotation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);//w  w w . j a v a2 s .  co m

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    AffineTransform rat = new AffineTransform();
    rat.setToTranslation(100, 0);
    rat.rotate(Math.PI / 6);
    g2.transform(rat);

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:TransformersRotationTranslation.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);/*  w  w w .j av  a 2s .  c o  m*/

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    AffineTransform rat = new AffineTransform();
    rat.setToRotation(Math.PI / 6);
    rat.translate(100, 100);

    g2.transform(rat);

    // Draw the "new" shapes in dashed.
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}

From source file:TransformShear.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    // Use antialiasing.
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Move the origin to 75, 75.
    AffineTransform at = AffineTransform.getTranslateInstance(75, 75);
    g2.transform(at);//from  w w  w.  j a  v  a 2s .co m

    // Draw the shapes in their original locations.
    g2.setPaint(Color.black);
    g2.draw(axes);
    g2.draw(shape);

    // Transform the Graphics2D.
    AffineTransform sat = AffineTransform.getTranslateInstance(150, 0);
    sat.shear(-.5, 0);
    g2.transform(sat);

    // Draw the "new" shapes in dashed.
    g2.transform(AffineTransform.getTranslateInstance(75, 75));

    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 },
            0);
    g2.setStroke(stroke);
    g2.draw(axes);
    g2.draw(shape);
}