Java Code Examples for org.eclipse.draw2d.PositionConstants#SOUTH_EAST
The following examples show how to use
org.eclipse.draw2d.PositionConstants#SOUTH_EAST .
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: CustomResizeHandle.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Draws the handle with fill color and outline color dependent on the * primary selection status of the owner editpart. * * @param g * The graphics used to paint the figure. */ public void paintFigure(Graphics g) { Rectangle r = getBounds() ; switch (cursorDirection) { case PositionConstants.SOUTH_EAST: g.drawImage(Pics.getImage("resize_SE.gif"),r.getLocation()) ; break; case PositionConstants.NORTH: g.drawImage(Pics.getImage("resize_N.gif"),r.getLocation().translate(0, -2)) ; break; case PositionConstants.SOUTH: g.drawImage(Pics.getImage("resize_S.gif"),r.getLocation().translate(0, 5)) ; break; case PositionConstants.WEST: g.drawImage(Pics.getImage("resize_W.gif"),r.getLocation().translate(-2, 0)) ; break; case PositionConstants.EAST: g.drawImage(Pics.getImage("resize_E.gif"),r.getLocation().translate(5, 0)) ; break; default: break; } }
Example 2
Source File: TableResizeEditPolice.java From birt with Eclipse Public License 1.0 | 5 votes |
protected List createSelectionHandles( ) { List list = new ArrayList( ); ReportResizableHandleKit.addMoveHandle( (GraphicalEditPart) getHost( ), list ); if ( ( this.getResizeDirections( ) & PositionConstants.SOUTH_EAST ) == PositionConstants.SOUTH_EAST ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.SOUTH_EAST ); return list; }
Example 3
Source File: SWTBotTestUtil.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public static Point computeTargetLocation(final SWTBotGefEditor gmfEditor, final String sourceElement, final int position) { final SWTBotGefEditPart gep = gmfEditor.getEditPart(sourceElement); Assert.assertNotNull("Error: No Edit Part \'" + sourceElement + "\' found.", gep); final SWTBotGefEditPart element = gep.parent(); final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) element.part(); switch (position) { case PositionConstants.NORTH: return graphicalEditPart.getFigure().getBounds().getTop().getCopy().translate(-20, -Y_MARGIN); case PositionConstants.SOUTH: return graphicalEditPart.getFigure().getBounds().getBottom().getCopy().translate(-20, Y_MARGIN); case PositionConstants.WEST: return graphicalEditPart.getFigure().getBounds().getLeft().getCopy().translate(-X_MARGIN, 10); case PositionConstants.EAST: return graphicalEditPart.getFigure().getBounds().getRight().getCopy().translate(X_MARGIN, 10); case PositionConstants.NORTH_EAST: return graphicalEditPart.getFigure().getBounds().getTopRight().getCopy().translate(X_MARGIN, -Y_MARGIN); case PositionConstants.NORTH_WEST: return graphicalEditPart.getFigure().getBounds().getTopLeft().getCopy().translate(-X_MARGIN, Y_MARGIN); case PositionConstants.SOUTH_EAST: return graphicalEditPart.getFigure().getBounds().getBottomRight().getCopy().translate(-X_MARGIN, Y_MARGIN); case PositionConstants.SOUTH_WEST: return graphicalEditPart.getFigure().getBounds().getBottomLeft().getCopy().translate(X_MARGIN, -Y_MARGIN); default: throw new RuntimeException("Invalid position specified"); } }
Example 4
Source File: BotGefProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private Point computeTargetLocation(final String pSourceElement, final int pOrientation) { final SWTBotGefEditPart gep = gmfEditor.getEditPart(pSourceElement); Assert.assertNotNull("Error: No Edit Part \'" + pSourceElement + "\' found.", gep); final SWTBotGefEditPart element = gep.parent(); final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) element.part(); switch (pOrientation) { case PositionConstants.NORTH: return graphicalEditPart.getFigure().getBounds().getTop().getCopy().translate(-30, -70); case PositionConstants.SOUTH: return graphicalEditPart.getFigure().getBounds().getBottom().getCopy().translate(-30, 70); case PositionConstants.WEST: return graphicalEditPart.getFigure().getBounds().getTopLeft().getCopy().translate(-140, 0); case PositionConstants.EAST: return graphicalEditPart.getFigure().getBounds().getTopRight().getCopy().translate(80, 0); case PositionConstants.NORTH_EAST: return graphicalEditPart.getFigure().getBounds().getTopRight().getCopy().translate(80, -70); case PositionConstants.NORTH_WEST: return graphicalEditPart.getFigure().getBounds().getTopLeft().getCopy().translate(-80, 70); case PositionConstants.SOUTH_EAST: return graphicalEditPart.getFigure().getBounds().getBottomRight().getCopy().translate(-80, 70); case PositionConstants.SOUTH_WEST: return graphicalEditPart.getFigure().getBounds().getBottomLeft().getCopy().translate(80, -70); default: throw new RuntimeException("Invalid position specified"); } }
Example 5
Source File: NodeElementSelectionEditPolicy.java From ermasterr with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override protected List createSelectionHandles() { final List selectedEditParts = getHost().getViewer().getSelectedEditParts(); if (selectedEditParts.size() == 1) { if (!(getHost().getModel() instanceof Category)) { final NodeElementEditPart editPart = (NodeElementEditPart) getHost(); editPart.reorder(); } } final List list = new ArrayList(); final int directions = getResizeDirections(); if (directions == 0) { // NonResizableHandleKit.addHandles((GraphicalEditPart) getHost(), // list); } else if (directions != -1) { // 0 list.add(new ERDiagramMoveHandle((GraphicalEditPart) getHost())); // 1 if ((directions & PositionConstants.EAST) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.EAST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.EAST); } // 2 if ((directions & PositionConstants.SOUTH_EAST) == PositionConstants.SOUTH_EAST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_EAST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_EAST); } // 3 if ((directions & PositionConstants.SOUTH) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH); } // 4 if ((directions & PositionConstants.SOUTH_WEST) == PositionConstants.SOUTH_WEST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_WEST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_WEST); } // 5 if ((directions & PositionConstants.WEST) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.WEST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.WEST); } // 6 if ((directions & PositionConstants.NORTH_WEST) == PositionConstants.NORTH_WEST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_WEST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_WEST); } // 7 if ((directions & PositionConstants.NORTH) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH); } // 8 if ((directions & PositionConstants.NORTH_EAST) == PositionConstants.NORTH_EAST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_EAST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_EAST); } } else { addHandles((GraphicalEditPart) getHost(), list); } return list; }
Example 6
Source File: DiagramWalkerSelectionEditPolicy.java From erflute with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") protected List<Object> createSelectionHandles() { final List<Object> selectedEditParts = getHost().getViewer().getSelectedEditParts(); if (selectedEditParts.size() == 1) { final ViewableModel currentElement = (ViewableModel) getHost().getModel(); if (!(currentElement instanceof Category) && !(currentElement instanceof ModelProperties)) { // #for_erflute maybe unneeded, already linkage between main and virtual by jflute //final ERDiagram diagram = ERModelUtil.getDiagram(getHost().getRoot().getContents()); //ViewableModel targetElement = currentElement; //if (currentElement instanceof ERVirtualTable) { // targetElement = ((ERVirtualTable) currentElement).getRawTable(); //} //final List<NodeElement> nodeElementList = diagram.getDiagramContents().getContents().getNodeElementList(); //nodeElementList.remove(targetElement); //nodeElementList.add((NodeElement) targetElement); getHost().getRoot().getContents().refresh(); } } final List<Object> list = new ArrayList<>(); final int directions = getResizeDirections(); if (directions == 0) { // #willanalyze what is this? by jflute //NonResizableHandleKit.addHandles((GraphicalEditPart) getHost(), list); } else if (directions != -1) { // 0 list.add(new ERDiagramMoveHandle((GraphicalEditPart) getHost())); // 1 if ((directions & PositionConstants.EAST) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.EAST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.EAST); } // 2 if ((directions & PositionConstants.SOUTH_EAST) == PositionConstants.SOUTH_EAST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_EAST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_EAST); } // 3 if ((directions & PositionConstants.SOUTH) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH); } // 4 if ((directions & PositionConstants.SOUTH_WEST) == PositionConstants.SOUTH_WEST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_WEST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_WEST); } // 5 if ((directions & PositionConstants.WEST) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.WEST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.WEST); } // 6 if ((directions & PositionConstants.NORTH_WEST) == PositionConstants.NORTH_WEST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_WEST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_WEST); } // 7 if ((directions & PositionConstants.NORTH) != 0) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH); } // 8 if ((directions & PositionConstants.NORTH_EAST) == PositionConstants.NORTH_EAST) { ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_EAST); } else { NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_EAST); } } else { addHandles((GraphicalEditPart) getHost(), list); } return list; }
Example 7
Source File: ReportElementResizablePolicy.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#createSelectionHandles() */ protected List createSelectionHandles( ) { List list = new ArrayList( ); if ( this.getResizeDirections( ) != -1 ) { ReportResizableHandleKit.addMoveHandle( (GraphicalEditPart) getHost( ), list ); if ( ( this.getResizeDirections( ) & PositionConstants.EAST ) != 0 ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.EAST ); if ( ( this.getResizeDirections( ) & PositionConstants.SOUTH_EAST ) == PositionConstants.SOUTH_EAST ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.SOUTH_EAST ); if ( ( this.getResizeDirections( ) & PositionConstants.SOUTH ) != 0 ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.SOUTH ); if ( ( this.getResizeDirections( ) & PositionConstants.SOUTH_WEST ) == PositionConstants.SOUTH_WEST ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.SOUTH_WEST ); if ( ( this.getResizeDirections( ) & PositionConstants.WEST ) != 0 ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.WEST ); if ( ( this.getResizeDirections( ) & PositionConstants.NORTH_WEST ) == PositionConstants.NORTH_WEST ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.NORTH_WEST ); if ( ( this.getResizeDirections( ) & PositionConstants.NORTH ) != 0 ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.NORTH ); if ( ( this.getResizeDirections( ) & PositionConstants.NORTH_EAST ) == PositionConstants.NORTH_EAST ) ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ), list, PositionConstants.NORTH_EAST ); } else ReportResizableHandleKit.addHandles( (GraphicalEditPart) getHost( ), list ); return list; }
Example 8
Source File: CustomResizeHandle.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override protected DragTracker createDragTracker() { return new ResizeTracker(getOwner(), cursorDirection){ @Override protected void updateSourceRequest() { ChangeBoundsRequest request = (ChangeBoundsRequest) getSourceRequest(); Dimension d = getDragMoveDelta(); Point location = new Point(getLocation()); Point moveDelta = new Point(0, 0); Dimension resizeDelta = new Dimension(0, 0); if (getOwner() != null) { if(isContrained){ request.setConstrainedResize(true); int origHeight = getOwner().getFigure().getBounds().height; int origWidth = getOwner().getFigure().getBounds().width; float ratio = 1; if (origWidth != 0 && origHeight != 0) ratio = ((float) origHeight / (float) origWidth); if (getResizeDirection() == PositionConstants.SOUTH_EAST) { if (d.height > (d.width * ratio)) d.width = (int) (d.height / ratio); else d.height = (int) (d.width * ratio); } else if (getResizeDirection() == PositionConstants.NORTH_WEST) { if (d.height < (d.width * ratio)) d.width = (int) (d.height / ratio); else d.height = (int) (d.width * ratio); } else if (getResizeDirection() == PositionConstants.NORTH_EAST) { if (-(d.height) > (d.width * ratio)) d.width = -(int) (d.height / ratio); else d.height = -(int) (d.width * ratio); } else if (getResizeDirection() == PositionConstants.SOUTH_WEST) { if (-(d.height) < (d.width * ratio)) d.width = -(int) (d.height / ratio); else d.height = -(int) (d.width * ratio); } } }else{ request.setConstrainedResize(false); } request.setCenteredResize(getCurrentInput().isModKeyDown(SWT.MOD1)); if ((getResizeDirection() & PositionConstants.NORTH) != 0) { if (getCurrentInput().isControlKeyDown()) { resizeDelta.height -= d.height; } moveDelta.y += d.height; resizeDelta.height -= d.height; } if ((getResizeDirection() & PositionConstants.SOUTH) != 0) { if (getCurrentInput().isControlKeyDown()) { moveDelta.y -= d.height; resizeDelta.height += d.height; } resizeDelta.height += d.height; } if ((getResizeDirection() & PositionConstants.WEST) != 0) { if (getCurrentInput().isControlKeyDown()) { resizeDelta.width -= d.width; } moveDelta.x += d.width; resizeDelta.width -= d.width; } if ((getResizeDirection() & PositionConstants.EAST) != 0) { if (getCurrentInput().isControlKeyDown()) { moveDelta.x -= d.width; resizeDelta.width += d.width; } resizeDelta.width += d.width; } request.setMoveDelta(moveDelta); request.setSizeDelta(resizeDelta); request.setLocation(location); request.setEditParts(getOperationSet()); request.getExtendedData().clear(); } @Override protected List<IGraphicalEditPart> createOperationSet() { ArrayList<IGraphicalEditPart> res = new ArrayList<IGraphicalEditPart>(); for (Object selection : getCurrentViewer().getSelectedEditParts()) { if (isResizable((IGraphicalEditPart)selection)) { res.add((IGraphicalEditPart)selection); } } return res; } }; }
Example 9
Source File: SWTBotTestUtil.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public static void selectElementInContextualPaletteAndDragIt(final SWTBotGefEditor gmfEditor, final String selectedElementName, final int elementIndex, final int position) { final SWTBotGefEditPart gep = gmfEditor.getEditPart(selectedElementName); Assert.assertNotNull("Error: No Edit Part \'" + selectedElementName + "\' found.", gep); final SWTBotGefEditPart element = gep.parent(); element.select(); final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) element.part(); final NextElementEditPolicy nextElementEditPolicy = (NextElementEditPolicy) graphicalEditPart .getEditPolicy(NextElementEditPolicy.NEXT_ELEMENT_ROLE); final IFigure toolbarFigure = nextElementEditPolicy.getFigure(elementIndex); Point dropLocation = null; final int xPaletteDelta = computeXPaletteDelta(elementIndex); final int yPaletteDelta = computeYPaletteDelta(elementIndex); final Rectangle bounds = graphicalEditPart.getFigure().getBounds(); switch (position) { case PositionConstants.NORTH: dropLocation = bounds.getTop().getCopy().translate(xPaletteDelta, -Y_MARGIN); break; case PositionConstants.SOUTH: dropLocation = bounds.getBottom().getCopy().translate(xPaletteDelta, Y_MARGIN); break; case PositionConstants.WEST: dropLocation = bounds.getLeft().getCopy().translate(-X_MARGIN, yPaletteDelta); break; case PositionConstants.EAST: dropLocation = bounds.getRight().getCopy().translate(X_MARGIN, yPaletteDelta); break; case PositionConstants.NORTH_EAST: dropLocation = bounds.getTopRight().getCopy().translate(X_MARGIN, -Y_MARGIN); break; case PositionConstants.NORTH_WEST: dropLocation = bounds.getTopLeft().getCopy().translate(-X_MARGIN, Y_MARGIN); break; case PositionConstants.SOUTH_EAST: dropLocation = bounds.getBottomRight().getCopy().translate(X_MARGIN, Y_MARGIN); break; case PositionConstants.SOUTH_WEST: dropLocation = bounds.getBottomLeft().getCopy().translate(-X_MARGIN, -Y_MARGIN); break; default: throw new RuntimeException("Invalid position specified"); } final Point location = toolbarFigure.getBounds().getCenter().getCopy(); toolbarFigure.translateToAbsolute(location); gmfEditor.drag(location.x, location.y, dropLocation.x, dropLocation.y); }