Drawing lines/edges using Graph API
Hi all,
Is it possible to draw lines or edges without connecting two nodes? for example, in sequence diagrams the life line is a vertical line connecting one class (Node) only.
How can I do it?
Thanks,
Andre
Please sign in to leave a comment.
Actually, my diagram draws polylines with many vertex (I don't know why). The lines start on left side of the Node (I don't know why either). Attached the layouter and image.
Any help is apreciated...
Attachment(s):
image.JPG
DiagramLayouter.java
Andre,
My idea is to implement special node type for life line and add custom NodeRealizer
for this node.
You can draw this nodes types in data model or draw manually in CustomGraphUpdater
(Take a look to public abstract void addCustomUpdater(final CustomGraphUpdater
updater); of GraphBuilder)
Serega
public interface NodeObject {}
public class CaptionNode implements NodeObject {}
public class LifeLineNode implements NodeObject {}
public interface EdgeObject {}
public class CaptionEdge implements EdgeObject {}
public class MessageEdge implements EdgeObject {}
public class SeqDataModel implements GraphDataModel<NodeObject, EdgeObject> {
private updateModel(PsiClass aClassSource, PsiClass aClassTarget) {
CaptionNode captionNode = addCaptionNode(aClassSource);
LifeLineNode sourceLine = addLifeLineNode(aClassSource);
addCaptionEdge(captionNode, sourceLine);
CaptionNode captionNodeTarget =addCaptionNode(aClassTarget);
LifeLineNode targetLine = addLifeLineNode(aClassTarget);
addEdge(captionNodeTarget, targetLine);
addMessageEdge(sourceLine, targetLine);
}
// other methods
}
>> Actually, my diagram draws polylines with many vertex (I don't know
>> why). The lines start on left side of the Node (I don't know why
>> either). Attached the layouter and image.
>>
>> Any help is apreciated...
>>
Hi Serega,
Some questions... :)
- Is it possible to use Edges instead of Nodes for timelines? Is it a good strategy?
- Edges are ever conected on left side of nodes?
- Why so mayn vertex in edges?
- Is it possible to draw Edges without Nodes?
Thanks,
Andre
public class SeqPresentationModel extends BasicGraphPresentationModel<NodeObject,
EdgeObject> {
@NotNull
public NodeRealizer getNodeRealizer(final NodeObject nodeObject) {
if (nodeObject instanceof CaptionNode) {
return createCaptionNodeRealizer((CaptionNode)nodeObject);
}
return createLifeLineNodeRealizer((LifeLineNode)nodeObject);
}
}
public class LifeLineNodeRealizer extends BasicNodeCellRenderer {
public JComponent getNodeCellRendererComponent(final Graph2DView graph2DView,
final NodeRealizer nodeRealizer, final Object object, final boolean b) {
return createLongVerticalRectangle();
}
}
>> Andre,
>>
>> My idea is to implement special node type for life line and add
>> custom
>> NodeRealizer
>> for this node.
>> You can draw this nodes types in data model or draw manually in
>> CustomGraphUpdater
>> (Take a look to public abstract void addCustomUpdater(final
>> CustomGraphUpdater updater); of GraphBuilder)
>> Serega
>>
>>> Actually, my diagram draws polylines with many vertex (I don't know
>>> why). The lines start on left side of the Node (I don't know why
>>> either). Attached the layouter and image.
>>>
>>> Any help is apreciated...
>>>
public class SeqPresentationModel extends BasicGraphPresentationModel<NodeObject,
EdgeObject> {
@NotNull
public EdgeRealizer getEdgeRealizer(final EdgeObject edgeObject) {
final EdgeRealizer edgeRealizer = GraphManager.getGraphManager().createPolyLineEdgeRealizer();
if (edgeObject instanceof CaptionEdge) {
edgeRealizer.setLineType(LineType.LINE_1);
edgeRealizer.setLineColor(Color.GRAY);
edgeRealizer.setArrow(Arrow.NONE);
} else {
edgeRealizer.setLineType(LineType.LINE_4);
edgeRealizer.setLineColor(Color.ORANGE); // :)
edgeRealizer.setArrow(Arrow.STANDARD);
}
return edgeRealizer;
}
}
>> Andre,
>>
>> My idea is to implement special node type for life line and add
>> custom
>> NodeRealizer
>> for this node.
>> You can draw this nodes types in data model or draw manually in
>> CustomGraphUpdater
>> (Take a look to public abstract void addCustomUpdater(final
>> CustomGraphUpdater updater); of GraphBuilder)
>> Serega
>>
>>> Actually, my diagram draws polylines with many vertex (I don't know
>>> why). The lines start on left side of the Node (I don't know why
>>> either). Attached the layouter and image.
>>>
>>> Any help is apreciated...
>>>