Mercurial > projects > doodle
annotate doodle/fig/diagram_elements.d @ 97:dcd641209671
What to do...
author | David Bryant <bagnose@gmail.com> |
---|---|
date | Fri, 27 Aug 2010 18:01:33 +0930 |
parents | 66210d8ea37a |
children | bc5baa585b32 |
rev | line source |
---|---|
54 | 1 module doodle.fig.diagram_elements; |
27 | 2 |
96 | 3 public { |
4 import doodle.tk.geometry; | |
5 } | |
6 | |
44 | 7 private { |
84 | 8 import doodle.tk.renderer; |
44 | 9 } |
10 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
11 interface IDiagram { |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
12 void add(DiagramElement element); |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
13 } |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
14 |
54 | 15 abstract class DiagramElement { |
44 | 16 Rectangle bounds() const; |
17 | |
84 | 18 void draw(in Rectangle damage, scope Renderer cr) const; |
44 | 19 |
20 private { | |
97 | 21 GraphElement _container; |
54 | 22 } |
23 } | |
24 | |
96 | 25 abstract class SemanticModelBridge { |
97 | 26 } |
27 | |
28 final class SimpleSemanticModelElement : SemanticModelBridge { | |
29 private { | |
30 string _typeInfo; | |
31 } | |
32 } | |
54 | 33 |
96 | 34 abstract class GraphElement : DiagramElement { |
35 // Link to model via bridge goes here | |
36 private { | |
37 SemanticModelBridge _modelBridge; | |
38 GraphConnector[] _anchorages; | |
97 | 39 DiagramElement[] _containeds; |
96 | 40 } |
44 | 41 } |
27 | 42 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
43 class GraphConnector { |
97 | 44 private { |
45 GraphElement _graphElement; | |
46 GraphEdge[] _graphEdges; | |
47 } | |
44 | 48 } |
27 | 49 |
67 | 50 final class GraphNode : GraphElement { |
97 | 51 override Rectangle bounds() const { return _bounds; } |
52 | |
53 override void draw(in Rectangle damage, scope Renderer cr) const { | |
54 } | |
55 | |
56 private { | |
57 Rectangle _bounds; | |
58 } | |
44 | 59 } |
27 | 60 |
67 | 61 final class GraphEdge : GraphElement { |
97 | 62 override Rectangle bounds() const { return _bounds; } |
63 | |
64 override void draw(in Rectangle damage, scope Renderer cr) const { | |
65 } | |
66 | |
96 | 67 private { |
68 GraphConnector[2] _anchors; | |
97 | 69 Point[] _waypoints; |
70 Rectangle _bounds; | |
96 | 71 } |
44 | 72 } |
73 | |
54 | 74 abstract class LeafElement : DiagramElement { |
75 } | |
76 | |
96 | 77 class TextElement : LeafElement { |
97 | 78 override Rectangle bounds() const { return _bounds; } |
79 | |
80 override void draw(in Rectangle damage, scope Renderer cr) const { | |
81 } | |
82 | |
83 private { | |
84 Rectangle _bounds; | |
85 } | |
96 | 86 } |
54 | 87 |
88 abstract class GraphicPrimitive : LeafElement { | |
44 | 89 } |
54 | 90 |
96 | 91 class PolylinePrimitive : GraphicPrimitive { |
97 | 92 override Rectangle bounds() const { return _bounds; } |
93 | |
94 override void draw(in Rectangle damage, scope Renderer cr) const { | |
95 } | |
96 | |
96 | 97 private { |
98 Point[] _waypoints; | |
97 | 99 Rectangle _bounds; |
96 | 100 } |
101 } | |
54 | 102 |
67 | 103 final class RectanglePrimitive : GraphicPrimitive { |
97 | 104 override Rectangle bounds() const { return _bounds; } |
105 | |
84 | 106 override void draw(in Rectangle damage, scope Renderer drawable) const { |
80
b759414d2b72
Switched from cairo to Drawable abstraction
"David Bryant <bagnose@gmail.com>"
parents:
73
diff
changeset
|
107 drawable.drawRectangle(bounds, false); |
54 | 108 } |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
109 |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
110 private { |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
111 Rectangle _bounds; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
112 } |
54 | 113 } |