use of org.knime.workbench.editor2.figures.WorkflowAnnotationFigure in project knime-core by knime.
the class WorkflowMarqueeSelectionTool method calculateNewSelection.
private void calculateNewSelection(final Collection<GraphicalEditPart> newSelections, final Collection<GraphicalEditPart> deselections) {
Rectangle marqueeRect = getMarqueeSelectionRectangle();
for (Iterator<GraphicalEditPart> itr = getAllChildren().iterator(); itr.hasNext(); ) {
GraphicalEditPart child = itr.next();
IFigure figure = child.getFigure();
if (!child.isSelectable() || child.getTargetEditPart(MARQUEE_REQUEST) != child || !isFigureVisible(figure) || !figure.isShowing()) {
continue;
}
if (!(child instanceof NodeContainerEditPart || child instanceof ConnectionContainerEditPart || child instanceof AbstractWorkflowPortBarEditPart || child instanceof AnnotationEditPart)) {
continue;
}
Rectangle r = figure.getBounds().getCopy();
figure.translateToAbsolute(r);
boolean included = false;
if (child instanceof ConnectionEditPart && marqueeRect.intersects(r)) {
Rectangle relMarqueeRect = Rectangle.SINGLETON;
figure.translateToRelative(relMarqueeRect.setBounds(marqueeRect));
included = ((PolylineConnection) figure).getPoints().intersects(relMarqueeRect);
} else if (child instanceof AnnotationEditPart) {
// select WorkflowAnnotations only if they are fully included in the selection
if (figure instanceof WorkflowAnnotationFigure) {
included = marqueeRect.contains(r);
}
} else if (marqueeBehavior == BEHAVIOR_NODES_AND_CONNECTIONS_TOUCHED) {
included = marqueeRect.intersects(r);
} else {
included = marqueeRect.contains(r);
}
if (included) {
if (isToggle()) {
if (wasSelected(child)) {
deselections.add(child);
} else {
newSelections.add(child);
}
} else {
newSelections.add(child);
}
} else if (isToggle()) {
// readded if it was in the selection before
if (wasSelected(child)) {
newSelections.add(child);
} else {
deselections.add(child);
}
}
}
if (marqueeBehavior == BEHAVIOR_NODES_AND_CONNECTIONS_TOUCHED) {
calculateConnections(newSelections, deselections);
}
}
use of org.knime.workbench.editor2.figures.WorkflowAnnotationFigure in project knime-core by knime.
the class AnnotationEditPart method getDragTracker.
/**
* {@inheritDoc}
* If dragging started on the "move" icon (top left corner) return the normal edit part dragger tool, otherwise
* return the marquee selection tool.
*/
@Override
public DragTracker getDragTracker(final Request request) {
Object object = request.getExtendedData().get(WorkflowSelectionTool.DRAG_START_LOCATION);
IFigure f = getFigure();
if (object instanceof Point && f instanceof WorkflowAnnotationFigure && getSelected() == SELECTED_NONE) {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite();
Rectangle iconBounds = ((WorkflowAnnotationFigure) f).getEditIconBounds().getCopy();
if (!iconBounds.contains((Point) object)) {
return new WorkflowMarqueeSelectionTool();
}
}
// "normal" edit part dragging
return new WorkflowSelectionDragEditPartsTracker(this);
}
use of org.knime.workbench.editor2.figures.WorkflowAnnotationFigure in project knime-core by knime.
the class AnnotationEditPart method createFigure.
/**
* {@inheritDoc}
*/
@Override
protected IFigure createFigure() {
Annotation anno = getModel();
NodeAnnotationFigure f = new WorkflowAnnotationFigure(anno);
if (anno instanceof WorkflowAnnotation) {
f.setBounds(new Rectangle(anno.getX(), anno.getY(), anno.getWidth(), anno.getHeight()));
}
return f;
}
Aggregations