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.g2d.image.impl;
14 import java.awt.Shape;
15 import java.awt.geom.Rectangle2D;
16 import java.awt.image.BufferedImage;
17 import java.util.EnumSet;
19 import org.simantics.g2d.image.Image;
20 import org.simantics.g2d.image.ImageUtils;
21 import org.simantics.scenegraph.Node;
22 import org.simantics.scenegraph.g2d.G2DParentNode;
23 import org.simantics.scenegraph.g2d.nodes.ImageNode;
26 * Adapts {@link BufferedImage} to {@link Image}
28 * @See {@link ImageUtils}
29 * @author Toni Kalajainen
31 public class AWTImage extends AbstractImage implements Image {
33 static EnumSet<Feature> feats = EnumSet.noneOf(Feature.class);
39 public AWTImage(BufferedImage bi, float alpha) {
43 rect = new Rectangle2D.Double(bi.getMinX(),bi.getMinY(),bi.getWidth(), bi.getHeight());
46 public AWTImage(BufferedImage bi) {
51 public Rectangle2D getBounds() {
56 public Shape getOutline() {
61 public Node init(G2DParentNode parent) {
62 ImageNode node = parent.getOrCreateNode("image", ImageNode.class);
70 public EnumSet<Feature> getFeatures() {