Example usage for java.awt BasicStroke JOIN_ROUND

List of usage examples for java.awt BasicStroke JOIN_ROUND

Introduction

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

Prototype

int JOIN_ROUND

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

Click Source Link

Document

Joins path segments by rounding off the corner at a radius of half the line width.

Usage

From source file:Main.java

static public void main(String args[]) throws Exception {
    int width = 200, height = 200;
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

    Graphics2D ig2 = bi.createGraphics();
    ig2.fillRect(0, 0, width - 1, height - 1);

    BasicStroke stroke = new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    ig2.setPaint(Color.lightGray);
    ig2.setStroke(stroke);//from   ww w .  j av a 2 s.co m
    ig2.draw(new Ellipse2D.Double(0, 0, 100, 100));

    ImageIO.write(bi, "GIF", new File("a.gif"));
}

From source file:LinesDashes3.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;

    float[] dash3 = { 4f, 0f, 2f };

    BasicStroke bs3 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash3, 2f);

    g2d.setStroke(bs3);/* w  ww.ja va 2s .  co m*/
    g2d.drawLine(20, 60, 250, 60);
}

From source file:LinesDashes4.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;

    float[] dash4 = { 4f, 4f, 1f };

    BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4, 2f);

    g2d.setStroke(bs4);//from  w  w  w. j a va  2  s  .  com
    g2d.drawLine(20, 20, 250, 20);
}

From source file:LinesDashes2.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = (Graphics2D) g;
    g2d.drawLine(20, 40, 250, 40);/*from   w ww  .ja  v a  2s  .c o  m*/
    float[] dash2 = { 1f, 1f, 1f };

    BasicStroke bs2 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash2, 2f);
    g2d.setStroke(bs2);
    g2d.drawLine(20, 20, 250, 20);
}

From source file:LinesDashes1.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = (Graphics2D) g;

    float[] dash1 = { 2f, 0f, 2f };

    g2d.drawLine(20, 40, 250, 40);//from   ww  w.  j  a  va 2 s  .c o  m

    BasicStroke bs1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash1, 2f);
    g2d.setStroke(bs1);
    g2d.drawLine(20, 80, 250, 80);

}

From source file:LinesDashes1.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = (Graphics2D) g;

    float[] dash1 = { 2f, 0f, 2f };

    g2d.drawLine(20, 40, 250, 40);/*from w  ww  .j  a v  a  2 s . c  o m*/

    BasicStroke bs1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash1, 2f);
    //BasicStroke bs2 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash2,2f);
    //float[] dash3 = { 4f, 0f, 2f };
    //BasicStroke bs3 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash3,2f);

    //float[] dash4 = { 4f, 4f, 1f };
    //BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4,2f);

    g2d.setStroke(bs1);
    g2d.drawLine(20, 80, 250, 80);

}

From source file:Main.java

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

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/*from   w w  w. j a v  a  2  s.  c om*/

    BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
    g2.setStroke(bs);

    GeneralPath path = new GeneralPath();
    path.moveTo(30.0f, 90.0f);
    path.lineTo(150.0f, 20.0f);
    path.lineTo(270.0f, 90.0f);
    g2.draw(path);
}

From source file:MainClass.java

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

    RenderingHints rh = g2.getRenderingHints();
    rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHints(rh);/*from   ww  w . jav  a 2  s  .co m*/

    BasicStroke bs = new BasicStroke(36.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
    g2.setStroke(bs);

    GeneralPath path = new GeneralPath();
    path.moveTo(30.0f, 90.0f);
    path.lineTo(150.0f, 20.0f);
    path.lineTo(270.0f, 90.0f);
    g2.draw(path);

}

From source file:Main.java

public static String convertLineJoinToString(int lineJoin) {
    if (lineJoin == BasicStroke.JOIN_BEVEL)
        return "bevel";
    else if (lineJoin == BasicStroke.JOIN_MITER)
        return "miter";
    else if (lineJoin == BasicStroke.JOIN_ROUND)
        return "round";
    return null;/*from   w  w  w  .j  a  v a  2  s  .co  m*/
}

From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.CompassRenderer.java

@Override
public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot,
        XYDataset dataset, int seriesIndex) {

    // compute the right color for the paint
    int length = GuiUtils.getAvailableColors().length;
    Color color = GuiUtils.getAvailableColors()[index % length];
    // get all the data points
    int numPoints = dataset.getItemCount(seriesIndex);
    // set STroke and Paint of the graphics
    g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175));

    // iterate through the points of the dataset
    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i); // the angle at the center         
        double radius = dataset.getYValue(seriesIndex, i); // the frequency

        Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea);
        Point p1 = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea);

        Line2D line = new Line2D.Double(p0, p1);
        g2.draw(line);//from www.j  ava 2s.  c  o m
    }
}