]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/flag/IFlagType.java
Added mechanism to diagram IFlagType to prevent graph modifications
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / flag / IFlagType.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.flag;
13
14 import java.awt.Shape;
15 import java.awt.geom.Rectangle2D;
16
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.g2d.canvas.ICanvasContext;
20 import org.simantics.g2d.elementclass.FlagClass;
21 import org.simantics.g2d.utils.Alignment;
22
23 /**
24  * @author Tuukka Lehtonen
25  */
26 public interface IFlagType {
27
28     /**
29      * @author Tuukka Lehtonen
30      * @see FlagInfoImpl
31      */
32     public interface FlagInfo {
33         Shape getShape();
34         String[] getText();
35         Rectangle2D getTextArea();
36         FlagClass.Type getType();
37         Alignment getHorizontalAlignment();
38         Alignment getVerticalAlignment();
39     }
40
41     /**
42      * Reads and calculates information about this flags graphical
43      * representation.
44      * 
45      * @param graph database read access
46      * @return all info gathered up about the flag
47      * @throws DatabaseException
48      * @Deprecated implement {@link #getInfo(ReadGraph, ICanvasContext)} instead
49      */
50     default FlagInfo getInfo(ReadGraph graph) throws DatabaseException {
51         throw new UnsupportedOperationException();
52     }
53
54     /**
55      * Reads and calculates information about this flags graphical
56      * representation.
57      * 
58      * @param graph database read access
59      * @param context the canvas context with which the info is loaded 
60      * @return all info gathered up about the flag
61      * @throws DatabaseException
62      */
63     default FlagInfo getInfo(ReadGraph graph, ICanvasContext context) throws DatabaseException {
64         return getInfo(graph);
65     }
66
67 }