[Title] add Skin logger and open usb kbd, rotate/scaling
authorSon Hyunjun <hj79.son@samsung.com>
Sat, 17 Mar 2012 15:09:19 +0000 (00:09 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Sat, 17 Mar 2012 15:09:19 +0000 (00:09 +0900)
[Type] Feature
[Module]
[Priority] Major
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

Change-Id: I4abd99bb356388c721bef703cab466a0b8675b65

tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/data/LcdStateData.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/data/StartData.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java [new file with mode: 0644]
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinRotation.java

index 7be93f8..3cb9933 100644 (file)
@@ -36,6 +36,8 @@ import java.util.List;
 import java.util.Map.Entry;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.DragDetectEvent;
@@ -70,7 +72,6 @@ import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
 import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
-import org.tizen.emulator.skin.comm.ICommunicator.Scale;
 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;
@@ -89,6 +90,7 @@ import org.tizen.emulator.skin.dbi.RgbType;
 import org.tizen.emulator.skin.dbi.RotationType;
 import org.tizen.emulator.skin.image.ImageRegistry;
 import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
+import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.SkinRegion;
 import org.tizen.emulator.skin.util.SkinRotation;
 import org.tizen.emulator.skin.util.SkinRotation.RotationInfo;
@@ -99,6 +101,8 @@ import org.tizen.emulator.skin.util.SkinRotation.RotationInfo;
  */
 public class EmulatorSkin {
 
+       private Logger logger = SkinLogger.getSkinLogger( EmulatorSkin.class ).getLogger();
+
        private EmulatorConfig config;
        private Shell shell;
        private ImageRegistry imageRegistry;
@@ -108,7 +112,7 @@ public class EmulatorSkin {
        private Color hoverColor;
        private boolean isDefaultHoverColor;
        
-       private Scale currentScale;
+       private int currentScale;
        private short currentRotationId;
        private int currentAngle;
        private int currentLcdWidth;
@@ -138,7 +142,6 @@ public class EmulatorSkin {
 
        public int compose() {
 
-               //TODO resolution
                imageRegistry = new ImageRegistry( shell.getDisplay(), config );
 
                shell.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) );
@@ -150,16 +153,20 @@ public class EmulatorSkin {
                String emulatorName = config.getArg( ArgsConstants.EMULATOR_NAME );
                shell.setText( emulatorName );
 
-               this.lcdCanvas = new Canvas( shell, SWT.EMBEDDED );
+               this.lcdCanvas = new Canvas( shell, SWT.EMBEDDED | SWT.NO_BACKGROUND );
                lcdCanvas.setBackground( shell.getDisplay().getSystemColor( SWT.COLOR_BLACK ) );
-
+               
                int lcdWidth = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_WIDTH ) );
                int lcdHeight = Integer.parseInt( config.getArg( ArgsConstants.RESOLUTION_HEIGHT ) );
 
-               short scale = config.getPropertyShort( PropertiesConstants.WINDOW_SCALE, Scale.ONE.value() );
+               int scale = config.getPropertyInt( PropertiesConstants.WINDOW_SCALE, 50 );
+               //TODO:
+               if (scale != 100 && scale != 75 && scale != 50 && scale != 25 ) {
+                       scale = 50;
+               }
                short rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_DIRECTION, (short) 0 );
 
-               arrangeSkin( lcdWidth, lcdHeight, Scale.getValue( scale ), (short) rotationId );
+               arrangeSkin( lcdWidth, lcdHeight, scale, (short) rotationId );
 
                Menu menu = new Menu( shell );
                addMenuItems( menu );
@@ -189,34 +196,34 @@ public class EmulatorSkin {
                        try {
                                Field field = lcdCanvas.getClass().getField( "embeddedHandle" );
                                windowHandleId = field.getInt( lcdCanvas );
-                               System.out.println( "lcdCanvas.embeddedHandle:" + windowHandleId );
+                               logger.info( "lcdCanvas.embeddedHandle:" + windowHandleId );
                        } catch ( IllegalArgumentException e ) {
-                               e.printStackTrace();
+                               logger.log( Level.SEVERE, e.getMessage(), e );
                                shutdown();
                                return windowHandleId;
                        } catch ( IllegalAccessException e ) {
-                               e.printStackTrace();
+                               logger.log( Level.SEVERE, e.getMessage(), e );
                                shutdown();
                                return windowHandleId;
                        } catch ( SecurityException e ) {
-                               e.printStackTrace();
+                               logger.log( Level.SEVERE, e.getMessage(), e );
                                shutdown();
                                return windowHandleId;
                        } catch ( NoSuchFieldException e ) {
-                               e.printStackTrace();
+                               logger.log( Level.SEVERE, e.getMessage(), e );
                                shutdown();
                                return windowHandleId;
                        }
                }else if( "win32".equalsIgnoreCase( platform ) ) {
-                       System.out.println( "lcdCanvas.handle:" + lcdCanvas.handle );
+                       logger.info( "lcdCanvas.handle:" + lcdCanvas.handle );
                        windowHandleId = lcdCanvas.handle;
                }else if( "cocoa".equalsIgnoreCase( platform ) ) {
                        //TODO
                }else {
-                       System.out.println( "Not Supported OS platform:" + platform );
+                       logger.severe( "Not Supported OS platform:" + platform );
                        System.exit( -1 );
                }
-
+               
                addLCDListener( lcdCanvas );
                addShellListener( shell );
 
@@ -227,7 +234,7 @@ public class EmulatorSkin {
        public void open() {
 
                if ( null == this.communicator ) {
-                       System.out.println( "communicator is null." );
+                       logger.severe( "communicator is null." );
                        shell.close();
                        return;
                }
@@ -246,7 +253,7 @@ public class EmulatorSkin {
 
        }
 
-       private void arrangeSkin( int lcdWidth, int lcdHeight, Scale scale, short rotationId ) {
+       private void arrangeSkin( int lcdWidth, int lcdHeight, int scale, short rotationId ) {
 
                this.currentLcdWidth = lcdWidth;
                this.currentLcdHeight = lcdHeight;
@@ -273,13 +280,13 @@ public class EmulatorSkin {
 
        }
 
-       private Image createScaledImage( short rotationId, Scale scale, ImageType type ) {
+       private Image createScaledImage( short rotationId, int scale, ImageType type ) {
 
                ImageData originalImageData = imageRegistry.getImageData( rotationId, type );
 
                ImageData imageData = (ImageData) originalImageData.clone();
-               int width = (int) ( originalImageData.width * scale.ratio() );
-               int height = (int) ( originalImageData.height * scale.ratio() );
+               int width = (int) ( originalImageData.width * (((float)scale) / 100) );
+               int height = (int) ( originalImageData.height * (((float)scale) / 100) );
                imageData = imageData.scaledTo( width, height );
 
                Image image = new Image( shell.getDisplay(), imageData );
@@ -312,7 +319,7 @@ public class EmulatorSkin {
 
        }
 
-       private void adjustLcdGeometry( Canvas lcdCanvas, Scale scale, short rotationId ) {
+       private void adjustLcdGeometry( Canvas lcdCanvas, int scale, short rotationId ) {
 
                RotationType rotation = SkinRotation.getRotation( rotationId );
 
@@ -324,10 +331,10 @@ public class EmulatorSkin {
                Integer width = region.getWidth();
                Integer height = region.getHeight();
 
-               int l = (int) ( left * scale.ratio() );
-               int t = (int) ( top * scale.ratio() );
-               int w = (int) ( width * scale.ratio() );
-               int h = (int) ( height * scale.ratio() );
+               int l = (int) ( left * (((float)scale) / 100) );
+               int t = (int) ( top * (((float)scale) / 100) );
+               int w = (int) ( width * (((float)scale) / 100) );
+               int h = (int) ( height * (((float)scale) / 100) );
 
                lcdCanvas.setBounds( l, t, w, h );
 
@@ -343,10 +350,10 @@ public class EmulatorSkin {
 
                        RegionType region = keyMap.getRegion();
 
-                       int scaledX = (int) ( region.getLeft() * currentScale.ratio() );
-                       int scaledY = (int) ( region.getTop() * currentScale.ratio() );
-                       int scaledWidth = (int) ( region.getWidth() * currentScale.ratio() );
-                       int scaledHeight = (int) ( region.getHeight() * currentScale.ratio() );
+                       int scaledX = (int) ( region.getLeft() * (((float)currentScale) / 100) );
+                       int scaledY = (int) ( region.getTop() * (((float)currentScale) / 100) );
+                       int scaledWidth = (int) ( region.getWidth() * (((float)currentScale) / 100) );
+                       int scaledHeight = (int) ( region.getHeight() * (((float)currentScale) / 100) );
 
                        if ( isInGeometry( currentX, currentY, scaledX, scaledY, scaledWidth, scaledHeight ) ) {
                                return new SkinRegion( scaledX, scaledY, scaledWidth, scaledHeight );
@@ -367,10 +374,10 @@ public class EmulatorSkin {
                for ( KeyMapType keyMap : keyMapList ) {
                        RegionType region = keyMap.getRegion();
 
-                       int scaledX = (int) ( region.getLeft() * currentScale.ratio() );
-                       int scaledY = (int) ( region.getTop() * currentScale.ratio() );
-                       int scaledWidth = (int) ( region.getWidth() * currentScale.ratio() );
-                       int scaledHeight = (int) ( region.getHeight() * currentScale.ratio() );
+                       int scaledX = (int) ( region.getLeft() * (((float)currentScale) / 100) );
+                       int scaledY = (int) ( region.getTop() * (((float)currentScale) / 100) );
+                       int scaledWidth = (int) ( region.getWidth() * (((float)currentScale) / 100) );
+                       int scaledHeight = (int) ( region.getHeight() * (((float)currentScale) / 100) );
 
                        if ( isInGeometry( currentX, currentY, scaledX, scaledY, scaledWidth, scaledHeight ) ) {
                                EventInfoType eventInfo = keyMap.getEventInfo();
@@ -397,8 +404,8 @@ public class EmulatorSkin {
 
        private int[] convertMouseGeometry( int originalX, int originalY ) {
 
-               int x = (int) ( originalX * ( 1 / currentScale.ratio() ) );
-               int y = (int) ( originalY * ( 1 / currentScale.ratio() ) );
+               int x = (int) ( originalX * ( 1 / (((float)currentScale) / 100) ) );
+               int y = (int) ( originalY * ( 1 / (((float)currentScale) / 100) ) );
 
                int rotatedX = x;
                int rotatedY = y;
@@ -428,7 +435,7 @@ public class EmulatorSkin {
 
                                        config.setProperty( PropertiesConstants.WINDOW_X, shell.getLocation().x );
                                        config.setProperty( PropertiesConstants.WINDOW_Y, shell.getLocation().y );
-                                       config.setProperty( PropertiesConstants.WINDOW_SCALE, currentScale.value() );
+                                       config.setProperty( PropertiesConstants.WINDOW_SCALE, currentScale );
                                        config.setProperty( PropertiesConstants.WINDOW_DIRECTION, currentRotationId );
 
                                        config.saveProperties();
@@ -528,7 +535,7 @@ public class EmulatorSkin {
                        @Override
                        public void mouseUp( MouseEvent e ) {
                                if ( 1 == e.button ) { // left button
-                                       System.out.println( "mouseUp in Skin" );
+                                       logger.info( "mouseUp in Skin" );
                                        EmulatorSkin.this.pressedMouseX = 0;
                                        EmulatorSkin.this.pressedMouseY = 0;
                                        EmulatorSkin.this.isMousePressed = false;
@@ -547,7 +554,7 @@ public class EmulatorSkin {
                        @Override
                        public void mouseDown( MouseEvent e ) {
                                if ( 1 == e.button ) { // left button
-                                       System.out.println( "mouseDown in Skin" );
+                                       logger.info( "mouseDown in Skin" );
                                        EmulatorSkin.this.pressedMouseX = e.x;
                                        EmulatorSkin.this.pressedMouseY = e.y;
 
@@ -597,11 +604,11 @@ public class EmulatorSkin {
 
                        @Override
                        public void dragDetected( DragDetectEvent e ) {
-                               System.out.println( "dragDetected e.button:" + e.button );
+                               logger.fine( "dragDetected e.button:" + e.button );
                                if ( 1 == e.button && // left button
                                                e.x > 0 && e.x < canvas.getSize().x && e.y > 0 && e.y < canvas.getSize().y ) {
 
-                                       System.out.println( "dragDetected in LCD" );
+                                       logger.fine( "dragDetected in LCD" );
                                        EmulatorSkin.this.isDragStartedInLCD = true;
 
                                }
@@ -650,7 +657,7 @@ public class EmulatorSkin {
                                if ( 1 == e.button ) { // left button
 
                                        int[] geometry = convertMouseGeometry( e.x, e.y );
-                                       System.out.println( "mouseUp in LCD" + " x:" + geometry[0] + " y:" + geometry[1] );
+                                       logger.info( "mouseUp in LCD" + " x:" + geometry[0] + " y:" + geometry[1] );
                                        MouseEventData mouseEventData = new MouseEventData( MouseEventType.UP.value(), geometry[0],
                                                        geometry[1], 0 );
                                        communicator.sendToQEMU( SendCommand.SEND_MOUSE_EVENT, mouseEventData );
@@ -664,7 +671,7 @@ public class EmulatorSkin {
                        public void mouseDown( MouseEvent e ) {
                                if ( 1 == e.button ) { // left button
                                        int[] geometry = convertMouseGeometry( e.x, e.y );
-                                       System.out.println( "mouseDown in LCD" + " x:" + geometry[0] + " y:" + geometry[1] );
+                                       logger.info( "mouseDown in LCD" + " x:" + geometry[0] + " y:" + geometry[1] );
                                        MouseEventData mouseEventData = new MouseEventData( MouseEventType.DOWN.value(), geometry[0],
                                                        geometry[1], 0 );
                                        communicator.sendToQEMU( SendCommand.SEND_MOUSE_EVENT, mouseEventData );
@@ -680,18 +687,19 @@ public class EmulatorSkin {
 
                        @Override
                        public void keyReleased( KeyEvent e ) {
-                               System.out.println( "key released. key event:" + e );
-//                             int keyCode = e.keyCode;
-//                             KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode );
-//                             communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
+                               logger.info( "key released. key event:" + e );
+                               int keyCode = e.keyCode;
+
+                               KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode );
+                               communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
                        }
 
                        @Override
                        public void keyPressed( KeyEvent e ) {
-                               System.out.println( "key pressed. key event:" + e );
-//                             int keyCode = e.keyCode;
-//                             KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode );
-//                             communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
+                               logger.info( "key pressed. key event:" + e );
+                               int keyCode = e.keyCode;
+                               KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode );
+                               communicator.sendToQEMU( SendCommand.SEND_KEY_EVENT, keyEventData );
                        }
 
                } );
@@ -704,52 +712,42 @@ public class EmulatorSkin {
 
                String emulatorName = config.getArg( ArgsConstants.EMULATOR_NAME );
                infoItem.setText( emulatorName );
+               //FIXME
                infoItem.setEnabled( false );
-//             infoItem.addSelectionListener( new SelectionAdapter() {
-//                     @Override
-//                     public void widgetSelected( SelectionEvent e ) {
-//                             System.out.println( "Selected Info." );
-//                             //TODO
-//                             MessageBox messageBox = new MessageBox( shell, SWT.OK | SWT.APPLICATION_MODAL );
-//                             messageBox.setMessage( "Under construction..." );
-//                             messageBox.open();
-//                     }
-//             } );
+               infoItem.addSelectionListener( new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected( SelectionEvent e ) {
+                               logger.fine( "Selected Info." );
+                       }
+               } );
 
                new MenuItem( menu, SWT.SEPARATOR );
 
                final MenuItem aotItem = new MenuItem( menu, SWT.CHECK );
                aotItem.setText( "Always On Top" );
+               //FIXME
                aotItem.setEnabled( false );
-//             aotItem.addSelectionListener( new SelectionAdapter() {
-//                     private boolean isTop;
-//
-//                     @Override
-//                     public void widgetSelected( SelectionEvent e ) {
-//                             System.out.println( "Selected Always On Top." );
-//                             isTop = !isTop;
-//                             
-//                             //TODO
-//                             MessageBox messageBox = new MessageBox( shell, SWT.OK | SWT.APPLICATION_MODAL );
-//                             messageBox.setMessage( "Under construction..." );
-//                             messageBox.open();
-//
-//                     }
-//             } );
+               aotItem.addSelectionListener( new SelectionAdapter() {
+                       private boolean isTop;
+
+                       @Override
+                       public void widgetSelected( SelectionEvent e ) {
+                               logger.fine( "Selected Always On Top." );
+                               isTop = !isTop;
+                               //TODO
+                       }
+               } );
 
                final MenuItem rotateItem = new MenuItem( menu, SWT.CASCADE );
                rotateItem.setText( "Rotate" );
-               rotateItem.setEnabled( false );
-               
-//             Menu rotateMenu = createRotateMenu( menu.getShell() );
-//             rotateItem.setMenu( rotateMenu );
+
+               Menu rotateMenu = createRotateMenu( menu.getShell() );
+               rotateItem.setMenu( rotateMenu );
 
                final MenuItem scaleItem = new MenuItem( menu, SWT.CASCADE );
                scaleItem.setText( "Scale" );
-               scaleItem.setEnabled( false );
-               
-//             Menu scaleMenu = createScaleMenu( menu.getShell() );
-//             scaleItem.setMenu( scaleMenu );
+               Menu scaleMenu = createScaleMenu( menu.getShell() );
+               scaleItem.setMenu( scaleMenu );
 
                new MenuItem( menu, SWT.SEPARATOR );
 
@@ -757,7 +755,7 @@ public class EmulatorSkin {
                advancedItem.setText( "Advanced" );
                Menu advancedMenu = createAdvancedMenu( menu.getShell() );
                advancedItem.setMenu( advancedMenu );
-//
+
 //             final MenuItem shellItem = new MenuItem( menu, SWT.PUSH );
 //             shellItem.setText( "Shell" );
 //             shellItem.addSelectionListener( new SelectionAdapter() {
@@ -776,8 +774,8 @@ public class EmulatorSkin {
 //                             communicator.sendToQEMU( SendCommand.OPEN_SHELL, null );
 //                     }
 //             } );
-
-               new MenuItem( menu, SWT.SEPARATOR );
+//
+//             new MenuItem( menu, SWT.SEPARATOR );
 
                MenuItem closeItem = new MenuItem( menu, SWT.PUSH );
                closeItem.setText( "Close" );
@@ -854,7 +852,7 @@ public class EmulatorSkin {
                                short rotationId = ( (Short) item.getData() );
 
                                arrangeSkin( currentLcdWidth, currentLcdHeight, currentScale, rotationId );
-                               LcdStateData lcdStateData = new LcdStateData( currentScale.value(), rotationId );
+                               LcdStateData lcdStateData = new LcdStateData( currentScale, rotationId );
                                communicator.sendToQEMU( SendCommand.CHANGE_LCD_STATE, lcdStateData );
 
                        }
@@ -875,25 +873,29 @@ public class EmulatorSkin {
 
                final MenuItem scaleOneItem = new MenuItem( menu, SWT.RADIO );
                scaleOneItem.setText( "1x" );
-               scaleOneItem.setData( Scale.ONE );
+               scaleOneItem.setData( 100 );
                scaleList.add( scaleOneItem );
 
                final MenuItem scaleThreeQtrItem = new MenuItem( menu, SWT.RADIO );
                scaleThreeQtrItem.setText( "3/4x" );
-               scaleThreeQtrItem.setData( Scale.THREE_QUARTERS );
+               scaleThreeQtrItem.setData( 75 );
                scaleList.add( scaleThreeQtrItem );
 
                final MenuItem scalehalfItem = new MenuItem( menu, SWT.RADIO );
                scalehalfItem.setText( "1/2x" );
-               scalehalfItem.setData( Scale.HALF );
+               scalehalfItem.setData( 50 );
                scaleList.add( scalehalfItem );
 
                final MenuItem scaleOneQtrItem = new MenuItem( menu, SWT.RADIO );
                scaleOneQtrItem.setText( "1/4x" );
-               scaleOneQtrItem.setData( Scale.ONE_QUARTER );
+               scaleOneQtrItem.setData( 25 );
                scaleList.add( scaleOneQtrItem );
 
-               final short storedScale = config.getPropertyShort( PropertiesConstants.WINDOW_SCALE, Scale.HALF.value() );
+               int storedScale = config.getPropertyInt( PropertiesConstants.WINDOW_SCALE, 100 );
+               //TODO:
+               if (storedScale != 100 && storedScale != 75 && storedScale != 50 && storedScale != 25 ) {
+                       storedScale = 50;
+               }
 
                SelectionAdapter selectionAdapter = new SelectionAdapter() {
 
@@ -908,10 +910,10 @@ public class EmulatorSkin {
                                        return;
                                }
 
-                               Scale scale = (Scale) item.getData();
+                               int scale = (Integer) item.getData();
 
                                arrangeSkin( currentLcdWidth, currentLcdHeight, scale, currentRotationId );
-                               LcdStateData lcdStateData = new LcdStateData( scale.value(), currentRotationId );
+                               LcdStateData lcdStateData = new LcdStateData( scale, currentRotationId );
                                communicator.sendToQEMU( SendCommand.CHANGE_LCD_STATE, lcdStateData );
 
                        }
@@ -919,8 +921,8 @@ public class EmulatorSkin {
 
                for ( MenuItem menuItem : scaleList ) {
 
-                       Scale scale = (Scale) menuItem.getData();
-                       if ( scale.value() == storedScale ) {
+                       int scale = (Integer) menuItem.getData();
+                       if ( scale == storedScale ) {
                                menuItem.setSelection( true );
                        }
 
@@ -938,16 +940,12 @@ public class EmulatorSkin {
 
                final MenuItem screenshotItem = new MenuItem( menu, SWT.PUSH );
                screenshotItem.setText( "Screen Shot" );
+               //FIXME
                screenshotItem.setEnabled( false );
                
                screenshotItem.addSelectionListener( new SelectionAdapter() {
                        @Override
                        public void widgetSelected( SelectionEvent e ) {
-
-                               //TODO
-                               MessageBox messageBox = new MessageBox( shell, SWT.OK | SWT.APPLICATION_MODAL );
-                               messageBox.setMessage( "Under construction..." );
-                               messageBox.open();
                                
 //                             Display display = shell.getDisplay();
 //                             final Image image = new Image( display, lcdCanvas.getBounds() );
@@ -1019,41 +1017,34 @@ public class EmulatorSkin {
                final MenuItem usbOffItem = new MenuItem( usbKeyBoardMenu, SWT.RADIO );
                usbOffItem.setText( "Off" );
                usbOffItem.setSelection( true );
-
-               usbOnItem.setEnabled( false );
-               usbOffItem.setEnabled( false );
                
-//             SelectionAdapter usbSelectionAdaptor = new SelectionAdapter() {
-//                     @Override
-//                     public void widgetSelected( SelectionEvent e ) {
-//                             MenuItem item = (MenuItem) e.getSource();
-//                             if ( item.getSelection() ) {
-//                                     boolean on = item.equals( usbOnItem );
-//                                     communicator
-//                                                     .sendToQEMU( SendCommand.USB_KBD, new BooleanData( on, SendCommand.USB_KBD.toString() ) );
-//                             }
-//
-//                     }
-//             };
-//
-//             usbOnItem.addSelectionListener( usbSelectionAdaptor );
-//             usbOffItem.addSelectionListener( usbSelectionAdaptor );
+               SelectionAdapter usbSelectionAdaptor = new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected( SelectionEvent e ) {
+                               MenuItem item = (MenuItem) e.getSource();
+                               if ( item.getSelection() ) {
+                                       boolean on = item.equals( usbOnItem );
+                                       communicator
+                                                       .sendToQEMU( SendCommand.USB_KBD, new BooleanData( on, SendCommand.USB_KBD.toString() ) );
+                               }
+
+                       }
+               };
+
+               usbOnItem.addSelectionListener( usbSelectionAdaptor );
+               usbOffItem.addSelectionListener( usbSelectionAdaptor );
 
                usbKeyboardItem.setMenu( usbKeyBoardMenu );
 
                final MenuItem aboutItem = new MenuItem( menu, SWT.PUSH );
                aboutItem.setText( "About" );
                aboutItem.setEnabled( false );
-//             aboutItem.addSelectionListener( new SelectionAdapter() {
-//                     @Override
-//                     public void widgetSelected( SelectionEvent e ) {
-//                             // TODO
-//                             MessageBox messageBox = new MessageBox( shell, SWT.OK | SWT.APPLICATION_MODAL );
-//                             messageBox.setText( "About" );
-//                             messageBox.setMessage( "Under construction..." );
-//                             messageBox.open();
-//                     }
-//             } );
+               aboutItem.addSelectionListener( new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected( SelectionEvent e ) {
+                               // TODO
+                       }
+               } );
 
                return menu;
 
@@ -1078,4 +1069,4 @@ public class EmulatorSkin {
 
        }
 
-}
\ No newline at end of file
+}
index 515781c..31f7807 100644 (file)
@@ -36,6 +36,8 @@ import java.net.Socket;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.config.EmulatorConfig;
@@ -43,32 +45,37 @@ import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.dbi.EmulatorUI;
 import org.tizen.emulator.skin.exception.JaxbException;
 import org.tizen.emulator.skin.image.ImageRegistry;
+import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.log.SkinLogger.SkinLogLevel;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.JaxbUtil;
-
-
+import org.tizen.emulator.skin.util.StringUtil;
 
 /**
  * 
  *
  */
 public class EmulatorSkinMain {
-       
+
+       private static Logger logger;
+
        public static final String PROPERTIES_FILE_NAME = ".skin.properties";
        public static final String DBI_FILE_NAME = "default.dbi";
-       
+
        /**
         * @param args
         */
        public static void main( String[] args ) {
 
+               initLog( args );
+
                Map<String, String> argsMap = parsArgs( args );
 
                int lcdWidth = Integer.parseInt( argsMap.get( ArgsConstants.RESOLUTION_WIDTH ) );
                int lcdHeight = Integer.parseInt( argsMap.get( ArgsConstants.RESOLUTION_HEIGHT ) );
                EmulatorUI dbiContents = loadDbi( lcdWidth, lcdHeight );
                if ( null == dbiContents ) {
-                       System.out.println( "Fail to load dbi file." );
+                       logger.severe( "Fail to load dbi file." );
                        return;
                }
 
@@ -76,7 +83,7 @@ public class EmulatorSkinMain {
                String propFilePath = vmPath + File.separator + PROPERTIES_FILE_NAME;
                Properties properties = loadProperties( propFilePath );
                if ( null == properties ) {
-                       System.out.println( "Fail to load properties file." );
+                       logger.severe( "Fail to load properties file." );
                        return;
                }
 
@@ -102,39 +109,68 @@ public class EmulatorSkinMain {
                        skin.open();
 
                } else {
-                       System.out.println( "CommSocket is null." );
+                       logger.severe( "CommSocket is null." );
                }
 
        }
 
+       private static void initLog( String[] args ) {
+
+               String logLevel = "";
+               for ( int i = 0; i < args.length; i++ ) {
+                       String[] split = args[i].split( "=" );
+                       if ( split[0].trim().equalsIgnoreCase( ArgsConstants.LOG_LEVEL ) ) {
+                               if ( !StringUtil.isEmpty( split[1].trim() ) ) {
+                                       logLevel = split[1];
+                                       break;
+                               }
+                       }
+               }
+
+               SkinLogLevel skinLogLevel = SkinLogLevel.DEBUG;
+               
+               if( !StringUtil.isEmpty( logLevel ) ) {
+                       SkinLogLevel[] values = SkinLogLevel.values();
+                       for ( SkinLogLevel level : values ) {
+                               if ( level.value().equalsIgnoreCase( logLevel ) ) {
+                                       skinLogLevel = level;
+                                       break;
+                               }
+                       }
+               }
+
+               SkinLogger.init( skinLogLevel );
+               logger = SkinLogger.getSkinLogger( EmulatorSkinMain.class ).getLogger();
+
+       }
+
        private static Map<String, String> parsArgs( String[] args ) {
 
                Map<String, String> map = new HashMap<String, String>();
 
-               // TODO parse
                for ( int i = 0; i < args.length; i++ ) {
                        String arg = args[i];
-                       System.out.println( "arg[" + i + "] " + arg );
+                       logger.info( "arg[" + i + "] " + arg );
                        String[] split = arg.split( "=" );
 
                        if ( 1 < split.length ) {
 
-                               String argKey = split[0];
-                               String argValue = split[1];
-                               System.out.println( "argKey:" + argKey + "  argValue:" + argValue );
+                               String argKey = split[0].trim();
+                               String argValue = split[1].trim();
+                               logger.info( "argKey:" + argKey + "  argValue:" + argValue );
                                map.put( argKey, argValue );
 
                        } else {
-                               System.out.println( "one argv:" + arg );
+                               logger.info( "one argv:" + arg );
                        }
                }
 
-               map.put( ArgsConstants.EMULATOR_NAME, "emulator" );
-               
-               System.out.println( "========================================");
-               System.out.println( "args:" + map );
-               System.out.println( "========================================");
-               
+               map.put( ArgsConstants.EMULATOR_NAME, "emulator-26100" );
+
+               logger.info( "========================================" );
+               logger.info( "args:" + map );
+               logger.info( "========================================" );
+
                return map;
 
        }
@@ -142,27 +178,26 @@ public class EmulatorSkinMain {
        private static EmulatorUI loadDbi( int lcdWidth, int lcdHeight ) {
 
                String skinPath = ImageRegistry.getSkinPath( lcdWidth, lcdHeight ) + File.separator + DBI_FILE_NAME;
-               
+
                FileInputStream fis = null;
                EmulatorUI emulatorUI = null;
 
                try {
 
                        fis = new FileInputStream( skinPath );
-
+                       
                        emulatorUI = JaxbUtil.unmarshal( fis, EmulatorUI.class );
 
-                       // XXX
                        fis = new FileInputStream( skinPath );
-                       System.out.println( "============ dbi contents ============" );
+                       logger.info( "============ dbi contents ============" );
                        byte[] bytes = IOUtil.getBytes( fis );
-                       System.out.println( new String( bytes, "UTF-8" ) );
-                       System.out.println( "=======================================" );
+                       logger.info( new String( bytes, "UTF-8" ) );
+                       logger.info( "=======================================" );
 
                } catch ( IOException e ) {
-                       e.printStackTrace();
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                } catch ( JaxbException e ) {
-                       e.printStackTrace();
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                } finally {
                        IOUtil.close( fis );
                }
@@ -181,7 +216,7 @@ public class EmulatorSkinMain {
                        File file = new File( filePath );
                        if ( !file.exists() ) {
                                if ( !file.createNewFile() ) {
-                                       System.out.println( "Fail to create new " + filePath + " property file." );
+                                       logger.severe( "Fail to create new " + filePath + " property file." );
                                        return null;
                                }
                        }
@@ -191,7 +226,7 @@ public class EmulatorSkinMain {
                        properties.load( fis );
 
                } catch ( IOException e ) {
-                       e.printStackTrace();
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                } finally {
                        IOUtil.close( fis );
                }
index 995e4d3..70d3ce5 100644 (file)
@@ -37,44 +37,44 @@ import org.tizen.emulator.skin.comm.sock.data.ISendData;
  */
 public interface ICommunicator extends Runnable {
 
-       public enum Scale {
-               ONE( (short)1, (float)1.0 ),
-               THREE_QUARTERS( (short)2, (float)0.75 ),
-               HALF( (short)3, (float)0.5 ),
-               ONE_QUARTER( (short)4, (float)0.25 );
-               
-               private short value;
-               private float ratio;
-               Scale( short value, float ratio ) {
-                       this.value = value;
-                       this.ratio = ratio;
-               }
-               public short value() {
-                       return this.value;
-               }
-               public float ratio() {
-                       return this.ratio;
-               }
-               public static Scale getValue( String val ) {
-                       Scale[] values = Scale.values();
-                       for (int i = 0; i < values.length; i++) {
-                               if( values[i].value == Integer.parseInt( val ) ) {
-                                       return values[i];
-                               }
-                       }
-                       throw new IllegalArgumentException( val );
-               }
-               public static Scale getValue( short val ) {
-                       Scale[] values = Scale.values();
-                       for (int i = 0; i < values.length; i++) {
-                               if( values[i].value == val ) {
-                                       return values[i];
-                               }
-                       }
-                       throw new IllegalArgumentException( Integer.toString(val) );
-               }
-
-       }
+//     public enum Scale {
+//             ONE( (short)1, (float)1.0 ),
+//             THREE_QUARTERS( (short)2, (float)0.75 ),
+//             HALF( (short)3, (float)0.5 ),
+//             ONE_QUARTER( (short)4, (float)0.25 );
+//             
+//             private short value;
+//             private float ratio;
+//             Scale( short value, float ratio ) {
+//                     this.value = value;
+//                     this.ratio = ratio;
+//             }
+//             public short value() {
+//                     return this.value;
+//             }
+//             public float ratio() {
+//                     return this.ratio;
+//             }
+//             public static Scale getValue( String val ) {
+//                     Scale[] values = Scale.values();
+//                     for (int i = 0; i < values.length; i++) {
+//                             if( values[i].value == Integer.parseInt( val ) ) {
+//                                     return values[i];
+//                             }
+//                     }
+//                     throw new IllegalArgumentException( val );
+//             }
+//             public static Scale getValue( short val ) {
+//                     Scale[] values = Scale.values();
+//                     for (int i = 0; i < values.length; i++) {
+//                             if( values[i].value == val ) {
+//                                     return values[i];
+//                             }
+//                     }
+//                     throw new IllegalArgumentException( Integer.toString(val) );
+//             }
+//
+//     }
 
        public enum MouseEventType {
                DOWN( (short)1 ),
index 27bbd22..134ecd2 100644 (file)
@@ -40,6 +40,8 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.tizen.emulator.skin.EmulatorConstants;
 import org.tizen.emulator.skin.EmulatorSkin;
@@ -49,6 +51,7 @@ import org.tizen.emulator.skin.comm.sock.data.StartData;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.config.EmulatorConfig.PropertiesConstants;
+import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.IOUtil;
 
 
@@ -58,6 +61,8 @@ import org.tizen.emulator.skin.util.IOUtil;
  */
 public class SocketCommunicator implements ICommunicator {
 
+       private Logger logger = SkinLogger.getSkinLogger( SocketCommunicator.class ).getLogger();
+       
        private EmulatorConfig config;
        private int uId;
        private int windowHandleId;
@@ -89,12 +94,12 @@ public class SocketCommunicator implements ICommunicator {
                        String portString = config.getArg(ArgsConstants.SERVER_PORT);
                        int port = Integer.parseInt(portString);
                        socket = new Socket("127.0.0.1", port);
-                       System.out.println("socket.isConnected():" + socket.isConnected());
+                       logger.info("socket.isConnected():" + socket.isConnected());
 
                } catch (UnknownHostException e) {
-                       e.printStackTrace();
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                } catch (IOException e) {
-                       e.printStackTrace();
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                }
 
        }
@@ -107,7 +112,11 @@ public class SocketCommunicator implements ICommunicator {
                        dis = new DataInputStream(socket.getInputStream());
                        dos = new DataOutputStream(socket.getOutputStream());
                        
-                       short scale = config.getPropertyShort(PropertiesConstants.WINDOW_SCALE, Scale.HALF.value() );
+                       int scale = config.getPropertyInt(PropertiesConstants.WINDOW_SCALE, 50 );
+                       //TODO:
+                       if (scale != 100 && scale != 75 && scale != 50 && scale != 25 ) {
+                               scale = 50;
+                       }
                        short rotation = config.getPropertyShort( PropertiesConstants.WINDOW_DIRECTION, (short) 0 );
                        
                        sendToQEMU(SendCommand.SEND_START,
@@ -117,7 +126,7 @@ public class SocketCommunicator implements ICommunicator {
                                                        scale, rotation));
 
                } catch (IOException e) {
-                       e.printStackTrace();
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                        terminate();
                        return;
                }
@@ -126,7 +135,7 @@ public class SocketCommunicator implements ICommunicator {
                Boolean ignoreHeartbeat = Boolean.parseBoolean( ignoreHeartbeatString );
                
                if( ignoreHeartbeat ) {
-                       System.out.println( "Ignore Skin heartbeat." );
+                       logger.info( "Ignore Skin heartbeat." );
                }else {
                        
                        heartbeatExecutor.scheduleAtFixedRate(new Runnable() {
@@ -157,25 +166,25 @@ public class SocketCommunicator implements ICommunicator {
                                int reqId = dis.readInt();
                                short cmd = dis.readShort();
 
-                               System.out.print( "= Socket read - reqId:" + reqId + ", command:" + cmd + ", " );
+                               logger.fine( "Socket read - reqId:" + reqId + ", command:" + cmd + ", " );
 
                                ReceiveCommand command = null;
                                
                                try {
                                        command = ReceiveCommand.getValue( cmd );
                                } catch ( IllegalArgumentException e ) {
-                                       System.out.println( "unknown command:" + cmd );
+                                       logger.severe( "unknown command:" + cmd );
                                        continue;
                                }
 
                                switch ( command ) {
                                case HEART_BEAT:
                                        resetHeartbeatCount();
-                                       System.out.println( "received HEAR_BEAT from QEMU." );
+                                       logger.info( "received HEAR_BEAT from QEMU." );
                                        sendToQEMU( SendCommand.RESPONSE_HEART_BEAT, null );
                                        break;
                                case SENSOR_DAEMON_START:
-                                       System.out.println( "received SENSOR_DAEMON_START from QEMU." );
+                                       logger.info( "received SENSOR_DAEMON_START from QEMU." );
                                        synchronized ( this ) {
                                                isSensorDaemonStarted = true;
                                        }
@@ -190,7 +199,7 @@ public class SocketCommunicator implements ICommunicator {
                                }
 
                        } catch ( IOException e ) {
-                               e.printStackTrace();
+                               logger.log( Level.SEVERE, e.getMessage(), e );
                                break;
                        }
 
@@ -229,17 +238,16 @@ public class SocketCommunicator implements ICommunicator {
                        dos.write(bao.toByteArray());
                        dos.flush();
 
-                       System.out.println("= Socket write - uid:" + uId + ", reqId:" + reqId +
-                                       ", command:" + command.value() + " - " + command.toString() + ", length:" + length );
+                       logger.fine( "Socket write - uid:" + uId + ", reqId:" + reqId + ", command:" + command.value() + " - "
+                                       + command.toString() + ", length:" + length );
 
-                       if (0 < length) {
-                               System.out.println("== data ==");
-                               System.out.println(data);
+                       if ( 0 < length ) {
+                               logger.fine( "== data ==" );
+                               logger.fine( data.toString() );
                        }
 
-               } catch (IOException e) {
-                       System.err.println("Fail to write socket.");
-                       e.printStackTrace();
+               } catch ( IOException e ) {
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                }
 
        }
@@ -254,7 +262,7 @@ public class SocketCommunicator implements ICommunicator {
 
        private void increaseHeartbeatCount() {
                int count = heartbeatCount.incrementAndGet();
-               System.out.println("HB count : " + count);
+               logger.fine("HB count : " + count);
        }
 
        private boolean isHeartbeatExpired() {
index d88cdca..190b4cc 100644 (file)
@@ -37,17 +37,17 @@ import java.io.IOException;
  */
 public class LcdStateData extends AbstractSendData {
        
-       short scale;
+       int scale;
        short rotation;
        
-       public LcdStateData(short scale, short rotation) {
+       public LcdStateData(int scale, short rotation) {
                this.scale = scale;
                this.rotation = rotation;
        }
 
        @Override
        protected void write() throws IOException {
-               writeShort(scale);
+               writeInt(scale);
                writeShort(rotation);
        }
 
index 9d776c8..99fe508 100644 (file)
@@ -40,10 +40,10 @@ public class StartData extends AbstractSendData {
        private int windowHandleId;
        private int lcdSizeWidth;
        private int lcdSizeHeight;
-       private short scale;
+       private int scale;
        private short rotation;
        
-       public StartData(int windowHandleId, int lcdSizeWidth, int lcdSizeHeight, short scale, short rotation ) {
+       public StartData(int windowHandleId, int lcdSizeWidth, int lcdSizeHeight, int scale, short rotation ) {
                this.windowHandleId = windowHandleId;
                this.lcdSizeWidth = lcdSizeWidth;
                this.lcdSizeHeight = lcdSizeHeight;
@@ -56,7 +56,7 @@ public class StartData extends AbstractSendData {
                writeInt( windowHandleId );
                writeInt( lcdSizeWidth );
                writeInt( lcdSizeHeight );
-               writeShort( scale );
+               writeInt( scale );
                writeShort( rotation );
        }
 
index 4e904f8..49551e0 100644 (file)
@@ -33,8 +33,11 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Map;
 import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.tizen.emulator.skin.dbi.EmulatorUI;
+import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.StringUtil;
 
@@ -45,8 +48,9 @@ import org.tizen.emulator.skin.util.StringUtil;
  */
 public class EmulatorConfig {
        
+       private Logger logger = SkinLogger.getSkinLogger( EmulatorConfig.class ).getLogger();
+       
        public interface ArgsConstants {
-               //TODO change as input args
                public static final String UID = "uid";
                public static final String SERVER_PORT = "svr.port";
                public static final String RESOLUTION_WIDTH = "width";
@@ -54,6 +58,7 @@ public class EmulatorConfig {
                public static final String EMULATOR_NAME = "emulname";
                public static final String TEST_HEART_BEAT_IGNORE = "test.hb.ignore";
                public static final String VM_PATH = "vm.path";
+               public static final String LOG_LEVEL = "log.level";
        }
        
        public interface PropertiesConstants {
@@ -85,7 +90,7 @@ public class EmulatorConfig {
                        properties.store( fos, "Generated automatically by emulator." );
                        
                } catch ( IOException e ) {
-                       e.printStackTrace();
+                       logger.log( Level.SEVERE, e.getMessage(), e );
                } finally {
                        IOUtil.close( fos );
                }
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java
new file mode 100644 (file)
index 0000000..777bab3
--- /dev/null
@@ -0,0 +1,145 @@
+/**
+ * 
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyunjun Son <hj79.son@samsung.com>
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@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.log;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
+
+/**
+ * 
+ *
+ */
+public class SkinLogger {
+       
+       public enum SkinLogLevel {
+               
+               ERROR(Level.SEVERE, "error"),
+               WARN(Level.WARNING, "warn"),
+               DEBUG(Level.INFO, "debug"),
+               TRACE(Level.FINE, "trace");
+               
+               private Level level;
+               private String value;
+               private SkinLogLevel( Level level, String value ) {
+                       this.level = level;
+                       this.value = value;
+               }
+               public Level level() {
+                       return this.level;
+               }
+               public String value() {
+                       return this.value;
+               }
+       }
+       
+       private static final String FILE_NAME = "emulator-skin.log";
+       
+       private static FileHandler fileHandler;
+       private static boolean isInit;
+       private static Map<Class<?>, SkinLogger> loggerMap = new HashMap<Class<?>, SkinLogger>();
+       
+       private Logger logger;
+       
+       private SkinLogger( Logger logger ) {
+               this.logger = logger;
+       }
+       
+       public Logger getLogger() {
+               return this.logger;
+       }
+       
+       public static void init( SkinLogLevel logLevel ) {
+               
+               if( !isInit ) {
+                       
+                       isInit = true;
+
+                       try {
+                               fileHandler = new FileHandler( FILE_NAME, false );
+                       } catch ( SecurityException e1 ) {
+                               e1.printStackTrace();
+                       } catch ( IOException e1 ) {
+                               e1.printStackTrace();
+                       }
+
+                       try {
+                               fileHandler.setEncoding( "UTF-8" );
+                       } catch ( SecurityException e ) {
+                               e.printStackTrace();
+                       } catch ( UnsupportedEncodingException e ) {
+                               e.printStackTrace();
+                       }
+                       
+                       SimpleFormatter simpleFormatter = new SimpleFormatter();
+                       fileHandler.setFormatter( simpleFormatter );
+                       
+                       fileHandler.setLevel( logLevel.level() );
+                       
+               }
+               
+       }
+       
+       public static <T> SkinLogger getSkinLogger( Class<T> clazz ) {
+               
+               String name = null;
+               
+               if( null == clazz ) {
+                       name = SkinLogger.class.getSimpleName();
+               }else {
+                       name = clazz.getSimpleName();
+               }
+               
+               SkinLogger skinLogger = loggerMap.get( clazz );
+               
+               if( null != skinLogger ) {
+                       return skinLogger;
+               }else {
+                       
+                       Logger logger = Logger.getLogger( name );
+                       logger.addHandler( fileHandler );
+                       logger.setLevel( fileHandler.getLevel() );
+                       logger.setUseParentHandlers( false );
+                       
+                       SkinLogger sLogger = new SkinLogger( logger );
+                       loggerMap.put( clazz, sLogger );
+                       
+                       return sLogger;
+                       
+               }
+               
+       }
+
+}
index c7e9919..444ec7a 100644 (file)
@@ -48,8 +48,8 @@ public class SkinRotation {
        public enum RotationInfo {
 
                PORTRAIT( RotationNameType.PORTRAIT.value(), (short)0, 0 ),
-               REVERSE_PORTRAIT( RotationNameType.REVERSE_PORTRAIT.value(), (short)1, 180 ),
-               LANDSCAPE( RotationNameType.LANDSCAPE.value(), (short)2, -90 ),
+               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;