Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ClusterGraphAttributes.h
Go to the documentation of this file.
1 
35 #pragma once
36 
39 
40 
41 namespace ogdf {
42 
45 {
46  double m_x, m_y;
47  double m_w, m_h;
48 
49  string m_label;
50 
53 
55  : m_stroke(LayoutStandards::defaultClusterStroke()), m_fill(LayoutStandards::defaultClusterFill())
56  {
57  m_x = m_y = 0.0;
58  m_w = m_h = 0.0;
59  }
60 };
61 
62 
64 
68 {
70 
71 private:
74 
75 public:
76  // don't hide these inherited methods by overloading
77  using GraphAttributes::x;
78  using GraphAttributes::y;
81 
83 
87 
91 
96 
98  ClusterGraphAttributes() : GraphAttributes(), m_pClusterGraph(nullptr) { }
99 
101 
104  explicit ClusterGraphAttributes(ClusterGraph& cg, long initAttributes = 0);
105 
107 
109  virtual void init(ClusterGraph &cg, long initAttributes = 0);
110 
112  virtual void init(const Graph &, long) override {
113  OGDF_THROW(Exception); // We need a cluster graph for initialization
114  }
115 
117  virtual void initAtt(long initAttributes = 0) {
118  GraphAttributes::addAttributes(initAttributes);
119  }
120 
122  const ClusterGraph& constClusterGraph() const { return *m_pClusterGraph; }
123 
124 
126 
130 
132  double x(cluster c) const { return m_clusterInfo[c].m_x; }
133 
135  double& x(cluster c) { return m_clusterInfo[c].m_x; }
136 
138  double y(cluster c) const { return m_clusterInfo[c].m_y; }
139 
141  double& y(cluster c) { return m_clusterInfo[c].m_y; }
142 
144  double width(cluster c) const { return m_clusterInfo[c].m_w; }
145 
147  double& width(cluster c) { return m_clusterInfo[c].m_w; }
148 
150  double height(cluster c) const { return m_clusterInfo[c].m_h; }
151 
153  double& height(cluster c) { return m_clusterInfo[c].m_h; }
154 
157  return m_clusterInfo[c].m_stroke.m_type;
158  }
159 
162  m_clusterInfo[c].m_stroke.m_type = st;
163  }
164 
166  const Color &strokeColor(cluster c) const {
167  return m_clusterInfo[c].m_stroke.m_color;
168  }
169 
172  return m_clusterInfo[c].m_stroke.m_color;
173  }
174 
176  const float &strokeWidth(cluster c) const {
177  return m_clusterInfo[c].m_stroke.m_width;
178  }
179 
181  float &strokeWidth(cluster c) {
182  return m_clusterInfo[c].m_stroke.m_width;
183  }
184 
187  return m_clusterInfo[c].m_fill.m_pattern;
188  }
189 
192  m_clusterInfo[c].m_fill.m_pattern = fp;
193  }
194 
196  const Color &fillColor(cluster c) const {
197  return m_clusterInfo[c].m_fill.m_color;
198  }
199 
202  return m_clusterInfo[c].m_fill.m_color;
203  }
204 
206  const Color &fillBgColor(cluster c) const {
207  return m_clusterInfo[c].m_fill.m_bgColor;
208  }
209 
212  return m_clusterInfo[c].m_fill.m_bgColor;
213  }
214 
216  const string &label(cluster c) const {
217  return m_clusterInfo[c].m_label;
218  }
219 
221  string &label(cluster c) {
222  return m_clusterInfo[c].m_label;
223  }
224 
226  const string &templateCluster(cluster c) const { return m_clusterTemplate[c]; }
227 
229  string &templateCluster(cluster c) { return m_clusterTemplate[c]; }
230 
232  const ClusterInfo& clusterInfo(cluster c) const { return m_clusterInfo[c]; }
233 
235  ClusterInfo& clusterInfo(cluster c) { return m_clusterInfo[c]; }
236 
238 
242 
246 
248 
255  virtual void scale(double sx, double sy, bool scaleNodes = true) override;
256 
258 
262  virtual void translate(double dx, double dy) override;
263 
265 
269  virtual void flipVertical(const DRect &box) override;
270 
272 
276  virtual void flipHorizontal(const DRect &box) override;
277 
279 
283 
285  virtual DRect boundingBox() const override;
286 
288  void updateClusterPositions(double boundaryDist = 1.0);
289 
291  cluster clusterOf(node v) { return m_pClusterGraph->clusterOf(v); }
292 
294 
295 };
296 
297 
298 } // end namespace ogdf
Color & strokeColor(cluster c)
Returns the stroke color of cluster c.
const Color & fillColor(cluster c) const
Returns the fill color of cluster c.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Color & fillColor(cluster c)
Returns the fill color of cluster c.
ClusterGraphAttributes()
Constructs cluster graph attributes for no associated graph.
const Color & fillBgColor(cluster c) const
Returns the background color of fill patterns for cluster c.
Stores information associated with a cluster.
double & width(cluster c)
Returns the width of cluster c.
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
const Color & fillColor(node v) const
Returns the fill color of node v.
FillPattern fillPattern(node v) const
Returns the fill pattern of node v.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
void addAttributes(long attr)
Enables attributes specified by attr and allocates required memory.
void setStrokeType(cluster c, StrokeType st)
Sets the stroke type of cluster c to st.
cluster clusterOf(node v) const
Returns the cluster to which a node belongs.
Definition: ClusterGraph.h:412
#define OGDF_THROW(CLASS)
Replacement for throw.
Definition: exceptions.h:60
const Color & strokeColor(node v) const
Returns the stroke color of node v.
Rectangles with real coordinates.
Definition: geometry.h:515
float & strokeWidth(cluster c)
Returns the stroke width of cluster c.
virtual void scale(double sx, double sy, bool scaleNodes=true)
Scales the layout by (sx,sy).
virtual void flipVertical()
Flips the layout vertically within its bounding box.
FillPattern fillPattern(cluster c) const
Returns the fill pattern of cluster c.
StrokeType strokeType(cluster c) const
Returns the stroke type of cluster c.
ClusterInfo & clusterInfo(cluster c)
Returns the cluster info structure of cluster c.
FillPattern
Fill patterns.
Definition: graphics.h:88
string & label(cluster c)
Returns the label of cluster c.
Base class of all ogdf exceptions.
Definition: exceptions.h:187
const string & templateCluster(cluster c) const
Returns the template of cluster c.
double m_y
position of lower left corner
cluster clusterOf(node v)
Returns the parent cluster of node v.
Properties of strokes.
Definition: graphics.h:390
double width(cluster c) const
Returns the width of cluster c.
T m_x
The default value for array elements.
Definition: ClusterArray.h:111
Representation of clustered graphs.
Definition: ClusterGraph.h:291
double y(node v) const
Returns the y-coordinate of node v.
string m_label
cluster label
virtual void flipHorizontal()
Flips the layout horizontally within its bounding box.
const string & label(node v) const
Returns the label of node v.
double height(cluster c) const
Returns the height of cluster c.
Colors represented as RGBA values.
Definition: graphics.h:161
Stores additional attributes of a graph (like layout information).
virtual void init(const Graph &, long) override
Forbidden initialization, use init(ClusterGraph &cg, long initAttributes) instead! ...
ClusterArray< ClusterInfo > m_clusterInfo
cluster attributes
double x(cluster c) const
Returns the x-position of cluster c&#39;s cage (lower left corner).
Standard values for graphical attributes and layouts.
Stores additional attributes of a clustered graph (like layout information).
Dynamic arrays indexed with clusters.
Definition: ClusterArray.h:110
string & templateCluster(cluster c)
Returns the template of cluster c.
double x(node v) const
Returns the x-coordinate of node v.
Class for the representation of nodes.
Definition: Graph_d.h:167
double & x(cluster c)
Returns the x-position of cluster c&#39;s cage (lower left corner).
const ClusterGraph & constClusterGraph() const
Returns the associated cluster graph.
double & height(cluster c)
Returns the height of cluster c.
const Color & fillBgColor(node v) const
Returns the background color of fill patterns for node v.
Fill m_fill
fill (style of interior)
const float & strokeWidth(cluster c) const
Returns the stroke width of cluster c.
StrokeType strokeType(node v) const
Returns the stroke type of node v.
virtual void initAtt(long initAttributes=0)
Initializes the attributes according to initAttributes.
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
double & y(cluster c)
Returns the y-position of cluster c&#39;s cage (lower left corner).
void setFillPattern(cluster c, FillPattern fp)
Sets the fill pattern of cluster c to fp.
ClusterArray< string > m_clusterTemplate
Name of cluster template.
const NodeArray< double > & height() const
Returns a reference to the node array m_height.
StrokeType
Line types of strokes.
Definition: graphics.h:43
double y(cluster c) const
Returns the y-position of cluster c&#39;s cage (lower left corner).
Declaration and implementation of ClusterArray class.
The namespace for all OGDF objects.
float strokeWidth(node v) const
Returns the stroke width of node v.
Stroke m_stroke
stroke (style of boundary)
const ClusterGraph * m_pClusterGraph
Only points to existing graphs.
Properties of fills.
Definition: graphics.h:406
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.
const ClusterInfo & clusterInfo(cluster c) const
Returns the cluster info structure of cluster c.
Color & fillBgColor(cluster c)
Returns the background color of fill patterns for cluster c.
const NodeArray< double > & width() const
Returns a reference to the node array m_width.