]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/image/ImageUtils.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / image / ImageUtils.java
index 1f1c21508e10ae06ebb09c87057988c1ed0b9334..240c31ea3fa6ec27b6a049cb56aee2900beac1f3 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g2d.image;\r
-\r
-import java.awt.GraphicsConfiguration;\r
-\r
-import org.simantics.g2d.image.Image.Feature;\r
-import org.simantics.g2d.image.impl.AWTImage;\r
-import org.simantics.g2d.image.impl.ImageProxy;\r
-import org.simantics.g2d.image.impl.MipMapBufferedImage;\r
-import org.simantics.g2d.image.impl.MipMapVRamBufferedImage;\r
-import org.simantics.g2d.image.impl.Shadow;\r
-import org.simantics.g2d.image.impl.VRamBufferedImage;\r
-import org.simantics.g2d.image.impl.Shadow.ShadowParameters;\r
-\r
-/**\r
- * Image utilities.\r
- * \r
- * @See {@link ProviderUtils}\r
- * @See {@link Image}\r
- * @author Toni Kalajainen\r
- */\r
-public class ImageUtils {\r
-\r
-    /**\r
-     * Adapt AWT {@link java.awt.image.BufferedImage} to {@link Image}\r
-     * @param awtImage\r
-     * @return\r
-     */\r
-    public static Image adaptAWT(java.awt.image.BufferedImage awtImage)\r
-    {\r
-        return new AWTImage(awtImage);\r
-    }\r
-\r
-    /**\r
-     * Creates a memory backed buffer for an Image.\r
-     * Use this with vector images and shadows.\r
-     * \r
-     * @param source\r
-     * @return video-ram optimized version of the symbol\r
-     */\r
-    public static Image createBuffer(Image source)\r
-    {\r
-        return new MipMapBufferedImage(source);\r
-    }\r
-\r
-    /**\r
-     * Creates a proxy of the source image. Proxy has a strong reference to the\r
-     * source but weak from source to proxy and thus a proxy prevents garbage\r
-     * collection of the source image.\r
-     * \r
-     * Example:\r
-     *  <pre>\r
-     *   Image i = ProviderUtils.at("https://www.simantics.org/simantics/simantics/logo.jpg");\r
-     *   Image p1 = ImageUtils.proxy(i);\r
-     *   Image p2 = ImageUtils.proxy(i);\r
-     *   i = null;\r
-     * \r
-     *   deliver p1 and p2 to user interface components.\r
-     * \r
-     *   i stays in memory until p1 and p2 are garbage collected.\r
-     *  </pre>\r
-     * \r
-     * @param source\r
-     * @return\r
-     */\r
-    public static Image createProxy(Image source)\r
-    {\r
-        return new ImageProxy(source);\r
-    }\r
-\r
-    /**\r
-     * Creates an instance of Image that reflects to the shadow of the source Image.\r
-     * <p>\r
-     * Shadow is created every time the image is painted. Usage of memory buffer\r
-     * is recommended (see createBuffer() ).\r
-     * \r
-     * @param source\r
-     * @param shadow\r
-     * @return\r
-     */\r
-    public static Image createShadow(Image source, ShadowParameters shadow)\r
-    {\r
-        return new Shadow(source, shadow);\r
-    }\r
-\r
-    public static Image createShadow(Image source, ShadowParameters shadow, int width, int height)\r
-    {\r
-        return new Shadow(source, shadow, width, height);\r
-    }\r
-\r
-    /**\r
-     * Raster symbol to video memory (lazy).\r
-     * \r
-     * @param ps\r
-     * @param gc Graphics configuration\r
-     * @return video-ram optimized version of the symbol\r
-     */\r
-    public static Image createVideoMemoryBuffer(Image ps, GraphicsConfiguration gc)\r
-    {\r
-        if (gc==null) throw new IllegalArgumentException("null arg");\r
-        if (ps instanceof VRamBufferedImage)\r
-        {\r
-            VRamBufferedImage p = (VRamBufferedImage) ps;\r
-            if (p.getGraphicsConfiguration()!=gc) ps = p.getSource(); else return ps;\r
-        }\r
-        if (ps instanceof MipMapVRamBufferedImage)\r
-        {\r
-            MipMapVRamBufferedImage p = (MipMapVRamBufferedImage) ps;\r
-            if (p.getGraphicsConfiguration()!=gc) ps = p.getSource(); else return ps;\r
-        }\r
-        if (ps.getFeatures().contains(Feature.Vector))\r
-            return new MipMapVRamBufferedImage(ps, gc);\r
-        else\r
-            return new VRamBufferedImage(ps, gc);\r
-    }\r
-\r
-\r
-\r
-\r
-}\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g2d.image;
+
+import java.awt.GraphicsConfiguration;
+
+import org.simantics.g2d.image.Image.Feature;
+import org.simantics.g2d.image.impl.AWTImage;
+import org.simantics.g2d.image.impl.ImageProxy;
+import org.simantics.g2d.image.impl.MipMapBufferedImage;
+import org.simantics.g2d.image.impl.MipMapVRamBufferedImage;
+import org.simantics.g2d.image.impl.Shadow;
+import org.simantics.g2d.image.impl.VRamBufferedImage;
+import org.simantics.g2d.image.impl.Shadow.ShadowParameters;
+
+/**
+ * Image utilities.
+ * 
+ * @See {@link ProviderUtils}
+ * @See {@link Image}
+ * @author Toni Kalajainen
+ */
+public class ImageUtils {
+
+    /**
+     * Adapt AWT {@link java.awt.image.BufferedImage} to {@link Image}
+     * @param awtImage
+     * @return
+     */
+    public static Image adaptAWT(java.awt.image.BufferedImage awtImage)
+    {
+        return new AWTImage(awtImage);
+    }
+
+    /**
+     * Creates a memory backed buffer for an Image.
+     * Use this with vector images and shadows.
+     * 
+     * @param source
+     * @return video-ram optimized version of the symbol
+     */
+    public static Image createBuffer(Image source)
+    {
+        return new MipMapBufferedImage(source);
+    }
+
+    /**
+     * Creates a proxy of the source image. Proxy has a strong reference to the
+     * source but weak from source to proxy and thus a proxy prevents garbage
+     * collection of the source image.
+     * 
+     * Example:
+     *  <pre>
+     *   Image i = ProviderUtils.at("https://www.simantics.org/simantics/simantics/logo.jpg");
+     *   Image p1 = ImageUtils.proxy(i);
+     *   Image p2 = ImageUtils.proxy(i);
+     *   i = null;
+     * 
+     *   deliver p1 and p2 to user interface components.
+     * 
+     *   i stays in memory until p1 and p2 are garbage collected.
+     *  </pre>
+     * 
+     * @param source
+     * @return
+     */
+    public static Image createProxy(Image source)
+    {
+        return new ImageProxy(source);
+    }
+
+    /**
+     * Creates an instance of Image that reflects to the shadow of the source Image.
+     * <p>
+     * Shadow is created every time the image is painted. Usage of memory buffer
+     * is recommended (see createBuffer() ).
+     * 
+     * @param source
+     * @param shadow
+     * @return
+     */
+    public static Image createShadow(Image source, ShadowParameters shadow)
+    {
+        return new Shadow(source, shadow);
+    }
+
+    public static Image createShadow(Image source, ShadowParameters shadow, int width, int height)
+    {
+        return new Shadow(source, shadow, width, height);
+    }
+
+    /**
+     * Raster symbol to video memory (lazy).
+     * 
+     * @param ps
+     * @param gc Graphics configuration
+     * @return video-ram optimized version of the symbol
+     */
+    public static Image createVideoMemoryBuffer(Image ps, GraphicsConfiguration gc)
+    {
+        if (gc==null) throw new IllegalArgumentException("null arg");
+        if (ps instanceof VRamBufferedImage)
+        {
+            VRamBufferedImage p = (VRamBufferedImage) ps;
+            if (p.getGraphicsConfiguration()!=gc) ps = p.getSource(); else return ps;
+        }
+        if (ps instanceof MipMapVRamBufferedImage)
+        {
+            MipMapVRamBufferedImage p = (MipMapVRamBufferedImage) ps;
+            if (p.getGraphicsConfiguration()!=gc) ps = p.getSource(); else return ps;
+        }
+        if (ps.getFeatures().contains(Feature.Vector))
+            return new MipMapVRamBufferedImage(ps, gc);
+        else
+            return new VRamBufferedImage(ps, gc);
+    }
+
+
+
+
+}
+