UmlPanel is an component used to
make and view UML diagrams. Whole project is divided in two part,
one is data part which gives you possibility to create,
store or add complet UML diagram. Second part is an graphical
representation of the same diagram. Fisrt (data part) can be used without
using graphical representation, second part (graphical representation) logicaly can't exist without data
part. |
|
Here is UmlManipulator diagram: |
 |
|
Possible operation with data part
(in fallowing text DP): |
Programaticaly create an UML diagram.
Save complet UML diagram in XML format.
Load UML diagram from XML format.
|
|
Possible operation with graphical part (in fallowing text GP) |
Graphical representation of UML diagram.
Changing size of each node.
Making conections in between nodes.
Selecting one or more node.
Changing position of nodes.
Turn on/off grid for easyest manipulation.
Showing captions and other data associated with given node. |
|
How all those stuffs work? |
|
Data Part (DP)
|
|
Here is DP diagram. As you can see data part
contains two basic classes:
CUmlDiagram
CNode
This two class are necessery minimum to desribe
an UML diagram. CUmlDiagram is class which provide functionality for
loading and saving UML diagram, in same time it holds list of nodes
in UML diagram. CNode class is an abstract class and it need to be
extended by any new class. It contains only basic functionality such
as conection to it graphical representation class (CVisNode).
Extended class from CNode class can represents (in UML diagram)
class,interface,connection etc.
| |
In case if
we dont want to have any graphical representation of UML diagram we can
use only DP classes. They
have functionality for programaticaly creating an UML diagram, saving or loading it. Offcourse
in real life it could be very difficult to make
an diagram without seen a real graphical representation of it. Any of CNode childrens
can have it own graphical representation. This graphical representation can be
customized by any user who wants top change "look&feel" of diagram". Those classes
are added to CNode by giving String parameter with
full package name and class which will represent our
CNode children class. Graphical represenation class must be extended from abstract
class CVisNode. In case if we want to have full graphical representation
we also need to conect Observers to our CUmlDiagram
class. |
|
Those two classes represent
connection in between graphical representation and DP. Instance
of CActionObserver have to be added
to CUmlDiagram. Trough this observer CUmlDiagram inform
class which implements IPaintListener that UML diagram was changed (Node was
moved, added, deleted etc). For this operation
CUmlDiagram send list of nodes to be updated same
as clip region for this update. In simple any kind of
action on diagram must "fly" trough thid observer.
On the other hand CUserEventObserver is
responisble for any kind of user events in graphical representation
of diagram. For example mouse or keyboard operations. Class
CUmlCanvas have to know about this Observer same as this observer
have to know about CUmlCanvas. CUserEventObserver implements all
interfaces for listening mouse and keyboard events.It also knows
about CUmlDiagram instance so it can ask CUmlDiagram for node which
was afected by user operation and inform CUmlCanvas that it must do
some operation with this node, such as draw selection rectangle,
move node, etc. | |
Graphical representation part (GP) |
|
On first look GP
parat have similar construction as data part. CUmlCanvas class is
responisble for drawing whole diagram. It is also responisble for
drawing manipulating primitives (xor rectangle for moving nodes,
etc). Class CVisNode is an abstract class from which have to be extended all other classes which will
represent data part of diagram. CUmlCanvas also implement IPaintListener
interface for comunication with CActionObserver class. Any kind of
data such as position or size of given node
are stored in data part of node. CVisNode is only responible for
proper draving node on screen. It is only on user how
he want to represent all kind of
data nodes. | |
|
Class Description |
DataPart
|
Observer Part |
Graphical Part |
|
CUmlDiagram |
public class
CUmlDiagram |
extends
java.lang.Object |
|
An class which hold all
data from an UML diagram. |
|
Constructor Summary |
CUmlDiagram()
Construct new diagram.
| |
|
Method
Summary |
Vector |
getNodes() Return
list of existing nodes. Each item is CNode type.
|
void |
setActionObserver(CActionObserver
observer) Set ActionObserver for graphical
representation of
diagram. |
|
|
|
| |
CNode |
public abstract class CNode |
extends java.lang.Object |
|
An abstract class need to
be extended by new representations of UML elements
(class,interface,arrows etc) |
|
Constructor Summary |
CNode()
Construct new
node.
|
CNode(String path)
Construct new node with graphical representation given by
parameter path, which is full package and class name of class
used
for graphical representation.
| |
|
Method
Summary |
Rectangle |
getClientRect() Return
client rectangle. |
void |
setSize(Dimension
d) Set client
size. |
void |
setLocation(Point
p) Set location of
node. |
boolean |
isSelected() Return
true if given node is selected otherwise return
false. |
|
| |
|
|
| |
CActionObserver |
public class CActionObserver |
extends java.lang.Object |
|
Class which take care of
all actions between data part and visual representation of it. |
|
Constructor Summary |
CActionObserver() Create
new instance of CActionObserver.
| |
|
Method
Summary |
CActionObserver |
static
getInstance() Return
static instance of CActionObserver class.
|
|
| |
|
| |
CUserEventObserver |
public class CUserEventObserver |
extends java.lang.Object |
|
Observer class which implements all action
listeners for mouse and keyboard events used by CUmlCanvas.It make communication
between DP and GP. |
|
Constructor Summary |
CUserEventObserver() Create
new instance of
CUserEventObserver.
| |
|
Method
Summary |
CUserEventObserver |
static
getInstance() Return
static instance of CUserEventObserver
|
|
| |
|
| |
IPaintListener |
public interface IPaintListener |
|
Listener used by CActionObserver |
|
Method
Summary |
void |
repaint(Rectangle clip,Vector
nodes) Repaint
area given by clip
parameter, nodes parameter contains all nodes to be repainted. |
|
| |
|
| |
CUmlCanvas |
public class CUmlCanvas |
extends java.awt.Canvas |
|
Class used to paint UML
diagram, also provide functionality for visualisation of moving or
resizing nodes. |
|
Constructor Summary |
CUmlCanvas()
Construct new canvas.
|
CUmlCanvas(CUserEventObserver
observer)
Construct new canvas with User event
observer.
| |
|
Method
Summary |
void |
setUserEventObserver(CUserEventObserver
observer) Set
User event observer,
and use it as an mouse and keyboarb listener.
|
|
| |
|
|
| |
CVisNode |
public abstract class VisNode |
extends java.awt.Object |
|
Abstract class as an
representation of nodes in UML diagram. |
|
Constructor Summary |
CVisNode() Create
new instance of CVisNode.
| |
|
Method
Summary |
Vector |
draw(CNode node,Graphics
g) Draw given node on
graphics context g. |
|
| |
| |
|
|
|
|