Java Utililty Methods Draw Thick Line

List of utility methods to do Draw Thick Line

Description

The list of methods to do Draw Thick Line are organized into topic(s).

Method

voiddrawThickLine(Graphics g, int x1, int y1, int x2, int y2)
draw Thick Line
float length = (float) Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
float dx = (x2 - x1) / length;
float dy = (y2 - y1) / length;
float xpos = x1;
float ypos = y1;
for (int i = 0; i < (int) length; i++) {
    drawDot(g, (int) xpos, (int) ypos);
    xpos += dx;
...
voiddrawThickLine(Graphics g, int x1, int y1, int x2, int y2, double t)
Simulates drawing of different thickness lines by using filled polygon.
double theta;
if (Math.abs(x2 - x1) > 0.01)
    theta = Math.atan((y2 - y1) / (x2 - x1));
else
    theta = Math.PI / 2;
double ct = Math.cos(theta), st = Math.sin(theta);
xtl[0] = (int) (x1 - t / 2 * st);
ytl[0] = (int) (y1 + t / 2 * ct);
...
voiddrawThickLine(Graphics g, int x1, int y1, int x2, int y2, int thickness)
Draws a line with a specified thickness
if (thickness == 1) {
    g.drawLine(x1, y1, x2, y2);
} else {
    int dX = x2 - x1;
    int dY = y2 - y1;
    double lineLength = Math.sqrt(dX * dX + dY * dY);
    double scale = (double) (thickness) / (2 * lineLength);
    double ddx = -scale * (double) dY;
...
voiddrawThickLine(Graphics graphics, int x1, int y1, int x2, int y2, int linewidth)
draw Thick Line
graphics.fillOval(x1 - linewidth / 2, y1 - linewidth / 2, linewidth, linewidth);
if (x1 == x2 && y1 == y2)
    return;
if (Math.abs(x2 - x1) > Math.abs(y2 - y1)) {
    int dy, srow;
    int dx, col, row, prevrow;
    if (x2 > x1)
        dx = 1;
...