]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/image/Image.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / image / Image.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.g2d.image;\r
13 \r
14  import java.awt.Shape;\r
15 import java.awt.geom.Rectangle2D;\r
16 import java.util.EnumSet;\r
17 \r
18 import org.simantics.scenegraph.Node;\r
19 import org.simantics.scenegraph.g2d.G2DParentNode;\r
20 \r
21 /**\r
22  * Interface for paintable graphics - either vector or raster.\r
23  * \r
24  * \r
25  * @See {@link ImageUtils} Image handling utilities\r
26  * @author Toni Kalajainen\r
27  */\r
28 public interface Image {\r
29         \r
30         /**\r
31          * Paint the image to a graphics 2d context.\r
32          * \r
33          * @param g graphics context\r
34          */\r
35         Node init(G2DParentNode parent);\r
36     \r
37         /**\r
38          * Get rectangle that contains the whole image.\r
39          * \r
40          * @return bounds\r
41          */\r
42         Rectangle2D getBounds();\r
43         \r
44         /**\r
45          * Get an outline of the image.\r
46          * \r
47          * @return boundary of the image\r
48          */\r
49         Shape getOutline();\r
50         \r
51         public enum Feature {\r
52                 Vector,         // Vector image, unlimited quality\r
53                 Volatile        // The content of the image may change\r
54         }\r
55         \r
56         EnumSet<Feature> VECTOR = EnumSet.of(Feature.Vector);\r
57         EnumSet<Feature> VOLATILE = EnumSet.of(Feature.Volatile);\r
58         EnumSet<Feature> VOLATILE_VECTOR = EnumSet.of(Feature.Vector, Feature.Volatile);\r
59         \r
60         public EnumSet<Feature> getFeatures();\r
61         \r
62         public interface ImageListener {\r
63                 /**\r
64                  * Notification signaling that the content (size, of content) \r
65                  * of an image has changed.\r
66                  * This notification can occur only to images with Volatile feature. \r
67                  * \r
68                  * @param image\r
69                  */\r
70                 void onContentChangedNotification(Image image);\r
71         }\r
72         \r
73         /**\r
74          * Add image listener.  \r
75          * @param listener\r
76          */\r
77         void addImageListener(ImageListener listener);\r
78         \r
79         /**\r
80          * Remove image listener\r
81          * @param listener\r
82          */\r
83         void removeImageListener(ImageListener listener);\r
84         \r
85 }\r