Search in sources :

Example 11 with Point2D

use of com.ait.lienzo.client.core.types.Point2D in project drools-wb by kiegroup.

the class RadarMenuViewImpl method setVisibleBounds.

@Override
public void setVisibleBounds(final Bounds bounds) {
    radarLayer.remove(visibleBounds);
    visibleBounds.setLocation(new Point2D(bounds.getX(), bounds.getY()));
    visibleBounds.setHeight(bounds.getHeight());
    visibleBounds.setWidth(bounds.getWidth());
    radarLayer.add(visibleBounds);
    visibleBounds.moveToTop();
    radarLayer.batch();
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 12 with Point2D

use of com.ait.lienzo.client.core.types.Point2D in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerViewImpl method addDecisionTable.

@Override
public void addDecisionTable(final GuidedDecisionTableView gridWidget) {
    // Ensure the first Decision Table is visible
    if (gridLayer.getGridWidgets().isEmpty()) {
        final Point2D translation = getTranslation(gridWidget);
        final Transform t = gridLayer.getViewport().getTransform();
        t.translate(translation.getX(), translation.getY());
    }
    gridLayer.add(gridWidget);
    gridLayer.batch();
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) Transform(com.ait.lienzo.client.core.types.Transform)

Example 13 with Point2D

use of com.ait.lienzo.client.core.types.Point2D in project drools-wb by kiegroup.

the class GuidedDecisionTableViewImpl method isNodeMouseEventOverCaption.

@Override
public boolean isNodeMouseEventOverCaption(final INodeXYEvent event) {
    final Point2D ap = CoordinateUtilities.convertDOMToGridCoordinate(this, new Point2D(event.getX(), event.getY()));
    final double cx = ap.getX();
    final double cy = ap.getY();
    if (cx > headerCaption.getX() && cx < headerCaption.getX() + getHeaderCaptionWidth()) {
        if (cy > headerCaption.getY() && cy < headerCaption.getY() + HEADER_CAPTION_HEIGHT) {
            return true;
        }
    }
    return false;
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 14 with Point2D

use of com.ait.lienzo.client.core.types.Point2D in project drools-wb by kiegroup.

the class ColumnHeaderPopOverHandler method onNodeMouseMove.

@Override
public void onNodeMouseMove(final NodeMouseMoveEvent event) {
    columnPopOverPresenter.hide();
    for (GuidedDecisionTableView.Presenter dtPresenter : modellerPresenter.getAvailableDecisionTables()) {
        final GuidedDecisionTableView dtView = dtPresenter.getView();
        if (!dtView.isVisible()) {
            continue;
        }
        final Point2D ap = CoordinateUtilities.convertDOMToGridCoordinate(dtView, new Point2D(event.getX(), event.getY()));
        if (!isMouseOverTableHeader(dtView, ap.getY())) {
            continue;
        }
        final Integer uiColumnIndex = getUiColumn(dtView, ap.getX());
        if (uiColumnIndex == null) {
            continue;
        }
        columnPopOverPresenter.show(modellerPresenter.getView(), dtPresenter, uiColumnIndex);
    }
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)

Example 15 with Point2D

use of com.ait.lienzo.client.core.types.Point2D in project drools-wb by kiegroup.

the class GuidedDecisionTreeWidget method layout.

void layout() {
    // Get layout information
    final Map<WiresBaseShape, Point2D> layout = layoutManager.getLayoutInformation(uiRoot);
    final Rectangle2D canvasBounds = WiresLayoutUtilities.alignLayoutInCanvas(layout);
    // Run an animation to move WiresBaseTreeNodes from their current position to the target position
    uiRoot.animate(AnimationTweener.EASE_OUT, new AnimationProperties(), ANIMATION_DURATION, new IAnimationCallback() {

        private final Map<WiresBaseShape, Pair<Point2D, Point2D>> transformations = new HashMap<WiresBaseShape, Pair<Point2D, Point2D>>();

        @Override
        public void onStart(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) {
            // Reposition nodes. First we store the WiresBaseTreeNode together with its current position and target position
            transformations.clear();
            for (Map.Entry<WiresBaseShape, Point2D> e : layout.entrySet()) {
                final Point2D origin = e.getKey().getLocation();
                final Point2D destination = new Point2D(e.getValue().getX(), e.getValue().getY());
                transformations.put(e.getKey(), new Pair<Point2D, Point2D>(origin, destination));
            }
            WiresLayoutUtilities.resizeViewPort(canvasBounds, canvasLayer.getViewport());
        }

        @Override
        public void onFrame(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) {
            // Lienzo's IAnimation.getPercent() passes values > 1.0
            final double pct = iAnimation.getPercent() > 1.0 ? 1.0 : iAnimation.getPercent();
            // Move each descendant along the line between its origin and the target destination
            for (Map.Entry<WiresBaseShape, Pair<Point2D, Point2D>> e : transformations.entrySet()) {
                final Point2D descendantOrigin = e.getValue().getK1();
                final Point2D descendantTarget = e.getValue().getK2();
                final double dx = (descendantTarget.getX() - descendantOrigin.getX()) * pct;
                final double dy = (descendantTarget.getY() - descendantOrigin.getY()) * pct;
                e.getKey().setX(descendantOrigin.getX() + dx);
                e.getKey().setY(descendantOrigin.getY() + dy);
            }
            // Without this call Lienzo doesn't update the Canvas for sub-classes of WiresBaseTreeNode
            uiRoot.getLayer().batch();
        }

        @Override
        public void onClose(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) {
        // Nothing to do
        }
    });
    canvasLayer.batch();
}
Also used : HashMap(java.util.HashMap) Rectangle2D(org.uberfire.ext.wires.core.trees.client.layout.treelayout.Rectangle2D) IAnimationHandle(com.ait.lienzo.client.core.animation.IAnimationHandle) WiresBaseShape(org.uberfire.ext.wires.core.api.shapes.WiresBaseShape) AnimationProperties(com.ait.lienzo.client.core.animation.AnimationProperties) Point2D(com.ait.lienzo.client.core.types.Point2D) IAnimation(com.ait.lienzo.client.core.animation.IAnimation) IAnimationCallback(com.ait.lienzo.client.core.animation.IAnimationCallback) Pair(org.uberfire.commons.data.Pair)

Aggregations

Point2D (com.ait.lienzo.client.core.types.Point2D)20 Test (org.junit.Test)5 GuidedDecisionTableModellerView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView)4 Group (com.ait.lienzo.client.core.shape.Group)2 Transform (com.ait.lienzo.client.core.types.Transform)2 HashMap (java.util.HashMap)2 WiresBaseShape (org.uberfire.ext.wires.core.api.shapes.WiresBaseShape)2 Rectangle2D (org.uberfire.ext.wires.core.trees.client.layout.treelayout.Rectangle2D)2 AnimationProperties (com.ait.lienzo.client.core.animation.AnimationProperties)1 IAnimation (com.ait.lienzo.client.core.animation.IAnimation)1 IAnimationCallback (com.ait.lienzo.client.core.animation.IAnimationCallback)1 IAnimationHandle (com.ait.lienzo.client.core.animation.IAnimationHandle)1 NodeDragMoveEvent (com.ait.lienzo.client.core.event.NodeDragMoveEvent)1 NodeDragMoveHandler (com.ait.lienzo.client.core.event.NodeDragMoveHandler)1 Layer (com.ait.lienzo.client.core.shape.Layer)1 Line (com.ait.lienzo.client.core.shape.Line)1 Picture (com.ait.lienzo.client.core.shape.Picture)1 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)1 TextMetrics (com.ait.lienzo.client.core.types.TextMetrics)1 LienzoPanel (com.ait.lienzo.client.widget.LienzoPanel)1