Search in sources :

Example 6 with DashArray

use of com.ait.lienzo.client.core.types.DashArray in project kie-wb-common by kiegroup.

the class AuthorityRequirementView method createLine.

private static Object[] createLine(final double x1, final double y1, final double x2, final double y2) {
    final MultiPath head = new MultiPath();
    final MultiPath tail = new MultiPath().M(DECORATOR_RADIUS, -DECORATOR_RADIUS).circle(DECORATOR_RADIUS).setFillColor(ColorName.BLACK).setFillAlpha(1);
    final DirectionalLine line = new DirectionalLine(x1, y1, x2, y2);
    line.setDashArray(new DashArray(4, 4));
    line.setDraggable(true);
    line.setSelectionStrokeOffset(SELECTION_OFFSET);
    line.setHeadOffset(head.getBoundingBox().getHeight());
    line.setTailOffset(tail.getBoundingBox().getHeight());
    final MultiPathDecorator headDecorator = new MultiPathDecorator(head);
    final MultiPathDecorator tailDecorator = new MultiPathDecorator(tail);
    return new Object[] { line, headDecorator, tailDecorator };
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) MultiPathDecorator(com.ait.lienzo.client.core.shape.MultiPathDecorator) DashArray(com.ait.lienzo.client.core.types.DashArray)

Example 7 with DashArray

use of com.ait.lienzo.client.core.types.DashArray in project lienzo-core by ahome-it.

the class LienzoCore method examineNativeLineDashSupported.

private final boolean examineNativeLineDashSupported() {
    if (IS_CANVAS_SUPPORTED) {
        try {
            final ScratchPad scratch = new ScratchPad(20, 10);
            final Context2D context = scratch.getContext();
            context.setStrokeWidth(10);
            context.setLineCap(LineCap.BUTT);
            context.setStrokeColor(ColorName.BLUE);
            context.beginPath();
            context.moveTo(0, 5);
            context.lineTo(20, 5);
            context.stroke();
            context.setStrokeColor(ColorName.RED);
            context.setLineDash(new DashArray(5, 5));
            context.beginPath();
            context.moveTo(0, 5);
            context.lineTo(20, 5);
            context.stroke();
            final ImageData backing = context.getImageData(0, 0, 20, 10);
            if (null != backing) {
                if ((backing.getRedAt(3, 5) == 255) && (backing.getBlueAt(3, 5) == 0) && (backing.getGreenAt(3, 5) == 0)) {
                    if ((backing.getRedAt(8, 5) == 0) && (backing.getBlueAt(8, 5) == 255) && (backing.getGreenAt(8, 5) == 0)) {
                        return true;
                    }
                }
            }
        } catch (final Exception e) {
            // FF 22 dev mode does not like line dashes
            error("Line Dash test failed ", e);
        }
    }
    return false;
}
Also used : Context2D(com.ait.lienzo.client.core.Context2D) ImageData(com.ait.lienzo.client.core.types.ImageData) ScratchPad(com.ait.lienzo.client.core.util.ScratchPad) DashArray(com.ait.lienzo.client.core.types.DashArray) UmbrellaException(com.google.gwt.event.shared.UmbrellaException)

Aggregations

DashArray (com.ait.lienzo.client.core.types.DashArray)7 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)3 MultiPathDecorator (com.ait.lienzo.client.core.shape.MultiPathDecorator)3 Point2D (com.ait.lienzo.client.core.types.Point2D)2 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)2 Context2D (com.ait.lienzo.client.core.Context2D)1 ImageData (com.ait.lienzo.client.core.types.ImageData)1 Transform (com.ait.lienzo.client.core.types.Transform)1 ScratchPad (com.ait.lienzo.client.core.util.ScratchPad)1 UmbrellaException (com.google.gwt.event.shared.UmbrellaException)1 JSONString (com.google.gwt.json.client.JSONString)1