skin: refactoring for rotation 97/17797/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 10 Mar 2014 10:28:44 +0000 (19:28 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Mon, 10 Mar 2014 11:14:57 +0000 (20:14 +0900)
remove RotationInfo class & add Rotation class
use ID for rotation checking

Change-Id: I5f1d224ffaeb4c9018077d8cba4d95fa4c710888
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
17 files changed:
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/info/EmulatorSkinState.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/rotation/Rotation.java [new file with mode: 0644]
tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java
tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinRotation.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java

index b2b914d..79288e4 100644 (file)
@@ -40,12 +40,12 @@ import org.eclipse.swt.graphics.PaletteData;
 import org.eclipse.swt.widgets.Display;
 import org.tizen.emulator.skin.comm.ICommunicator.MouseButtonType;
 import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.comm.sock.data.MouseEventData;
 import org.tizen.emulator.skin.info.EmulatorSkinState;
 import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.util.SkinRotation;
 
 public class EmulatorFingers {
        private static final int MAX_FINGER_CNT = 10;
@@ -417,7 +417,7 @@ public class EmulatorFingers {
 
        private Boolean calculateOriginCoordinates(
                        int scaledDisplayWitdh, int scaledDisplayHeight,
-                       double scaleFactor, int rotationType, FingerPoint finger) {
+                       double scaleFactor, short rotationId, FingerPoint finger) {
                int pointX = 0, pointY = 0;
                int rotatedPointX = 0, rotatedPointY = 0;
                int flag = 0;
@@ -432,13 +432,13 @@ public class EmulatorFingers {
                /* logger.info("rotatedPointX:" + rotatedPointX +
                                " rotatedPointY:" + rotatedPointY); */
 
-               if (rotationType == RotationInfo.LANDSCAPE.id()) {
+               if (rotationId == SkinRotation.LANDSCAPE_ID) {
                        rotatedPointX = pointY;
                        rotatedPointY = scaledDisplayWitdh - pointX;
-               } else if (rotationType == RotationInfo.REVERSE_PORTRAIT.id()) {
+               } else if (rotationId == SkinRotation.REVERSE_PORTRAIT_ID) {
                        rotatedPointX = scaledDisplayWitdh - pointX;
                        rotatedPointY = scaledDisplayHeight - pointY;
-               } else if (rotationType == RotationInfo.REVERSE_LANDSCAPE.id()) {
+               } else if (rotationId == SkinRotation.REVERSE_LANDSCAPE_ID) {
                        rotatedPointX = scaledDisplayHeight - pointY;
                        rotatedPointY = pointX;
                } else {
@@ -463,8 +463,8 @@ public class EmulatorFingers {
                return false;
        }
 
-       public int rearrangeFingerPoints(
-                       int displayWidth, int displayHeight, double scaleFactor, int rotationType) {
+       public int rearrangeFingerPoints(int displayWidth, int displayHeight,
+                       double scaleFactor, short rotationId) {
                if (multiTouchEnable == 0) {
                        return 0;
                }
@@ -479,8 +479,8 @@ public class EmulatorFingers {
                for (int i = 0; i < fingerCnt; i++) {
                        finger = getFingerPointFromSlot(i);
                        if (finger != null && finger.id != 0) {
-                               if (calculateOriginCoordinates(
-                                               displayWidth, displayHeight, scaleFactor, rotationType, finger) == true) {
+                               if (calculateOriginCoordinates(displayWidth, displayHeight,
+                                               scaleFactor, rotationId, finger) == true) {
                                        count++;
                                }
                        }
index d3da2e4..6ada6e7 100644 (file)
@@ -57,6 +57,7 @@ import org.tizen.emulator.skin.image.ImageRegistry.IconName;
 import org.tizen.emulator.skin.info.SkinInformation;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.screenshot.ShmScreenShotWindow;
+import org.tizen.emulator.skin.util.SkinRotation;
 import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
 
@@ -340,29 +341,33 @@ public class EmulatorShmSkin extends EmulatorSkin {
                                        e.gc.setInterpolation(SWT.HIGH);
                                }
 
-                               switch(currentState.getCurrentAngle()) {
-                               case -90: /* landscape */
+                               switch(currentState.getCurrentRotationId()) {
+                               case SkinRotation.LANDSCAPE_ID:
+                                       /* landscape */
                                        e.gc.setTransform(displayTransform);
                                        e.gc.drawImage(bufferPainter.imageFramebuffer,
                                                        0, 0, bufferPainter.widthFB, bufferPainter.heightFB,
                                                        0, 0, screen_height, screen_width);
                                        e.gc.setTransform(null); /* set to the identity transform */
                                        break;
-                               case 180: /* reverse-portrait */
+                               case SkinRotation.REVERSE_PORTRAIT_ID:
+                                       /* reverse-portrait */
                                        e.gc.setTransform(displayTransform);
                                        e.gc.drawImage(bufferPainter.imageFramebuffer,
                                                        0, 0, bufferPainter.widthFB, bufferPainter.heightFB,
                                                        0, 0, screen_width, screen_height);
                                        e.gc.setTransform(null);
                                        break;
-                               case 90: /* reverse-landscape */
+                               case SkinRotation.REVERSE_LANDSCAPE_ID:
+                                       /* reverse-landscape */
                                        e.gc.setTransform(displayTransform);
                                        e.gc.drawImage(bufferPainter.imageFramebuffer,
                                                        0, 0, bufferPainter.widthFB, bufferPainter.heightFB,
                                                        0, 0, screen_height, screen_width);
                                        e.gc.setTransform(null);
                                        break;
-                               default: /* portrait */
+                               default:
+                                       /* portrait */
                                        e.gc.drawImage(bufferPainter.imageFramebuffer,
                                                        0, 0, bufferPainter.widthFB, bufferPainter.heightFB,
                                                        0, 0, screen_width, screen_height);
@@ -461,7 +466,8 @@ public class EmulatorShmSkin extends EmulatorSkin {
                int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
                                currentState.getCurrentResolutionWidth(),
                                currentState.getCurrentResolutionHeight(),
-                               currentState.getCurrentScale(), currentState.getCurrentAngle());
+                               currentState.getCurrentScale(),
+                               currentState.getCurrentRotationId());
 
                //eventType = MouseEventType.DRAG.value();
                if (finger.getMultiTouchEnable() == 1) {
@@ -487,7 +493,8 @@ public class EmulatorShmSkin extends EmulatorSkin {
                int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
                                currentState.getCurrentResolutionWidth(),
                                currentState.getCurrentResolutionHeight(),
-                               currentState.getCurrentScale(), currentState.getCurrentAngle());
+                               currentState.getCurrentScale(),
+                               currentState.getCurrentRotationId());
                logger.info("mouseUp in display" +
                                " x:" + geometry[0] + " y:" + geometry[1]);
 
@@ -519,7 +526,8 @@ public class EmulatorShmSkin extends EmulatorSkin {
                int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
                                currentState.getCurrentResolutionWidth(),
                                currentState.getCurrentResolutionHeight(),
-                               currentState.getCurrentScale(), currentState.getCurrentAngle());
+                               currentState.getCurrentScale(),
+                               currentState.getCurrentRotationId());
                logger.info("mouseDown in display" +
                                " x:" + geometry[0] + " y:" + geometry[1]);
 
index 41ad2bc..ec66a68 100755 (executable)
@@ -74,7 +74,6 @@ import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
 import org.tizen.emulator.skin.comm.ICommunicator.MouseButtonType;
 import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.comm.sock.data.BooleanData;
@@ -99,6 +98,7 @@ import org.tizen.emulator.skin.info.SkinInformation;
 import org.tizen.emulator.skin.layout.GeneralPurposeSkinComposer;
 import org.tizen.emulator.skin.layout.ISkinComposer;
 import org.tizen.emulator.skin.layout.ProfileSpecificSkinComposer;
+import org.tizen.emulator.skin.layout.rotation.Rotation;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.menu.KeyWindowKeeper;
 import org.tizen.emulator.skin.menu.PopupMenu;
@@ -260,9 +260,7 @@ public class EmulatorSkin {
                currentState.setCurrentResolutionHeight(config.getValidResolutionHeight());
 
                currentState.setCurrentScale(config.getValidScale());
-
-               short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
-               currentState.setCurrentRotationId(rotationId);
+               currentState.setCurrentRotationId();
 
                /* create and attach a popup menu */
                popupMenu = new PopupMenu(config, this);
@@ -832,7 +830,7 @@ public class EmulatorSkin {
                                                currentState.getCurrentResolutionWidth(),
                                                currentState.getCurrentResolutionHeight(),
                                                currentState.getCurrentScale(),
-                                               currentState.getCurrentAngle());
+                                               currentState.getCurrentRotationId());
                                logger.info("mouseWheel in display" + " x:" + geometry[0]
                                                + " y:" + geometry[1] + " value:" + e.count);
 
@@ -1121,7 +1119,8 @@ public class EmulatorSkin {
                int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
                                currentState.getCurrentResolutionWidth(),
                                currentState.getCurrentResolutionHeight(),
-                               currentState.getCurrentScale(), currentState.getCurrentAngle());
+                               currentState.getCurrentScale(),
+                               currentState.getCurrentRotationId());
 
                MouseEventData mouseEventData = new MouseEventData(
                                MouseButtonType.LEFT.value(), eventType,
@@ -1135,7 +1134,8 @@ public class EmulatorSkin {
                int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
                                currentState.getCurrentResolutionWidth(),
                                currentState.getCurrentResolutionHeight(),
-                               currentState.getCurrentScale(), currentState.getCurrentAngle());
+                               currentState.getCurrentScale(),
+                               currentState.getCurrentRotationId());
                logger.info("mouseUp in display" +
                                " x:" + geometry[0] + " y:" + geometry[1]);
 
@@ -1151,7 +1151,8 @@ public class EmulatorSkin {
                int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
                                currentState.getCurrentResolutionWidth(),
                                currentState.getCurrentResolutionHeight(),
-                               currentState.getCurrentScale(), currentState.getCurrentAngle());
+                               currentState.getCurrentScale(),
+                               currentState.getCurrentRotationId());
                logger.info("mouseDown in display" +
                                " x:" + geometry[0] + " y:" + geometry[1]);
 
@@ -1271,16 +1272,21 @@ public class EmulatorSkin {
                }
 
                displayTransform = new Transform(lcdCanvas.getDisplay());
-               displayTransform.rotate(currentState.getCurrentAngle());
 
-               if (currentState.getCurrentAngle() == -90) { /* landscape */
+               short rotationId = currentState.getCurrentRotationId();
+               displayTransform.rotate(SkinRotation.getAngle(rotationId));
+
+               if (rotationId == SkinRotation.LANDSCAPE_ID) {
+                       /* landscape */
                        displayTransform.translate(
                                        lcdCanvas.getSize().y * -1, 0);
-               } else if (currentState.getCurrentAngle() == 180) { /* reverse-portrait */
+               } else if (rotationId == SkinRotation.REVERSE_PORTRAIT_ID) {
+                       /* reverse-portrait */
                        displayTransform.translate(
                                        lcdCanvas.getSize().x * -1,
                                        lcdCanvas.getSize().y * -1);
-               } else if (currentState.getCurrentAngle() == 90) { /* reverse-landscape */
+               } else if (rotationId == SkinRotation.REVERSE_LANDSCAPE_ID) {
+                       /* reverse-landscape */
                        displayTransform.translate(
                                        0, lcdCanvas.getSize().x * -1);
                }
@@ -1410,11 +1416,11 @@ public class EmulatorSkin {
 
                final List<MenuItem> rotationList = new ArrayList<MenuItem>();
 
-               Iterator<Entry<Short, RotationType>> iterator =
+               Iterator<Entry<Short, Rotation>> iterator =
                                SkinRotation.getRotationIterator();
 
                while (iterator.hasNext()) {
-                       Entry<Short, RotationType> entry = iterator.next();
+                       Entry<Short, Rotation> entry = iterator.next();
                        Short rotationId = entry.getKey();
                        RotationType section = entry.getValue();
 
@@ -1435,21 +1441,21 @@ public class EmulatorSkin {
                        for (MenuItem m : rotationList) {
                                short rotationId = (Short) m.getData();
 
-                               if (rotationId == RotationInfo.PORTRAIT.id()) {
+                               if (rotationId == SkinRotation.PORTRAIT_ID) {
                                        String landscape = SkinRotation.getRotation(
-                                                       RotationInfo.LANDSCAPE.id()).getName().value();
+                                                       SkinRotation.LANDSCAPE_ID).getName().value();
                                        m.setText(landscape);
-                               } else if (rotationId == RotationInfo.LANDSCAPE.id()) {
+                               } else if (rotationId == SkinRotation.LANDSCAPE_ID) {
                                        String portrait = SkinRotation.getRotation(
-                                                       RotationInfo.PORTRAIT.id()).getName().value();
+                                                       SkinRotation.PORTRAIT_ID).getName().value();
                                        m.setText(portrait);
-                               } else if (rotationId == RotationInfo.REVERSE_PORTRAIT.id()) {
+                               } else if (rotationId == SkinRotation.REVERSE_PORTRAIT_ID) {
                                        String landscapeReverse = SkinRotation.getRotation(
-                                                       RotationInfo.REVERSE_LANDSCAPE.id()).getName().value();
+                                                       SkinRotation.REVERSE_LANDSCAPE_ID).getName().value();
                                        m.setText(landscapeReverse);
-                               } else if (rotationId == RotationInfo.REVERSE_LANDSCAPE.id()) {
+                               } else if (rotationId == SkinRotation.REVERSE_LANDSCAPE_ID) {
                                        String portraitReverse = SkinRotation.getRotation(
-                                                       RotationInfo.REVERSE_PORTRAIT.id()).getName().value();
+                                                       SkinRotation.REVERSE_PORTRAIT_ID).getName().value();
                                        m.setText(portraitReverse);
                                }
                        }
index 231175a..5872771 100644 (file)
@@ -30,7 +30,6 @@
 package org.tizen.emulator.skin.comm;
 
 import org.tizen.emulator.skin.comm.sock.data.ISendData;
-import org.tizen.emulator.skin.dbi.RotationNameType;
 
 /**
  * 
@@ -165,46 +164,6 @@ public interface ICommunicator extends Runnable {
 
        }
 
-       public enum RotationInfo {
-               PORTRAIT( RotationNameType.PORTRAIT.value(), (short)0, 0 ),
-               LANDSCAPE( RotationNameType.LANDSCAPE.value(), (short)1, -90 ),
-               REVERSE_PORTRAIT( RotationNameType.REVERSE_PORTRAIT.value(), (short)2, 180 ),
-               REVERSE_LANDSCAPE( RotationNameType.REVERSE_LANDSCAPE.value(), (short)3, 90 );
-
-               private String value;
-               private short id;
-               private int angle;
-
-               RotationInfo( String value, short id, int ratio ) {
-                       this.value = value;
-                       this.id = id;
-                       this.angle = ratio;
-               }
-
-               public String value() {
-                       return this.value;
-               }
-
-               public int angle() {
-                       return this.angle;
-               }
-
-               public short id() {
-                       return this.id;
-               }
-
-               public static RotationInfo getValue(short id) {
-                       RotationInfo[] values = RotationInfo.values();
-                       for (int i = 0; i < values.length; i++) {
-                               if (values[i].id == id) {
-                                       return values[i];
-                               }
-                       }
-
-                       throw new IllegalArgumentException(Integer.toString(id));
-               }
-       }
-
        public enum SendCommand {
                /* This values must match the QEMU definitions */
 
index 4f748e1..fbdb821 100644 (file)
@@ -39,7 +39,6 @@ import java.util.logging.Logger;
 
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Display;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.dbi.EmulatorUI;
 import org.tizen.emulator.skin.exception.ConfigException;
 import org.tizen.emulator.skin.log.SkinLogger;
@@ -60,7 +59,6 @@ public class EmulatorConfig {
        public static final int DEFAULT_WINDOW_SCALE = 50;
        public static final int MIN_SCALE_FACTOR = 25;
        public static final int MAX_SCALE_FACTOR = 200;
-       public static final short DEFAULT_WINDOW_ROTATION = RotationInfo.PORTRAIT.id();
        public static final int DEFAULT_WINDOW_X = 50;
        public static final int DEFAULT_WINDOW_Y = 50;
        public static final SkinLogLevel DEFAULT_LOG_LEVEL = SkinLogLevel.DEBUG;
index 9690504..e3351c0 100644 (file)
@@ -88,6 +88,10 @@ public class ProfileSkinImageRegistry {
                        logger.info("get skin image from " + skinPath);
 
                        RotationType targetRotation = SkinRotation.getRotation(id);
+                       if (targetRotation == null) {
+                               return null;
+                       }
+
                        List<RotationType> rotationList = rotations.getRotation();
 
                        for (RotationType rotation : rotationList) {
index 066efb5..c680a51 100644 (file)
@@ -53,7 +53,7 @@ public class EmulatorSkinState {
        public EmulatorSkinState() {
                this.currentResolution = new Point(720, 1280);
                this.currentScale = EmulatorConfig.DEFAULT_WINDOW_SCALE;
-               this.currentRotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
+               this.currentRotationId = SkinRotation.PORTRAIT_ID;
 
                this.displayBounds = null;
                this.updateDisplayBounds = false;
@@ -105,8 +105,8 @@ public class EmulatorSkinState {
                return currentRotationId;
        }
 
-       public synchronized int getCurrentAngle() {
-               return SkinRotation.getAngle(currentRotationId);
+       public synchronized void setCurrentRotationId() {
+               this.currentRotationId = SkinRotation.PORTRAIT_ID;
        }
 
        public synchronized void setCurrentRotationId(short rotationId) {
index 84988ec..083be4f 100644 (file)
@@ -49,7 +49,6 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.EmulatorSkinMain;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
 import org.tizen.emulator.skin.custom.ColorTag;
@@ -64,6 +63,7 @@ import org.tizen.emulator.skin.info.EmulatorSkinState;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.menu.KeyWindowKeeper;
 import org.tizen.emulator.skin.menu.PopupMenu;
+import org.tizen.emulator.skin.util.SkinRotation;
 import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
 
@@ -267,21 +267,21 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                }
 
                /* arrange the pair tag */
-               if (rotationId == RotationInfo.PORTRAIT.id()) {
+               if (rotationId == SkinRotation.PORTRAIT_ID) {
                        pairTag.setBounds(
                                        PAIR_TAG_POSITION_X, PAIR_TAG_POSITION_Y,
                                        pairTag.getWidth(), pairTag.getHeight());
-               } else if (rotationId == RotationInfo.LANDSCAPE.id()) {
+               } else if (rotationId == SkinRotation.LANDSCAPE_ID) {
                        pairTag.setBounds(
                                        PAIR_TAG_POSITION_Y,
                                        shell.getSize().y - PAIR_TAG_POSITION_X - pairTag.getHeight(),
                                        pairTag.getWidth(), pairTag.getHeight());
-               } else if (rotationId == RotationInfo.REVERSE_PORTRAIT.id()) {
+               } else if (rotationId == SkinRotation.REVERSE_PORTRAIT_ID) {
                        pairTag.setBounds(
                                        shell.getSize().x - PAIR_TAG_POSITION_X - pairTag.getWidth(),
                                        shell.getSize().y - PAIR_TAG_POSITION_Y - pairTag.getHeight(),
                                        pairTag.getWidth(), pairTag.getHeight());
-               } else if (rotationId == RotationInfo.REVERSE_LANDSCAPE.id()) {
+               } else if (rotationId == SkinRotation.REVERSE_LANDSCAPE_ID) {
                        pairTag.setBounds(
                                        shell.getSize().x - PAIR_TAG_POSITION_Y - pairTag.getWidth(),
                                        PAIR_TAG_POSITION_X,
@@ -306,11 +306,10 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                frameMaker.getPatchWidth(), frameMaker.getPatchHeight(), 0, 0);
 
                float convertedScale = SkinUtil.convertScale(scale);
-               RotationInfo rotation = RotationInfo.getValue(rotationId);
 
                /* resoultion, that is display size in general skin mode */
-               if (RotationInfo.LANDSCAPE == rotation ||
-                               RotationInfo.REVERSE_LANDSCAPE == rotation) {
+               if (SkinRotation.LANDSCAPE_ID == rotationId ||
+                               SkinRotation.REVERSE_LANDSCAPE_ID == rotationId) {
                        displayBounds.width = (int)(resolutionH * convertedScale);
                        displayBounds.height = (int)(resolutionW * convertedScale);
                } else {
index 1edab15..8a91795 100644 (file)
@@ -270,6 +270,9 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
 
                float convertedScale = SkinUtil.convertScale(scale);
                RotationType rotation = SkinRotation.getRotation(rotationId);
+               if (rotation == null) {
+                       return null;
+               }
 
                DisplayType display = rotation.getDisplay(); /* from dbi */
                if (display == null) {
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/rotation/Rotation.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/rotation/Rotation.java
new file mode 100644 (file)
index 0000000..ee73108
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * Rotation Information
+ *
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin.layout.rotation;
+
+import org.tizen.emulator.skin.dbi.RotationType;
+
+
+public class Rotation extends RotationType {
+       private int angle;
+
+       public void setAngle(int degree) {
+               this.angle = degree;
+       }
+
+       public int getAngle() {
+               return angle;
+       }
+}
index d75d6b1..9c33bd2 100644 (file)
@@ -42,7 +42,6 @@ import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.EmulatorSkin;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.dbi.MenuItemType;
 import org.tizen.emulator.skin.dbi.PopupMenuType;
@@ -159,8 +158,7 @@ public class PopupMenu {
                                                ROTATE_MENUITEM_NAME : rotationMenuType.getItemName());
                        } else {
                                /* do not rotate */
-                               skin.getEmulatorSkinState().setCurrentRotationId(
-                                               RotationInfo.PORTRAIT.id());
+                               skin.getEmulatorSkinState().setCurrentRotationId();
                        }
                }
 
index 57fded0..a235bc0 100644 (file)
@@ -60,7 +60,6 @@ import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
 import org.tizen.emulator.skin.comm.sock.data.MouseEventData;
-import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.custom.SkinWindow;
 import org.tizen.emulator.skin.exception.JaxbException;
 import org.tizen.emulator.skin.image.SpecialKeyWindowImageRegistry;
@@ -70,9 +69,9 @@ import org.tizen.emulator.skin.keywindow.dbi.KeyMapType;
 import org.tizen.emulator.skin.keywindow.dbi.KeyWindowUI;
 import org.tizen.emulator.skin.keywindow.dbi.RegionType;
 import org.tizen.emulator.skin.layout.HWKey;
+import org.tizen.emulator.skin.util.HWKeyRegion;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.JaxbUtil;
-import org.tizen.emulator.skin.util.HWKeyRegion;
 import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
 
@@ -127,11 +126,9 @@ public class SpecialKeyWindow extends SkinWindow {
                /* get keywindow image */
                //TODO: null
                this.keyWindowImage = imageRegistry.getKeyWindowImage(
-                               EmulatorConfig.DEFAULT_WINDOW_ROTATION,
-                               SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL);
+                               (short)0, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL);
                this.keyWindowPressedImage = imageRegistry.getKeyWindowImage(
-                               EmulatorConfig.DEFAULT_WINDOW_ROTATION,
-                               SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED);
+                               (short)0, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED);
 
                /* set window size */
                if (keyWindowImage != null) {
index 93816c4..3adf552 100644 (file)
@@ -72,13 +72,13 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.ToolBar;
 import org.eclipse.swt.widgets.ToolItem;
 import org.tizen.emulator.skin.EmulatorSkin;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.exception.ScreenShotException;
 import org.tizen.emulator.skin.image.ImageRegistry;
 import org.tizen.emulator.skin.image.ImageRegistry.IconName;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.IOUtil;
+import org.tizen.emulator.skin.util.SkinRotation;
 import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.StringUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
@@ -343,19 +343,19 @@ public class ScreenShotDialog {
                }
        }
 
-       protected ImageData rotateImageData(ImageData srcData, RotationInfo rotation) {
+       protected ImageData getRotateImageData(ImageData srcData) {
                int direction = SWT.NONE;
 
-               switch (rotation) {
-               case PORTRAIT:
+               switch (skin.getEmulatorSkinState().getCurrentRotationId()) {
+               case SkinRotation.PORTRAIT_ID:
                        return srcData;
-               case LANDSCAPE:
+               case SkinRotation.LANDSCAPE_ID:
                        direction = SWT.LEFT;
                        break;
-               case REVERSE_PORTRAIT:
+               case SkinRotation.REVERSE_PORTRAIT_ID:
                        direction = SWT.DOWN;
                        break;
-               case REVERSE_LANDSCAPE:
+               case SkinRotation.REVERSE_LANDSCAPE_ID:
                        direction = SWT.RIGHT;
                        break;
                default:
@@ -413,14 +413,6 @@ public class ScreenShotDialog {
                                srcData.depth, srcData.palette, destBytesPerLine, newData);
        }
 
-       protected RotationInfo getCurrentRotation() {
-               short currentRotationId =
-                               skin.getEmulatorSkinState().getCurrentRotationId();
-               RotationInfo rotationInfo = RotationInfo.getValue(currentRotationId);
-
-               return rotationInfo;
-       }
-
        private void createToolBar(final Shell parent) {
                ImageRegistry imageRegistry = skin.getImageRegistry();
 
index 45e48dc..e05fda7 100644 (file)
@@ -35,7 +35,6 @@ import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.PaletteData;
 import org.eclipse.swt.widgets.Display;
 import org.tizen.emulator.skin.EmulatorSdlSkin;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator.DataTranfer;
 import org.tizen.emulator.skin.config.EmulatorConfig;
@@ -73,8 +72,7 @@ public class SdlScreenShotWindow extends ScreenShotDialog {
                        ImageData imageData = new ImageData(width, height,
                                        EmulatorSdlSkin.DISPLAY_COLOR_DEPTH, palette, 1, receivedData);
 
-                       RotationInfo rotation = getCurrentRotation();
-                       imageData = rotateImageData(imageData, rotation);
+                       imageData = getRotateImageData(imageData);
 
                        Image tempImage = imageShot;
                        imageShot = new Image(Display.getDefault(), imageData);
index 0267db2..d08bc2e 100644 (file)
@@ -35,7 +35,6 @@ import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.PaletteData;
 import org.eclipse.swt.widgets.Display;
 import org.tizen.emulator.skin.EmulatorShmSkin;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.exception.ScreenShotException;
 import org.tizen.emulator.skin.log.SkinLogger;
@@ -74,8 +73,7 @@ public class ShmScreenShotWindow extends ScreenShotDialog {
                imageData.setPixels(0, 0,
                                width * height, arrayFramebuffer, 0);
 
-               RotationInfo rotation = getCurrentRotation();
-               imageData = rotateImageData(imageData, rotation);
+               imageData = getRotateImageData(imageData);
 
                Image tempImage = imageShot;
                imageShot = new Image(Display.getDefault(), imageData);
index 845581f..495b854 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Rotation Utilities
+ * Rotation Informations
  *
  * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
 
 package org.tizen.emulator.skin.util;
 
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
+import org.tizen.emulator.skin.dbi.RotationNameType;
 import org.tizen.emulator.skin.dbi.RotationType;
-
+import org.tizen.emulator.skin.layout.rotation.Rotation;
 
 /**
  * 
  *
  */
 public class SkinRotation {
-       private static Map<Short, RotationType> rotationMap;
-       private static Map<Short, RotationInfo> angleMap;
+       public static final short PORTRAIT_ID = 0;
+       public static final short LANDSCAPE_ID = 1;
+       public static final short REVERSE_PORTRAIT_ID = 2;
+       public static final short REVERSE_LANDSCAPE_ID = 3;
+
+       private static Map<Short, Rotation> rotationMap =
+                       new LinkedHashMap<Short, Rotation>();
 
        private SkinRotation() {
                /* do nothing */
        }
 
-       static {
-               rotationMap = new LinkedHashMap<Short, RotationType>();
-               angleMap = new HashMap<Short, RotationInfo>();
-       }
+       public static void put(RotationType rotationType) {
+               Rotation rotation = new Rotation();
+               rotation.setName(rotationType.getName());
+               rotation.setDisplay(rotationType.getDisplay());
+               rotation.setImageList(rotationType.getImageList());
+               rotation.setKeyMapList(rotationType.getKeyMapList());
 
-       public static void put(RotationType rotation) {
-               if (RotationInfo.PORTRAIT.value()
-                               .equalsIgnoreCase(rotation.getName().value()))
+               if (RotationNameType.PORTRAIT.value()
+                               .equalsIgnoreCase(rotationType.getName().value()))
                {
-                       rotationMap.put(RotationInfo.PORTRAIT.id(), rotation);
-                       angleMap.put(RotationInfo.PORTRAIT.id(), RotationInfo.PORTRAIT);
+                       rotation.setAngle(0);
+                       rotationMap.put(PORTRAIT_ID, rotation);
                }
-               else if (RotationInfo.LANDSCAPE.value()
-                               .equalsIgnoreCase(rotation.getName().value()))
+               else if (RotationNameType.LANDSCAPE.value()
+                               .equalsIgnoreCase(rotationType.getName().value()))
                {
-                       rotationMap.put(RotationInfo.LANDSCAPE.id(), rotation);
-                       angleMap.put(RotationInfo.LANDSCAPE.id(), RotationInfo.LANDSCAPE);
+                       rotation.setAngle(-90);
+                       rotationMap.put(LANDSCAPE_ID, rotation);
                }
-               else if (RotationInfo.REVERSE_PORTRAIT.value()
-                               .equalsIgnoreCase(rotation.getName().value()))
+               else if (RotationNameType.REVERSE_PORTRAIT.value()
+                               .equalsIgnoreCase(rotationType.getName().value()))
                {
-                       rotationMap.put(RotationInfo.REVERSE_PORTRAIT.id(), rotation);
-                       angleMap.put(RotationInfo.REVERSE_PORTRAIT.id(), RotationInfo.REVERSE_PORTRAIT);
+                       rotation.setAngle(180);
+                       rotationMap.put(REVERSE_PORTRAIT_ID, rotation);
                }
-               else if (RotationInfo.REVERSE_LANDSCAPE.value()
-                               .equalsIgnoreCase(rotation.getName().value()))
+               else if (RotationNameType.REVERSE_LANDSCAPE.value()
+                               .equalsIgnoreCase(rotationType.getName().value()))
                {
-                       rotationMap.put(RotationInfo.REVERSE_LANDSCAPE.id(), rotation);
-                       angleMap.put(RotationInfo.REVERSE_LANDSCAPE.id(), RotationInfo.REVERSE_LANDSCAPE);
+                       rotation.setAngle(90);
+                       rotationMap.put(REVERSE_LANDSCAPE_ID, rotation);
                }
        }
 
+       public static Rotation getRotation(Short rotationId) {
+               return rotationMap.get(rotationId);
+       }
+
        public static int getAngle(Short rotationId) {
-               RotationInfo rotationInfo = angleMap.get(rotationId);
-               if (null != rotationInfo) {
-                       return rotationInfo.angle();
-               } else {
+               Rotation rotation = rotationMap.get(rotationId);
+               if (rotation == null) {
                        return 0;
                }
-       }
 
-       public static RotationType getRotation(Short rotationId) {
-               return rotationMap.get(rotationId);
+               return rotation.getAngle();
        }
 
-       public static Iterator<Entry<Short, RotationType>> getRotationIterator() {
+       public static Iterator<Entry<Short, Rotation>> getRotationIterator() {
                return rotationMap.entrySet().iterator();
        }
 }
index b586124..241233a 100644 (file)
@@ -49,7 +49,6 @@ import org.eclipse.swt.graphics.Region;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.dbi.EventInfoType;
@@ -177,7 +176,7 @@ public class SkinUtil {
                KeyMapListType list = rotation.getKeyMapList();
                if (list == null) {
                        /* try to using a KeyMapList of portrait */
-                       rotation = SkinRotation.getRotation(RotationInfo.PORTRAIT.id());
+                       rotation = SkinRotation.getRotation(SkinRotation.PORTRAIT_ID);
                        if (rotation == null) {
                                return null;
                        }
@@ -294,7 +293,7 @@ public class SkinUtil {
 
        public static int[] convertMouseGeometry(
                        int originalX, int originalY, int displayWidth, int displayHeight,
-                       int scale, int angle) {
+                       int scale, short rotationId) {
                float convertedScale = convertScale(scale);
 
                int x = (int) (originalX * (1 / convertedScale));
@@ -303,13 +302,13 @@ public class SkinUtil {
                int rotatedX = x;
                int rotatedY = y;
 
-               if (RotationInfo.LANDSCAPE.angle() == angle) {
+               if (rotationId == SkinRotation.LANDSCAPE_ID) {
                        rotatedX = displayWidth - y;
                        rotatedY = x;
-               } else if (RotationInfo.REVERSE_PORTRAIT.angle() == angle) {
+               } else if (rotationId == SkinRotation.REVERSE_PORTRAIT_ID) {
                        rotatedX = displayWidth - x;
                        rotatedY = displayHeight - y;
-               } else if (RotationInfo.REVERSE_LANDSCAPE.angle() == angle) {
+               } else if (rotationId == SkinRotation.REVERSE_LANDSCAPE_ID) {
                        rotatedX = y;
                        rotatedY = displayHeight - x;
                }