ShapePainter - そしてdrop me
2008/08/16
java
swingx
Javaです。swingxです。
BasicStrokeの使い方よくわかないです.....
下記のコードはなんとなくできたのでよろしくないかもです。
背景の市松模様はCheckerboardPainterです。
BasicStrokeからcreateStrokedShapeするとshapeが作れるので、それをShapePainterに渡してます。
static private Painter getPainter() {
CheckerboardPainter cbp = new CheckerboardPainter();
RoundRectangle2D.Double rrd = new RoundRectangle2D.Double(0, 0, 140,
140, 20, 20);
float[] dash = { 18, 15 };
Shape shape = new BasicStroke(10, BasicStroke.CAP_SQUARE,
BasicStroke.JOIN_MITER, 20, dash, 3).createStrokedShape(rrd);
ShapePainter p = new ShapePainter(shape);
p.setAntialiasing(true);
p.setBorderPaint(Color.DARK_GRAY);
p.setFillPaint(Color.DARK_GRAY);
TextPainter textPainter = new TextPainter("Drop me");
Font font = new Font("Arial", Font.BOLD, 24);
textPainter.setAntialiasing(true);
textPainter.setFillPaint(Color.DARK_GRAY);
textPainter.setFont(font);
return (new CompoundPainter(cbp, p, textPainter));
}
CheckerboardPainter cbp = new CheckerboardPainter();
RoundRectangle2D.Double rrd = new RoundRectangle2D.Double(0, 0, 140,
140, 20, 20);
float[] dash = { 18, 15 };
Shape shape = new BasicStroke(10, BasicStroke.CAP_SQUARE,
BasicStroke.JOIN_MITER, 20, dash, 3).createStrokedShape(rrd);
ShapePainter p = new ShapePainter(shape);
p.setAntialiasing(true);
p.setBorderPaint(Color.DARK_GRAY);
p.setFillPaint(Color.DARK_GRAY);
TextPainter textPainter = new TextPainter("Drop me");
Font font = new Font("Arial", Font.BOLD, 24);
textPainter.setAntialiasing(true);
textPainter.setFillPaint(Color.DARK_GRAY);
textPainter.setFont(font);
return (new CompoundPainter(cbp, p, textPainter));
}
: