From: GiWoong Kim Date: Mon, 10 Mar 2014 10:28:44 +0000 (+0900) Subject: skin: refactoring for rotation X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~471 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F97%2F17797%2F1;p=sdk%2Femulator%2Fqemu.git skin: refactoring for rotation remove RotationInfo class & add Rotation class use ID for rotation checking Change-Id: I5f1d224ffaeb4c9018077d8cba4d95fa4c710888 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java index b2b914dc54..79288e4988 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java @@ -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++; } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java index d3da2e4cea..6ada6e76d5 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java @@ -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]); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 41ad2bc29f..ec66a68861 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -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 rotationList = new ArrayList(); - Iterator> iterator = + Iterator> iterator = SkinRotation.getRotationIterator(); while (iterator.hasNext()) { - Entry entry = iterator.next(); + Entry 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); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java index 231175a0a9..587277144d 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java @@ -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 */ diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java index 4f748e138c..fbdb821c3b 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java @@ -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; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java index 9690504e9c..e3351c0bee 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java @@ -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 rotationList = rotations.getRotation(); for (RotationType rotation : rotationList) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/info/EmulatorSkinState.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/info/EmulatorSkinState.java index 066efb50c6..c680a5151e 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/info/EmulatorSkinState.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/info/EmulatorSkinState.java @@ -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) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java index 84988ecc7c..083be4ff7e 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java @@ -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 { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java index 1edab15dbc..8a917951ef 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java @@ -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 index 0000000000..ee7310874e --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/rotation/Rotation.java @@ -0,0 +1,43 @@ +/** + * Rotation Information + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * + * 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; + } +} diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java index d75d6b1016..9c33bd2698 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java @@ -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(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java index 57fded00c0..a235bc00a0 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java @@ -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) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java index 93816c4a6b..3adf5525a4 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ScreenShotDialog.java @@ -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(); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java index 45e48dc5d2..e05fda7d7f 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/SdlScreenShotWindow.java @@ -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); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java index 0267db2c0b..d08bc2e809 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/screenshot/ShmScreenShotWindow.java @@ -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); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinRotation.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinRotation.java index 845581fe8d..495b8545f2 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinRotation.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinRotation.java @@ -1,5 +1,5 @@ /** - * Rotation Utilities + * Rotation Informations * * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * @@ -29,74 +29,79 @@ 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 rotationMap; - private static Map 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 rotationMap = + new LinkedHashMap(); private SkinRotation() { /* do nothing */ } - static { - rotationMap = new LinkedHashMap(); - angleMap = new HashMap(); - } + 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> getRotationIterator() { + public static Iterator> getRotationIterator() { return rotationMap.entrySet().iterator(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java index b586124b1d..241233ac6d 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java @@ -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; }