public Point getAnchor(Point curr, int level) { int x = 0, y = 0; switch (level) { case 0: return curr; case 1: Rectangle lArect = getParent().getConstraints(); x = curr.x - lArect.x; y = curr.y - lArect.y; return new Point(x, y); case 2: Rectangle lBpRect = getParent().getConstraints(); Rectangle lBgpRect = getParent().getParent().getConstraints(); x = curr.x - (lBpRect.x + lBgpRect.x); y = curr.y - (lBpRect.y + lBgpRect.y); return new Point(x, y); case 3: Rectangle lCpRect = getParent().getConstraints(); Rectangle lCgpRect = getParent().getParent().getConstraints(); Rectangle lCggpRect = getParent().getParent().getParent().getConstraints(); x = curr.x - (lCpRect.x + lCpRect.x + lCggpRect.x); y = curr.y - (lCgpRect.y + lCgpRect.y + lCggpRect.y); return new Point(x, y); } return curr; }
public Point getAbsolute(Point curr, int level) { int x = 0, y = 0; switch (level) { case 0: return new Point(x, y); case 1: Rectangle lArect = getParent().getConstraints(); x = curr.x + lArect.x; y = curr.y + lArect.y; return new Point(x, y); case 2: Rectangle lBpRect = getParent().getConstraints(); Rectangle lBgpRect = getParent().getParent().getConstraints(); x = curr.x + (lBpRect.x + lBgpRect.x); y = curr.y + (lBpRect.y + lBgpRect.y); return new Point(x, y); case 3: Rectangle lCpRect = getParent().getConstraints(); Rectangle lCgpRect = getParent().getParent().getConstraints(); Rectangle lCggpRect = getParent().getParent().getParent().getConstraints(); x = curr.x + (lCpRect.x + lCpRect.x + lCggpRect.x); y = curr.y + (lCgpRect.y + lCgpRect.y + lCggpRect.y); return new Point(x, y); } return curr; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(ModuleInstancePropertyNode.class) && getHost().getModel() instanceof ModuleInstanceNode) { ModuleInstancePropertyCreateCommand cmd = new ModuleInstancePropertyCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 2); cmd.setNode((ModuleInstancePropertyNode) node); cmd.setParent((ModuleInstanceNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, ModuleInstancePropertyNode.DEF_WIDTH, ModuleInstancePropertyNode.DEF_HEIGHT)); ret = cmd; } return ret; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(ModuleOperationParameterNode.class) && (getHost().getModel() instanceof ModuleOperationNode)) { ModuleOperationNode par = (ModuleOperationNode) getHost().getModel(); if (!(par.getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_READ.name()) || par.getType().equalsIgnoreCase(Enums.ModuleOperationTypes.DATA_WRITE.name()))) { ModuleOperationParameterCreateCommand cmd = new ModuleOperationParameterCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 2); cmd.setNode((ModuleOperationParameterNode) node); cmd.setParent((ModuleOperationNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, ModuleOperationParameterNode.DEF_WIDTH, ModuleOperationParameterNode.DEF_HEIGHT)); ret = cmd; } } return ret; }
private void trackExecution(Graphics graphics) { Rectangle rectangle = getBounds().getCopy(); if(componentStatus!=null){ if (componentStatus.equals(ComponentExecutionStatus.BLANK)){ compStatusImage = null; }else if (componentStatus.equals(ComponentExecutionStatus.PENDING)){ compStatusImage =ImagePathConstant.COMPONENT_PENDING_ICON.getImageFromRegistry(); }else if (componentStatus.equals(ComponentExecutionStatus.RUNNING)){ compStatusImage =ImagePathConstant.COMPONENT_RUNNING_ICON.getImageFromRegistry(); }else if (componentStatus.equals(ComponentExecutionStatus.SUCCESSFUL)){ compStatusImage =ImagePathConstant.COMPONENT_SUCCESS_ICON.getImageFromRegistry(); }else if (componentStatus.equals(ComponentExecutionStatus.FAILED)){ compStatusImage = ImagePathConstant.COMPONENT_FAILED_ICON.getImageFromRegistry(); } } if (compStatusImage != null) { graphics.drawImage(compStatusImage, new Point (8, rectangle.height - 22)); } }
protected Command getCreateBendpointCommand(BendpointRequest request) { CreateBendpointCommand com = new CreateBendpointCommand(); Point p = request.getLocation(); conn = getConnection(); conn.translateToRelative(p); com.setLocation(p); Point ref1 = conn.getSourceAnchor().getReferencePoint(); Point ref2 = conn.getTargetAnchor().getReferencePoint(); conn.translateToRelative(ref1); conn.translateToRelative(ref2); com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2)); com.setConn((Connection) request.getSource().getModel()); com.setIndex(request.getIndex()); return com; }
@Override public void mouseHover(MouseEvent e) { final java.awt.Point mouseLocation1 = MouseInfo.getPointerInfo().getLocation(); EditPart paletteInternalController = viewer.findObjectAt(new Point( e.x, e.y)); if(paletteInternalController.getModel() instanceof CombinedTemplateCreationEntry){ setGenericComponent(paletteInternalController); // Hide tooltip if already showing hidePaletteToolTip(); showToolTipWithDelay(mouseLocation1); } }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(LogicalComputingPlatformNode.class) && (getHost().getModel() instanceof LogicalSystemNode)) { LogicalComputingPlatformCreateCommand cmd = new LogicalComputingPlatformCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); cmd.setNode((LogicalComputingPlatformNode) node); cmd.setParent((LogicalSystemNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingPlatformNode.DEF_WIDTH, LogicalComputingPlatformNode.DEF_HEIGHT)); ret = cmd; } return ret; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(LogicalComputingNode.class) && (getHost().getModel() instanceof LogicalComputingPlatformNode)) { LogicalComputingCreateCommand cmd = new LogicalComputingCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 1); cmd.setNode((LogicalComputingNode) node); cmd.setParent((LogicalComputingPlatformNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingNode.DEF_WIDTH, LogicalComputingNode.DEF_HEIGHT)); ret = cmd; } return ret; }
@Override protected void paintFigure(Graphics g) { super.paintFigure(g); final int LEG = 5; Rectangle r = getBounds(); g.setLineWidth(1); g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR); g.drawLine(r.x, r.y, r.x, r.y+r.height-1); g.drawLine(r.x, r.y, r.x+LEG, r.y); g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1); g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height); g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y); g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1); if(!valid) { g.setForegroundColor(PandionJConstants.Colors.ERROR); String text = "Invalid matrix"; int textWidth = FigureUtilities.getTextWidth(text, g.getFont()); Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5); g.drawText(text, p); } }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(ComponentPropertyNode.class) && (getHost().getModel() instanceof ComponentNode)) { ComponentPropertyNodeCreateCommand cmd = new ComponentPropertyNodeCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 1); cmd.setNode((ComponentPropertyNode) node); cmd.setParent((ComponentNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, ComponentPropertyNode.DEF_WIDTH, ComponentPropertyNode.DEF_HEIGHT)); ret = cmd; } return ret; }
protected Command getMoveBendpointCommand(BendpointRequest request) { MoveBendpointCommand com = new MoveBendpointCommand(); Point p = request.getLocation(); conn = getConnection(); conn.translateToRelative(p); com.setLocation(p); Point ref1 = getConnection().getSourceAnchor().getReferencePoint(); Point ref2 = getConnection().getTargetAnchor().getReferencePoint(); conn.translateToRelative(ref1); conn.translateToRelative(ref2); com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2)); com.setConn((Connection) request.getSource().getModel()); com.setIndex(request.getIndex()); return com; }
@Override public Point getLocation(Point arg0) { int xLocation =0, yLocation = 0; if(PortAlignmentEnum.LEFT.value().equalsIgnoreCase(this.alignment)){ xLocation=getOwner().getBounds().getTopLeft().x-1; yLocation=getOwner().getBounds().getTopLeft().y+4; }else if(PortAlignmentEnum.RIGHT.value().equalsIgnoreCase(this.alignment)){ xLocation=getOwner().getBounds().getTopRight().x-1; yLocation=getOwner().getBounds().getTopRight().y+4; }else if(PortAlignmentEnum.BOTTOM.value().equalsIgnoreCase(this.alignment)){ xLocation=getOwner().getBounds().getBottomRight().x-20; yLocation=getOwner().getBounds().getBottomRight().y-2; } Point point= new Point(xLocation, yLocation); getOwner().getParent().translateToAbsolute(point); return point; }
@Override protected void refreshVisuals() { EdgeFigure figure = (EdgeFigure) getFigure(); GWEdge model = (GWEdge) getModel(); figure.setName(model.getName()); Connection connection = getConnectionFigure(); List<AbsoluteBendpoint> figureConstraint = new ArrayList<AbsoluteBendpoint>(); Iterator<Point> iter = ((GWLink) getModel()).getBendpointsIterator(); while(iter.hasNext()) { Point p = iter.next(); figureConstraint.add(new AbsoluteBendpoint(p)); } connection.setRoutingConstraint(figureConstraint); figure.setTooltipText(this.getTooltipData()); figure.setBlockedOrGuarded(model.isBlocked(),model.getGuard().getSource()); figure.setActionScripted(model.getAction().getSource()); }
@Override protected IFigure createFigure() { ComponentFigure componentFigure = ((ComponentEditPart) getParent()).getComponentFigure(); Component component = ((ComponentEditPart) getParent()).getCastedModel(); PortFigure port = null; Color borderColor = CustomColorRegistry.INSTANCE.getColorFromRegistry( ELTColorConstants.DARK_GREY_RGB[0], ELTColorConstants.DARK_GREY_RGB[1], ELTColorConstants.DARK_GREY_RGB[2]); Point portPoint = null; int height = component.getSize().height-componentFigure.getComponentLabelMargin(); int width = component.getSize().width; int margin = componentFigure.getComponentLabelMargin(); port = new PortFigure(borderColor, getCastedModel().getSequence(), getCastedModel().getNumberOfPortsOfThisType(),getCastedModel().getTerminal(), getCastedModel().getLabelOfPort(), getCastedModel().getPortAlignment()); portPoint = getPortLocation(getCastedModel().getNumberOfPortsOfThisType(), getCastedModel().getPortType(), getCastedModel().getSequence(), height, width, margin, getCastedModel().getPortAlignment()); Point tmpPoint = new Point(componentFigure.getLocation().x+portPoint.x , componentFigure.getLocation().y+portPoint.y); port.setLocation(tmpPoint); componentFigure.setAnchors(port.getAnchor()); return port; }
public Object getAdapter(Class key) { if (key.equals(Node.class)) { Node node = new Node (); node.getAttributes().put(OWNER, this); org.eclipse.gef4.geometry.planar.Point point = new org.eclipse.gef4.geometry.planar.Point(0,0); Dimension dimension = new Dimension( 100, 100 ); if (this.getLayout()!=null) { point = new org.eclipse.gef4.geometry.planar.Point(this.getLayout().x(),this.getLayout().y()); dimension = new Dimension(this.getLayout().width, this.getLayout().height ); } LayoutProperties.setLocation(node,point); LayoutProperties.setSize(node,dimension); return node; } return null; }
public GWEdge duplicate (GWGraph graph) { GWEdge edge = new GWEdge(graph,UUID.randomUUID() ,getName(), getId()); edge.setAction(this.getAction()); edge.setBlocked(this.isBlocked()); edge.setDependency(this.getDependency()); edge.setGuard(this.getGuard()); edge.setLabel(this.getLabel()); edge.setLayout(this.getLayout()); edge.setName(this.getName()); edge.setProperties(this.getProperties()); edge.setWeight(this.getWeight()); int index=0; for (Point point : bendpoints) { edge.setBendpoints(index, point); index++; } return edge; }
/** * reset if x or y coordinates of components are negative * * @param newLocation */ private void resetLocation(Point newLocation) { if (newLocation.x < 0) { newLocation.x = 0; } if (newLocation.y < 0) { newLocation.y = 0; } }
public PolygonController ( final SymbolController controller, final Polygon element, final ResourceManager manager ) { super ( controller, manager ); this.figure = new PolygonShape () { @Override public void addNotify () { super.addNotify (); start (); } @Override public void removeNotify () { stop (); super.removeNotify (); } }; final PointList points = new PointList (); for ( final Position pos : element.getPoints () ) { final Point p = new PrecisionPoint ( pos.getX (), pos.getY () ); points.addPoint ( p ); } setPoints ( points ); controller.addElement ( element, this ); applyCommon ( element ); }
public Point getLocationForNewComponent(){ List<Component> compListFromCanvas = getCanvasCompAndUpdateCompList(); updateComponentListForDeletedComponents(compListFromCanvas); Entry<String, Point> lastAddedComponent = getLastAddedComponentFromCanvas(); Point calculatedNewCompPosition = calculateNewComponentLocation(lastAddedComponent, compListFromCanvas); return calculatedNewCompPosition; }
private Point getIndexLocation(int index) { Point origin = arrayFigure.getPositionBounds(index, horizontal).getLocation(); if(horizontal) origin.translate(firstPositionBounds.width/2, firstPositionBounds.height + PandionJConstants.ARRAY_POSITION_SPACING); else { origin.translate(-PandionJConstants.POSITION_WIDTH/2, firstPositionBounds.height/2); } return origin; }
/** * display the comment box * @param event * @return Object */ @Override public Object execute(ExecutionEvent event) throws ExecutionException{ ELTGraphicalEditor editor = (ELTGraphicalEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); Container container = editor.getContainer(); editor.setDirty(true); if(container.getChildren().isEmpty() && !(commentBoxList.isEmpty())){ commentBoxList.clear(); } for(Object obj : container.getChildren()){ if((obj instanceof CommentBox)){ commentBoxList.add((CommentBox) obj); } else{ commentBoxList.clear(); } } if(commentBoxList.isEmpty()){ oldLocation = new Point(0,0); } else{ oldLocation = (commentBoxList.get(commentBoxList.size()-1)).getLocation(); } newLocation = new Point(oldLocation.x+6 ,oldLocation.y+6); CommentBox comment = new CommentBox(LABEL); comment.setLocation(newLocation); CommentBoxCommand command = new CommentBoxCommand(comment,LABEL,container); command.execute(); return null; }
private ComponentTooltip getToolBarToolTip(Shell parent, org.eclipse.swt.graphics.Rectangle toltipBounds) { ToolBarManager toolBarManager = new ToolBarManager(); ComponentTooltip tooltip = new ComponentTooltip(component,parent, toolBarManager, propertyToolTipInformation); org.eclipse.swt.graphics.Point location = new org.eclipse.swt.graphics.Point(toltipBounds.x, toltipBounds.y); tooltip.setLocation(location); tooltip.setSize(toltipBounds.width + 20, toltipBounds.height + 20); return tooltip; }
@Override protected Command getCreateBendpointCommand(BendpointRequest request) { Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); BendpointCreateCommand cmd = new BendpointCreateCommand(); cmd.setLink((Link) request.getSource().getModel()); cmd.setLocation(p); cmd.setIndex(request.getIndex()); return cmd; }
@Override protected Command getDeleteBendpointCommand(BendpointRequest request) { Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); BendpointDeleteCommand cmd = new BendpointDeleteCommand(); cmd.setLink((Link) request.getSource().getModel()); cmd.setLocation(p); cmd.setIndex(request.getIndex()); return cmd; }
@Override protected IFigure createFigure() { ComponentImplementationNode model = (ComponentImplementationNode) getModel(); ComponentImplementationFigure figure = new ComponentImplementationFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); return figure; }
@Override protected void refreshVisuals() { ComponentImplementationNode model = (ComponentImplementationNode) getModel(); ComponentImplementationFigure figure = (ComponentImplementationFigure) getFigure(); figure.setNode(model); figure.setBounds(model.getConstraints()); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); }
@Override protected Command getMoveCommand(ChangeBoundsRequest request) { TransitionLabel transitionLabel=(TransitionLabel)(this.getHost().getModel()); Point p=request.getMoveDelta(); IFigure parentFigure=((GraphicalEditPart)this.getHost().getParent()).getFigure(); return new MoveTransitionLabelCommand(transitionLabel,parentFigure,p); }
@Override protected void refreshVisuals() { DeploymentNode model = (DeploymentNode) getModel(); DeploymentFigure figure = (DeploymentFigure) getFigure(); figure.setNode(model); Dimension dim = getDimension(model); model.setConstraints(new Rectangle(new Point(0, 0), (dim != null) ? dim : new Dimension(1000, 1000))); figure.setBounds(model.getConstraints()); figure.rebuildFigure(); }
private ConnectionAnchor closestAnchor(Point p, List<FixedConnectionAnchor> connectionAnchors) { ConnectionAnchor closest = null; double min = Double.MAX_VALUE; for (ConnectionAnchor c : connectionAnchors) { double d = p.getDistance(c.getLocation(null)); if (d < min) { min = d; closest = c; } } return closest; }
@Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); if(isWatched) setBackgroundColor(watchColor); Rectangle r = getBounds().getCopy(); if(PortAlignmentEnum.LEFT.equals(portAlignment)){ graphics.fillRectangle(getBounds().getLocation().x-20, getBounds() .getLocation().y-1, r.width, r.height-2); }else if(PortAlignmentEnum.RIGHT.equals(portAlignment)){ graphics.fillRectangle(getBounds().getLocation().x+20, getBounds() .getLocation().y-1, r.width, r.height-2); }else if(PortAlignmentEnum.BOTTOM.equals(portAlignment)){ graphics.fillRectangle(getBounds().getLocation().x-16, getBounds() .getLocation().y+10, r.width,r.height); } if(isDisplayPortlabels()){ if(PortAlignmentEnum.LEFT.equals(portAlignment)){ graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x+8,getBounds() .getLocation().y-0.2)); }else if(PortAlignmentEnum.RIGHT.equals(portAlignment)){ graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x,getBounds() .getLocation().y-0.2)); }else if(PortAlignmentEnum.BOTTOM.equals(portAlignment)){ graphics.drawText(labelOfPort,new Point(getBounds().getLocation().x,getBounds() .getLocation().y-0.2)); } } }
private void drawHistory(Graphics g, IArrayIndexModel v, Color color) { g.setBackgroundColor(color); List<String> history = v.getHistory(); for (int j = 0; j < history.size()-1; j++) { Integer i = Integer.parseInt(history.get(j)); Point p = getIndexLocation(i); if(horizontal) p = p.translate(0, EXTRA); g.fillOval(p.x, p.y, PandionJConstants.ILLUSTRATION_LINE_WIDTH+1, PandionJConstants.ILLUSTRATION_LINE_WIDTH+1); } }
@Override protected void paintBorder(Graphics graphics) { super.paintBorder(graphics); for(IArrayIndexModel v : vars.values()) { if(v.getBound() != null) { Point origin = getIndexLocation(v.getBound().getValue()); Point from = origin.getTranslated(0, -100); Point to = origin.getTranslated(0, 100); graphics.drawLine(from, to); } } }
private void drawBar(Graphics g, Integer boundVal, IBound bound, Direction direction) { if(direction != Direction.NONE) { Point origin = getIndexLocation(boundVal); int s; boolean b = direction == Direction.FORWARD && bound.getType() == BoundType.CLOSE || direction == Direction.BACKWARD && bound.getType() == BoundType.OPEN; if(horizontal){ s = firstLabelBounds.width/2 + PandionJConstants.ARRAY_POSITION_SPACING; if(!b) s = -s; }else{ s = firstPositionBounds.height/2 + PandionJConstants.ARRAY_POSITION_SPACING; if(!b) s = -s; } origin.translate(horizontal ? s : 0, horizontal ? 0 : s); Point from = origin.getTranslated(horizontal ? 0 : -BAR_HEIGHT, horizontal ? -BAR_HEIGHT : 0);; Point to = origin.getTranslated(horizontal ? 0 : BAR_HEIGHT, horizontal ? BAR_HEIGHT : 0); setIllustrationStyle(g); g.drawLine(from, to); } }