首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >月食-帕皮勒斯在液滴位置创建节点

月食-帕皮勒斯在液滴位置创建节点
EN

Stack Overflow用户
提问于 2016-12-19 14:01:11
回答 1查看 94关注 0票数 0

我想将一些项目从列表中拖放到模型查看器中。我已经可以这样做了,但是节点总是在查看器的左上角创建的,我不知道如何在删除的位置创建节点。

下面是创建节点的函数(x和y是液滴定位的坐标)。

代码语言:javascript
复制
private View addNode(Node node, View deploymentView) {

    // use the view service to create the types. This is a bit cleaner than
    // using the sequence-diagram view provider directlys
    final String nodeType = UMLVisualIDRegistry
            .getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NodeEditPart.VISUAL_ID);
    org.eclipse.gmf.runtime.notation.Node nodeView = ViewService.createNode(deploymentView.getDiagram(), node,
            nodeType, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
    Bounds location = NotationFactory.eINSTANCE.createBounds();

    System.out.println("Dropped at x: "+ (int)this.x + " y: "+ (int)this.y);
    location.setX((int)this.x);
    location.setY((int)this.y);
    return nodeView;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-19 22:11:54

好吧,修好它不是很难.

代码语言:javascript
复制
private View addNode(Node node, View deploymentView) {


    // use the view service to create the types. This is a bit cleaner than
    // using the sequence-diagram view provider directlys
    final String nodeType = UMLVisualIDRegistry
            .getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NodeEditPart.VISUAL_ID);
    org.eclipse.gmf.runtime.notation.Node nodeView = ViewService.createNode(deploymentView.getDiagram(), node,
            nodeType, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);


    System.out.println("Dropped at x: "+ (int)this.x + " y: "+ (int)this.y);

    //for(int i=0;i<nodeView.getDiagram().getChildren().size();i++)System.out.println(nodeView.getDiagram().getChildren().get(i).toString());

    nodeView.setLayoutConstraint(NotationFactory.eINSTANCE
            .createLocation());
    Location location = (Location) nodeView.getLayoutConstraint();
    location.setX((int)this.x);
    location.setY((int)this.y);
    return nodeView;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41224265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档