Java Graphics Draw drawDottedDashLine(Graphics2D g, int x1, int y1, int x2, int y2)

Here you can find the source of drawDottedDashLine(Graphics2D g, int x1, int y1, int x2, int y2)

Description

draw Dotted Dash Line

License

LGPL

Declaration

public static void drawDottedDashLine(Graphics2D g, int x1, int y1, int x2, int y2) 

Method Source Code


//package com.java2s;
/*/* www .  java  2 s . c o  m*/
 * Copyright (c) 2007-2012 The Broad Institute, Inc.
 * SOFTWARE COPYRIGHT NOTICE
 * This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved.
 *
 * This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality.
 *
 * This software is licensed under the terms of the GNU Lesser General Public License (LGPL),
 * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php.
 */

import java.awt.*;

public class Main {
    public static void drawDottedDashLine(Graphics2D g, int x1, int y1, int x2, int y2) {
        Stroke thindashed = new BasicStroke(1.0f, // line width
                BasicStroke.CAP_BUTT, // cap style
                BasicStroke.JOIN_BEVEL, 1.0f, // join style, miter limit
                new float[] { 8.0f, 3.0f, 2.0f, 3.0f }, // the dash pattern :  on 8, off 3, on 2, off 3
                0.0f); // the dash phase
        drawDashedLine(g, thindashed, x1, y1, x2, y2);

    }

    public static void drawDashedLine(Graphics2D g, int x1, int y1, int x2, int y2) {
        Stroke thindashed = new BasicStroke(1.0f, // line width
                BasicStroke.CAP_BUTT, // cap style
                BasicStroke.JOIN_BEVEL, 1.0f, // join style, miter limit
                new float[] { 3.0f, 3.0f }, // the dash pattern :  on 8, off 3, on 2, off 3
                0.0f); // the dash phase
        drawDashedLine(g, thindashed, x1, y1, x2, y2);

    }

    /**
     * Method description
     * Stroke thindashed = new BasicStroke(thickness, // line width
     * BasicStroke.CAP_BUTT, // cap style
     * BasicStroke.JOIN_BEVEL, 1.0f, // join style, miter limit
     * dashPattern, // the dash pattern :  on 8, off 3, on 2, off 3
     * phase);  // the dash phase
     *
     * @param g
     */
    public static void drawDashedLine(Graphics2D g, Stroke stroke, int x1, int y1, int x2, int y2) {

        Stroke currentStroke = g.getStroke();
        g.setStroke(stroke);
        g.drawLine(x1, y1, x2, y2);
        g.setStroke(currentStroke);

    }
}

Related

  1. drawCube(Graphics g, int x, int y, int w, int h, int d, float fac)
  2. drawDiamond(Graphics2D g2d, int xPos, int yPos)
  3. drawDisc(Graphics g)
  4. drawDot(Graphics g, int x, int y)
  5. drawDots(Graphics g, int x0, int y0, int x1, int y1, int interval)
  6. drawDottedRect(Graphics g, int x, int y, int w, int h)
  7. drawDropshipISPip(Graphics2D g2d, int width, int height, int circleSize, int fillCircleSize)
  8. drawEdge(Graphics g, int w, int h)
  9. drawEtchedRect(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)