Search in sources :

Example 6 with Point2D

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

the class GuidedDecisionTableModellerPresenterTest method refreshingDecisionTableRetainsExistingLocation.

@Test
public void refreshingDecisionTableRetainsExistingLocation() {
    final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
    final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent();
    final GuidedDecisionTableView dtView = dtPresenter.getView();
    final ObservablePath path = mock(ObservablePath.class);
    final PlaceRequest placeRequest = mock(PlaceRequest.class);
    final Point2D dtLocation = new Point2D(100, 100);
    when(dtView.getLocation()).thenReturn(dtLocation);
    final ArgumentCaptor<Command> afterRemovalCommandCaptor = ArgumentCaptor.forClass(Command.class);
    presenter.refreshDecisionTable(dtPresenter, path, placeRequest, dtContent, false);
    verify(dtView, times(1)).getLocation();
    verify(view, times(1)).removeDecisionTable(eq(dtView), afterRemovalCommandCaptor.capture());
    final Command afterRemovalCommand = afterRemovalCommandCaptor.getValue();
    assertNotNull(afterRemovalCommand);
    afterRemovalCommand.execute();
    verify(dtView, times(1)).setLocation(eq(dtLocation));
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Point2D(com.ait.lienzo.client.core.types.Point2D) Command(com.google.gwt.user.client.Command) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 7 with Point2D

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

the class GuidedDecisionTreeWidget method setModel.

public void setModel(final GuidedDecisionTree model, final boolean isReadOnly) {
    this.uiRoot = null;
    this.model = model;
    // Clear existing state
    super.clear();
    clearEvent.fire(new ClearEvent());
    // Walk model creating UIModel
    final TypeNode root = model.getRoot();
    if (root != null) {
        final WiresBaseTreeNode uiRoot = typeNodeFactory.getShape(root, isReadOnly);
        this.uiRoot = uiRoot;
        processChildren(root, uiRoot, isReadOnly);
        final Map<WiresBaseShape, Point2D> layout = layoutManager.getLayoutInformation(uiRoot);
        final Rectangle2D canvasBounds = WiresLayoutUtilities.alignLayoutInCanvas(layout);
        for (Map.Entry<WiresBaseShape, Point2D> e : layout.entrySet()) {
            final Point2D destination = new Point2D(e.getValue().getX(), e.getValue().getY());
            e.getKey().setLocation(destination);
        }
        WiresLayoutUtilities.resizeViewPort(canvasBounds, canvasLayer.getViewport());
    }
    if (shapesInCanvas.isEmpty()) {
        showGettingStartedHint();
    }
    canvasLayer.batch();
}
Also used : WiresBaseShape(org.uberfire.ext.wires.core.api.shapes.WiresBaseShape) Point2D(com.ait.lienzo.client.core.types.Point2D) WiresBaseTreeNode(org.uberfire.ext.wires.core.trees.client.shapes.WiresBaseTreeNode) Rectangle2D(org.uberfire.ext.wires.core.trees.client.layout.treelayout.Rectangle2D) ClearEvent(org.uberfire.ext.wires.core.api.events.ClearEvent) TypeNode(org.drools.workbench.models.guided.dtree.shared.model.nodes.TypeNode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with Point2D

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

the class BaseGuidedDecisionTreeShape method setupControl.

protected Group setupControl(final ImageResource resource, final Command command) {
    final Group controlGroup = new Group();
    final Picture p = new Picture(resource, picture1 -> {
        final double offsetX = -picture1.getImageData().getWidth() / 2;
        final double offsetY = -picture1.getImageData().getHeight() / 2;
        picture1.setLocation(new Point2D(offsetX, offsetY));
        picture1.addNodeMouseClickHandler(e -> command.execute());
    }, ImageSelectionMode.SELECT_BOUNDS);
    controlGroup.add(p);
    return controlGroup;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Point2D(com.ait.lienzo.client.core.types.Point2D) Picture(com.ait.lienzo.client.core.shape.Picture)

Example 9 with Point2D

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

the class BaseGuidedDecisionTreeShape method getControlTarget.

@Override
protected Point2D getControlTarget(final Group ctrl) {
    final Point2D target = super.getControlTarget(ctrl);
    target.setX(circle.getRadius() + 25);
    return target;
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 10 with Point2D

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

the class ColumnHeaderPopOverHandlerTest method popOverWhenEventOverDecisionTableHeaderAndColumn.

@Test
public void popOverWhenEventOverDecisionTableHeaderAndColumn() {
    when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {

        {
            add(dtPresenter1);
        }
    });
    when(event.getX()).thenReturn(50);
    when(event.getY()).thenReturn(50);
    when(dtView1.getLocation()).thenReturn(new Point2D(0, 0));
    handler.onNodeMouseMove(event);
    verify(columnPopOverPresenter, times(1)).show(any(GuidedDecisionTableModellerView.class), eq(dtPresenter1), eq(0));
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) GuidedDecisionTableModellerView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView) Test(org.junit.Test)

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