public void setStroke(Stroke s) { _stroke = s; /* * Code borrowed from SwingWT */ if (s == null) { _gc.setLineWidth(1); _gc.setLineCap(SWT.CAP_SQUARE); _gc.setLineJoin(SWT.JOIN_MITER); _gc.setLineDash(null); return; } if (!(s instanceof BasicStroke)) { return; } BasicStroke bs = (BasicStroke) s; // Setup the line width _gc.setLineWidth((int) bs.getLineWidth()); // Setup the line cap int gcCap = SWT.CAP_SQUARE; switch (bs.getEndCap()) { case BasicStroke.CAP_BUTT: gcCap = SWT.CAP_FLAT; break; case BasicStroke.CAP_ROUND: gcCap = SWT.CAP_ROUND; break; case BasicStroke.CAP_SQUARE: gcCap = SWT.CAP_SQUARE; break; } _gc.setLineCap(gcCap); // Setup the line Join int gcJoin = SWT.JOIN_MITER; switch (bs.getLineJoin()) { case BasicStroke.JOIN_BEVEL: gcJoin = SWT.JOIN_BEVEL; break; case BasicStroke.JOIN_MITER: gcJoin = SWT.JOIN_MITER; break; case BasicStroke.JOIN_ROUND: gcJoin = SWT.JOIN_ROUND; } _gc.setLineJoin(gcJoin); float d[] = bs.getDashArray(); int[] dashes = new int[d.length]; for (int i = 0; i < d.length; i++) { dashes[i] = (int) d[i]; } _gc.setLineDash(dashes); }