抽象类的表示
选中需要设置的类,勾选Properties->General->IsAbstract进行设置,设置完成后,类名会变成斜体

接口的表示
在Properties->General中将Stereotype设置为interface

新增类的属性
选中需要新增属性的类,点击Properties->General->Attributes的右侧按钮

弹出Collection Editor窗口,在选项为Attributes界面,点击Insert新增属性

选中新增的那一条属性,现在右侧的Properties菜单变成了属性的Properties菜单,在Properties->General中,通过Name和Type分别设置属性的名称和类型

static属性表示
在类图中,如果属性带下划线,表示这是一个static的属性,设置Properties->OwnerScope为CLASSFIFIER即可表示static属性


新增类的方法
和属性设置类似,选中需要新增方法的类,点击Properties->General->Operations的右侧按钮,弹出Collection Editor窗口,在选项为Operations的界面,点击Insert新增方法

设置方法的返回值
设置方法的返回值同样通过Operations界面进行设置,点击Properties->General->Operations的右侧按钮

弹出Operations窗口后,选中需要设置返回值的方法,现在右侧的Properties菜单变成了方法的Properties菜单,再次点击Properties->Parameters的右侧按钮

弹出Parameters窗口,点击在Parameters窗口中点击Insert新增一条Parameter

在Properties->General->Type中设置该Parameter的类型,Properties->General->Detail中设置DirectionKind为RETURN,表示该参数为返回值

完整的设置过程如下图:

设置方法的参数
设置方法的参数的过程基本和设置方法返回值的步骤一致,唯一不同的是:在Properties->General->Name中设置参数的名字,在Properties->General->Type中设置参数的类型,Properties->General->Detail中设置DirectionKind为IN,表示该参数为方法传入的参数


内部类的表示
设置内部类可以分为2步:第一步,将内部类拖到它所属的类里面

完成拖动的效果如下图,我们切换到Model Explorer中,可以看到整个类图之间的关系

第二步,在Model Explorer中,将CallBack拖到到KeyEvent中,从类图关系上表示CallBack是KeyEvent的类图内

完整的设置过程如下图:

导出类图为Java代码
我们在画完一个类图后,还可以将其导出为Java代码。选择需要设置的类图,然后右键会弹出设置窗口,选择Java->Generate Code

选择Generate Code后可能会报错:Java Profile has not been include.

可以在Model->Profile菜单中,将Java Profile添加进去

导入Java Profile,尝试重新生成Java代码成功

最后,查看导出的Java代码

自定义颜色
我们还可以自定义类图的颜色,选择需要设置的类图,然后右键会弹出设置窗口,选择Format->Fill Color就可以设置颜色

