Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ClusterGraphAttributes.h
Go to the documentation of this file.
1 
35 #pragma once
36 
37 #include <ogdf/basic/Graph.h>
39 #include <ogdf/basic/basic.h>
40 #include <ogdf/basic/geometry.h>
41 #include <ogdf/basic/graphics.h>
43 
44 #include <string>
45 
46 namespace ogdf {
47 
49 
53 protected:
55 
64 
65 public:
71  static const long clusterGraphics;
74 
78  static const long clusterStyle;
79 
81  static const long clusterLabel;
82 
84  static const long clusterTemplate;
85 
87  static const long all;
88 
90 
91  // Don't hide these inherited methods by overloading.
94  using GraphAttributes::x;
95  using GraphAttributes::y;
96 
98 
102 
106 
112  ClusterGraphAttributes() : GraphAttributes(), m_pClusterGraph(nullptr) { }
114 
116  explicit ClusterGraphAttributes(const ClusterGraph& cg,
117  long initAttributes = nodeGraphics | edgeGraphics | clusterGraphics);
118 
119 private:
121  using GraphAttributes::init;
122 
124 
127  void addClusterAttributes(long attr);
128 
130 
133  void destroyClusterAttributes(long attr);
134 
135 public:
137 
144  void init(ClusterGraph& cg, long attr = 0);
145 
148  void init(long attr = 0);
149 
151  void addAttributes(long attr);
152 
154  void destroyAttributes(long attr);
155 
157  const ClusterGraph& constClusterGraph() const { return *m_pClusterGraph; }
158 
165 
169  double x(cluster c) const {
170  OGDF_ASSERT(has(clusterGraphics));
171  return m_x[c];
172  }
173 
175 
178  double& x(cluster c) {
179  OGDF_ASSERT(has(clusterGraphics));
180  return m_x[c];
181  }
182 
184 
187  double y(cluster c) const {
188  OGDF_ASSERT(has(clusterGraphics));
189  return m_y[c];
190  }
191 
193 
196  double& y(cluster c) {
197  OGDF_ASSERT(has(clusterGraphics));
198  return m_y[c];
199  }
200 
202 
205  double width(cluster c) const {
206  OGDF_ASSERT(has(clusterGraphics));
207  return m_width[c];
208  }
209 
211 
214  double& width(cluster c) {
215  OGDF_ASSERT(has(clusterGraphics));
216  return m_width[c];
217  }
218 
220 
223  double height(cluster c) const {
224  OGDF_ASSERT(has(clusterGraphics));
225  return m_height[c];
226  }
227 
229 
232  double& height(cluster c) {
233  OGDF_ASSERT(has(clusterGraphics));
234  return m_height[c];
235  }
236 
238 
241  const StrokeType& strokeType(cluster c) const {
242  OGDF_ASSERT(has(clusterStyle));
243  return m_stroke[c].m_type;
244  }
245 
247 
251  OGDF_ASSERT(has(clusterStyle));
252  return m_stroke[c].m_type;
253  }
254 
256 
259  const Color& strokeColor(cluster c) const {
260  OGDF_ASSERT(has(clusterStyle));
261  return m_stroke[c].m_color;
262  }
263 
265 
269  OGDF_ASSERT(has(clusterStyle));
270  return m_stroke[c].m_color;
271  }
272 
274 
277  const float& strokeWidth(cluster c) const {
278  OGDF_ASSERT(has(clusterStyle));
279  return m_stroke[c].m_width;
280  }
281 
283 
286  float& strokeWidth(cluster c) {
287  OGDF_ASSERT(has(clusterStyle));
288  return m_stroke[c].m_width;
289  }
290 
292 
295  const FillPattern& fillPattern(cluster c) const {
296  OGDF_ASSERT(has(clusterStyle));
297  return m_fill[c].m_pattern;
298  }
299 
301 
305  OGDF_ASSERT(has(clusterStyle));
306  return m_fill[c].m_pattern;
307  }
308 
310 
313  const Color& fillColor(cluster c) const {
314  OGDF_ASSERT(has(clusterStyle));
315  return m_fill[c].m_color;
316  }
317 
319 
323  OGDF_ASSERT(has(clusterStyle));
324  return m_fill[c].m_color;
325  }
326 
328 
331  const Color& fillBgColor(cluster c) const {
332  OGDF_ASSERT(has(clusterStyle));
333  return m_fill[c].m_bgColor;
334  }
335 
337 
341  OGDF_ASSERT(has(clusterStyle));
342  return m_fill[c].m_bgColor;
343  }
344 
346 
349  const string& label(cluster c) const {
350  OGDF_ASSERT(has(clusterLabel));
351  return m_label[c];
352  }
353 
355 
358  string& label(cluster c) {
359  OGDF_ASSERT(has(clusterLabel));
360  return m_label[c];
361  }
362 
364 
367  const string& templateCluster(cluster c) const {
368  OGDF_ASSERT(has(clusterTemplate));
369  return m_clusterTemplate[c];
370  }
371 
373 
377  OGDF_ASSERT(has(clusterTemplate));
378  return m_clusterTemplate[c];
379  }
380 
390 
392 
399  virtual void scale(double sx, double sy, bool scaleNodes = true) override;
400 
402 
406  virtual void translate(double dx, double dy) override;
407 
409 
413  virtual void flipVertical(const DRect& box) override;
414 
416 
420  virtual void flipHorizontal(const DRect& box) override;
421 
423 
426 
429  virtual DRect boundingBox() const override;
430 
432  void updateClusterPositions(double boundaryDist = 1.0);
433 
435  cluster clusterOf(node v) { return m_pClusterGraph->clusterOf(v); }
436 
438 };
439 
440 }
ogdf::Color
Colors represented as RGBA values.
Definition: graphics.h:164
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Graph.h
Includes declaration of graph class.
ogdf::ClusterGraphAttributes::strokeColor
const Color & strokeColor(cluster c) const
Returns the stroke color of cluster c.
Definition: ClusterGraphAttributes.h:259
graphics.h
Declaration of basic types for graphics.
ogdf::StrokeType
StrokeType
Line types of strokes.
Definition: graphics.h:50
ogdf::GraphAttributes::fillBgColor
const Color & fillBgColor(node v) const
Returns the background color of fill patterns for node v.
Definition: GraphAttributes.h:537
ogdf::GraphAttributes::fillColor
const Color & fillColor(node v) const
Returns the fill color of node v.
Definition: GraphAttributes.h:519
geometry.h
Declaration of classes GenericPoint, GenericPolyline, GenericLine, GenericSegment,...
ogdf::GraphAttributes::fillPattern
FillPattern fillPattern(node v) const
Returns the fill pattern of node v.
Definition: GraphAttributes.h:501
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::ClusterGraphAttributes::height
double height(cluster c) const
Returns the height of cluster c.
Definition: ClusterGraphAttributes.h:223
ogdf::ClusterGraphAttributes::strokeType
StrokeType & strokeType(cluster c)
Returns the stroke type of cluster c.
Definition: ClusterGraphAttributes.h:250
ogdf::ClusterGraphAttributes::label
string & label(cluster c)
Returns the label of cluster c.
Definition: ClusterGraphAttributes.h:358
ogdf::ClusterGraphAttributes::y
double & y(cluster c)
Returns the y-position of cluster c's cage (lower left corner).
Definition: ClusterGraphAttributes.h:196
ogdf::ClusterGraphAttributes::m_y
ClusterArray< double > m_y
Y-position of lower left corner.
Definition: ClusterGraphAttributes.h:57
ogdf::ClusterArrayBase
RegisteredArray for labeling the clusters of a ClusterGraph.
Definition: ClusterGraph.h:311
ogdf::GraphAttributes::x
double x(node v) const
Returns the x-coordinate of node v.
Definition: GraphAttributes.h:247
ogdf::GraphAttributes::init
virtual void init(const Graph &G, long attr)
Initializes the graph attributes for graph G.
ogdf::ClusterGraphAttributes::m_width
ClusterArray< double > m_width
Cluster width.
Definition: ClusterGraphAttributes.h:58
ogdf::ClusterGraphAttributes::height
double & height(cluster c)
Returns the height of cluster c.
Definition: ClusterGraphAttributes.h:232
ogdf::GraphAttributes::width
const NodeArray< double > & width() const
Returns a reference to the node array m_width.
Definition: GraphAttributes.h:375
ogdf::ClusterGraphAttributes::fillBgColor
const Color & fillBgColor(cluster c) const
Returns the background color of fill patterns for cluster c.
Definition: ClusterGraphAttributes.h:331
ogdf::ClusterGraphAttributes::m_pClusterGraph
const ClusterGraph * m_pClusterGraph
Only points to existing graphs.
Definition: ClusterGraphAttributes.h:54
ogdf::ClusterGraphAttributes::fillBgColor
Color & fillBgColor(cluster c)
Returns the background color of fill patterns for cluster c.
Definition: ClusterGraphAttributes.h:340
ogdf::ClusterGraphAttributes::fillColor
const Color & fillColor(cluster c) const
Returns the fill color of cluster c.
Definition: ClusterGraphAttributes.h:313
ogdf::ClusterGraphAttributes::templateCluster
string & templateCluster(cluster c)
Returns the template of cluster c.
Definition: ClusterGraphAttributes.h:376
ogdf::ClusterGraphAttributes::m_stroke
ClusterArray< Stroke > m_stroke
Stroke (style of boundary)
Definition: ClusterGraphAttributes.h:61
ogdf::GraphAttributes::height
const NodeArray< double > & height() const
Returns a reference to the node array m_height.
Definition: GraphAttributes.h:411
ogdf::ClusterGraphAttributes::strokeWidth
float & strokeWidth(cluster c)
Returns the stroke width of cluster c.
Definition: ClusterGraphAttributes.h:286
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:62
ogdf::GraphAttributes::y
double y(node v) const
Returns the y-coordinate of node v.
Definition: GraphAttributes.h:265
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:52
ogdf::ClusterGraphAttributes::width
double & width(cluster c)
Returns the width of cluster c.
Definition: ClusterGraphAttributes.h:214
ogdf::ClusterGraphAttributes::y
double y(cluster c) const
Returns the y-position of cluster c's cage (lower left corner).
Definition: ClusterGraphAttributes.h:187
ogdf::ClusterGraphAttributes::m_height
ClusterArray< double > m_height
Cluster height.
Definition: ClusterGraphAttributes.h:59
ogdf::DRect
Rectangles with real coordinates.
Definition: geometry.h:798
ogdf::ClusterGraphAttributes::strokeType
const StrokeType & strokeType(cluster c) const
Returns the stroke type of cluster c.
Definition: ClusterGraphAttributes.h:241
ogdf::GraphAttributes::scale
virtual void scale(double sx, double sy, bool scaleNodes=true)
Scales the layout by (sx,sy).
ogdf::ClusterGraphAttributes::fillPattern
const FillPattern & fillPattern(cluster c) const
Returns the fill pattern of cluster c.
Definition: ClusterGraphAttributes.h:295
ogdf::ClusterGraphAttributes::clusterTemplate
static const long clusterTemplate
Corresponds to cluster attribute templateCluster(cluster).
Definition: ClusterGraphAttributes.h:84
ogdf::ClusterGraphAttributes::label
const string & label(cluster c) const
Returns the label of cluster c.
Definition: ClusterGraphAttributes.h:349
ogdf::ClusterGraphAttributes::m_label
ClusterArray< string > m_label
Cluster label.
Definition: ClusterGraphAttributes.h:60
ogdf::ClusterGraphAttributes::m_clusterTemplate
ClusterArray< string > m_clusterTemplate
Name of cluster template.
Definition: ClusterGraphAttributes.h:63
ogdf::GraphAttributes::flipVertical
virtual void flipVertical()
Flips the layout vertically within its bounding box.
Definition: GraphAttributes.h:919
ogdf::ClusterGraphAttributes::width
double width(cluster c) const
Returns the width of cluster c.
Definition: ClusterGraphAttributes.h:205
ogdf::graphics::init
void init()
Definition: graphics.h:450
ogdf::ClusterGraphAttributes::x
double x(cluster c) const
Returns the x-position of cluster c's cage (lower left corner).
Definition: ClusterGraphAttributes.h:169
ogdf::ClusterGraphAttributes::constClusterGraph
const ClusterGraph & constClusterGraph() const
Returns the associated cluster graph.
Definition: ClusterGraphAttributes.h:157
basic.h
Basic declarations, included by all source files.
ogdf::ClusterGraphAttributes::clusterLabel
static const long clusterLabel
Corresponds to cluster attribute label(cluster).
Definition: ClusterGraphAttributes.h:81
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::ClusterGraphAttributes::all
static const long all
Enables all available flags.
Definition: ClusterGraphAttributes.h:87
ogdf::ClusterGraphAttributes::templateCluster
const string & templateCluster(cluster c) const
Returns the template of cluster c.
Definition: ClusterGraphAttributes.h:367
ogdf::ClusterGraphAttributes::strokeWidth
const float & strokeWidth(cluster c) const
Returns the stroke width of cluster c.
Definition: ClusterGraphAttributes.h:277
ogdf::ClusterGraphAttributes::m_x
ClusterArray< double > m_x
X-position of lower left corner.
Definition: ClusterGraphAttributes.h:56
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::ClusterGraph::clusterOf
cluster clusterOf(node v) const
Returns the cluster to which a node belongs.
Definition: ClusterGraph.h:449
ogdf::GraphAttributes::strokeColor
const Color & strokeColor(node v) const
Returns the stroke color of node v.
Definition: GraphAttributes.h:465
ogdf::ClusterGraphAttributes::clusterOf
cluster clusterOf(node v)
Returns the parent cluster of node v.
Definition: ClusterGraphAttributes.h:435
ogdf::GraphAttributes::flipHorizontal
virtual void flipHorizontal()
Flips the layout horizontally within its bounding box.
Definition: GraphAttributes.h:933
ogdf::ClusterGraphAttributes::m_fill
ClusterArray< Fill > m_fill
Fill (style of interior)
Definition: ClusterGraphAttributes.h:62
ogdf::ClusterGraphAttributes::fillPattern
FillPattern & fillPattern(cluster c)
Returns the fill pattern of cluster c.
Definition: ClusterGraphAttributes.h:304
ogdf::FillPattern
FillPattern
Fill patterns.
Definition: graphics.h:86
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::ClusterGraphAttributes::clusterStyle
static const long clusterStyle
Corresponds to cluster attributes strokeColor(cluster), strokeType(cluster), strokeWidth(cluster),...
Definition: ClusterGraphAttributes.h:78
ogdf::ClusterGraphAttributes::x
double & x(cluster c)
Returns the x-position of cluster c's cage (lower left corner).
Definition: ClusterGraphAttributes.h:178
ogdf::ClusterGraphAttributes::fillColor
Color & fillColor(cluster c)
Returns the fill color of cluster c.
Definition: ClusterGraphAttributes.h:322
ogdf::ClusterGraphAttributes::strokeColor
Color & strokeColor(cluster c)
Returns the stroke color of cluster c.
Definition: ClusterGraphAttributes.h:268
ogdf::GraphAttributes::strokeType
StrokeType strokeType(node v) const
Returns the stroke type of node v.
Definition: GraphAttributes.h:447
ogdf::GraphAttributes::label
const string & label(node v) const
Returns the label of node v.
Definition: GraphAttributes.h:555
ogdf::GraphAttributes::strokeWidth
float strokeWidth(node v) const
Returns the stroke width of node v.
Definition: GraphAttributes.h:483