1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.flag;
15 import java.awt.Shape;
16 import java.awt.geom.Rectangle2D;
18 import org.simantics.diagram.flag.IFlagType.FlagInfo;
19 import org.simantics.g2d.elementclass.FlagClass.Type;
20 import org.simantics.g2d.utils.Alignment;
23 * A builder for {@link FlagInfoImpl} instances.
25 * @author Tuukka Lehtonen
27 public class FlagInfoBuilder {
29 private static final String[] NO_TEXT = {};
32 private String[] text = NO_TEXT;
34 private Rectangle2D textArea;
35 private Alignment horizontalAlignment = Alignment.LEADING;
36 private Alignment verticalAlignment = Alignment.CENTER;
39 public static FlagInfoBuilder fill(Type type) {
40 return new FlagInfoBuilder().type(type);
43 public FlagInfoBuilder() {
46 public FlagInfo create() {
47 return new FlagInfoImpl(shape, text, type, textArea, horizontalAlignment, verticalAlignment, font);
50 public Shape shape() {
54 public String[] text() {
66 public Rectangle2D textArea() {
70 public Alignment horizontalAlignment() {
71 return horizontalAlignment;
74 public Alignment verticalAlignment() {
75 return verticalAlignment;
78 public FlagInfoBuilder shape(Shape shape) {
83 public FlagInfoBuilder text(String[] text) {
88 public FlagInfoBuilder font(Font font) {
93 public FlagInfoBuilder type(Type type) {
98 public FlagInfoBuilder textArea(Rectangle2D textArea) {
99 this.textArea = textArea;
103 public FlagInfoBuilder horizontalAlignment(Alignment align) {
104 this.horizontalAlignment = align;
108 public FlagInfoBuilder verticalAlignment(Alignment align) {
109 this.verticalAlignment = align;