stroke = new BasicStroke(
            0.2f*ds,//width
            BasicStroke.CAP_SQUARE,
            BasicStroke.JOIN_BEVEL);//don't care
    g2.setStroke(stroke);
    g2.setPaint(Color.blue);
    g2.draw(new Line2D.Double(
               -1.5*ds,-0.5*ds,-0.5*ds,-0.5*ds));

Figure 5