Search in sources :

Example 16 with Point2D

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

the class GuidedDecisionTreeWidget method onDragPreviewHandler.

public void onDragPreviewHandler(@Observes ShapeDragPreviewEvent shapeDragPreviewEvent) {
    // We can only connect WiresTreeNodes to each other
    if (!(shapeDragPreviewEvent.getShape() instanceof BaseGuidedDecisionTreeShape)) {
        dropContext.setContext(null);
        return;
    }
    // Find a Parent Node to attach the Shape to
    final double cx = getX(shapeDragPreviewEvent.getX());
    final double cy = getY(shapeDragPreviewEvent.getY());
    final BaseGuidedDecisionTreeShape uiChild = (BaseGuidedDecisionTreeShape) shapeDragPreviewEvent.getShape();
    final BaseGuidedDecisionTreeShape uiProspectiveParent = getParentNode(uiChild, cx, cy);
    // If there is a prospective parent show the line between child and parent
    if (uiProspectiveParent != null) {
        if (connector == null) {
            connector = new WiresTreeNodeConnector();
            canvasLayer.add(connector);
            connector.moveToBottom();
        }
        connector.getPoints().get(0).set(uiProspectiveParent.getLocation());
        connector.getPoints().get(1).set(new Point2D(cx, cy));
    } else if (connector != null) {
        canvasLayer.remove(connector);
        connector = null;
    }
    dropContext.setContext(uiProspectiveParent);
    canvasLayer.batch();
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) WiresTreeNodeConnector(org.uberfire.ext.wires.core.trees.client.canvas.WiresTreeNodeConnector) BaseGuidedDecisionTreeShape(org.drools.workbench.screens.guided.dtree.client.widget.shapes.BaseGuidedDecisionTreeShape)

Example 17 with Point2D

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

the class NodeLabel method setLabel.

public void setLabel(final String label) {
    final Layer scratchLayer = new Layer();
    final LienzoPanel scratchPanel = new LienzoPanel(100, 100);
    scratchPanel.add(scratchLayer);
    text.setText(label);
    final TextMetrics tm = text.measure(scratchLayer.getContext());
    final double cw = tm.getWidth() + 10;
    final double ch = tm.getHeight() + 10;
    container.setWidth(cw);
    container.setHeight(ch);
    container.setLocation(new Point2D(-cw / 2, -ch / 2));
}
Also used : LienzoPanel(com.ait.lienzo.client.widget.LienzoPanel) Point2D(com.ait.lienzo.client.core.types.Point2D) TextMetrics(com.ait.lienzo.client.core.types.TextMetrics) Layer(com.ait.lienzo.client.core.shape.Layer)

Example 18 with Point2D

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

the class ColumnHeaderPopOverHandlerTest method noPopOverWhenEventNotOverDecisionTableHeader.

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

        {
            add(dtPresenter1);
        }
    });
    when(event.getX()).thenReturn(50);
    when(event.getY()).thenReturn(100);
    when(dtView1.getLocation()).thenReturn(new Point2D(0, 0));
    handler.onNodeMouseMove(event);
    verify(columnPopOverPresenter, never()).show(any(GuidedDecisionTableModellerView.class), any(GuidedDecisionTableView.Presenter.class), any(Integer.class));
}
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)

Example 19 with Point2D

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

the class ColumnHeaderPopOverHandlerTest method popOverWhenEventOverDecisionTableHeaderAndColumnWithMultipleTables.

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

        {
            add(dtPresenter1);
            add(dtPresenter2);
        }
    });
    when(dtView1.getLocation()).thenReturn(new Point2D(0, 0));
    when(dtView2.getLocation()).thenReturn(new Point2D(200, 200));
    when(event.getX()).thenReturn(50);
    when(event.getY()).thenReturn(50);
    handler.onNodeMouseMove(event);
    verify(columnPopOverPresenter, times(1)).show(any(GuidedDecisionTableModellerView.class), eq(dtPresenter1), eq(0));
    when(event.getX()).thenReturn(250);
    when(event.getY()).thenReturn(250);
    handler.onNodeMouseMove(event);
    verify(columnPopOverPresenter, times(1)).show(any(GuidedDecisionTableModellerView.class), eq(dtPresenter2), 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)

Example 20 with Point2D

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

the class ColumnHeaderPopOverHandlerTest method noPopOverWhenEventNotOverDecisionTableColumn.

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

        {
            add(dtPresenter1);
        }
    });
    when(event.getX()).thenReturn(150);
    when(event.getY()).thenReturn(50);
    when(dtView1.getLocation()).thenReturn(new Point2D(0, 0));
    handler.onNodeMouseMove(event);
    verify(columnPopOverPresenter, never()).show(any(GuidedDecisionTableModellerView.class), any(GuidedDecisionTableView.Presenter.class), any(Integer.class));
}
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