skin: load nine-patch image throught imageRegistry 57/11057/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Wed, 16 Oct 2013 09:11:16 +0000 (18:11 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Thu, 17 Oct 2013 03:52:51 +0000 (12:52 +0900)
Change-Id: Ieaf2046efa8cd52c163a2c2d18cb7dd7d4c084fb
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/GeneralKeyWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java
tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java

index a1e4bef3bd3f62a49a64751b2ba10251ce34c5a6..0af8d5deb35e960341af6ebb1c6ad84412d2947c 100755 (executable)
@@ -205,6 +205,7 @@ public class EmulatorSkin {
                this.currentState = new EmulatorSkinState();
 
                setColorVM(); /* generate a identity color */
+
                this.keyWindowKeeper = new KeyWindowKeeper(this);
        }
 
@@ -231,6 +232,8 @@ public class EmulatorSkin {
        }
 
        public long initLayout() {
+               logger.info("initialize the skin layout");
+
                imageRegistry = ImageRegistry.getInstance();
 
                /* set emulator states */
@@ -249,8 +252,6 @@ public class EmulatorSkin {
                isOnKbd = false;
                popupMenu = new PopupMenu(config, this);
 
-               getKeyWindowKeeper().determineLayout();
-
                /* build a skin layout */
                if (skinInfo.isGeneralPurposeSkin() == false) {
                        skinComposer = new ProfileSpecificSkinComposer(config, this);
@@ -406,7 +407,7 @@ public class EmulatorSkin {
 
                                        /* close the Key Window */
                                        if (getKeyWindowKeeper() != null) {
-                                               getKeyWindowKeeper().closeKeyWindow();
+                                               getKeyWindowKeeper().dispose();
                                        }
 
                                        /* dispose the images */
index fb784f4ca2030d83013b1a91eb10ac3046dde2e7..baf44b9722bb769b379022ef0daf6c99dad0a281 100644 (file)
@@ -61,7 +61,6 @@ import org.tizen.emulator.skin.layout.SkinPatches;
 import org.tizen.emulator.skin.util.SwtUtil;
 
 public class GeneralKeyWindow extends SkinWindow {
-       private static final String PATCH_IMAGES_PATH = "images/key-window/";
        private static final int SHELL_MARGIN_BOTTOM = 3;
        private static final int PAIRTAG_CIRCLE_SIZE = 8;
        private static final int PAIRTAG_MARGIN_BOTTOM = 6;
@@ -95,7 +94,8 @@ public class GeneralKeyWindow extends SkinWindow {
        private boolean isGrabbedShell;
        private Point grabPosition;
 
-       public GeneralKeyWindow(EmulatorSkin skin, List<KeyMapType> keyMapList) {
+       public GeneralKeyWindow(EmulatorSkin skin,
+                       GeneralKeyWindowImageRegistry imageRegstry, List<KeyMapType> keyMapList) {
                super(skin.getShell(), SWT.RIGHT | SWT.CENTER);
 
                this.skin = skin;
@@ -103,8 +103,24 @@ public class GeneralKeyWindow extends SkinWindow {
                this.shell = new Shell(parent.getDisplay() /* for Mac & Always on Top */,
                                SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL | SWT.NO_FOCUS);
 
-               this.imageRegistry = new GeneralKeyWindowImageRegistry(shell.getDisplay());
-               this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
+               this.imageRegistry = imageRegstry;
+               this.frameMaker = new SkinPatches(
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_LT),
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_T),
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_RT),
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_L),
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_R),
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_LB),
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_B),
+                               imageRegistry.getKeyWindowImage(
+                                               GeneralKeyWindowImageName.KEYWINDOW_PATCH_RB));
 
                this.keyMapList = keyMapList; //TODO: null
                this.grabPosition = new Point(0, 0);
@@ -504,8 +520,5 @@ public class GeneralKeyWindow extends SkinWindow {
                }
 
                colorFrame.dispose();
-
-               frameMaker.freePatches();
-               imageRegistry.dispose();
        }
 }
index d9fdf91e139f6dafee47a23e8c2a5427936e3e59..7aef8b912166fe7f96cb58a9bf5c209bbe035742 100644 (file)
@@ -47,6 +47,15 @@ public class GeneralKeyWindowImageRegistry {
                        GeneralKeyWindowImageRegistry.class).getLogger();
 
        public enum GeneralKeyWindowImageName {
+               KEYWINDOW_PATCH_LT("LT.png"),
+               KEYWINDOW_PATCH_T("T.png"),
+               KEYWINDOW_PATCH_RT("RT.png"),
+               KEYWINDOW_PATCH_L("L.png"),
+               KEYWINDOW_PATCH_R("R.png"),
+               KEYWINDOW_PATCH_LB("LB.png"),
+               KEYWINDOW_PATCH_B("B.png"),
+               KEYWINDOW_PATCH_RB("RB.png"),
+
                KEYBUTTON_NORMAL("keybutton_nml.png"),
                KEYBUTTON_HOVER("keybutton_hover.png"),
                KEYBUTTON_PUSHED("keybutton_pushed.png"),
@@ -113,6 +122,8 @@ public class GeneralKeyWindowImageRegistry {
        }
 
        public void dispose() {
+               logger.info("dispose");
+
                if (null != keyWindowImageMap) {
                        Image image = null;
 
index df77af4888dd7eb36a4053203222d829855fafc7..158ce6ccb5b954cefed05c695ce698e58801f423 100644 (file)
@@ -47,6 +47,15 @@ public class GeneralSkinImageRegistry {
                        GeneralSkinImageRegistry.class).getLogger();
 
        public enum GeneralSkinImageName {
+               SKIN_PATCH_LT("LT.png"),
+               SKIN_PATCH_T("T.png"),
+               SKIN_PATCH_RT("RT.png"),
+               SKIN_PATCH_L("L.png"),
+               SKIN_PATCH_R("R.png"),
+               SKIN_PATCH_LB("LB.png"),
+               SKIN_PATCH_B("B.png"),
+               SKIN_PATCH_RB("RB.png"),
+
                TOGGLE_BUTTON_NORMAL("arrow_nml.png"),
                TOGGLE_BUTTON_HOVER("arrow_hover.png"),
                TOGGLE_BUTTON_PUSHED("arrow_pushed.png");
@@ -104,6 +113,8 @@ public class GeneralSkinImageRegistry {
        }
 
        public void dispose() {
+               logger.info("dispose");
+
                if (null != skinImageMap) {
                        Image image = null;
 
index 35e3e57449ef8b4dda7cbf6978cefbb7b339d56f..84e81ac97a25a343ae86e1a65edb79e08cb3a83b 100644 (file)
@@ -119,6 +119,8 @@ public class ProfileSkinImageRegistry {
        }
 
        public void dispose() {
+               logger.info("dispose");
+
                if (null != skinImageMap) {
                        Image image = null;
 
index fa68254f785a8ee7c0c32fe096e5bf14c8af258c..adcf4d96a658dbed011941279fdb163aa2d71e7a 100644 (file)
@@ -106,6 +106,8 @@ public class SpecialKeyWindowImageRegistry {
        }
 
        public void dispose() {
+               logger.info("dispose");
+
                if (null != keyWindowImageMap) {
                        Image image = null;
 
index 5eac5fa24198d6f4674cf4d6b76c9a6d13152108..73c6e6b6fb1ee4266fc421f780a386b63c2f7c40 100644 (file)
@@ -63,7 +63,6 @@ import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
 
 public class GeneralPurposeSkinComposer implements ISkinComposer {
-       private static final String PATCH_IMAGES_PATH = "images/emul-window/";
        private static final int PAIR_TAG_POSITION_X = 26;
        private static final int PAIR_TAG_POSITION_Y = 13;
 
@@ -101,7 +100,16 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                this.imageRegistry =
                                new GeneralSkinImageRegistry(shell.getDisplay());
 
-               this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
+               this.frameMaker = new SkinPatches(
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_LT),
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_T),
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_RT),
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_L),
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_R),
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_LB),
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_B),
+                               imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_RB));
+
                this.backgroundColor = new Color(shell.getDisplay(), new RGB(38, 38, 38));
        }
 
@@ -463,7 +471,6 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                        backgroundColor.dispose();
                }
 
-               frameMaker.freePatches();
                imageRegistry.dispose();
        }
 }
index 5ca395f7da386874af46293ae0b300b64aed57ff..68de9c9fe2d2ca2dcc03fef56a90cd478cdd23bd 100644 (file)
@@ -1,7 +1,7 @@
 /**
+ * General Skin Frame Maker
  *
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
@@ -43,7 +43,6 @@ public class SkinPatches {
                        SkinLogger.getSkinLogger(SkinPatches.class).getLogger();
 
        private Display display;
-       private String pathImage;
        private int patchWidth;
        private int patchHeight;
 
@@ -59,23 +58,25 @@ public class SkinPatches {
        private Image imageB;
        private Image imageRB;
 
-       // TODO: configurable
-       private static final String SKIN_PATCH_IMG_LT = "LT.png";
-       private static final String SKIN_PATCH_IMG_T = "T.png";
-       private static final String SKIN_PATCH_IMG_RT = "RT.png";
+       /**
+        *  Constructor
+        */
+       public SkinPatches(
+                       Image leftTop, Image middleTop, Image rightTop,
+                       Image leftMiddle, Image rightMiddle,
+                       Image leftBottom, Image middleBottom, Image rightBottom) {
+               this.display = Display.getCurrent();
 
-       private static final String SKIN_PATCH_IMG_L = "L.png";
-       private static final String SKIN_PATCH_IMG_R = "R.png";
+               imageLT = leftTop;
+               imageT = middleTop;
+               imageRT = rightTop;
 
-       private static final String SKIN_PATCH_IMG_LB = "LB.png";
-       private static final String SKIN_PATCH_IMG_B = "B.png";
-       private static final String SKIN_PATCH_IMG_RB = "RB.png";
+               imageL = leftMiddle;
+               imageR = rightMiddle;
 
-       public SkinPatches(String path) {
-               this.display = Display.getCurrent();
-               this.pathImage = path;
-
-               loadPatches(pathImage);
+               imageLB = leftBottom;
+               imageB = middleBottom;
+               imageRB = rightBottom;
 
                // TODO: configurable
                this.patchWidth = imageLT.getImageData().width;
@@ -127,42 +128,4 @@ public class SkinPatches {
 
                return patchedImage;
        }
-
-       private void loadPatches(String path) {
-               ClassLoader loader = this.getClass().getClassLoader();
-
-               imageLT = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_LT));
-               logger.info("left-top image is loaded from " +
-                               path + SKIN_PATCH_IMG_LT);
-               imageT = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_T));
-               imageRT = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_RT));
-
-               imageL = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_L));
-               imageR = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_R));
-
-               imageLB = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_LB));
-               imageB = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_B));
-               imageRB = new Image(display,
-                               loader.getResourceAsStream(path + SKIN_PATCH_IMG_RB));
-       }
-
-       public void freePatches() {
-               imageLT.dispose();
-               imageT.dispose();
-               imageRT.dispose();
-
-               imageL.dispose();
-               imageR.dispose();
-
-               imageLB.dispose();
-               imageB.dispose();
-               imageRB.dispose();
-       }
 }
index 5f7bfeca48991f41d35c52640cec6599fabbf41c..66e0e441e99b539b5bf744af916e482eddf1e7a3 100644 (file)
@@ -38,6 +38,7 @@ import org.tizen.emulator.skin.custom.GeneralKeyWindow;
 import org.tizen.emulator.skin.custom.SkinWindow;
 import org.tizen.emulator.skin.custom.SpecialKeyWindow;
 import org.tizen.emulator.skin.dbi.KeyMapType;
+import org.tizen.emulator.skin.image.GeneralKeyWindowImageRegistry;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.SkinUtil;
 
@@ -50,6 +51,8 @@ public class KeyWindowKeeper {
        private int recentlyDocked;
        private int indexLayout;
 
+       private GeneralKeyWindowImageRegistry imageRegstry;
+
        /**
         *  Constructor
         */
@@ -57,6 +60,7 @@ public class KeyWindowKeeper {
                this.skin = skin;
                this.recentlyDocked = SWT.NONE;
                this.indexLayout = -1;
+               this.imageRegstry = null;
        }
 
        public void openKeyWindow(int dockValue, boolean recreate) {
@@ -80,7 +84,14 @@ public class KeyWindowKeeper {
                }
 
                /* create a Key Window */
+               determineLayout();
+
                if (isGeneralKeyWindow() == true) {
+                       if (imageRegstry == null) {
+                               logger.warning("GeneralKeyWindowImageRegistry is null");
+                               return;
+                       }
+
                        List<KeyMapType> keyMapList = SkinUtil.getHWKeyMapList(
                                        skin.getEmulatorSkinState().getCurrentRotationId());
 
@@ -94,7 +105,7 @@ public class KeyWindowKeeper {
                                return;
                        }
 
-                       keyWindow = new GeneralKeyWindow(skin, keyMapList);
+                       keyWindow = new GeneralKeyWindow(skin, imageRegstry, keyMapList);
                } else {
                        // TODO:
                        String layoutName =
@@ -171,7 +182,13 @@ public class KeyWindowKeeper {
                        }
                } else {
                        logger.info("key window has a general layout");
+
                        indexLayout = -1;
+
+                       if (imageRegstry == null) {
+                               imageRegstry = new GeneralKeyWindowImageRegistry(
+                                               skin.getShell().getDisplay());
+                       }
                }
 
                return indexLayout;
@@ -230,4 +247,12 @@ public class KeyWindowKeeper {
        public void setRecentlyDocked(int dockValue) {
                recentlyDocked = dockValue;
        }
+
+       public void dispose() {
+               closeKeyWindow();
+
+               if (imageRegstry != null) {
+                       imageRegstry.dispose();
+               }
+       }
 }