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;
14 import java.awt.Shape;
15 import java.awt.geom.Rectangle2D;
17 import org.simantics.diagram.flag.IFlagType.FlagInfo;
18 import org.simantics.g2d.elementclass.FlagClass.Type;
19 import org.simantics.g2d.utils.Alignment;
22 * A builder for {@link FlagInfoImpl} instances.
24 * @author Tuukka Lehtonen
26 public class FlagInfoBuilder {
28 private static final String[] NO_TEXT = {};
31 private String[] text = NO_TEXT;
33 private Rectangle2D textArea;
34 private Alignment horizontalAlignment = Alignment.LEADING;
35 private Alignment verticalAlignment = Alignment.CENTER;
37 public static FlagInfoBuilder fill(Type type) {
38 return new FlagInfoBuilder().type(type);
41 public FlagInfoBuilder() {
44 public FlagInfo create() {
45 return new FlagInfoImpl(shape, text, type, textArea, horizontalAlignment, verticalAlignment);
48 public Shape shape() {
52 public String[] text() {
60 public Rectangle2D textArea() {
64 public Alignment horizontalAlignment() {
65 return horizontalAlignment;
68 public Alignment verticalAlignment() {
69 return verticalAlignment;
72 public FlagInfoBuilder shape(Shape shape) {
77 public FlagInfoBuilder text(String[] text) {
82 public FlagInfoBuilder type(Type type) {
87 public FlagInfoBuilder textArea(Rectangle2D textArea) {
88 this.textArea = textArea;
92 public FlagInfoBuilder horizontalAlignment(Alignment align) {
93 this.horizontalAlignment = align;
97 public FlagInfoBuilder verticalAlignment(Alignment align) {
98 this.verticalAlignment = align;