skin: KeyWindow code refactoring 40/10640/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 1 Oct 2013 02:35:32 +0000 (11:35 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 8 Oct 2013 06:13:02 +0000 (15:13 +0900)
Change-Id: I666ac48e5dd26a802eecb44720f582e5af2b9281
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/GeneralKeyWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/KeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java

index b8f091196068c673215d53c891ab4b6ab0c6da80..5a1084e98ef8e68e7ba2690fad9685ca457b1651 100644 (file)
@@ -56,7 +56,7 @@ import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
 import org.tizen.emulator.skin.dbi.KeyMapType;
 import org.tizen.emulator.skin.image.GeneralKeyWindowImageRegistry;
-import org.tizen.emulator.skin.image.GeneralKeyWindowImageRegistry.KeyWindowImageName;
+import org.tizen.emulator.skin.image.GeneralKeyWindowImageRegistry.GeneralKeyWindowImageName;
 import org.tizen.emulator.skin.layout.SkinPatches;
 import org.tizen.emulator.skin.util.SwtUtil;
 
@@ -118,12 +118,12 @@ public class GeneralKeyWindow extends SkinWindow {
                shell.setImage(parent.getImage());
 
                /* load image for HW key button */
-               imageNormal = imageRegistry.getKeyWindowImageData(
-                               KeyWindowImageName.KEYBUTTON_NORMAL);
-               imageHover = imageRegistry.getKeyWindowImageData(
-                               KeyWindowImageName.KEYBUTTON_HOVER);
-               imagePushed = imageRegistry.getKeyWindowImageData(
-                               KeyWindowImageName.KEYBUTTON_PUSHED);
+               imageNormal = imageRegistry.getGeneralKeyWindowImageData(
+                               GeneralKeyWindowImageName.KEYBUTTON_NORMAL);
+               imageHover = imageRegistry.getGeneralKeyWindowImageData(
+                               GeneralKeyWindowImageName.KEYBUTTON_HOVER);
+               imagePushed = imageRegistry.getGeneralKeyWindowImageData(
+                               GeneralKeyWindowImageName.KEYBUTTON_PUSHED);
 
                /* calculate the key window size */
                widthBase = imageNormal.getImageData().width;
@@ -176,27 +176,27 @@ public class GeneralKeyWindow extends SkinWindow {
                        Image imagesScrollArrowUp[] = new Image[3];
                        Image imagesScrollArrowDown[] = new Image[3];
 
-                       imagesScrollArrowUp[0] = imageRegistry.getKeyWindowImageData(
-                                       KeyWindowImageName.SCROLL_UPBUTTON_NORMAL);
-                       imagesScrollArrowUp[1] = imageRegistry.getKeyWindowImageData(
-                                       KeyWindowImageName.SCROLL_UPBUTTON_HOVER);
-                       imagesScrollArrowUp[2] = imageRegistry.getKeyWindowImageData(
-                                       KeyWindowImageName.SCROLL_UPBUTTON_PUSHED);
+                       imagesScrollArrowUp[0] = imageRegistry.getGeneralKeyWindowImageData(
+                                       GeneralKeyWindowImageName.SCROLL_UPBUTTON_NORMAL);
+                       imagesScrollArrowUp[1] = imageRegistry.getGeneralKeyWindowImageData(
+                                       GeneralKeyWindowImageName.SCROLL_UPBUTTON_HOVER);
+                       imagesScrollArrowUp[2] = imageRegistry.getGeneralKeyWindowImageData(
+                                       GeneralKeyWindowImageName.SCROLL_UPBUTTON_PUSHED);
 
-                       imagesScrollArrowDown[0] = imageRegistry.getKeyWindowImageData(
-                                       KeyWindowImageName.SCROLL_DOWNBUTTON_NORMAL);
-                       imagesScrollArrowDown[1] = imageRegistry.getKeyWindowImageData(
-                                       KeyWindowImageName.SCROLL_DOWNBUTTON_HOVER);
-                       imagesScrollArrowDown[2] = imageRegistry.getKeyWindowImageData(
-                                       KeyWindowImageName.SCROLL_DOWNBUTTON_PUSHED);
+                       imagesScrollArrowDown[0] = imageRegistry.getGeneralKeyWindowImageData(
+                                       GeneralKeyWindowImageName.SCROLL_DOWNBUTTON_NORMAL);
+                       imagesScrollArrowDown[1] = imageRegistry.getGeneralKeyWindowImageData(
+                                       GeneralKeyWindowImageName.SCROLL_DOWNBUTTON_HOVER);
+                       imagesScrollArrowDown[2] = imageRegistry.getGeneralKeyWindowImageData(
+                                       GeneralKeyWindowImageName.SCROLL_DOWNBUTTON_PUSHED);
 
                        CustomScrolledComposite compositeScroll =
                                        new CustomScrolledComposite(shell, SWT.NONE,
                                                        imagesScrollArrowUp, imagesScrollArrowDown,
-                                                       imageRegistry.getKeyWindowImageData(
-                                                                       KeyWindowImageName.SCROLL_THUMB),
-                                                       imageRegistry.getKeyWindowImageData(
-                                                                       KeyWindowImageName.SCROLL_SHAFT));
+                                                       imageRegistry.getGeneralKeyWindowImageData(
+                                                                       GeneralKeyWindowImageName.SCROLL_THUMB),
+                                                       imageRegistry.getGeneralKeyWindowImageData(
+                                                                       GeneralKeyWindowImageName.SCROLL_SHAFT));
                        compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
 
                        Composite compositeBase = new Composite(compositeScroll, SWT.NONE);
@@ -331,7 +331,7 @@ public class GeneralKeyWindow extends SkinWindow {
                shellListener = new ShellListener() {
                        @Override
                        public void shellClosed(ShellEvent event) {
-                               logger.info("Key Window is closed");
+                               logger.info("General Key Window is closed");
 
                                dispose();
                        }
index 6cc93b27f740c5840575b381bb4e202734659695..0663f8c08c31ee8d7d840680776cc2b4ade31715 100644 (file)
@@ -1,7 +1,7 @@
 /**
+ * Special Key Window
  *
- *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
@@ -45,12 +45,8 @@ import org.eclipse.swt.events.ShellListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
@@ -64,32 +60,29 @@ import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.dbi.EmulatorUI;
 import org.tizen.emulator.skin.exception.JaxbException;
 import org.tizen.emulator.skin.image.KeyWindowImageRegistry;
-import org.tizen.emulator.skin.image.KeyWindowImageRegistry.ImageType;
+import org.tizen.emulator.skin.image.KeyWindowImageRegistry.SpecailKeyWindowImageType;
 import org.tizen.emulator.skin.layout.HWKey;
-import org.tizen.emulator.skin.layout.SkinPatches;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.JaxbUtil;
 import org.tizen.emulator.skin.util.SpecialKeyWindowUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
 
 public class SpecialKeyWindow extends SkinWindow {
-       private static final String PATCH_IMAGES_PATH = "images/key-window/";
        private static final String KEYWINDOW_LAYOUT = "keywindow-layout";      
        private static final String DBI_FILE_NAME = "default.dbi";      
 
        private EmulatorSkin skin;
-       private SkinPatches frameMaker;
        
        private HWKey currentPressedHWKey;
 
        private int widthBase;
        private int heightBase;
-       
-       private Image imageFrame; /* nine-patch image */
+
        private Image keyWindowImage;
        private Image keyWindowPressedImage;
 
        private Color colorFrame;
+       private KeyWindowImageRegistry imageRegistry;
        private SocketCommunicator communicator;        
 
        private ShellListener shellListener;
@@ -101,32 +94,37 @@ public class SpecialKeyWindow extends SkinWindow {
        private boolean isGrabbedShell;
        private Point grabPosition;
 
-       public SpecialKeyWindow(EmulatorSkin skin, Shell parent, SocketCommunicator communicator, String path) {
-               super(parent, SWT.RIGHT | SWT.CENTER);
+       public SpecialKeyWindow(EmulatorSkin skin, String layoutName) {
+               super(skin.getShell(), SWT.RIGHT | SWT.CENTER);
 
                this.skin = skin;
-               this.shell = new Shell(Display.getDefault(),
-                               SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL);
-               this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
-               
-               this.communicator = communicator;       
+               this.parent = skin.getShell();
+               if (SwtUtil.isMacPlatform() == false) {
+                       this.shell = new Shell(parent,
+                                       SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL);
+               } else {
+                       this.shell = new Shell(parent.getDisplay(),
+                                       SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL);
+               }
+
+               this.communicator = skin.communicator;
                this.grabPosition = new Point(0, 0);
 
                shell.setText(parent.getText());
                shell.setImage(parent.getImage());
-               
+
                /* load dbi file */
                String skinPath = skin.skinInfo.getSkinPath();
-               String specialKeyWindowPath = skinPath + File.separator + KEYWINDOW_LAYOUT + File.separator + path;
+               String specialKeyWindowPath = skinPath + File.separator + KEYWINDOW_LAYOUT + File.separator + layoutName;
                logger.info("special key window path : " + specialKeyWindowPath);
                EmulatorUI dbiContents = loadXMLForKeyWindow(specialKeyWindowPath);
 
                /* image init */
-               KeyWindowImageRegistry.getInstance().initialize(dbiContents, specialKeyWindowPath);
+               this.imageRegistry = new KeyWindowImageRegistry(shell.getDisplay(), dbiContents, specialKeyWindowPath);
                
                /* get keywindow image */
-               keyWindowImage = KeyWindowImageRegistry.getInstance().getSpecialKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, ImageType.IMG_TYPE_MAIN);                
-               keyWindowPressedImage = KeyWindowImageRegistry.getInstance().getSpecialKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, ImageType.IMG_TYPE_PRESSED);
+               keyWindowImage = imageRegistry.getSpecialKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL);           
+               keyWindowPressedImage = imageRegistry.getSpecialKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED);
                
                SpecialKeyWindowUtil.trimShell(shell, keyWindowImage);
                SpecialKeyWindowUtil.trimShell(shell, keyWindowPressedImage);
@@ -136,14 +134,9 @@ public class SpecialKeyWindow extends SkinWindow {
                heightBase = keyWindowImage.getImageData().height;
 
                /* make a frame image */
-               this.imageFrame = frameMaker.getPatchedImage(
-                               widthBase,
-                               heightBase);
                this.colorFrame = new Color(shell.getDisplay(), new RGB(38, 38, 38));
 
                shell.setBackground(colorFrame);
-               
-               trimPatchedShell(shell, imageFrame);
 
                addKeyWindowListener();
 
@@ -176,41 +169,6 @@ public class SpecialKeyWindow extends SkinWindow {
                return emulatorUI;
        }
 
-       public static void trimPatchedShell(Shell shell, Image image) {
-               if (null == image) {
-                       return;
-               }
-               ImageData imageData = image.getImageData();
-
-               int width = imageData.width;
-               int height = imageData.height;
-
-               Region region = new Region();
-               region.add(new Rectangle(0, 0, width, height));
-
-               int r = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getRed();
-               int g = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getGreen();
-               int b = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getBlue();
-               int colorKey;
-
-               if (SwtUtil.isWindowsPlatform()) {
-                       colorKey = r << 24 | g << 16 | b << 8;
-               } else {
-                       colorKey = r << 16 | g << 8 | b;
-               }
-
-               for (int i = 0; i < width; i++) {
-                       for (int j = 0; j < height; j++) {
-                               int colorPixel = imageData.getPixel(i, j);
-                               if (colorPixel == colorKey /* magenta */) {
-                                       region.subtract(i, j, 1, 1);
-                               }
-                       }
-               }
-
-               shell.setRegion(region);
-       }
-
        private void addKeyWindowListener() {
                shellPaintListener = new PaintListener() {
                        @Override
@@ -228,29 +186,7 @@ public class SpecialKeyWindow extends SkinWindow {
                        public void shellClosed(ShellEvent event) {
                                logger.info("Special Key Window is closed");
 
-                               if (skin.pairTag != null) {
-                                       skin.pairTag.setVisible(false);
-                               }
-
-                               if (null != shellPaintListener) {
-                                       shell.removePaintListener(shellPaintListener);
-                               }
-
-                               if (null != shellListener) {
-                                       shell.removeShellListener(shellListener);
-                               }
-
-                               if (null != shellMouseMoveListener) {
-                                       shell.removeMouseMoveListener(shellMouseMoveListener);
-                               }
-
-                               if (null != shellMouseListener) {
-                                       shell.removeMouseListener(shellMouseListener);
-                               }
-
-                               colorFrame.dispose();
-
-                               frameMaker.freePatches();
+                               dispose();
                        }
 
                        @Override
@@ -309,7 +245,7 @@ public class SpecialKeyWindow extends SkinWindow {
                                        int width = pressedHWKey.getRegion().width;
                                        int height = pressedHWKey.getRegion().height;
                                        int eventType;
-                                       
+
                                        if (SpecialKeyWindowUtil.isInGeometry(e.x, e.y, x, y, width, height)) {
                                                eventType = MouseEventType.DRAG.value();
                                        } else {
@@ -318,7 +254,7 @@ public class SpecialKeyWindow extends SkinWindow {
                                                /* rollback a keyPressed image resion */
                                                shell.redraw(x, y, width, height, false);
                                        }
-                                       
+
                                        MouseEventData mouseEventData = new MouseEventData(
                                                        MouseButtonType.LEFT.value(), MouseEventType.DRAG.value(), e.x, e.y, e.x, e.y, 0);
                                        communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData, false);
@@ -349,7 +285,7 @@ public class SpecialKeyWindow extends SkinWindow {
                                        isGrabbedShell = false;
                                        grabPosition.x = grabPosition.y = 0;
                                        HWKey pressedHWKey = currentPressedHWKey;
-                                       
+
                                        if (pressedHWKey != null && pressedHWKey.getKeyCode() != SpecialKeyWindowUtil.UNKNOWN_KEYCODE) {
                                                /* send event */
                                                if (isTouch) {
@@ -361,9 +297,9 @@ public class SpecialKeyWindow extends SkinWindow {
                                                        KeyEventData keyEventData = new KeyEventData(KeyEventType.RELEASED.value(), pressedHWKey.getKeyCode(), 0, 0);
                                                        communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false);
                                                }
-                                               
+
                                                currentPressedHWKey = null;
-                                               
+
                                                /* rollback a keyPressed image resion */
                                                shell.redraw(pressedHWKey.getRegion().x, pressedHWKey.getRegion().y, 
                                                                pressedHWKey.getRegion().width, pressedHWKey.getRegion().height, false);
@@ -375,7 +311,7 @@ public class SpecialKeyWindow extends SkinWindow {
                        public void mouseDown(MouseEvent e) {
                                if (1 == e.button) { /* left button */
                                        logger.info("MouseDown in SpecialKeyWindow : " + e.x + ", " + e.y);
-                                               
+
                                        /* HW key handling */
                                        final HWKey hwKey = SpecialKeyWindowUtil.getHWKey(e.x, e.y, EmulatorConfig.DEFAULT_WINDOW_ROTATION);
                                        if (hwKey == null) {            
@@ -384,7 +320,7 @@ public class SpecialKeyWindow extends SkinWindow {
                                                grabPosition.y = e.y;
                                                return;                                         
                                        }
-                                       
+
                                        if (hwKey.getKeyCode() != SpecialKeyWindowUtil.UNKNOWN_KEYCODE) {
                                                if (hwKey.getTooltip().equalsIgnoreCase("touch")) {
                                                        isTouch = true;
@@ -396,10 +332,10 @@ public class SpecialKeyWindow extends SkinWindow {
                                                        KeyEventData keyEventData = new KeyEventData(KeyEventType.PRESSED.value(), hwKey.getKeyCode(), 0, 0);
                                                        communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false);
                                                }
-                                               
+
                                                currentPressedHWKey = hwKey;
                                                shell.setToolTipText(null);
-                                               
+
                                                /* draw the HW key region as the cropped keyPressed image area */
                                                if(hwKey.getRegion() != null &&
                                                                hwKey.getRegion().width != 0 && hwKey.getRegion().height != 0) {
@@ -431,4 +367,29 @@ public class SpecialKeyWindow extends SkinWindow {
 
                shell.addMouseListener(shellMouseListener);
        }
+
+       private void dispose() {
+               if (skin.pairTag != null) {
+                       skin.pairTag.setVisible(false);
+               }
+
+               if (null != shellPaintListener) {
+                       shell.removePaintListener(shellPaintListener);
+               }
+
+               if (null != shellListener) {
+                       shell.removeShellListener(shellListener);
+               }
+
+               if (null != shellMouseMoveListener) {
+                       shell.removeMouseMoveListener(shellMouseMoveListener);
+               }
+
+               if (null != shellMouseListener) {
+                       shell.removeMouseListener(shellMouseListener);
+               }
+
+               colorFrame.dispose();
+               imageRegistry.dispose();
+       }
 }
index 1ed1e27eeddc77eca188bdd11887d530acb4caec..4505d3a27db9e70154f1e0c0ac7d30968c2f4f68 100644 (file)
@@ -46,7 +46,7 @@ public class GeneralKeyWindowImageRegistry {
        private static Logger logger = SkinLogger.getSkinLogger(
                        GeneralKeyWindowImageRegistry.class).getLogger();
 
-       public enum KeyWindowImageName {
+       public enum GeneralKeyWindowImageName {
                KEYBUTTON_NORMAL("keybutton_nml.png"),
                KEYBUTTON_HOVER("keybutton_hover.png"),
                KEYBUTTON_PUSHED("keybutton_pushed.png"),
@@ -62,7 +62,7 @@ public class GeneralKeyWindowImageRegistry {
 
                private String name;
 
-               private KeyWindowImageName(String name) {
+               private GeneralKeyWindowImageName(String name) {
                        this.name = name;
                }
 
@@ -82,15 +82,15 @@ public class GeneralKeyWindowImageRegistry {
                this.keyWindowImageMap = new HashMap<String, Image>();
        }
 
-       public Image getKeyWindowImageData(KeyWindowImageName name) {
+       public Image getGeneralKeyWindowImageData(GeneralKeyWindowImageName name) {
                if (keyWindowImageMap.size() == 0) {
                        /* load all of the images at once */
                        ClassLoader classLoader = this.getClass().getClassLoader();
                        InputStream is = null;
                        String imageName, imagePath;
 
-                       KeyWindowImageName[] values = KeyWindowImageName.values();
-                       for (KeyWindowImageName value : values) {
+                       GeneralKeyWindowImageName[] values = GeneralKeyWindowImageName.values();
+                       for (GeneralKeyWindowImageName value : values) {
                                imageName = value.getName();
                                imagePath = ImageRegistry.IMAGES_FOLDER + "/" +
                                                KEYWINDOW_FOLDER + "/" + imageName;
index 8567ea81fa96b70cd894b77f2c99dc558407fd90..2b0d9dd78d568483df00eda0623bc9362da30ab0 100644 (file)
@@ -1,12 +1,11 @@
 /**
- * image resources management
+ * Image Resource Management For Special Key Window
  *
- * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- * HyunJun Son
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -30,7 +29,6 @@
 package org.tizen.emulator.skin.image;
 
 import java.io.File;
-import java.io.InputStream;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -39,16 +37,14 @@ import java.util.Map;
 import java.util.logging.Logger;
 
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.widgets.Display;
-import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.dbi.EmulatorUI;
 import org.tizen.emulator.skin.dbi.ImageListType;
 import org.tizen.emulator.skin.dbi.RotationType;
 import org.tizen.emulator.skin.dbi.RotationsType;
 import org.tizen.emulator.skin.log.SkinLogger;
-import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.KeyWindowRotation;
+import org.tizen.emulator.skin.util.SkinRotation;
 
 
 /**
@@ -56,126 +52,37 @@ import org.tizen.emulator.skin.util.KeyWindowRotation;
  *
  */
 public class KeyWindowImageRegistry {
-       public static final String GENERAL_FOLDER = "emul-general-3btn";
-       public static final String ICON_FOLDER = "icons";
-       public static final String IMAGES_FOLDER = "images";
-       public static final String KEYWINDOW_FOLDER = "key-window";
-
        private static Logger logger =
                        SkinLogger.getSkinLogger(KeyWindowImageRegistry.class).getLogger();
 
-       public enum ImageType {
-               IMG_TYPE_MAIN,
-               IMG_TYPE_PRESSED
-       }
-
-       public enum IconName {
-               DETAIL_INFO("detail_info.png"),
-               ROTATE("rotate.png"),
-               SCALE("scale.png"),
-               SHELL("shell.png"),
-               ADVANCED("advanced.png"),
-               CLOSE("close.png"),
-               SCREENSHOT("screenshot.png"),
-               USB_KEYBOARD("usb_keyboard.png"),
-               HOST_KEYBOARD("host_keyboard.png"),
-               DIAGNOSIS("diagnosis.png"),
-               FORCE_CLOSE("force_close.png"),
-               ABOUT("about.png"),
-
-               COPY_SCREEN_SHOT("copy_screenshot_dialog.png"),
-               REFRESH_SCREEN_SHOT("refresh_screenshot_dialog.png"),
-               INCREASE_SCALE("increase_scale.png"),
-               DECREASE_SCALE("decrease_scale.png"),
-               SAVE_SCREEN_SHOT("save_screenshot_dialog.png"),
-
-               EMULATOR_TITLE("emulator_icon.png"),
-               EMULATOR_TITLE_ICO("emulator_icon.ico");
-               
-               private String name;
-               
-               private IconName(String name) {
-                       this.name = name;
-               }
-               
-               public String getName() {
-                       return this.name;
-               }
-               
-       }
-
-       public enum KeyWindowImageName {
-               KEYBUTTON_NORMAL("keybutton_nml.png"),
-               KEYBUTTON_HOVER("keybutton_hover.png"),
-               KEYBUTTON_PUSHED("keybutton_pushed.png"),
-
-               SCROLL_UPBUTTON_NORMAL("scroll_button_up_nml.png"),
-               SCROLL_UPBUTTON_HOVER("scroll_button_up_hover.png"),
-               SCROLL_UPBUTTON_PUSHED("scroll_button_up_pushed.png"),
-               SCROLL_DOWNBUTTON_NORMAL("scroll_button_down_nml.png"),
-               SCROLL_DOWNBUTTON_HOVER("scroll_button_down_hover.png"),
-               SCROLL_DOWNBUTTON_PUSHED("scroll_button_down_pushed.png"),
-               SCROLL_THUMB("scroll_thumb.png"),
-               SCROLL_SHAFT("scroll_back.png");
-
-               private String name;
-
-               private KeyWindowImageName(String name) {
-                       this.name = name;
-               }
-
-               public String getName() {
-                       return this.name;
-               }
+       public enum SpecailKeyWindowImageType {
+               SPECIAL_IMAGE_TYPE_NORMAL,
+               SPECIAL_IMAGE_TYPE_PRESSED
        }
 
        private Display display;
+       private String skinPath;
        private EmulatorUI dbiContents;
-
-       private Map<String, Image> skinImageMap;
-       private Map<String, Image> iconMap;
        private Map<String, Image> keyWindowImageMap;
 
-       private String skinPath;
-
-       private static KeyWindowImageRegistry instance;
-       private static boolean isInitialized;
-
-       private KeyWindowImageRegistry() {
-               /* do nothing */
-       }
-
-       public static KeyWindowImageRegistry getInstance() {
-               if (null == instance) {
-                       instance = new KeyWindowImageRegistry();
-               }
-
-               return instance;
-       }
-
-       public void initialize(EmulatorUI dbiContents, String skinPath) {
-               if (isInitialized) 
-                       KeyWindowRotation.clear();      
-               
-               isInitialized = true;
-
-               this.display = Display.getDefault();
-
+       /**
+        *  Constructor
+        */
+       public KeyWindowImageRegistry(
+                       Display display, EmulatorUI dbiContents, String skinPath) {
+               this.display = display;
                this.skinPath = skinPath;
                this.dbiContents = dbiContents;
-               this.skinImageMap = new HashMap<String, Image>();
-               this.iconMap = new HashMap<String, Image>();
                this.keyWindowImageMap = new HashMap<String, Image>();
 
-               init(this.skinPath);
+               initialize(skinPath);
        }
 
-       private void init(String argSkinPath) {
-
+       private void initialize(String argSkinPath) {
                RotationsType rotations = dbiContents.getRotations();
 
                if (null == rotations) {
-                       logger.severe("Fail to loading rotations element from dbi.");
+                       logger.severe("Fail to loading rotations element from XML");
                        return;
                }
 
@@ -186,23 +93,24 @@ public class KeyWindowImageRegistry {
                }
        }
 
-       public Image getSpecialKeyWindowImage(Short id, ImageType imageType) {
+       private String makeKey(Short id, SpecailKeyWindowImageType imageType) {
+               return id + ":" + imageType.ordinal();
+       }
 
-               Image image = skinImageMap.get(makeKey(id, imageType));
+       public Image getSpecialKeyWindowImage(Short id, SpecailKeyWindowImageType imageType) {
+               Image image = keyWindowImageMap.get(makeKey(id, imageType));
 
-               if (null != image) {
-                       return image;
-               } else {
+               if (image == null) {
                        RotationsType rotations = dbiContents.getRotations();
 
                        if (null == rotations) {
-                               logger.severe("Fail to loading rotations element from dbi.");
+                               logger.severe("Fail to loading rotations element from XML");
                                return null;
                        }
 
-                       logger.info("get image data of skin from " + skinPath);
+                       logger.info("get skin image from " + skinPath);
 
-                       RotationType targetRotation = KeyWindowRotation.getRotation(id);
+                       RotationType targetRotation = SkinRotation.getRotation(id);
                        List<RotationType> rotationList = rotations.getRotation();
 
                        for (RotationType rotation : rotationList) {
@@ -215,66 +123,35 @@ public class KeyWindowImageRegistry {
                                String keyPressedImage = imageList.getKeyPressedImage();
 
                                if (targetRotation.getName().value().equals(rotation.getName().value())) {
-                                       String mainKey = makeKey(id, ImageType.IMG_TYPE_MAIN);
-                                       skinImageMap.put(mainKey,
+                                       String mainKey = makeKey(id,
+                                                       SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL);
+                                       keyWindowImageMap.put(mainKey,
                                                        new Image(display, skinPath + File.separator + mainImage));
 
-                                       String pressedKey = makeKey(id, ImageType.IMG_TYPE_PRESSED);
-                                       skinImageMap.put(pressedKey,
+                                       String pressedKey = makeKey(id,
+                                                       SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED);
+                                       keyWindowImageMap.put(pressedKey,
                                                        new Image(display, skinPath + File.separator + keyPressedImage));
 
                                        break;
                                }
                        }
 
-                       Image registeredImage = skinImageMap.get(makeKey(id, imageType));
-
-                       if (null != registeredImage) {
-                               return registeredImage;
-                       } else {
-                               return null;
-                       }
-
+                       image = keyWindowImageMap.get(makeKey(id, imageType));
                }
-       }
 
-       private String makeKey(Short id, ImageType imageType) {
-               return id + ":" + imageType.ordinal();
+               return image;
        }
 
        public void dispose() {
-               /* skin image */
-               if (null != skinImageMap) {
-                       Collection<Image> images = skinImageMap.values();
+               if (null != keyWindowImageMap) {
+                       Image image = null;
 
+                       Collection<Image> images = keyWindowImageMap.values();
                        Iterator<Image> imageIterator = images.iterator();
 
                        while (imageIterator.hasNext()) {
-                               Image image = imageIterator.next();
-                               image.dispose();
-                       }
-               }
-
-               /* icon */
-               if (null != iconMap) {
-                       Collection<Image> icons = iconMap.values();
-
-                       Iterator<Image> iconIterator = icons.iterator();
-
-                       while (iconIterator.hasNext()) {
-                               Image image = iconIterator.next();
-                               image.dispose();
-                       }
-               }
-
-               /* key window image */
-               if (null != keyWindowImageMap) {
-                       Collection<Image> images = keyWindowImageMap.values();
-
-                       Iterator<Image> imagesIterator = images.iterator();
-
-                       while (imagesIterator.hasNext()) {
-                               Image image = imagesIterator.next();
+                               image = imageIterator.next();
                                image.dispose();
                        }
                }
index 2a81e5866f65b8bcf657d1b6a584be86e6cf988c..cd720da24f14f0ac307fa65c8ac3ac0dc7d933f0 100644 (file)
@@ -38,7 +38,6 @@ import java.util.logging.Logger;
 
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Display;
-import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.dbi.EmulatorUI;
 import org.tizen.emulator.skin.dbi.ImageListType;
 import org.tizen.emulator.skin.dbi.RotationType;
@@ -63,11 +62,11 @@ public class ProfileSkinImageRegistry {
        /**
         *  Constructor
         */
-       public ProfileSkinImageRegistry(EmulatorConfig config,
-                       Display display, String skinPath) {
+       public ProfileSkinImageRegistry(
+                       Display display, EmulatorUI dbiContents, String skinPath) {
                this.display = display;
                this.skinPath = skinPath;
-               this.dbiContents = config.getDbiContents();
+               this.dbiContents = dbiContents;
                this.skinImageMap = new HashMap<String, Image>();
 
                initialize(skinPath);
index 51afcc3b8199092f836302b7291be53d6c20979d..4d2c90ca037c19d07ac52d5587d0c44951feab8b 100644 (file)
@@ -101,7 +101,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                this.grabPosition = new Point(0, 0);
 
                this.imageRegistry = new ProfileSkinImageRegistry(
-                               config, shell.getDisplay(), skin.skinInfo.getSkinPath());
+                               shell.getDisplay(), config.getDbiContents(), skin.skinInfo.getSkinPath());
        }
 
        @Override
index 7ca7c88d7d1f1376953a128a1619a968e69f58b8..5f7bfeca48991f41d35c52640cec6599fabbf41c 100644 (file)
@@ -101,8 +101,7 @@ public class KeyWindowKeeper {
                                        skin.getPopupMenu().keyWindowItem.getMenu().getItem(indexLayout).getText();
                        logger.info("generate a \'" + layoutName + "\' key window!");
 
-                       keyWindow = new SpecialKeyWindow(
-                                       skin, skin.getShell(), skin.communicator, layoutName);
+                       keyWindow = new SpecialKeyWindow(skin, layoutName);
                }
 
                selectKeyWindowMenu(skin.isKeyWindow = true);