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();
}
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));
}
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));
}
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));
}
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));
}
Aggregations