Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java中的企业架构师脚本:如何更改连接器的方式?_Java_Uml_Enterprise Architect_Activity Diagram - Fatal编程技术网

java中的企业架构师脚本:如何更改连接器的方式?

java中的企业架构师脚本:如何更改连接器的方式?,java,uml,enterprise-architect,activity-diagram,Java,Uml,Enterprise Architect,Activity Diagram,我试图改变连接活动图中两个元素的连接器的方式。我使用来自sparx的JavaAPI(eaapi.jar)。 我的功能是连接两个元素: public void connectTwoElements(Element source, Element target) { Connector con = source.GetConnectors().AddNew("","ControlFlow"); con.SetSupplierID(target.GetElementID());

我试图改变连接活动图中两个元素的连接器的方式。我使用来自sparx的JavaAPI(eaapi.jar)。 我的功能是连接两个元素:

public void connectTwoElements(Element source, Element target) {
    Connector con = source.GetConnectors().AddNew("","ControlFlow");
    con.SetSupplierID(target.GetElementID());
    con.Update();
    source.GetConnectors().Refresh();
}
我的目标是改变连接器的方式,如下图所示。连接到目标元件的连接器应具有一个边缘点,以形成90°角。

我没有找到类连接器的任何属性来实现它。我希望我可以使用如下函数: myConnector.addBetweenPoint(intx,inty)

也许有人能帮我:)

问候,, 菲尔

编辑:

在Nizam Mohamed和Uffe在下面帮助我之后,我修改了我的方法:

 public void connectTwoElements(Element source, Element target, String connectorLabel) {
    Connector con = source.GetConnectors().AddNew(connectorLabel,"ControlFlow");        
    con.SetSupplierID(target.GetElementID());
    con.Update();        
    source.GetConnectors().Refresh();
    diagram.GetDiagramLinks().Refresh();

    //change style of diagram link
    Collection<DiagramLink> diagramLinks = diagram.GetDiagramLinks();
    for(DiagramLink dl : diagramLinks){
        if(dl.GetConnectorID()==con.GetConnectorID()){
            dl.SetStyle("Mode=3;TREE=LV;");
            dl.Update();
            diagram.GetDiagramLinks().Refresh();
            break;
        }
    }
}
public void connecttwolements(元素源、元素目标、字符串connectorLabel){
Connector con=source.GetConnectors().AddNew(connectorLabel,“ControlFlow”);
con.SetSupplierID(target.GetElementID());
con.Update();
source.GetConnectors().Refresh();
gram.GetDiagramLinks().Refresh();
//更改图表链接的样式
集合diagramLinks=diagram.GetDiagramLinks();
用于(DiagramLink dl:DiagramLink){
如果(dl.GetConnectorID()==con.GetConnectorID()){
dl.SetStyle(“模式=3;树=LV;”);
dl.Update();
gram.GetDiagramLinks().Refresh();
打破
}
}
}

在添加新连接器后刷新()关系图的集合DiagramLinks非常重要,因为否则该DiagramLinks在集合DiagramLinks中不可用,无法更改样式。当然,更改样式后必须再次刷新()。

可以将线型设置为正交-方形或横向-垂直以实现此目的。 为此,需要获取DiagramLink并设置其样式

下面是一些组合

(对于正交正方形)模式=3;树=操作系统


(横向垂直)模式=3;树=LV

类似元素,其在一个特定图表中的视觉表示由
DiagramObject
表示,
DiagramLink
控制一个图表中一个连接器的显示。因此,如果要在一个图中更改连接器的外观而不影响任何其他图,则需要从
diagram.DiagramLinks
中检索相关的
DiagramLink
,并对其进行更改


您建议的方法不存在,因此最简单的方法可能是绘制一些外观符合您要求的连接器,然后检查数据库(t_connector和t_diagramlinks)看看几何体是如何表现的。

我建议你挖掘一下
SetRouteStyle
setStylex
方法。你好,尼扎姆·穆罕默德,非常感谢你的回答。它的工作:)嘿,乌夫,再次非常感谢:-)你是我的EA脚本英雄!