Reputation: 56
I wonder how to show object assignment in the collaboration diagram I made with this given code, in particular in aNode = path.getLastPathComponent()
.
/* @author Scott Violet */
public class SampleTreeModel extends DefaultTreeModel {
public SampleTreeModel(TreeNode newRoot) { super(newRoot); }
public void valueForPathChanged(TreePath path, Object newValue) {
DefaultMutableTreeNode aNode =
(DefaultMutableTreeNode)path.getLastPathComponent();
SampleData sampleData = (SampleData)aNode.getUserObject();
sampleData.setString((String)newValue);
if (this.isColorGreen) sampleData.setColor(Color.green);
else sampleData.setColor(Color.black);
nodeChanged(aNode);
}
}
I tried showing the assignment like in the code, but not sure if that is the correct way, maybe the relationships with the objects make this implicit. Hope you can help me. Thanks!
Upvotes: 3
Views: 80
Reputation: 3625
I think, this is the correct way. The assignment target is shown in front of the equals sign. If you wanted to specify the returned value, it would be shown after a colon behind the label of the reply message.
However, I have some remarks on the diagram:
Upvotes: 3