]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graphviz/src/org/simantics/graphviz/Cluster.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graphviz / src / org / simantics / graphviz / Cluster.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.graphviz;\r
13 \r
14 /**\r
15  * A special kind of subgraph that is laid out separately.\r
16  * A rectangle is drawn around the cluster and it is\r
17  * labeled, if the cluster is given a label.\r
18  * \r
19  * @author Hannu Niemistö\r
20  */\r
21 public class Cluster extends Subgraph {\r
22 \r
23     public Cluster(IGraph parent) {\r
24         super(parent);\r
25         id = "cluster_" + id;\r
26     }\r
27 \r
28     public Cluster(IGraph parent, String label) {\r
29         super(parent);\r
30         id = "cluster_" + id;\r
31         setLabel(label);\r
32     }\r
33 \r
34     /**\r
35      * Text label attached to objects. \r
36      */\r
37     public void setLabel(String label) {\r
38         set("label", label);        \r
39     }\r
40     \r
41     /**\r
42      * <p>\r
43      * Basic drawing color for graphics, not text. For the latter, use the\r
44      * fontcolor attribute. For edges, the value can either be a single color or\r
45      * a colorList. In the latter case, the edge is drawn using parallel splines\r
46      * or lines, one for each color in the list, in the order given. The head\r
47      * arrow, if any, is drawn using the first color in the list, and the tail\r
48      * arrow, if any, the second color. This supports the common case of drawing\r
49      * opposing edges, but using parallel splines instead of separately routed\r
50      * multiedges.\r
51      * </p>\r
52      * <p>Supports arbitrary RGB(A) colors in format #xxxxxx, where\r
53      * each x is a hex digit. Supports also color names in x11 color chart.</p>\r
54      */\r
55     public void setColor(String color) {\r
56         set("color", color);\r
57     }\r
58     \r
59     /**\r
60      * Color used for text.\r
61      */\r
62     public void setFontColor(String color) {\r
63         set("fontcolor", color);\r
64     }\r
65     \r
66     /**\r
67      * Color used to fill the background of a node or cluster assuming style=filled. If fillcolor is not defined, color is used. (For clusters, if color is not defined, bgcolor is used.) If this is not defined, the default is used, except for shape=point or when the output format is MIF, which use black by default. Note that a cluster inherits the root graph's attributes if defined. Thus, if the root graph has defined a fillcolor, this will override a color or bgcolor attribute set for the cluster.\r
68      */\r
69     public void setFillColor(String color) {\r
70         set("fillcolor", color);\r
71     }\r
72     \r
73     /**\r
74      * Set style for node or edge. For cluster subgraph, if "filled", the cluster box's background is filled.\r
75      */\r
76     public void setStyle(String style) {\r
77         set("style", style);\r
78     }\r
79 \r
80 }\r