Example usage for com.google.gwt.canvas.dom.client Context2d getStrokeStyle

List of usage examples for com.google.gwt.canvas.dom.client Context2d getStrokeStyle

Introduction

In this page you can find the example usage for com.google.gwt.canvas.dom.client Context2d getStrokeStyle.

Prototype

public final FillStrokeStyle getStrokeStyle() 

Source Link

Document

Returns the context's strokeStyle.

Usage

From source file:examples.geometry.containment.PolygonPolylineContainment.java

License:Open Source License

@Override
protected AbstractControllableShape createControllableShape2(final Canvas canvas) {
    return new AbstractControllableShape(canvas) {
        @Override// w w  w  .  jav a2 s.c om
        public void createControlPoints() {
            addControlPoint(new Point(100, 100));
            addControlPoint(new Point(100, 300));
            addControlPoint(new Point(300, 300));
            addControlPoint(new Point(300, 100));
        }

        @Override
        public Polyline createGeometry() {
            Point[] points = getControlPoints();
            Polyline polyline = new Polyline(points);
            return polyline;
        }

        @Override
        public void drawShape() {
            Polyline polyline = createGeometry();
            CanvasDrawer.strokePath(polyline.toPath(), canvas.getContext2d());
        }

        @Override
        public void fillShape(CssColor color) {
            Context2d context2d = canvas.getContext2d();
            FillStrokeStyle style = context2d.getStrokeStyle();
            context2d.setLineWidth(3);
            context2d.setStrokeStyle(color.value());

            drawShape();

            context2d.setLineWidth(1);
            //            context2d.setStrokeStyle(CssColor.make(0, 0, 0).value());
            context2d.setStrokeStyle(style);
        }
    };
}