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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.diagram.flag;
\r
14 import java.awt.Shape;
\r
15 import java.awt.geom.Rectangle2D;
\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
22 * A builder for {@link FlagInfoImpl} instances.
\r
24 * @author Tuukka Lehtonen
\r
26 public class FlagInfoBuilder {
\r
28 private static final String[] NO_TEXT = {};
\r
30 private Shape shape;
\r
31 private String[] text = NO_TEXT;
\r
33 private Rectangle2D textArea;
\r
34 private Alignment horizontalAlignment = Alignment.LEADING;
\r
35 private Alignment verticalAlignment = Alignment.CENTER;
\r
37 public static FlagInfoBuilder fill(Type type) {
\r
38 return new FlagInfoBuilder().type(type);
\r
41 public FlagInfoBuilder() {
\r
44 public FlagInfo create() {
\r
45 return new FlagInfoImpl(shape, text, type, textArea, horizontalAlignment, verticalAlignment);
\r
48 public Shape shape() {
\r
52 public String[] text() {
\r
56 public Type type() {
\r
60 public Rectangle2D textArea() {
\r
64 public Alignment horizontalAlignment() {
\r
65 return horizontalAlignment;
\r
68 public Alignment verticalAlignment() {
\r
69 return verticalAlignment;
\r
72 public FlagInfoBuilder shape(Shape shape) {
\r
77 public FlagInfoBuilder text(String[] text) {
\r
82 public FlagInfoBuilder type(Type type) {
\r
87 public FlagInfoBuilder textArea(Rectangle2D textArea) {
\r
88 this.textArea = textArea;
\r
92 public FlagInfoBuilder horizontalAlignment(Alignment align) {
\r
93 this.horizontalAlignment = align;
\r
97 public FlagInfoBuilder verticalAlignment(Alignment align) {
\r
98 this.verticalAlignment = align;
\r