Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ClusterGraphAttributes.h
Go to the documentation of this file.
1
35#pragma once
36
39
40namespace ogdf {
41
43
47protected:
49
58
59public:
67 static const long clusterGraphics;
68
72 static const long clusterStyle;
73
75 static const long clusterLabel;
76
78 static const long clusterTemplate;
79
81 static const long all;
82
84
85 // Don't hide these inherited methods by overloading.
86 using GraphAttributes::height;
87 using GraphAttributes::width;
88 using GraphAttributes::x;
89 using GraphAttributes::y;
90
91 using GraphAttributes::label;
92
93 using GraphAttributes::strokeColor;
94 using GraphAttributes::strokeType;
95 using GraphAttributes::strokeWidth;
96
97 using GraphAttributes::fillBgColor;
98 using GraphAttributes::fillColor;
99 using GraphAttributes::fillPattern;
100
108
111 long initAttributes = nodeGraphics | edgeGraphics | clusterGraphics);
112
114
115private:
117 using GraphAttributes::init;
118
120
124
126
130
131public:
133
140 void init(ClusterGraph& cg, long attr = 0);
141
144 void init(long attr = 0);
145
147 void addAttributes(long attr);
148
151
153 const ClusterGraph& constClusterGraph() const { return *m_pClusterGraph; }
154
162
165 double x(cluster c) const {
166 OGDF_ASSERT(has(clusterGraphics));
167 return m_x[c];
168 }
169
171
174 double& x(cluster c) {
175 OGDF_ASSERT(has(clusterGraphics));
176 return m_x[c];
177 }
178
180
183 double y(cluster c) const {
184 OGDF_ASSERT(has(clusterGraphics));
185 return m_y[c];
186 }
187
189
192 double& y(cluster c) {
193 OGDF_ASSERT(has(clusterGraphics));
194 return m_y[c];
195 }
196
198
201 double width(cluster c) const {
202 OGDF_ASSERT(has(clusterGraphics));
203 return m_width[c];
204 }
205
207
210 double& width(cluster c) {
211 OGDF_ASSERT(has(clusterGraphics));
212 return m_width[c];
213 }
214
216
219 double height(cluster c) const {
220 OGDF_ASSERT(has(clusterGraphics));
221 return m_height[c];
222 }
223
225
228 double& height(cluster c) {
229 OGDF_ASSERT(has(clusterGraphics));
230 return m_height[c];
231 }
232
234
237 const StrokeType& strokeType(cluster c) const {
238 OGDF_ASSERT(has(clusterStyle));
239 return m_stroke[c].m_type;
240 }
241
243
247 OGDF_ASSERT(has(clusterStyle));
248 return m_stroke[c].m_type;
249 }
250
252
255 const Color& strokeColor(cluster c) const {
256 OGDF_ASSERT(has(clusterStyle));
257 return m_stroke[c].m_color;
258 }
259
261
265 OGDF_ASSERT(has(clusterStyle));
266 return m_stroke[c].m_color;
267 }
268
270
273 const float& strokeWidth(cluster c) const {
274 OGDF_ASSERT(has(clusterStyle));
275 return m_stroke[c].m_width;
276 }
277
279
283 OGDF_ASSERT(has(clusterStyle));
284 return m_stroke[c].m_width;
285 }
286
288
292 OGDF_ASSERT(has(clusterStyle));
293 return m_fill[c].m_pattern;
294 }
295
297
301 OGDF_ASSERT(has(clusterStyle));
302 return m_fill[c].m_pattern;
303 }
304
306
309 const Color& fillColor(cluster c) const {
310 OGDF_ASSERT(has(clusterStyle));
311 return m_fill[c].m_color;
312 }
313
315
319 OGDF_ASSERT(has(clusterStyle));
320 return m_fill[c].m_color;
321 }
322
324
327 const Color& fillBgColor(cluster c) const {
328 OGDF_ASSERT(has(clusterStyle));
329 return m_fill[c].m_bgColor;
330 }
331
333
337 OGDF_ASSERT(has(clusterStyle));
338 return m_fill[c].m_bgColor;
339 }
340
342
345 const string& label(cluster c) const {
346 OGDF_ASSERT(has(clusterLabel));
347 return m_label[c];
348 }
349
351
354 string& label(cluster c) {
355 OGDF_ASSERT(has(clusterLabel));
356 return m_label[c];
357 }
358
360
363 const string& templateCluster(cluster c) const {
364 OGDF_ASSERT(has(clusterTemplate));
365 return m_clusterTemplate[c];
366 }
367
369
373 OGDF_ASSERT(has(clusterTemplate));
374 return m_clusterTemplate[c];
375 }
376
383 using GraphAttributes::flipHorizontal;
384 using GraphAttributes::flipVertical;
385 using GraphAttributes::scale;
386
388
395 virtual void scale(double sx, double sy, bool scaleNodes = true) override;
396
398
402 virtual void translate(double dx, double dy) override;
403
405
409 virtual void flipVertical(const DRect& box) override;
410
412
416 virtual void flipHorizontal(const DRect& box) override;
417
419
423
425 virtual DRect boundingBox() const override;
426
429
431 cluster clusterOf(node v) { return m_pClusterGraph->clusterOf(v); }
432
434};
435
436}
Declaration and implementation of ClusterArray class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Dynamic arrays indexed with clusters.
Representation of clusters in a clustered graph.
Stores additional attributes of a clustered graph (like layout information).
ClusterArray< string > m_label
Cluster label.
FillPattern & fillPattern(cluster c)
Returns the fill pattern of cluster c.
void addAttributes(long attr)
Enables attributes specified by attr and allocates required memory.
double x(cluster c) const
Returns the x-position of cluster c's cage (lower left corner).
float & strokeWidth(cluster c)
Returns the stroke width of cluster c.
void init(long attr=0)
Re-initializes the ClusterGraphAttributes while maintaining the associated CluterGraph.
const FillPattern & fillPattern(cluster c) const
Returns the fill pattern of cluster c.
ClusterArray< double > m_x
X-position of lower left corner.
static const long clusterTemplate
Corresponds to cluster attribute templateCluster(cluster).
double & height(cluster c)
Returns the height of cluster c.
ClusterArray< double > m_y
Y-position of lower left corner.
const float & strokeWidth(cluster c) const
Returns the stroke width of cluster c.
const string & templateCluster(cluster c) const
Returns the template of cluster c.
static const long clusterStyle
Corresponds to cluster attributes strokeColor(cluster), strokeType(cluster), strokeWidth(cluster),...
ClusterArray< Fill > m_fill
Fill (style of interior)
string & label(cluster c)
Returns the label of cluster c.
double width(cluster c) const
Returns the width of cluster c.
const Color & strokeColor(cluster c) const
Returns the stroke color of cluster c.
const string & label(cluster c) const
Returns the label of cluster c.
static const long clusterGraphics
Corresponds to cluster attributes x(cluster), y(cluster), width(cluster), height(cluster).
void destroyAttributes(long attr)
Disables attributes specified by attr and releases available memory.
ClusterArray< Stroke > m_stroke
Stroke (style of boundary)
const ClusterGraph & constClusterGraph() const
Returns the associated cluster graph.
virtual DRect boundingBox() const override
Returns the bounding box of the layout.
ClusterArray< string > m_clusterTemplate
Name of cluster template.
ClusterGraphAttributes(const ClusterGraph &cg, long initAttributes=nodeGraphics|edgeGraphics|clusterGraphics)
Constructs cluster graph attributes for cluster graph cg with attributes initAttributes.
ClusterGraphAttributes()
Constructs cluster graph attributes for no associated graph.
static const long clusterLabel
Corresponds to cluster attribute label(cluster).
const Color & fillBgColor(cluster c) const
Returns the background color of fill patterns for cluster c.
virtual void translate(double dx, double dy) override
Translates the layout by (dx,dy).
ClusterArray< double > m_height
Cluster height.
double y(cluster c) const
Returns the y-position of cluster c's cage (lower left corner).
virtual void flipVertical(const DRect &box) override
Flips the (whole) layout vertically such that the part in box remains in this area.
cluster clusterOf(node v)
Returns the parent cluster of node v.
static const long all
Enables all available flags.
const ClusterGraph * m_pClusterGraph
Only points to existing graphs.
virtual void flipHorizontal(const DRect &box) override
Flips the (whole) layout horizontally such that the part in box remains in this area.
double & width(cluster c)
Returns the width of cluster c.
string & templateCluster(cluster c)
Returns the template of cluster c.
ClusterArray< double > m_width
Cluster width.
virtual void scale(double sx, double sy, bool scaleNodes=true) override
Scales the layout by (sx,sy).
Color & fillColor(cluster c)
Returns the fill color of cluster c.
double height(cluster c) const
Returns the height of cluster c.
void updateClusterPositions(double boundaryDist=1.0)
Updates positions of cluster boundaries wrt to children and child clusters.
void destroyClusterAttributes(long attr)
Destroy all cluster-related attributes in attr.
double & x(cluster c)
Returns the x-position of cluster c's cage (lower left corner).
const Color & fillColor(cluster c) const
Returns the fill color of cluster c.
const StrokeType & strokeType(cluster c) const
Returns the stroke type of cluster c.
double & y(cluster c)
Returns the y-position of cluster c's cage (lower left corner).
Color & strokeColor(cluster c)
Returns the stroke color of cluster c.
Color & fillBgColor(cluster c)
Returns the background color of fill patterns for cluster c.
StrokeType & strokeType(cluster c)
Returns the stroke type of cluster c.
void init(ClusterGraph &cg, long attr=0)
Initializes the ClusterGraphAttributes for ClusterGraph cg.
void addClusterAttributes(long attr)
Add all cluster-related attributes in attr.
Representation of clustered graphs.
cluster clusterOf(node v) const
Returns the cluster to which a node belongs.
Colors represented as RGBA values.
Definition graphics.h:160
Rectangles with real coordinates.
Definition geometry.h:790
Stores additional attributes of a graph (like layout information).
Class for the representation of nodes.
Definition Graph_d.h:177
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
FillPattern
Fill patterns.
Definition graphics.h:82
StrokeType
Line types of strokes.
Definition graphics.h:46
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.