Diagram example

PGUI: Model-View-Controller: Diagram example

The simple diagram editor is an example of using the model-view-controller -architecture.

The diagrams consist of nodes (with title) and connectors between the nodes.

Diagram in Java

The Java version of diagram application uses the following keyboard commands:

"S" - selection tool,
"N" - node creation tool, and
"C" - connector creation tool.

Example directory (zipped)
Application: DiagramApp.java
Model: Diagram.java
View: DiagramView.java

 

Diagram with APItoOO

This example extends the previous example APItoOO. It adds to more classes to the "framework": Observable and Observer. The diagram data inherits Observable and diagram view inherits Window and Observer.

Example directory (zipped)

Observer.h
Observable.h and Observable.cpp
Diagram.h and Diagram.cpp
DiagramView.h and DiagramView.cpp
DiagramApp.cpp

Diagram_Win_API.exe

 

Diagram with .NET

The .NET version uses separate controller objects for easy switching of the editing mode.

Example directory (zipped)

Code in HTML

Diagram.exe

 

Diagram with MFC (document-view)

See the detailed explanation in Document-View Architecture.

Example directory (zipped)

Code in HTML

Diagram.exe

 

See also: