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