emulator-skin

16:35:36.570 INFO  jd.cli.Main - Decompiling emulator-skin.jar
package org.tizen.emulator.skin;

public class EmulatorFingers$FingerPoint
{
  int id;
  int originX;
  int originY;
  int x;
  int y;
  
  EmulatorFingers$FingerPoint(EmulatorFingers paramEmulatorFingers, int originX, int originY, int x, int y)
  {
    this.originX = originX;
    this.originY = (-originY);
    this.x = x;
    this.y = y;
  }
  
  EmulatorFingers$FingerPoint(EmulatorFingers paramEmulatorFingers, int id, int originX, int originY, int x, int y)
  {
    this.id = id;
    this.originX = originX;
    this.originY = (-originY);
    this.x = x;
    this.y = y;
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorFingers.FingerPoint
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import java.util.ArrayList;
import java.util.logging.Logger;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.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.log.SkinLogger;

public class EmulatorFingers
{
  private static final int MAX_FINGER_CNT = 10;
  private static final int RED_MASK = 65280;
  private static final int GREEN_MASK = 16711680;
  private static final int BLUE_MASK = -16777216;
  private static final int COLOR_DEPTH = 32;
  private Logger logger = SkinLogger.getSkinLogger(EmulatorFingers.class).getLogger();
  private int multiTouchEnable;
  private int maxTouchPoint;
  protected int fingerCnt;
  private int fingerCntMax;
  protected int fingerPointSize;
  protected int fingerPointSizeHalf;
  private Color fingerPointColor;
  private Color fingerPointOutlineColor;
  private int grabFingerID = 0;
  protected Image fingerSlotimage;
  protected ImageData imageData;
  protected FingerPoint fingerSlot;
  protected SocketCommunicator communicator;
  protected EmulatorSkin emulatorSkin;
  ArrayList<FingerPoint> FingerPointList;
  EmulatorSkinState currentState;
  
  EmulatorFingers(EmulatorSkinState currentState)
  {
    this.currentState = currentState;
    initMultiTouchState();
  }
  
  protected void setCommunicator(SocketCommunicator communicator)
  {
    this.communicator = communicator;
  }
  
  protected class FingerPoint
  {
    int id;
    int originX;
    int originY;
    int x;
    int y;
    
    FingerPoint(int originX, int originY, int x, int y)
    {
      this.originX = originX;
      this.originY = (-originY);
      this.x = x;
      this.y = y;
    }
    
    FingerPoint(int id, int originX, int originY, int x, int y)
    {
      this.id = id;
      this.originX = originX;
      this.originY = (-originY);
      this.x = x;
      this.y = y;
    }
  }
  
  public FingerPoint getFingerPointFromSlot(int index)
  {
    if ((index < 0) || (index > fingerCntMax)) {
      return null;
    }
    return (FingerPoint)FingerPointList.get(index);
  }
  
  public FingerPoint getFingerPointSearch(int x, int y)
  {
    FingerPoint fingerPoint = null;
    int fingerRegion = fingerPointSize + 2;
    for (int i = fingerCnt - 1; i >= 0; i--)
    {
      fingerPoint = getFingerPointFromSlot(i);
      if ((fingerPoint != null) && 
        (x >= x - fingerRegion) && (x < x + fingerRegion) && (y >= y - fingerRegion) && (y < y + fingerRegion)) {
        return fingerPoint;
      }
    }
    return null;
  }
  
  protected void setEmulatorSkin(EmulatorSkin emulatorSkin)
  {
    this.emulatorSkin = emulatorSkin;
  }
  
  public void initMultiTouchState()
  {
    multiTouchEnable = 0;
    fingerCntMax = currentState.getMaxTouchPoint();
    if (fingerCntMax > 10)
    {
      fingerCntMax = 10;
      setMaxTouchPoint(fingerCntMax);
    }
    logger.info("maxTouchPoint=" + fingerCntMax);
    fingerCnt = 0;
    if (fingerSlot != null) {
      fingerSlot = null;
    }
    FingerPointList = new ArrayList();
    for (int i = 0; i <= fingerCntMax; i++) {
      FingerPointList.add(new FingerPoint(-1, -1, -1, -1));
    }
    fingerPointSize = 32;
    fingerPointSizeHalf = (fingerPointSize / 2);
    
    fingerPointOutlineColor = new Color(Display.getCurrent(), 221, 221, 221);
    fingerPointColor = new Color(Display.getCurrent(), 15, 15, 15);
    PaletteData palette = new PaletteData(65280, 16711680, -16777216);
    
    imageData = new ImageData(fingerPointSize + 4, fingerPointSize + 4, 32, palette);
    
    imageData.transparentPixel = 0;
    fingerSlotimage = new Image(Display.getCurrent(), imageData);
    
    GC gc = new GC(fingerSlotimage);
    
    gc.setForeground(fingerPointOutlineColor);
    gc.drawOval(0, 0, fingerPointSize + 2, fingerPointSize + 2);
    
    gc.setBackground(fingerPointColor);
    gc.fillOval(2, 2, fingerPointSize, fingerPointSize);
    
    gc.dispose();
  }
  
  public void setMultiTouchEnable(int multiTouchEnable)
  {
    this.multiTouchEnable = multiTouchEnable;
  }
  
  public int getMultiTouchEnable()
  {
    return multiTouchEnable;
  }
  
  protected int addFingerPoint(int originX, int originY, int x, int y)
  {
    if (fingerCnt == fingerCntMax)
    {
      logger.info("support multi-touch up to " + fingerCntMax + " fingers");
      
      return -1;
    }
    fingerCnt += 1;
    
    FingerPointList.get(fingerCnt - 1)).id = fingerCnt;
    FingerPointList.get(fingerCnt - 1)).originX = originX;
    FingerPointList.get(fingerCnt - 1)).originY = originY;
    FingerPointList.get(fingerCnt - 1)).x = x;
    FingerPointList.get(fingerCnt - 1)).y = y;
    logger.info(fingerCnt + " finger touching");
    
    return fingerCnt;
  }
  
  protected void drawImage(PaintEvent e, int currentAngle)
  {
    for (int i = 0; i < fingerCnt; i++)
    {
      fingerSlot = getFingerPointFromSlot(i);
      gc.setAlpha(126);
      
      gc.drawImage(fingerSlotimage, fingerSlot.originX - fingerPointSizeHalf - 2, fingerSlot.originY - fingerPointSizeHalf - 2);
      
      gc.setAlpha(255);
    }
  }
  
  public void maruFingerProcessing1(int touchType, int originX, int originY, int x, int y)
  {
    FingerPoint finger = null;
    if ((touchType == ICommunicator.MouseEventType.PRESS.value()) || (touchType == ICommunicator.MouseEventType.DRAG.value()))
    {
      if (grabFingerID > 0)
      {
        finger = getFingerPointFromSlot(grabFingerID - 1);
        if (finger != null)
        {
          originX = originX;
          originY = originY;
          x = x;
          y = y;
          if (id != 0)
          {
            logger.info(String.format("id %d finger multi-touch dragging = (%d, %d)", new Object[] { Integer.valueOf(grabFingerID), Integer.valueOf(x), Integer.valueOf(y) }));
            
            MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.PRESS.value(), originX, originY, x, y, grabFingerID - 1);
            
            communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
          }
        }
        return;
      }
      if (fingerCnt == 0)
      {
        if (addFingerPoint(originX, originY, x, y) == -1) {
          return;
        }
        MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.PRESS.value(), originX, originY, x, y, 0);
        
        communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
      }
      else if ((finger = getFingerPointSearch(x, y)) != null)
      {
        grabFingerID = id;
        logger.info(String.format("id %d finger is grabbed\n", new Object[] { Integer.valueOf(grabFingerID) }));
      }
      else if (fingerCnt == fingerCntMax)
      {
        finger = getFingerPointFromSlot(fingerCntMax - 1);
        if (finger != null)
        {
          MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.RELEASE.value(), originX, originY, x, y, fingerCntMax - 1);
          
          communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
          
          originX = originX;
          originY = originY;
          x = x;
          y = y;
          if (id != 0)
          {
            mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.PRESS.value(), originX, originY, x, y, fingerCntMax - 1);
            
            communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
          }
        }
      }
      else
      {
        addFingerPoint(originX, originY, x, y);
        MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.PRESS.value(), originX, originY, x, y, fingerCnt - 1);
        
        communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
      }
    }
    else if (touchType == ICommunicator.MouseEventType.RELEASE.value())
    {
      logger.info("mouse up for multi touch");
      grabFingerID = 0;
    }
  }
  
  public void maruFingerProcessing2(int touchType, int originX, int originY, int x, int y)
  {
    FingerPoint finger = null;
    if ((touchType == ICommunicator.MouseEventType.PRESS.value()) || (touchType == ICommunicator.MouseEventType.DRAG.value()))
    {
      if (grabFingerID > 0)
      {
        finger = getFingerPointFromSlot(grabFingerID - 1);
        if (finger != null)
        {
          int originDistanceX = originX - originX;
          int originDistanceY = originY - originY;
          int distanceX = x - x;
          int distanceY = y - y;
          
          int currrntScreenW = currentState.getCurrentResolutionWidth();
          int currrntScreenH = currentState.getCurrentResolutionHeight();
          for (int i = 0; i < fingerCnt; i++)
          {
            finger = getFingerPointFromSlot(i);
            if (finger != null)
            {
              int tempFingerX = x + distanceX;
              int tempFingerY = y + distanceY;
              if ((tempFingerX > currrntScreenW) || (tempFingerX < 0) || (tempFingerY > currrntScreenH) || (tempFingerY < 0))
              {
                logger.info(String.format("id %d finger is out of bounds (%d, %d)\n", new Object[] { Integer.valueOf(i + 1), Integer.valueOf(tempFingerX), Integer.valueOf(tempFingerY) }));
                
                return;
              }
            }
          }
          for (i = 0; i < fingerCnt; i++)
          {
            finger = getFingerPointFromSlot(i);
            if (finger != null)
            {
              originX += originDistanceX;
              originY += originDistanceY;
              x += distanceX;
              y += distanceY;
              if (id != 0)
              {
                MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.PRESS.value(), originX, originY, x, y, i);
                
                communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
              }
              try
              {
                Thread.sleep(2L);
              }
              catch (InterruptedException e)
              {
                e.printStackTrace();
              }
            }
          }
        }
        return;
      }
      if (fingerCnt == 0)
      {
        if (addFingerPoint(originX, originY, x, y) == -1) {
          return;
        }
        MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.PRESS.value(), originX, originY, x, y, 0);
        
        communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
      }
      else if ((finger = getFingerPointSearch(x, y)) != null)
      {
        grabFingerID = id;
        logger.info(String.format("id %d finger is grabbed\n", new Object[] { Integer.valueOf(grabFingerID) }));
      }
      else if (fingerCnt != fingerCntMax)
      {
        addFingerPoint(originX, originY, x, y);
        MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.PRESS.value(), originX, originY, x, y, fingerCnt - 1);
        
        communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
      }
    }
    else if (touchType == ICommunicator.MouseEventType.RELEASE.value())
    {
      logger.info("mouse up for multi touch");
      grabFingerID = 0;
    }
  }
  
  private Boolean CalculateOriginCoordinates(int ScaledLcdWitdh, int ScaledLcdHeight, double scaleFactor, int rotationType, FingerPoint finger)
  {
    int flag = 0;
    int pointX;
    int rotatedPointX = pointX = (int)(x * scaleFactor);
    int pointY;
    int rotatedPointY = pointY = (int)(y * scaleFactor);
    if (rotationType == ICommunicator.RotationInfo.LANDSCAPE.id())
    {
      rotatedPointX = pointY;
      rotatedPointY = ScaledLcdWitdh - pointX;
    }
    else if (rotationType == ICommunicator.RotationInfo.REVERSE_PORTRAIT.id())
    {
      rotatedPointX = ScaledLcdWitdh - pointX;
      rotatedPointY = ScaledLcdHeight - pointY;
    }
    else if (rotationType == ICommunicator.RotationInfo.REVERSE_LANDSCAPE.id())
    {
      rotatedPointX = ScaledLcdHeight - pointY;
      rotatedPointY = pointX;
    }
    if (originX != rotatedPointX)
    {
      logger.info("finger.originX: " + originX);
      originX = rotatedPointX;
      flag = 1;
    }
    if (originY != rotatedPointY)
    {
      logger.info("finger.originY: " + originY);
      originY = rotatedPointY;
      flag = 1;
    }
    if (flag != 0) {
      return Boolean.valueOf(true);
    }
    return Boolean.valueOf(false);
  }
  
  public int rearrangeFingerPoints(int lcdWidth, int lcdHeight, double scaleFactor, int rotationType)
  {
    int i = 0;
    int count = 0;
    FingerPoint finger = null;
    if (multiTouchEnable == 0) {
      return 0;
    }
    scaleFactor /= 100.0D;
    lcdWidth = (int)(lcdWidth * scaleFactor);
    lcdHeight = (int)(lcdHeight * scaleFactor);
    for (i = 0; i < fingerCnt; i++)
    {
      finger = getFingerPointFromSlot(i);
      if ((finger != null) && (id != 0) && 
        (CalculateOriginCoordinates(lcdWidth, lcdHeight, scaleFactor, rotationType, finger).booleanValue() == true)) {
        count++;
      }
    }
    return count;
  }
  
  public void clearFingerSlot()
  {
    int i = 0;
    FingerPoint finger = null;
    for (i = 0; i < fingerCnt; i++)
    {
      finger = getFingerPointFromSlot(i);
      if ((finger != null) && (id != 0))
      {
        logger.info(String.format("clear %d, %d, %d", new Object[] { Integer.valueOf(x), Integer.valueOf(y), Integer.valueOf(id - 1) }));
        
        MouseEventData mouseEventData = new MouseEventData(ICommunicator.MouseButtonType.LEFT.value(), ICommunicator.MouseEventType.RELEASE.value(), 0, 0, x, y, id - 1);
        
        communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
      }
      id = 0;
      originX = (originY = x = y = -1);
    }
    grabFingerID = 0;
    fingerCnt = 0;
    logger.info("clear multi touch");
  }
  
  public void cleanup_multiTouchState()
  {
    multiTouchEnable = 0;
    clearFingerSlot();
    fingerSlotimage.dispose();
  }
  
  public int getMaxTouchPoint()
  {
    if (maxTouchPoint <= 0) {
      setMaxTouchPoint(1);
    }
    return maxTouchPoint;
  }
  
  public void setMaxTouchPoint(int cnt)
  {
    if (cnt <= 0) {
      cnt = 1;
    }
    maxTouchPoint = cnt;
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorFingers
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import java.lang.reflect.Field;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.swt.SWT;
import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
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.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.info.SkinInformation;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.screenshot.ScreenShotDialog;
import org.tizen.emulator.skin.screenshot.SdlScreenShotWindow;
import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.SwtUtil;

public class EmulatorSdlSkin
  extends EmulatorSkin
{
  private Logger logger = SkinLogger.getSkinLogger(EmulatorSdlSkin.class).getLogger();
  
  public EmulatorSdlSkin(EmulatorSkinState state, EmulatorFingers finger, EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop)
  {
    super(state, finger, config, skinInfo, 16777216, isOnTop);
  }
  
  public long initLayout()
  {
    super.initLayout();
    
    return getWindowHandleId();
  }
  
  private long getWindowHandleId()
  {
    long windowHandleId = 0L;
    if (SwtUtil.isLinuxPlatform())
    {
      try
      {
        Field field = lcdCanvas.getClass().getField("embeddedHandle");
        windowHandleId = field.getLong(lcdCanvas);
        logger.info("lcdCanvas.embeddedHandle:" + windowHandleId);
      }
      catch (IllegalArgumentException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
      catch (IllegalAccessException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
      catch (SecurityException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
      catch (NoSuchFieldException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
    }
    else if (SwtUtil.isWindowsPlatform())
    {
      try
      {
        Field field = lcdCanvas.getClass().getField("handle");
        windowHandleId = field.getLong(lcdCanvas);
        logger.info("lcdCanvas.handle:" + windowHandleId);
      }
      catch (IllegalArgumentException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
      catch (IllegalAccessException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
      catch (SecurityException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
      catch (NoSuchFieldException e)
      {
        logger.log(Level.SEVERE, e.getMessage(), e);
        shutdown();
      }
    }
    else if (SwtUtil.isMacPlatform())
    {
      windowHandleId = 0L;
    }
    else
    {
      logger.severe("Not Supported OS platform:" + SWT.getPlatform());
      System.exit(-1);
    }
    return windowHandleId;
  }
  
  public void displayOn()
  {
    logger.info("display on");
  }
  
  public void displayOff()
  {
    logger.info("display off");
    if (isDisplayDragging == true)
    {
      logger.info("auto release : mouseEvent");
      MouseEventData mouseEventData = new MouseEventData(0, ICommunicator.MouseEventType.RELEASE.value(), 0, 0, 0, 0, 0);
      
      communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
    }
  }
  
  protected void openScreenShotWindow()
  {
    if (screenShotDialog != null)
    {
      logger.info("screenshot window was already opened");
      return;
    }
    try
    {
      screenShotDialog = new SdlScreenShotWindow(shell, communicator, this, config, imageRegistry.getIcon(ImageRegistry.IconName.SCREENSHOT));
      
      screenShotDialog.open();
    }
    catch (ScreenShotException ex)
    {
      screenShotDialog = null;
      logger.log(Level.SEVERE, ex.getMessage(), ex);
      
      SkinUtil.openMessage(shell, null, "Fail to create a screen shot.", 1, config);
    }
    catch (Exception ex)
    {
      screenShotDialog = null;
      logger.log(Level.SEVERE, ex.getMessage(), ex);
      
      SkinUtil.openMessage(shell, null, "ScreenShot is not ready.\nPlease wait until the emulator is completely boot up.", 8, config);
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorSdlSkin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import java.util.logging.Logger;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Canvas;

class EmulatorShmSkin$1
  implements PaintListener
{
  EmulatorShmSkin$1(EmulatorShmSkin paramEmulatorShmSkin) {}
  
  public void paintControl(PaintEvent e)
  {
    int x = this$0.lcdCanvas.getSize().x;
    int y = this$0.lcdCanvas.getSize().y;
    if (EmulatorShmSkin.access$500(this$0).getWaitIntervalTime() == 0)
    {
      EmulatorShmSkin.access$400(this$0).info("draw black screen");
      
      gc.drawRectangle(-1, -1, x + 1, y + 1);
      return;
    }
    if (this$0.currentState.getCurrentAngle() == 0)
    {
      gc.drawImage(EmulatorShmSkin.PollFBThread.access$100(EmulatorShmSkin.access$500(this$0)), 0, 0, EmulatorShmSkin.PollFBThread.access$600(EmulatorShmSkin.access$500(this$0)), EmulatorShmSkin.PollFBThread.access$700(EmulatorShmSkin.access$500(this$0)), 0, 0, x, y);
      if ((this$0.finger.getMultiTouchEnable() == 1) || (this$0.finger.getMultiTouchEnable() == 2)) {
        this$0.finger.rearrangeFingerPoints(this$0.currentState.getCurrentResolutionWidth(), this$0.currentState.getCurrentResolutionHeight(), this$0.currentState.getCurrentScale(), this$0.currentState.getCurrentRotationId());
      }
      this$0.finger.drawImage(e, this$0.currentState.getCurrentAngle());
      return;
    }
    Transform transform = new Transform(this$0.lcdCanvas.getDisplay());
    Transform oldtransform = new Transform(this$0.lcdCanvas.getDisplay());
    transform.rotate(this$0.currentState.getCurrentAngle());
    if (this$0.currentState.getCurrentAngle() == 90)
    {
      int temp = x;
      x = y;
      y = temp;
      transform.translate(0.0F, y * -1);
    }
    else if (this$0.currentState.getCurrentAngle() == 180)
    {
      transform.translate(x * -1, y * -1);
    }
    else if (this$0.currentState.getCurrentAngle() == -90)
    {
      int temp = x;
      x = y;
      y = temp;
      transform.translate(x * -1, 0.0F);
    }
    if (this$0.finger.getMultiTouchEnable() == 1) {
      this$0.finger.rearrangeFingerPoints(this$0.currentState.getCurrentResolutionWidth(), this$0.currentState.getCurrentResolutionHeight(), this$0.currentState.getCurrentScale(), this$0.currentState.getCurrentRotationId());
    }
    gc.getTransform(oldtransform);
    
    gc.setTransform(transform);
    gc.drawImage(EmulatorShmSkin.PollFBThread.access$100(EmulatorShmSkin.access$500(this$0)), 0, 0, EmulatorShmSkin.PollFBThread.access$600(EmulatorShmSkin.access$500(this$0)), EmulatorShmSkin.PollFBThread.access$700(EmulatorShmSkin.access$500(this$0)), 0, 0, x, y);
    
    gc.setTransform(oldtransform);
    
    transform.dispose();
    this$0.finger.drawImage(e, this$0.currentState.getCurrentAngle());
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorShmSkin.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import org.eclipse.swt.widgets.Canvas;

class EmulatorShmSkin$2
  implements Runnable
{
  EmulatorShmSkin$2(EmulatorShmSkin paramEmulatorShmSkin) {}
  
  public void run()
  {
    this$0.lcdCanvas.redraw();
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorShmSkin.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import org.eclipse.swt.widgets.Canvas;

class EmulatorShmSkin$PollFBThread$1
  implements Runnable
{
  EmulatorShmSkin$PollFBThread$1(EmulatorShmSkin.PollFBThread paramPollFBThread, EmulatorShmSkin paramEmulatorShmSkin) {}
  
  public void run()
  {
    if (!this$1.this$0.lcdCanvas.isDisposed()) {
      this$1.this$0.lcdCanvas.redraw();
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorShmSkin.PollFBThread.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import org.eclipse.swt.graphics.Image;

class EmulatorShmSkin$PollFBThread$2
  implements Runnable
{
  EmulatorShmSkin$PollFBThread$2(EmulatorShmSkin.PollFBThread paramPollFBThread) {}
  
  public void run()
  {
    EmulatorShmSkin.PollFBThread.access$100(this$1).dispose();
    EmulatorShmSkin.PollFBThread.access$102(this$1, new Image(EmulatorShmSkin.PollFBThread.access$200(this$1), EmulatorShmSkin.PollFBThread.access$300(this$1)));
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorShmSkin.PollFBThread.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import java.util.logging.Logger;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;

class EmulatorShmSkin$PollFBThread
  extends Thread
{
  private Display display;
  private int widthFB;
  private int heightFB;
  private int[] arrayFramebuffer;
  private ImageData imageData;
  private Image framebuffer;
  private volatile boolean stopRequest;
  private Runnable runnable;
  private int intervalWait;
  
  public EmulatorShmSkin$PollFBThread(final EmulatorShmSkin paramEmulatorShmSkin, int widthFB, int heightFB)
  {
    display = Display.getDefault();
    this.widthFB = widthFB;
    this.heightFB = heightFB;
    arrayFramebuffer = new int[widthFB * heightFB];
    imageData = new ImageData(widthFB, heightFB, 24, EmulatorShmSkin.access$000(paramEmulatorShmSkin));
    framebuffer = new Image(Display.getDefault(), imageData);
    
    setDaemon(true);
    setWaitIntervalTime(30);
    
    runnable = new Runnable()
    {
      public void run()
      {
        if (!this$0.lcdCanvas.isDisposed()) {
          this$0.lcdCanvas.redraw();
        }
      }
    };
  }
  
  public synchronized void setWaitIntervalTime(int ms)
  {
    intervalWait = ms;
  }
  
  public synchronized int getWaitIntervalTime()
  {
    return intervalWait;
  }
  
  public void run()
  {
    stopRequest = false;
    
    int sizeFramebuffer = widthFB * heightFB;
    while (!stopRequest)
    {
      synchronized (this)
      {
        try
        {
          wait(intervalWait);
        }
        catch (InterruptedException e)
        {
          e.printStackTrace();
          break;
        }
      }
      int result = this$0.getPixels(arrayFramebuffer);
      
      imageData.setPixels(0, 0, sizeFramebuffer, arrayFramebuffer, 0);
      
      display.syncExec(new Runnable()
      {
        public void run()
        {
          framebuffer.dispose();
          framebuffer = new Image(display, imageData);
        }
      });
      if (!display.isDisposed()) {
        display.asyncExec(runnable);
      }
    }
    EmulatorShmSkin.access$400(this$0).info("PollFBThread is stopped");
    
    int result = this$0.shmdt();
    EmulatorShmSkin.access$400(this$0).info("shmdt native function returned " + result);
  }
  
  public void stopRequest()
  {
    stopRequest = true;
    synchronized (EmulatorShmSkin.access$500(this$0))
    {
      EmulatorShmSkin.access$500(this$0).notify();
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorShmSkin.PollFBThread
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType;
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.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.info.SkinInformation;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.screenshot.ScreenShotDialog;
import org.tizen.emulator.skin.screenshot.ShmScreenShotWindow;
import org.tizen.emulator.skin.util.SkinUtil;

public class EmulatorShmSkin
  extends EmulatorSkin
{
  private Logger logger = SkinLogger.getSkinLogger(EmulatorShmSkin.class).getLogger();
  public static final int RED_MASK = 16711680;
  public static final int GREEN_MASK = 65280;
  public static final int BLUE_MASK = 255;
  public static final int COLOR_DEPTH = 24;
  private PaletteData paletteData;
  private PollFBThread pollThread;
  public native int shmget(int paramInt1, int paramInt2);
  
  public native int shmdt();
  
  public native int getPixels(int[] paramArrayOfInt);
  
  class PollFBThread
    extends Thread
  {
    private Display display;
    private int widthFB;
    private int heightFB;
    private int[] arrayFramebuffer;
    private ImageData imageData;
    private Image framebuffer;
    private volatile boolean stopRequest;
    private Runnable runnable;
    private int intervalWait;
    
    public PollFBThread(int widthFB, int heightFB)
    {
      display = Display.getDefault();
      this.widthFB = widthFB;
      this.heightFB = heightFB;
      arrayFramebuffer = new int[widthFB * heightFB];
      imageData = new ImageData(widthFB, heightFB, 24, paletteData);
      framebuffer = new Image(Display.getDefault(), imageData);
      
      setDaemon(true);
      setWaitIntervalTime(30);
      
      runnable = new Runnable()
      {
        public void run()
        {
          if (!lcdCanvas.isDisposed()) {
            lcdCanvas.redraw();
          }
        }
      };
    }
    
    public synchronized void setWaitIntervalTime(int ms)
    {
      intervalWait = ms;
    }
    
    public synchronized int getWaitIntervalTime()
    {
      return intervalWait;
    }
    
    public void run()
    {
      stopRequest = false;
      
      int sizeFramebuffer = widthFB * heightFB;
      while (!stopRequest)
      {
        synchronized (this)
        {
          try
          {
            wait(intervalWait);
          }
          catch (InterruptedException e)
          {
            e.printStackTrace();
            break;
          }
        }
        int result = getPixels(arrayFramebuffer);
        
        imageData.setPixels(0, 0, sizeFramebuffer, arrayFramebuffer, 0);
        
        display.syncExec(new Runnable()
        {
          public void run()
          {
            framebuffer.dispose();
            framebuffer = new Image(display, imageData);
          }
        });
        if (!display.isDisposed()) {
          display.asyncExec(runnable);
        }
      }
      logger.info("PollFBThread is stopped");
      
      int result = shmdt();
      logger.info("shmdt native function returned " + result);
    }
    
    public void stopRequest()
    {
      stopRequest = true;
      synchronized (pollThread)
      {
        pollThread.notify();
      }
    }
  }
  
  public EmulatorShmSkin(EmulatorSkinState state, EmulatorFingers finger, EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop)
  {
    super(state, finger, config, skinInfo, 0, isOnTop);
    paletteData = new PaletteData(16711680, 65280, 255);
  }
  
  protected void skinFinalize()
  {
    pollThread.stopRequest();
    
    finger.setMultiTouchEnable(0);
    finger.clearFingerSlot();
    finger.cleanup_multiTouchState();
    
    super.skinFinalize();
  }
  
  public long initLayout()
  {
    super.initLayout();
    
    int shmkey = config.getArgInt("net.baseport") + 2;
    logger.info("shmkey = " + shmkey);
    
    int result = shmget(shmkey, currentState.getCurrentResolutionWidth() * currentState.getCurrentResolutionHeight() * 4);
    
    logger.info("shmget native function returned " + result);
    
    pollThread = new PollFBThread(currentState.getCurrentResolutionWidth(), currentState.getCurrentResolutionHeight());
    
    lcdCanvas.addPaintListener(new PaintListener()
    {
      public void paintControl(PaintEvent e)
      {
        int x = lcdCanvas.getSize().x;
        int y = lcdCanvas.getSize().y;
        if (pollThread.getWaitIntervalTime() == 0)
        {
          logger.info("draw black screen");
          
          gc.drawRectangle(-1, -1, x + 1, y + 1);
          return;
        }
        if (currentState.getCurrentAngle() == 0)
        {
          gc.drawImage(access$500framebuffer, 0, 0, access$500widthFB, access$500heightFB, 0, 0, x, y);
          if ((finger.getMultiTouchEnable() == 1) || (finger.getMultiTouchEnable() == 2)) {
            finger.rearrangeFingerPoints(currentState.getCurrentResolutionWidth(), currentState.getCurrentResolutionHeight(), currentState.getCurrentScale(), currentState.getCurrentRotationId());
          }
          finger.drawImage(e, currentState.getCurrentAngle());
          return;
        }
        Transform transform = new Transform(lcdCanvas.getDisplay());
        Transform oldtransform = new Transform(lcdCanvas.getDisplay());
        transform.rotate(currentState.getCurrentAngle());
        if (currentState.getCurrentAngle() == 90)
        {
          int temp = x;
          x = y;
          y = temp;
          transform.translate(0.0F, y * -1);
        }
        else if (currentState.getCurrentAngle() == 180)
        {
          transform.translate(x * -1, y * -1);
        }
        else if (currentState.getCurrentAngle() == -90)
        {
          int temp = x;
          x = y;
          y = temp;
          transform.translate(x * -1, 0.0F);
        }
        if (finger.getMultiTouchEnable() == 1) {
          finger.rearrangeFingerPoints(currentState.getCurrentResolutionWidth(), currentState.getCurrentResolutionHeight(), currentState.getCurrentScale(), currentState.getCurrentRotationId());
        }
        gc.getTransform(oldtransform);
        
        gc.setTransform(transform);
        gc.drawImage(access$500framebuffer, 0, 0, access$500widthFB, access$500heightFB, 0, 0, x, y);
        
        gc.setTransform(oldtransform);
        
        transform.dispose();
        finger.drawImage(e, currentState.getCurrentAngle());
      }
    });
    pollThread.start();
    
    return 0L;
  }
  
  public void displayOn()
  {
    logger.info("display on");
    if (pollThread.isAlive())
    {
      pollThread.setWaitIntervalTime(30);
      synchronized (pollThread)
      {
        pollThread.notify();
      }
    }
  }
  
  public void displayOff()
  {
    logger.info("display off");
    if (isDisplayDragging == true)
    {
      logger.info("auto release : mouseEvent");
      MouseEventData mouseEventData = new MouseEventData(0, ICommunicator.MouseEventType.RELEASE.value(), 0, 0, 0, 0, 0);
      
      communicator.sendToQEMU(ICommunicator.SendCommand.SEND_MOUSE_EVENT, mouseEventData);
    }
    if (pollThread.isAlive())
    {
      pollThread.setWaitIntervalTime(0);
      
      shell.getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          lcdCanvas.redraw();
        }
      });
    }
  }
  
  protected void openScreenShotWindow()
  {
    if (screenShotDialog != null)
    {
      logger.info("screenshot window was already opened");
      return;
    }
    try
    {
      screenShotDialog = new ShmScreenShotWindow(shell, communicator, this, config, imageRegistry.getIcon(ImageRegistry.IconName.SCREENSHOT));
      
      screenShotDialog.open();
    }
    catch (ScreenShotException ex)
    {
      screenShotDialog = null;
      logger.log(Level.SEVERE, ex.getMessage(), ex);
      
      SkinUtil.openMessage(shell, null, "Fail to create a screen shot.", 1, config);
    }
    catch (Exception ex)
    {
      screenShotDialog = null;
      logger.log(Level.SEVERE, ex.getMessage(), ex);
      
      SkinUtil.openMessage(shell, null, "ScreenShot is not ready.\nPlease wait until the emulator is completely boot up.", 8, config);
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorShmSkin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import java.util.logging.Logger;
import org.tizen.emulator.skin.comm.ICommunicator;
import org.tizen.emulator.skin.log.SkinLogger;

public class EmulatorShutdownhook
  extends Thread
{
  private Logger logger = SkinLogger.getSkinLogger(EmulatorShutdownhook.class).getLogger();
  private ICommunicator communicator;
  
  public EmulatorShutdownhook(ICommunicator communicator)
  {
    this.communicator = communicator;
  }
  
  public void run()
  {
    logger.info("EmulatorShutdownhook run by a signal.");
    communicator.terminate();
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorShutdownhook
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.custom.KeyWindow;

class EmulatorSkin$1$1
  implements Runnable
{
  EmulatorSkin$1$1(EmulatorSkin.1 param1) {}
  
  public void run()
  {
    if ((EmulatorSkin.access$700(this$1.this$0) == true) && (this$1.this$0.keyWindow != null) && 
      (!this$1.this$0.keyWindow.getShell().getMinimized()))
    {
      this$1.this$0.keyWindow.getShell().setVisible(false);
      
      this$1.this$0.keyWindow.getShell().setMinimized(true);
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.emulator.skin.EmulatorSkin.1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.emulator.skin;

import java.util.logging.Logger;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
import org.tizen.emulator.skin.comm.sock.data.DisplayStateData;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.custom.KeyWindow;
import org.tizen.emulator.skin.info.SkinInformation;
import org.tizen.emulator.skin.screenshot.ScreenShotDialog;

class EmulatorSkin$1
  implements ShellListener
{
  EmulatorSkin$1(EmulatorSkin paramEmulatorSkin, Shell paramShell) {}
  
  public void shellClosed(ShellEvent event)
  {
    EmulatorSkin.access$100().info("Main Window is closed");
    if (EmulatorSkin.access$200(this$0))
    {
      EmulatorSkin.access$300(this$0);
      EmulatorSkin.access$400(this$0);
      if (!EmulatorSkin.access$500(this$0))
      {
        if (null
1 2 3 4 5 6 7 8 9 10 11 12 13

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd