Search in sources :

Example 1 with Point2D

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

the class RadarMenuViewImpl method setup.

@PostConstruct
public void setup() {
    radarCanvas.add(radarLayer);
    radarMenuDropdown.setTitle(translationService.getTranslation(GuidedDecisionTableErraiConstants.RowContextMenuViewImpl_Title));
    visibleBounds.setDraggable(true);
    visibleBounds.addNodeDragMoveHandler(new NodeDragMoveHandler() {

        @Override
        public void onNodeDragMove(final NodeDragMoveEvent event) {
            presenter.onDragVisibleBounds(visibleBounds.getX(), visibleBounds.getY());
        }
    });
    visibleBounds.setFillColor(ColorName.GRAY);
    visibleBounds.setAlpha(0.25);
    visibleBounds.setLocation(new Point2D((RADAR_WIDTH - visibleBounds.getWidth()) / 2, (RADAR_HEIGHT - visibleBounds.getHeight()) / 2));
    radarLayer.add(visibleBounds);
    radarCanvas.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (eventTargetsPopup(event.getNativeEvent(), radarMenu)) {
                event.stopPropagation();
                event.preventDefault();
            }
        }

        private boolean eventTargetsPopup(final NativeEvent event, final Element element) {
            final EventTarget target = event.getEventTarget();
            if (Element.is(target)) {
                return element.isOrHasChild(Element.as(target));
            }
            return false;
        }
    });
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Point2D(com.ait.lienzo.client.core.types.Point2D) NodeDragMoveHandler(com.ait.lienzo.client.core.event.NodeDragMoveHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ButtonElement(com.google.gwt.dom.client.ButtonElement) LIElement(com.google.gwt.dom.client.LIElement) Element(com.google.gwt.dom.client.Element) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) EventTarget(com.google.gwt.dom.client.EventTarget) NativeEvent(com.google.gwt.dom.client.NativeEvent) PostConstruct(javax.annotation.PostConstruct)

Example 2 with Point2D

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

the class GuidedDecisionTableModellerPresenter method refreshDecisionTable.

@Override
public GuidedDecisionTableView.Presenter refreshDecisionTable(final GuidedDecisionTableView.Presenter dtPresenter, final ObservablePath path, final PlaceRequest placeRequest, final GuidedDecisionTableEditorContent content, final boolean isReadOnly) {
    // Remove old view from Modeller
    final Point2D oldLocation = dtPresenter.getView().getLocation();
    view.removeDecisionTable(dtPresenter.getView(), () -> {
        // Refresh existing Presenter with new content
        dtPresenter.refreshContent(path, placeRequest, content, isReadOnly);
        // Add new view to Modeller and ensure selection
        dtPresenter.getView().setLocation(oldLocation);
        view.addDecisionTable(dtPresenter.getView());
    });
    return dtPresenter;
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 3 with Point2D

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

the class GuidedDecisionTableModellerViewImpl method getTranslation.

private Point2D getTranslation(final GuidedDecisionTableView gridWidget) {
    final double boundsPadding = GuidedDecisionTableModellerBoundsHelper.BOUNDS_PADDING;
    final Transform t = gridLayer.getViewport().getTransform();
    final double requiredTranslateX = boundsPadding - gridWidget.getX();
    final double requiredTranslateY = boundsPadding - gridWidget.getY();
    final double actualTranslateX = t.getTranslateX();
    final double actualTranslateY = t.getTranslateY();
    final double dx = requiredTranslateX - actualTranslateX;
    final double dy = requiredTranslateY - actualTranslateY;
    return new Point2D(dx, dy);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) Transform(com.ait.lienzo.client.core.types.Transform)

Example 4 with Point2D

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

the class GuidedDecisionTableRenderer method renderHeaderBodyDivider.

@Override
public RendererCommand renderHeaderBodyDivider(final double width) {
    return (RenderHeaderGridLinesCommand) (rc) -> {
        if (!rc.isSelectionLayer()) {
            final Group g = new Group();
            final Line dividerLine1 = theme.getGridHeaderBodyDivider();
            final Line dividerLine2 = theme.getGridHeaderBodyDivider();
            dividerLine1.setPoints(new Point2DArray(new Point2D(0, getHeaderHeight() - 1.5), new Point2D(width, getHeaderHeight() - 1.5)));
            dividerLine2.setPoints(new Point2DArray(new Point2D(0, getHeaderHeight() + 0.5), new Point2D(width, getHeaderHeight() + 0.5)));
            g.add(dividerLine1);
            g.add(dividerLine2);
            rc.getGroup().add(g);
        }
    };
}
Also used : Line(com.ait.lienzo.client.core.shape.Line) Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Group(com.ait.lienzo.client.core.shape.Group) Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 5 with Point2D

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

the class GuidedDecisionTableModellerContextMenuSupportTest method makeDecisionTable.

private GuidedDecisionTableView.Presenter makeDecisionTable(final double x, final double y) {
    final GridData uiModel = spy(new BaseGridData());
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final GuidedDecisionTableView dtView = mock(GuidedDecisionTableView.class);
    final GridRenderer renderer = mock(GridRenderer.class);
    final BaseGridRendererHelper helper = mock(BaseGridRendererHelper.class);
    uiModel.appendRow(new BaseGridRow());
    when(dtPresenter.getView()).thenReturn(dtView);
    when(dtPresenter.getAccess()).thenReturn(mock(GuidedDecisionTablePresenter.Access.class));
    when(dtPresenter.getModel()).thenReturn(mock(GuidedDecisionTable52.class));
    when(dtView.getViewport()).thenReturn(viewport);
    when(dtView.getLayer()).thenReturn(layer);
    when(dtView.getLocation()).thenReturn(new Point2D(x, y));
    when(dtView.getAbsoluteX()).thenReturn(x);
    when(dtView.getAbsoluteY()).thenReturn(y);
    when(dtView.getWidth()).thenReturn(50.0);
    when(dtView.getHeight()).thenReturn(52.0);
    when(dtView.getModel()).thenReturn(uiModel);
    when(dtView.getRenderer()).thenReturn(renderer);
    when(renderer.getHeaderHeight()).thenReturn(32.0);
    when(dtView.getRendererHelper()).thenReturn(helper);
    when(helper.getColumnInformation(any(Double.class))).thenReturn(columnInformation);
    return dtPresenter;
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Point2D(com.ait.lienzo.client.core.types.Point2D) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

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