]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/flag/FlagInfoBuilder.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / flag / FlagInfoBuilder.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.diagram.flag;\r
13 \r
14 import java.awt.Shape;\r
15 import java.awt.geom.Rectangle2D;\r
16 \r
17 import org.simantics.diagram.flag.IFlagType.FlagInfo;\r
18 import org.simantics.g2d.elementclass.FlagClass.Type;\r
19 import org.simantics.g2d.utils.Alignment;\r
20 \r
21 /**\r
22  * A builder for {@link FlagInfoImpl} instances.\r
23  * \r
24  * @author Tuukka Lehtonen\r
25  */\r
26 public class FlagInfoBuilder {\r
27 \r
28     private static final String[] NO_TEXT = {};\r
29 \r
30     private Shape       shape;\r
31     private String[]    text = NO_TEXT;\r
32     private Type        type;\r
33     private Rectangle2D textArea;\r
34     private Alignment   horizontalAlignment = Alignment.LEADING;\r
35     private Alignment   verticalAlignment = Alignment.CENTER;\r
36 \r
37     public static FlagInfoBuilder fill(Type type) {\r
38         return new FlagInfoBuilder().type(type);\r
39     }\r
40 \r
41     public FlagInfoBuilder() {\r
42     }\r
43 \r
44     public FlagInfo create() {\r
45         return new FlagInfoImpl(shape, text, type, textArea, horizontalAlignment, verticalAlignment);\r
46     }\r
47 \r
48     public Shape shape() {\r
49         return shape;\r
50     }\r
51 \r
52     public String[] text() {\r
53         return text;\r
54     }\r
55 \r
56     public Type type() {\r
57         return type;\r
58     }\r
59 \r
60     public Rectangle2D textArea() {\r
61         return textArea;\r
62     }\r
63 \r
64     public Alignment horizontalAlignment() {\r
65         return horizontalAlignment;\r
66     }\r
67 \r
68     public Alignment verticalAlignment() {\r
69         return verticalAlignment;\r
70     }\r
71 \r
72     public FlagInfoBuilder shape(Shape shape) {\r
73         this.shape = shape;\r
74         return this;\r
75     }\r
76 \r
77     public FlagInfoBuilder text(String[] text) {\r
78         this.text = text;\r
79         return this;\r
80     }\r
81 \r
82     public FlagInfoBuilder type(Type type) {\r
83         this.type = type;\r
84         return this;\r
85     }\r
86 \r
87     public FlagInfoBuilder textArea(Rectangle2D textArea) {\r
88         this.textArea = textArea;\r
89         return this;\r
90     }\r
91 \r
92     public FlagInfoBuilder horizontalAlignment(Alignment align) {\r
93         this.horizontalAlignment = align;\r
94         return this;\r
95     }\r
96 \r
97     public FlagInfoBuilder verticalAlignment(Alignment align) {\r
98         this.verticalAlignment = align;\r
99         return this;\r
100     }\r
101 \r
102 }\r