public XYContainerController ( final SymbolController controller, final XYContainer element, final BasicViewElementFactory factory ) throws Exception { this.figure = new Layer (); this.figure.setOpaque ( false ); this.figure.setLayoutManager ( new XYLayout () ); for ( final XYChild child : element.getChildren () ) { final Controller elementController = factory.create ( controller, child.getElement () ); final IFigure childFigure = elementController.getFigure (); final Rectangle rect = factory.create ( child.getPosition (), child.getDimension () ); controller.addRawElement ( child.getName (), new XYChildController ( childFigure, rect ) ); this.figure.add ( childFigure, rect ); } controller.addElement ( element, this ); }
/** * Draws the status image to right corner of the component * * @param graphics */ private void drawPropertyStatus(Graphics graphics) { Rectangle rectangle = getBounds().getCopy(); if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.WARN.name())) { statusImage = ImagePathConstant.COMPONENT_WARN_ICON.getImageFromRegistry(); } else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.ERROR.name())) { statusImage = ImagePathConstant.COMPONENT_ERROR_ICON.getImageFromRegistry(); } else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(Constants.UPDATE_AVAILABLE)) { statusImage = ImagePathConstant.COMPONENT_UPDATE_ICON.getImageFromRegistry(); } else if (StringUtils.isNotBlank(getPropertyStatus()) && getPropertyStatus().equals(ValidityStatus.VALID.name())){ statusImage=null; } logger.trace("Component has {} property status.", getPropertyStatus()); if (statusImage != null && !statusImage.isDisposed()) { graphics.drawImage(statusImage, new Point(rectangle.width - 25, 8 + componentLabelMargin)); } }
@Override public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(ServiceNode.FONT_COLOR); if (node.getType().equalsIgnoreCase(Enums.ServiceTypes.PROVIDED.name())) setBackgroundColor(ColorConstants.green); else if (node.getType().equalsIgnoreCase(Enums.ServiceTypes.REQUIRED.name())) setBackgroundColor(ColorConstants.orange); else setBackgroundColor(ServiceNode.DEF_COLOR); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("Service"); setToolTip(tooltip); }
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(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; }
@Override public void relocate(CellEditor celleditor) { Text text = (Text) celleditor.getControl(); Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle rect = nameLabel.getTextBounds().getCopy(); nameLabel.translateToAbsolute(rect); text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(ComputingNodeConfigurationNode.class) && (getHost().getModel() instanceof PlatformConfigurationNode)) { ComputingNodeConfigurationCreateCommand cmd = new ComputingNodeConfigurationCreateCommand(); 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((ComputingNodeConfigurationNode) node); cmd.setParent((PlatformConfigurationNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, ComputingNodeConfigurationNode.DEF_WIDTH, ComputingNodeConfigurationNode.DEF_HEIGHT)); ret = cmd; } return ret; }
public Vertex duplicate(GWGraph graph, int X , int Y, String name) { UUID uuid = UUID.randomUUID(); if (name==null) { name = "v_" + ID.getId(); } Vertex vertex = new SharedVertex (this.getGraph(),uuid,name,uuid.toString(),this.getSharedName()); vertex.setBlocked(this.isBlocked()); vertex.setGraph(this.getGraph()); vertex.setInitScript((InitScript)this.getInitScript().clone()); vertex.setLabel(this.getLabel()); vertex.setRequirement((Requirement)this.getRequirement().clone()); vertex.setShared(this.isShared()); vertex.setStart(false); vertex.setProperties(this.getProperties()); vertex.setLayout(new Rectangle( X, Y, getLayout().width, getLayout().height) ); return vertex; }
@Override protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, Object constraint) { if (child instanceof TableEditPart && constraint instanceof Rectangle) { return new TableLayoutCommand((Table) child.getModel(), request, (Rectangle) constraint); } return super.createChangeConstraintCommand(request, child, constraint); }
private org.eclipse.swt.graphics.Point getToolTipLocation(org.eclipse.swt.graphics.Point reletiveMouseLocation, org.eclipse.swt.graphics.Point mouseLocation, Rectangle rectangle) { int subtractFromMouseX, addToMouseY; subtractFromMouseX = reletiveMouseLocation.x - rectangle.x; addToMouseY = (rectangle.y + rectangle.height) - reletiveMouseLocation.y; return new org.eclipse.swt.graphics.Point((mouseLocation.x - subtractFromMouseX), (mouseLocation.y + addToMouseY)); }
@Override protected void paintFigure(Graphics g) { super.paintFigure(g); g.setForegroundColor(ColorConstants.gray); Rectangle r = getBounds(); g.drawLine(r.getTopLeft(), r.getBottomRight()); }
public void setLocation(Rectangle rect) { this.node.setConstraints(rect); int i = 1; for (Node child : node.getChild()) { child.setConstraints(new Rectangle(i * 50, i * 50, DynamicTriggerInstanceTerminalNode.DEF_WIDTH, DynamicTriggerInstanceTerminalNode.DEF_HEIGHT)); i++; } }
@Override protected Command createChangeConstraintCommand(EditPart child, Object constraint) { AbstractLayoutCommand command = null; if (child instanceof VertexPart) { command = new VertexChangeLayoutCommand(); } if (command == null) { ResourceManager.logException(new Exception(""), "Dont know how to get comand for " + child.getClass().getName()); return UnexecutableCommand.INSTANCE; } command.setModel(child.getModel()); command.setConstraint((Rectangle) constraint); return command; }
@Override public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(TriggerInstanceNode.FONT_COLOR); setBackgroundColor(TriggerInstanceNode.DEF_COLOR); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("TriggerInstance"); setToolTip(tooltip); }
@Override public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(TriggerInstanceTerminalNode.FONT_COLOR); setBackgroundColor(TriggerInstanceTerminalNode.DEF_COLOR); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("Trigger Terminal"); setToolTip(tooltip); }
@Override public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(DynamicTriggerInstanceNode.FONT_COLOR); setBackgroundColor(DynamicTriggerInstanceNode.DEF_COLOR); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("DynamicTriggerInstance"); setToolTip(tooltip); }
public void springLayout() { Display.getDefault().syncExec(new Runnable() { @Override public void run() { resetEdgesRouteLayout(); gWGraph.setLayout(new Rectangle(0, 0, getDimension().width, getDimension().height)); LayoutAlgoritmManager.springLayout(gWGraph, getDimension()); } }); }
@Override public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(ReferenceNode.FONT_COLOR); setBackgroundColor(ReferenceNode.DEF_COLOR); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("Required Service"); setToolTip(tooltip); }
@Override protected void refreshVisuals() { CompositeNode model = (CompositeNode) getModel(); CompositeFigure figure = (CompositeFigure) 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(); }
public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(ColorConstants.black); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("Composite"); setToolTip(tooltip); }
private void readSchema(Document document, Schema schema) { Element elementSchema = document.getDocumentElement(); String currentDbType = readAttribute(elementSchema, Schema.DB_TYPE); schema.setCurrentDbType(currentDbType); Rectangle r = readElementConstraintsInfo(elementSchema); schema.setConstraints(r); }
/** * Create a command that can resize and/or move a shape. * * @param shape the shape to manipulate * @param request the move and resize request * @param newBounds the new size and location * @throws IllegalArgumentException if any of the parameters is null */ public CommentBoxSetConstraintCommand(CommentBox shape, ChangeBoundsRequest request, Rectangle newBounds) { if (shape == null || request == null || newBounds == null) { throw new IllegalArgumentException(); } this.shape = shape; this.request = request; this.newBounds = newBounds.getCopy(); this.newSize = newBounds.getSize(); setLabel("move / resize"); }
public void setConstraint(Rectangle r) { int width = 0; int height = 0; List children = getChildren(); for (Object object : children) { Figure l = (Figure) object; width = width + l.getBounds().width; height = Math.max(height, l.getBounds().height); } Rectangle rect = new Rectangle(r.width - width - 3, r.height - height - 3, r.width, r.height); VertexFigure.this.setConstraint(this,rect); }
/** * Create a command that can resize and/or move a shape. * * @param shape the shape to manipulate * @param request the move and resize request * @param newBounds the new size and location * @throws IllegalArgumentException if any of the parameters is null */ public ComponentSetConstraintCommand(Component shape, ChangeBoundsRequest request, Rectangle newBounds) { if (shape == null || request == null || newBounds == null) { throw new IllegalArgumentException(); } this.shape = shape; this.request = request; this.newBounds = newBounds.getCopy(); setLabel("move / resize"); }
public void sugiyamaLayout() { Display.getDefault().syncExec(new Runnable() { @Override public void run() { resetEdgesRouteLayout(); gWGraph.setLayout(new Rectangle(0, 0, getDimension().width, getDimension().height)); LayoutAlgoritmManager.sugiyamaLayout(gWGraph, getDimension()); } }); }
@Override protected Command createChangeConstraintCommand(EditPart child, Object constraint) { ChangeConstraintCommand ret = new ChangeConstraintCommand(); ret.setModel((Node) child.getModel()); ret.setNewConstraint((Rectangle) constraint); return ret; }
@Override public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(CompositePropertyNode.FONT_COLOR); setBackgroundColor(CompositePropertyNode.DEF_COLOR); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("Composite Property"); setToolTip(tooltip); }
public TableLayoutCommand(Table table, ChangeBoundsRequest req, Rectangle newBounds) { if (table == null || req == null || newBounds == null) { throw new IllegalArgumentException(); } this.table = table; this.request = req; this.newBounds = newBounds.getCopy(); setLabel("Table Move/Resize"); }
@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 public void rebuildFigure() { getDisplay().setForegroundColor(ColorConstants.black); add(getDisplay()); setConstraint(getDisplay(), new Rectangle(10, 10, -1, -1)); setOpaque(true); setVisible(true); setForegroundColor(ComponentNode.FONT_COLOR); setBackgroundColor(ComponentNode.DEF_COLOR); TooltipFigure tooltip = new TooltipFigure(); tooltip.setMessage("Component"); setToolTip(tooltip); }
@Override public void propertyChange(PropertyChangeEvent evt) { String prop = evt.getPropertyName(); if (StringUtils.equalsIgnoreCase(prop, LABEL_CONTENTS)) { refreshVisuals(); } else if (StringUtils.equalsIgnoreCase(prop, SIZE) || StringUtils.equalsIgnoreCase(prop, LOCATION)) { Point loc = getLabel().getLocation(); Dimension size = getLabel().getSize(); Rectangle r = new Rectangle(loc, size); ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), r); refreshVisuals(); } }
@Override protected void refreshVisuals() { AbstractNodeElement node = getModel(); Rectangle bounds = new Rectangle(node.getX(), node.getY(), node.getWidth(), node.getHeight()); ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds); super.refreshVisuals(); }