Java Code Examples for org.eclipse.draw2d.IFigure#getBounds()
The following examples show how to use
org.eclipse.draw2d.IFigure#getBounds() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableViewComponentEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
private int getColumnIndex(DirectEditRequest editRequest) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); IFigure figure = ((TableViewEditPart) this.getHost()).getFigure(); int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { TableView newTableView = (TableView) this.getHost().getModel(); index = newTableView.getColumns().size(); } return index; }
Example 2
Source File: PrintERDiagramOperation.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void printPages() { final Graphics graphics = getFreshPrinterGraphics(); final IFigure figure = getPrintSource(); setupPrinterGraphicsFor(graphics, figure); final Rectangle bounds = figure.getBounds(); int x = bounds.x, y = bounds.y; final Rectangle clipRect = new Rectangle(); while (y < bounds.y + bounds.height) { while (x < bounds.x + bounds.width) { graphics.pushState(); getPrinter().startPage(); graphics.translate(-x, -y); graphics.getClip(clipRect); clipRect.setLocation(x, y); graphics.clipRect(clipRect); figure.paint(graphics); getPrinter().endPage(); graphics.popState(); x += clipRect.width; } x = bounds.x; y += clipRect.height; } }
Example 3
Source File: SaveImageAction.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override public void run() { if (file == null) return; log.trace("export product graph as image: {}", file); ScalableRootEditPart editPart = (ScalableRootEditPart) editor.getGraphicalViewer().getRootEditPart(); IFigure rootFigure = editPart.getLayer(LayerConstants.PRINTABLE_LAYERS); Rectangle bounds = rootFigure.getBounds(); Image img = new Image(null, bounds.width, bounds.height); GC imageGC = new GC(img); Graphics graphics = new SWTGraphics(imageGC); rootFigure.paint(graphics); ImageLoader imgLoader = new ImageLoader(); imgLoader.data = new ImageData[] { img.getImageData() }; imgLoader.save(file.getAbsolutePath(), SWT.IMAGE_PNG); }
Example 4
Source File: ReportFlowLayoutEditPolicy.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Generates a draw2d constraint object derived from the specified child * EditPart using the provided Request. The returned constraint will be * translated to the application's model later using * {@link #translateToModelConstraint(Object)}. * * @param request * the ChangeBoundsRequest * @param child * the child EditPart for which the constraint should be * generated * @return the draw2d constraint */ protected Object getConstraintFor( ChangeBoundsRequest request, GraphicalEditPart child ) { IFigure figure = child.getFigure( ); Rectangle rect = new PrecisionRectangle(figure.getBounds()); figure.translateToAbsolute(rect); rect = request.getTransformedRectangle( rect ); figure.translateToRelative(rect); rect.translate( getLayoutOrigin( ).getNegated( ) ); if (figure instanceof IOutsideBorder) { Border border = ((IOutsideBorder)figure).getOutsideBorder( ); if (border != null) { Insets insets = border.getInsets( figure ); rect.shrink( insets.right, insets.bottom ); } } return getConstraintFor( rect ); }
Example 5
Source File: ImageInfo.java From ermasterr with Apache License 2.0 | 6 votes |
private static Map<TableView, Location> getTableLocationMap(final ScalableFreeformRootEditPart rootEditPart, final int translateX, final int translateY, final ERDiagram diagram) { final Map<TableView, Location> tableLocationMap = new HashMap<TableView, Location>(); final Category category = diagram.getCurrentCategory(); for (final Object child : rootEditPart.getContents().getChildren()) { final NodeElementEditPart editPart = (NodeElementEditPart) child; final NodeElement nodeElement = (NodeElement) editPart.getModel(); if (!(nodeElement instanceof TableView)) { continue; } if (category == null || category.isVisible(nodeElement, diagram)) { final IFigure figure = editPart.getFigure(); final Rectangle figureRectangle = figure.getBounds(); final Location location = new Location(figureRectangle.x + translateX, figureRectangle.y + translateY, figureRectangle.width, figureRectangle.height); tableLocationMap.put((TableView) nodeElement, location); } } return tableLocationMap; }
Example 6
Source File: PrintERDiagramOperation.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void setupPrinterGraphicsFor(final Graphics graphics, final IFigure figure) { final ERDiagram diagram = getDiagram(); final PageSetting pageSetting = diagram.getPageSetting(); final double dpiScale = (double) getPrinter().getDPI().x / Display.getCurrent().getDPI().x * pageSetting.getScale() / 100; final Rectangle printRegion = getPrintRegion(); // put the print region in display coordinates printRegion.width /= dpiScale; printRegion.height /= dpiScale; final Rectangle bounds = figure.getBounds(); final double xScale = (double) printRegion.width / bounds.width; final double yScale = (double) printRegion.height / bounds.height; switch (getPrintMode()) { case FIT_PAGE: graphics.scale(Math.min(xScale, yScale) * dpiScale); break; case FIT_WIDTH: graphics.scale(xScale * dpiScale); break; case FIT_HEIGHT: graphics.scale(yScale * dpiScale); break; default: graphics.scale(dpiScale); } graphics.setForegroundColor(figure.getForegroundColor()); graphics.setBackgroundColor(figure.getBackgroundColor()); graphics.setFont(figure.getFont()); }
Example 7
Source File: ReportPrintGraphicalViewerOperation.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Prints the pages based on the current print mode. * * @see org.eclipse.draw2d.PrintOperation#printPages() */ protected void printPages( ) { Graphics graphics = getFreshGraphics( ); IFigure figure = getPrintSource( ); setupPrinterGraphicsFor( graphics, figure ); Rectangle bounds = figure.getBounds( ); int x = bounds.x, y = bounds.y; Rectangle clipRect = new Rectangle( ); while ( y < bounds.y + bounds.height ) { while ( x < bounds.x + bounds.width ) { graphics.pushState( ); graphics.translate( -x, -y ); graphics.getClip( clipRect ); clipRect.setLocation( x, y ); graphics.clipRect( clipRect ); figure.paint( graphics ); graphics.popState( ); x += clipRect.width; if ( x == 0 ) { return; } } x = bounds.x; y += clipRect.height; } }
Example 8
Source File: DiagramWalkerGraphicalNodeEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
@Override protected Command getReconnectTargetCommand(ReconnectRequest reconnectrequest) { final WalkerConnection connection = (WalkerConnection) reconnectrequest.getConnectionEditPart().getModel(); if (!(connection instanceof Relationship)) { return null; } final Relationship relation = (Relationship) connection; if (relation.getSourceWalker() == relation.getTargetWalker()) { return null; } final DiagramWalker newTarget = ((DiagramWalker) reconnectrequest.getTarget().getModel()).toMaterialize(); if (!relation.getTargetWalker().equals(newTarget)) { return null; } final DiagramWalkerEditPart targetEditPart = (DiagramWalkerEditPart) reconnectrequest.getConnectionEditPart().getTarget(); final Point location = new Point(reconnectrequest.getLocation()); final IFigure targetFigure = targetEditPart.getFigure(); targetFigure.translateToRelative(location); int xp = -1; int yp = -1; final Rectangle bounds = targetFigure.getBounds(); final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); if (!centerRectangle.contains(location)) { final Point point = ERTableEditPart.getIntersectionPoint(location, targetFigure); xp = 100 * (point.x - bounds.x) / bounds.width; yp = 100 * (point.y - bounds.y) / bounds.height; } final ReconnectTargetCommand command = new ReconnectTargetCommand(relation, xp, yp); return command; }
Example 9
Source File: ExportToHtmlAction.java From ermaster-b with Apache License 2.0 | 5 votes |
public static Map<TableView, Location> getTableLocationMap( GraphicalViewer viewer, ERDiagram diagram) { Map<TableView, Location> tableLocationMap = new HashMap<TableView, Location>(); ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer .getEditPartRegistry().get(LayerManager.ID); IFigure rootFigure = ((LayerManager) rootEditPart) .getLayer(LayerConstants.PRINTABLE_LAYERS); int translateX = ExportToImageAction .translateX(rootFigure.getBounds().x); int translateY = ExportToImageAction .translateY(rootFigure.getBounds().y); Category category = diagram.getCurrentCategory(); for (Object child : rootEditPart.getContents().getChildren()) { NodeElementEditPart editPart = (NodeElementEditPart) child; NodeElement nodeElement = (NodeElement) editPart.getModel(); if (!(nodeElement instanceof TableView)) { continue; } if (category == null || category.isVisible(nodeElement, diagram)) { IFigure figure = editPart.getFigure(); Rectangle figureRectangle = figure.getBounds(); Location location = new Location( figureRectangle.x + translateX, figureRectangle.y + translateY, figureRectangle.width, figureRectangle.height); tableLocationMap.put((TableView) nodeElement, location); } } return tableLocationMap; }
Example 10
Source File: NodeElementGraphicalNodeEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Command getReconnectTargetCommand(final ReconnectRequest reconnectrequest) { final ConnectionElement connection = (ConnectionElement) reconnectrequest.getConnectionEditPart().getModel(); if (connection.getSource() == connection.getTarget()) { return null; } final NodeElement newTarget = (NodeElement) reconnectrequest.getTarget().getModel(); if (connection.getTarget() != newTarget) { return null; } final NodeElementEditPart targetEditPart = (NodeElementEditPart) reconnectrequest.getConnectionEditPart().getTarget(); final Point location = new Point(reconnectrequest.getLocation()); final IFigure targetFigure = targetEditPart.getFigure(); targetFigure.translateToRelative(location); int xp = -1; int yp = -1; final Rectangle bounds = targetFigure.getBounds(); final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); if (!centerRectangle.contains(location)) { final Point point = NodeElementEditPart.getIntersectionPoint(location, targetFigure); xp = 100 * (point.x - bounds.x) / bounds.width; yp = 100 * (point.y - bounds.y) / bounds.height; } final ReconnectTargetCommand command = new ReconnectTargetCommand(connection, xp, yp); return command; }
Example 11
Source File: NodeElementGraphicalNodeEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Command getReconnectSourceCommand(final ReconnectRequest reconnectrequest) { final ConnectionElement connection = (ConnectionElement) reconnectrequest.getConnectionEditPart().getModel(); if (connection.getSource() == connection.getTarget()) { return null; } final NodeElement newSource = (NodeElement) reconnectrequest.getTarget().getModel(); if (connection.getSource() != newSource) { return null; } final NodeElementEditPart sourceEditPart = (NodeElementEditPart) reconnectrequest.getConnectionEditPart().getSource(); final Point location = new Point(reconnectrequest.getLocation()); final IFigure sourceFigure = sourceEditPart.getFigure(); sourceFigure.translateToRelative(location); int xp = -1; int yp = -1; final Rectangle bounds = sourceFigure.getBounds(); final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); if (!centerRectangle.contains(location)) { final Point point = NodeElementEditPart.getIntersectionPoint(location, sourceFigure); xp = 100 * (point.x - bounds.x) / bounds.width; yp = 100 * (point.y - bounds.y) / bounds.height; } final ReconnectSourceCommand command = new ReconnectSourceCommand(connection, xp, yp); return command; }
Example 12
Source File: MultipleLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
protected Dimension calculatePreferredSize( IFigure container, int wHint, int hHint ) { Rectangle rect = container.getParent( ).getClientArea( ).getCopy( ); List list = container.getChildren( ); if (list.size( ) == 0) { return Dimension.SINGLETON; } Figure child = (Figure)list.get( 0 ); wHint = Math.max( -1, wHint - container.getInsets( ).getWidth( ) ); hHint = Math.max( -1, hHint - container.getInsets( ).getHeight( ) ); wHint = Math.max( wHint,rect.width - container.getInsets( ).getWidth( ) ); hHint = Math.max( hHint, rect.height - container.getInsets( ).getHeight( ) ); if (child instanceof TableFigure && needlayout) { IFigure tablePane = ( (LayeredPane) ( (LayeredPane) ( (TableFigure) child ).getContents( ) ).getLayer( LayerConstants.PRINTABLE_LAYERS ) ).getLayer( LayerConstants.PRIMARY_LAYER ); LayoutManager layoutManager = tablePane.getLayoutManager( ); ( (TableLayout) layoutManager ).markDirty( ); container.getBounds( ).width = wHint; container.getBounds( ).height = hHint; //child.invalidateTree( ); child.validate( ); //dim = getPreferredSize( container, wHint, hHint ).expand( container.getInsets( ).getWidth( ), container.getInsets( ).getHeight( ) );; needlayout = false; } Dimension dim = child.getPreferredSize(wHint, hHint ).expand( container.getInsets( ).getWidth( ), container.getInsets( ).getHeight( ) ); return dim; }
Example 13
Source File: SankeyImageAction.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private Image createImage() { try { ScalableRootEditPart root = (ScalableRootEditPart) sankeyDiagram.getGraphicalViewer().getRootEditPart(); IFigure figure = root.getLayer(LayerConstants.PRINTABLE_LAYERS); Rectangle bounds = figure.getBounds(); Image img = new Image(null, bounds.width, bounds.height); GC imageGC = new GC(img); Graphics graphics = new SWTGraphics(imageGC); figure.paint(graphics); return img; } catch (Exception e) { log.error("Could not create image", e); return null; } }
Example 14
Source File: NodeElementGraphicalNodeEditPolicy.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected Command getReconnectTargetCommand( ReconnectRequest reconnectrequest) { ConnectionElement connection = (ConnectionElement) reconnectrequest .getConnectionEditPart().getModel(); if (!(connection instanceof Relation)) { return null; } Relation relation = (Relation) connection; if (relation.getSource() == relation.getTarget()) { return null; } NodeElement newTarget = (NodeElement) reconnectrequest.getTarget() .getModel(); if (!relation.getTarget().equals(newTarget)) { return null; } NodeElementEditPart targetEditPart = (NodeElementEditPart) reconnectrequest .getConnectionEditPart().getTarget(); Point location = new Point(reconnectrequest.getLocation()); IFigure targetFigure = targetEditPart.getFigure(); targetFigure.translateToRelative(location); int xp = -1; int yp = -1; Rectangle bounds = targetFigure.getBounds(); Rectangle centerRectangle = new Rectangle( bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); if (!centerRectangle.contains(location)) { Point point = ERTableEditPart.getIntersectionPoint(location, targetFigure); xp = 100 * (point.x - bounds.x) / bounds.width; yp = 100 * (point.y - bounds.y) / bounds.height; } ReconnectTargetCommand command = new ReconnectTargetCommand(relation, xp, yp); return command; }
Example 15
Source File: EnlargeContainerEditPolicy.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public Command getCommand(Request request) { if (!RequestConstants.REQ_RESIZE.equals(request.getType()) && !RequestConstants.REQ_MOVE.equals(request.getType())) { return null; } if (request instanceof SetPreferredSizeRequest) { showSourceFeedback(request); } ChangeBoundsRequest cbr = (ChangeBoundsRequest) request; CompoundCommand result = new CompoundCommand(); // Update Bounds of the container hierarchy if (containerHierachy != null) { for (IGraphicalEditPart currentContainer : containerHierachy) { IFigure figure = currentContainer.getFigure(); SetBoundsCommand boundsCommand = new SetBoundsCommand(getHost().getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(currentContainer.getNotationView()), figure.getBounds()); result.add(new ICommandProxy(boundsCommand)); FixedBendpointEditPolicy editPolicy = (FixedBendpointEditPolicy) currentContainer .getEditPolicy(FixedBendpointEditPolicy.ROLE); if (editPolicy != null) { Command command = editPolicy.getCommand(cbr); result.add(command); } // Update child bounds of elements that stand in the way... List<IGraphicalEditPart> children = currentContainer.getParent().getChildren(); for (IGraphicalEditPart childPart : children) { if (cbr.getEditParts().contains(childPart)) continue; IFigure childFigure = childPart.getFigure(); if (childPart == currentContainer) continue; SetBoundsCommand childBoundsCommand = new SetBoundsCommand(getHost().getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(childPart.getNotationView()), childFigure.getBounds()); result.add(new ICommandProxy(childBoundsCommand)); } } } return result; }
Example 16
Source File: TableViewEditPart.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public ConnectionAnchor getSourceConnectionAnchor(Request request) { if (request instanceof ReconnectRequest) { ReconnectRequest reconnectRequest = (ReconnectRequest) request; ConnectionEditPart connectionEditPart = reconnectRequest .getConnectionEditPart(); if (!(connectionEditPart instanceof RelationEditPart)) { return super.getSourceConnectionAnchor(request); } Relation relation = (Relation) connectionEditPart.getModel(); if (relation.getSource() == relation.getTarget()) { return new XYChopboxAnchor(this.getFigure()); } EditPart editPart = reconnectRequest.getTarget(); if (editPart == null || !editPart.getModel().equals(relation.getSource())) { return new XYChopboxAnchor(this.getFigure()); } Point location = new Point(reconnectRequest.getLocation()); this.getFigure().translateToRelative(location); IFigure sourceFigure = ((TableViewEditPart) connectionEditPart .getSource()).getFigure(); XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure()); Rectangle bounds = sourceFigure.getBounds(); Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); if (!centerRectangle.contains(location)) { Point point = getIntersectionPoint(location, sourceFigure); anchor.setLocation(point); } return anchor; } else if (request instanceof CreateConnectionRequest) { CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request; Command command = connectionRequest.getStartCommand(); if (command instanceof CreateCommentConnectionCommand) { return super.getTargetConnectionAnchor(request); } } return new XYChopboxAnchor(this.getFigure()); }
Example 17
Source File: TableViewEditPart.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public ConnectionAnchor getTargetConnectionAnchor(Request request) { if (request instanceof ReconnectRequest) { ReconnectRequest reconnectRequest = (ReconnectRequest) request; ConnectionEditPart connectionEditPart = reconnectRequest .getConnectionEditPart(); if (!(connectionEditPart instanceof RelationEditPart)) { return super.getTargetConnectionAnchor(request); } Relation relation = (Relation) connectionEditPart.getModel(); if (relation.getSource() == relation.getTarget()) { return new XYChopboxAnchor(this.getFigure()); } EditPart editPart = reconnectRequest.getTarget(); if (editPart == null || !editPart.getModel().equals(relation.getTarget())) { return new XYChopboxAnchor(this.getFigure()); } Point location = new Point(reconnectRequest.getLocation()); this.getFigure().translateToRelative(location); IFigure targetFigure = ((TableViewEditPart) connectionEditPart .getTarget()).getFigure(); XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure()); Rectangle bounds = targetFigure.getBounds(); Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); if (!centerRectangle.contains(location)) { Point point = getIntersectionPoint(location, targetFigure); anchor.setLocation(point); } return anchor; } else if (request instanceof CreateConnectionRequest) { CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request; Command command = connectionRequest.getStartCommand(); if (command instanceof CreateCommentConnectionCommand) { return super.getTargetConnectionAnchor(request); } } return new XYChopboxAnchor(this.getFigure()); }
Example 18
Source File: TableViewEditPart.java From erflute with Apache License 2.0 | 4 votes |
@Override public ConnectionAnchor getTargetConnectionAnchor(Request request) { if (request instanceof ReconnectRequest) { final ReconnectRequest reconnectRequest = (ReconnectRequest) request; final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart(); if (!(connectionEditPart instanceof RelationEditPart)) { return super.getTargetConnectionAnchor(request); } final Relationship relation = (Relationship) connectionEditPart.getModel(); if (relation.getSourceWalker() == relation.getTargetWalker()) { return new XYChopboxAnchor(getFigure()); } final EditPart editPart = reconnectRequest.getTarget(); if (editPart == null || !editPart.getModel().equals(relation.getTargetWalker())) { return new XYChopboxAnchor(getFigure()); } final Point location = new Point(reconnectRequest.getLocation()); getFigure().translateToRelative(location); final IFigure targetFigure = ((TableViewEditPart) connectionEditPart.getTarget()).getFigure(); final Rectangle bounds = targetFigure.getBounds(); final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure()); if (!centerRectangle.contains(location)) { final Point point = getIntersectionPoint(location, targetFigure); anchor.setLocation(point); } return anchor; } else if (request instanceof CreateConnectionRequest) { final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request; final Command command = connectionRequest.getStartCommand(); if (command instanceof CreateCommentConnectionCommand) { return super.getTargetConnectionAnchor(request); } } return new XYChopboxAnchor(getFigure()); }
Example 19
Source File: TableViewComponentEditPolicy.java From ermasterr with Apache License 2.0 | 4 votes |
private int getColumnIndex(final DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure figure = ((TableViewEditPart) getHost()).getFigure(); final int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { final TableView newTableView = (TableView) getHost().getModel(); index = newTableView.getColumns().size(); } return index; }
Example 20
Source File: NodeElementEditPart.java From ermasterr with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public ConnectionAnchor getSourceConnectionAnchor(final Request request) { if (request instanceof ReconnectRequest) { final ReconnectRequest reconnectRequest = (ReconnectRequest) request; final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart(); // if (!(connectionEditPart instanceof RelationEditPart)) { // return super.getSourceConnectionAnchor(request); // } final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel(); if (connection.getSource() == connection.getTarget()) { return new XYChopboxAnchor(getFigure()); } final EditPart editPart = reconnectRequest.getTarget(); if (editPart == null || !editPart.getModel().equals(connection.getSource())) { return new XYChopboxAnchor(getFigure()); } final Point location = new Point(reconnectRequest.getLocation()); getFigure().translateToRelative(location); final IFigure sourceFigure = ((TableViewEditPart) connectionEditPart.getSource()).getFigure(); final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure()); final Rectangle bounds = sourceFigure.getBounds(); final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2); if (!centerRectangle.contains(location)) { final Point point = getIntersectionPoint(location, sourceFigure); anchor.setLocation(point); } return anchor; } else if (request instanceof CreateConnectionRequest) { final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request; final Command command = connectionRequest.getStartCommand(); if (command instanceof CreateCommentConnectionCommand) { return new ChopboxAnchor(getFigure()); } } return new XYChopboxAnchor(getFigure()); }