将类元素更改为界面元素
当对类图进行建模时,工具箱包含类和接口的特殊对象。它们的不同之处在于它们的图标,如果将它们添加到图表中,这些图标会显示在项目浏览器
中。 (它们的属性似乎是相同的。)
是否可以将创建为 class
的对象更改为 interface
类型的对象?或者我是否必须删除类
并创建一个新的接口
?
When modelling a class diagram the toolbox contains special objects for a class and for an interface. They differs by their icons which are shown in the Project Browser
if they were added to a diagram. (Their properties seems to be the same.)
Is it possible to change an object which was created as class
to an object of type interface
? Or do I have to delete the class
and create a new interface
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在早期版本的 EA 中:
是的,这是可能的,而且非常简单。
选择该类并查看“元素属性”窗口(如果它不可见,请在“视图”菜单中选择它)。属性窗口有三个分支:类设置(或接口等)、项目和高级。
如果您查看“类设置”下,会发现一个名为“类型”的字段,带有省略号按钮 (...)。选择它,您可以将元素类型更改为接口或您想要的任何其他类型。
请注意,更改类型后,您可能需要仔细检查元素属性。
例如,将一个简单的类更改为接口非常简单。
另一方面,如果将接口更改为类,则该类将是抽象的(因为接口是抽象的)并保留“接口”构造型。
在 2023 年推出的 EA 中,
单击该类别。右侧有一个属性对话框。此对话框中是“常规”窗格,其中包含“类型”行,其值为“类别”。双击班级。弹出一个对话框。在元素类型下拉列表中,选择接口。单击“确定”。请参阅上述旧 EA 的注释,了解上述转换过程中的预期情况。
In ancient versions of EA:
Yes, it's possible and quite simple.
Select the class and look at the Element Properties window (if it isn't visible, select it in the View menu). The Properties window has three branches: Class Settings (or Interface, etc), Project, and Advanced.
If you look under Class Settings, there's a field called Type with an ellipsis button (...). Select that, and you can change the element type to Interface or any other type you wish.
Be aware that you may need to double-check the element properties once you've changed the type.
For instance, changing a simple Class to an Interface is pretty straightforward.
If on the other hand you change an Interface to a Class, the class will be abstract (because an Interface is) and retain the "interface" stereotype.
In an EA available in 2023
Click on the class. On the right, there is a Properties dialog. Within this dialog is General pane with a Type line, with the value Class. Double-click on Class. A dialog pops up. In the Element Type dropdown, select Interface. Click OK. See notes above for the old EA about what to expect during the conversion process above.