*/
public class EmulatorSkin {
public enum SkinBasicColor {
- BLUE(0, 174, 239), YELLOW(246, 226, 0), LIME(0, 246, 12), VIOLET(168,
- 43, 255), ORANGE(246, 110, 0), MAGENTA(245, 48, 233), PURPLE(
- 94, 73, 255), GREEN(179, 246, 0), RED(245, 48, 48), CYON(29,
- 223, 221);
+ BLUE(0, 174, 239),
+ YELLOW(246, 226, 0),
+ LIME(0, 246, 12),
+ VIOLET(168, 43, 255),
+ ORANGE(246, 110, 0),
+ MAGENTA(245, 48, 233),
+ PURPLE(94, 73, 255),
+ GREEN(179, 246, 0),
+ RED(245, 48, 48),
+ CYON(29, 223, 221);
private int channelRed;
private int channelGreen;
}
}
- private static Logger logger = SkinLogger.getSkinLogger(EmulatorSkin.class)
- .getLogger();
+ private static Logger logger =
+ SkinLogger.getSkinLogger(EmulatorSkin.class).getLogger();
public EmulatorConfig config;
protected Shell shell;
/**
* @brief constructor
- * @param config
- * : configuration of emulator skin
- * @param isOnTop
- * : always on top flag
+ * @param config : configuration of emulator skin
+ * @param isOnTop : always on top flag
*/
protected EmulatorSkin(EmulatorConfig config, SkinInformation skinInfo,
int displayCanvasStyle, boolean isOnTop) {
int red = rand.nextInt(255);
int green = rand.nextInt(255);
int blue = rand.nextInt(255);
- this.colorVM = new Color(shell.getDisplay(), new RGB(red, green,
- blue));
+ this.colorVM = new Color(shell.getDisplay(), new RGB(red, green, blue));
} else {
int vmIndex = (portNumber % 100) / 10;
imageRegistry = ImageRegistry.getInstance();
/* set emulator states */
- currentState
- .setCurrentResolutionWidth(config.getValidResolutionWidth());
- currentState.setCurrentResolutionHeight(config
- .getValidResolutionHeight());
+ currentState.setCurrentResolutionWidth(config.getValidResolutionWidth());
+ currentState.setCurrentResolutionHeight(config.getValidResolutionHeight());
currentState.setCurrentScale(config.getValidScale());
currentState.setCurrentRotationId();
displayCanvas = skinComposer.compose(displayCanvasStyle);
/* */
- // TODO: move
+ //TODO: move
if (config.getArgBoolean(ArgsConstants.INPUT_MOUSE, false) == true) {
prev_x = displayCanvas.getSize().x / 2;
prev_y = displayCanvas.getSize().y / 2;
shellGrabPosition.y = y;
if (SwtUtil.isWindowsPlatform() == true) {
- final BooleanData dataGrabbing = new BooleanData(true,
- SendCommand.SEND_SKIN_GRABBED.toString());
- communicator.sendToQEMU(SendCommand.SEND_SKIN_GRABBED,
- dataGrabbing, false);
+ final BooleanData dataGrabbing = new BooleanData(
+ true, SendCommand.SEND_SKIN_GRABBED.toString());
+ communicator.sendToQEMU(SendCommand.SEND_SKIN_GRABBED, dataGrabbing, false);
}
}
shellGrabPosition.y = -1;
if (SwtUtil.isWindowsPlatform() == true) {
- final BooleanData dataGrabbing = new BooleanData(false,
- SendCommand.SEND_SKIN_GRABBED.toString());
- communicator.sendToQEMU(SendCommand.SEND_SKIN_GRABBED,
- dataGrabbing, false);
+ final BooleanData dataGrabbing = new BooleanData(
+ false, SendCommand.SEND_SKIN_GRABBED.toString());
+ communicator.sendToQEMU(SendCommand.SEND_SKIN_GRABBED, dataGrabbing, false);
}
}
}
/* save config only for emulator close */
- config.setSkinProperty(SkinPropertiesConstants.WINDOW_X,
+ config.setSkinProperty(
+ SkinPropertiesConstants.WINDOW_X,
shell.getLocation().x);
- config.setSkinProperty(SkinPropertiesConstants.WINDOW_Y,
+ config.setSkinProperty(
+ SkinPropertiesConstants.WINDOW_Y,
shell.getLocation().y);
config.setSkinProperty(
SkinPropertiesConstants.WINDOW_SCALE,
skinFinalize();
} else {
- /*
- * Skin have to be alive until receiving shutdown request
- * from qemu
- */
+ /* Skin have to be alive until receiving shutdown request from qemu */
event.doit = false;
if (pressedKeyEventList.isEmpty() == true
&& demanderFlag.compareAndSet(false, true)) {
if (null != communicator) {
- communicator.sendToQEMU(SendCommand.SEND_CLOSE_REQ,
- null, false);
+ communicator.sendToQEMU(
+ SendCommand.SEND_CLOSE_REQ, null, false);
}
/* block for a while */
@Override
public void keyReleased(KeyEvent e) {
if (logger.isLoggable(Level.INFO)) {
- String character = (e.character == '\0') ? "\\0"
- : (e.character == '\n') ? "\\n"
- : (e.character == '\r') ? "\\r"
- : ("" + e.character);
-
- logger.info("'" + character + "':" + e.keyCode + ":"
- + e.stateMask + ":" + e.keyLocation);
+ String character =
+ (e.character == '\0') ? "\\0" :
+ (e.character == '\n') ? "\\n" :
+ (e.character == '\r') ? "\\r" :
+ ("" + e.character);
+
+ logger.info("'" + character + "':"
+ + e.keyCode + ":"
+ + e.stateMask + ":"
+ + e.keyLocation);
} else if (logger.isLoggable(Level.FINE)) {
logger.fine(e.toString());
}
KeyEventType.RELEASED.value(),
disappearKeycode, disappearStateMask,
disappearKeyLocation);
- communicator.sendToQEMU(
- SendCommand.SEND_KEYBOARD_KEY_EVENT,
+ communicator.sendToQEMU(SendCommand.SEND_KEYBOARD_KEY_EVENT,
keyEventData, false);
removePressedKeyFromList(keyEventData);
KeyEventData keyEventData = null;
/* separate a merged release event */
- if (previous.keyCode == SWT.CR
- && (keyCode & SWT.KEYCODE_BIT) != 0
- && e.character == SWT.CR) {
- logger.info("send upon release : keycode="
- + (int) SWT.CR);
+ if (previous.keyCode == SWT.CR &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 && e.character == SWT.CR) {
+ logger.info("send upon release : keycode=" + (int)SWT.CR);
keyEventData = new KeyEventData(
- KeyEventType.RELEASED.value(), SWT.CR, 0, 0);
- } else if (previous.keyCode == SWT.SPACE
- && (keyCode & SWT.KEYCODE_BIT) != 0
- && (e.character == SWT.SPACE)) {
- logger.info("send upon release : keycode="
- + (int) SWT.SPACE);
+ KeyEventType.RELEASED.value(),
+ SWT.CR, 0, 0);
+ } else if (previous.keyCode == SWT.SPACE &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 &&
+ (e.character == SWT.SPACE)) {
+ logger.info("send upon release : keycode=" + (int)SWT.SPACE);
keyEventData = new KeyEventData(
- KeyEventType.RELEASED.value(), SWT.SPACE,
- 0, 0);
- } else if (previous.keyCode == SWT.TAB
- && (keyCode & SWT.KEYCODE_BIT) != 0
- && (e.character == SWT.TAB)) {
- logger.info("send upon release : keycode="
- + (int) SWT.TAB);
+ KeyEventType.RELEASED.value(),
+ SWT.SPACE, 0, 0);
+ } else if (previous.keyCode == SWT.TAB &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 &&
+ (e.character == SWT.TAB)) {
+ logger.info("send upon release : keycode=" + (int)SWT.TAB);
keyEventData = new KeyEventData(
- KeyEventType.RELEASED.value(), SWT.TAB, 0,
- 0);
- } else if (previous.keyCode == SWT.KEYPAD_CR
- && (keyCode & SWT.KEYCODE_BIT) != 0
- && (e.character == SWT.CR)
- && (keyCode != SWT.KEYPAD_CR)) {
- logger.info("send upon release : keycode="
- + (int) SWT.KEYPAD_CR);
+ KeyEventType.RELEASED.value(),
+ SWT.TAB, 0, 0);
+ } else if (previous.keyCode == SWT.KEYPAD_CR &&
+ (keyCode & SWT.KEYCODE_BIT) != 0 &&
+ (e.character == SWT.CR) &&
+ (keyCode != SWT.KEYPAD_CR)) {
+ logger.info("send upon release : keycode=" + (int)SWT.KEYPAD_CR);
keyEventData = new KeyEventData(
KeyEventType.RELEASED.value(),
}
if (keyEventData != null) {
- communicator.sendToQEMU(
- SendCommand.SEND_KEYBOARD_KEY_EVENT,
+ communicator.sendToQEMU(SendCommand.SEND_KEYBOARD_KEY_EVENT,
keyEventData, false);
removePressedKeyFromList(keyEventData);
}
disappearStateMask = stateMask;
disappearKeyLocation = e.keyLocation;
} else {
- /*
- * three or more keys were pressed at the same
- * time
- */
+ /* three or more keys were pressed at the
+ * same time */
if (disappearEvent == true) {
logger.info("replace the disappearEvent : "
+ disappearKeycode + "->" + keyCode);
int previousStateMask = previous.stateMask;
if (logger.isLoggable(Level.INFO)) {
- String character = (previous.character == '\0') ? "\\0"
- : (previous.character == '\n') ? "\\n"
- : (previous.character == '\r') ? "\\r"
- : ("" + previous.character);
+ String character =
+ (previous.character == '\0') ? "\\0" :
+ (previous.character == '\n') ? "\\n" :
+ (previous.character == '\r') ? "\\r" :
+ ("" + previous.character);
logger.info("send previous release : '"
+ character + "':"
} /* end isWindowsPlatform */
if (logger.isLoggable(Level.INFO)) {
- String character = (e.character == '\0') ? "\\0"
- : (e.character == '\n') ? "\\n"
- : (e.character == '\r') ? "\\r"
- : ("" + e.character);
-
- logger.info("'" + character + "':" + e.keyCode + ":"
- + e.stateMask + ":" + e.keyLocation);
+ String character =
+ (e.character == '\0') ? "\\0" :
+ (e.character == '\n') ? "\\n" :
+ (e.character == '\r') ? "\\r" :
+ ("" + e.character);
+
+ logger.info("'" + character + "':"
+ + e.keyCode + ":"
+ + e.stateMask + ":"
+ + e.keyLocation);
} else if (logger.isLoggable(Level.FINE)) {
logger.fine(e.toString());
}
currentState.getCurrentRotationId());
MouseEventData mouseEventData = new MouseEventData(
- MouseButtonType.LEFT.value(), eventType, e.x, e.y, geometry[0],
- geometry[1], 0);
+ MouseButtonType.LEFT.value(), eventType,
+ e.x, e.y, geometry[0], geometry[1], 0);
- communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData,
- false);
+ communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT,
+ mouseEventData, false);
}
protected void mouseUpDelivery(MouseEvent e) {
currentState.getCurrentResolutionHeight(),
currentState.getCurrentScale(),
currentState.getCurrentRotationId());
- logger.info("mouseUp in display" + " x:" + geometry[0] + " y:"
- + geometry[1]);
+ logger.info("mouseUp in display" +
+ " x:" + geometry[0] + " y:" + geometry[1]);
MouseEventData mouseEventData = new MouseEventData(
MouseButtonType.LEFT.value(), MouseEventType.RELEASE.value(),
e.x, e.y, geometry[0], geometry[1], 0);
- communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData,
- false);
+ communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT,
+ mouseEventData, false);
}
protected void mouseDownDelivery(MouseEvent e) {
currentState.getCurrentResolutionHeight(),
currentState.getCurrentScale(),
currentState.getCurrentRotationId());
- logger.info("mouseDown in display" + " x:" + geometry[0] + " y:"
- + geometry[1]);
+ logger.info("mouseDown in display" +
+ " x:" + geometry[0] + " y:" + geometry[1]);
MouseEventData mouseEventData = new MouseEventData(
MouseButtonType.LEFT.value(), MouseEventType.PRESS.value(),
e.x, e.y, geometry[0], geometry[1], 0);
- communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData,
- false);
+ communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT,
+ mouseEventData, false);
}
- protected void keyReleasedDelivery(int keyCode, int stateMask,
- int keyLocation, boolean remove) {
+ protected void keyReleasedDelivery(int keyCode,
+ int stateMask, int keyLocation, boolean remove) {
KeyEventData keyEventData = new KeyEventData(
KeyEventType.RELEASED.value(), keyCode, stateMask, keyLocation);
- communicator.sendToQEMU(SendCommand.SEND_KEYBOARD_KEY_EVENT,
- keyEventData, false);
+ communicator.sendToQEMU(
+ SendCommand.SEND_KEYBOARD_KEY_EVENT, keyEventData, false);
if (remove == true) {
removePressedKeyFromList(keyEventData);
}
}
- protected void keyPressedDelivery(int keyCode, int stateMask,
- int keyLocation, boolean add) {
+ protected void keyPressedDelivery(int keyCode,
+ int stateMask, int keyLocation, boolean add) {
KeyEventData keyEventData = new KeyEventData(
KeyEventType.PRESSED.value(), keyCode, stateMask, keyLocation);
- communicator.sendToQEMU(SendCommand.SEND_KEYBOARD_KEY_EVENT,
- keyEventData, false);
+ communicator.sendToQEMU(
+ SendCommand.SEND_KEYBOARD_KEY_EVENT, keyEventData, false);
if (add == true) {
addPressedKeyToList(keyEventData);
}
protected void rearrangeSkin() {
- skinComposer.arrangeSkin(currentState.getCurrentScale(),
+ skinComposer.arrangeSkin(
+ currentState.getCurrentScale(),
currentState.getCurrentRotationId());
}
displayTransform.translate(displayCanvas.getSize().y * -1, 0);
} else if (rotationId == SkinRotations.REVERSE_PORTRAIT_ID) {
/* reverse-portrait */
- displayTransform.translate(displayCanvas.getSize().x * -1,
+ displayTransform.translate(
+ displayCanvas.getSize().x * -1,
displayCanvas.getSize().y * -1);
} else if (rotationId == SkinRotations.REVERSE_LANDSCAPE_ID) {
/* reverse-landscape */
if (isDisplayDragging == true) {
logger.info("auto release : mouseEvent");
- MouseEventData mouseEventData = new MouseEventData(0,
- MouseEventType.RELEASE.value(), 0, 0, 0, 0, 0);
+ MouseEventData mouseEventData = new MouseEventData(
+ 0, MouseEventType.RELEASE.value(),
+ 0, 0, 0, 0, 0);
- communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT,
- mouseEventData, false);
+ communicator.sendToQEMU(
+ SendCommand.SEND_MOUSE_EVENT, mouseEventData, false);
}
}
logger.fine("Open detail info");
}
- DetailInfoDialog detailInfoDialog = new DetailInfoDialog(shell,
- communicator, config, skinInfo);
+ DetailInfoDialog detailInfoDialog = new DetailInfoDialog(
+ shell, communicator, config, skinInfo);
detailInfoDialog.open();
}
};
final List<MenuItem> rotationList = new ArrayList<MenuItem>();
- Iterator<Entry<Short, Rotation>> iterator = SkinRotations
- .getRotationIterator();
+ Iterator<Entry<Short, Rotation>> iterator =
+ SkinRotations.getRotationIterator();
while (iterator.hasNext()) {
Entry<Short, Rotation> entry = iterator.next();
}
/* temp : swap rotation menu names */
- if (currentState.getCurrentResolutionWidth() > currentState
- .getCurrentResolutionHeight()) {
+ if (currentState.getCurrentResolutionWidth() >
+ currentState.getCurrentResolutionHeight()) {
for (MenuItem m : rotationList) {
short rotationId = (Short) m.getData();
if (rotationId == SkinRotations.PORTRAIT_ID) {
- String landscape = SkinRotations
- .getRotation(SkinRotations.LANDSCAPE_ID).getName()
- .value();
+ String landscape = SkinRotations.getRotation(
+ SkinRotations.LANDSCAPE_ID).getName().value();
m.setText(landscape);
} else if (rotationId == SkinRotations.LANDSCAPE_ID) {
- String portrait = SkinRotations
- .getRotation(SkinRotations.PORTRAIT_ID).getName()
- .value();
+ String portrait = SkinRotations.getRotation(
+ SkinRotations.PORTRAIT_ID).getName().value();
m.setText(portrait);
} else if (rotationId == SkinRotations.REVERSE_PORTRAIT_ID) {
- String landscapeReverse = SkinRotations
- .getRotation(SkinRotations.REVERSE_LANDSCAPE_ID)
- .getName().value();
+ String landscapeReverse = SkinRotations.getRotation(
+ SkinRotations.REVERSE_LANDSCAPE_ID).getName().value();
m.setText(landscapeReverse);
} else if (rotationId == SkinRotations.REVERSE_LANDSCAPE_ID) {
- String portraitReverse = SkinRotations
- .getRotation(SkinRotations.REVERSE_PORTRAIT_ID)
- .getName().value();
+ String portraitReverse = SkinRotations.getRotation(
+ SkinRotations.REVERSE_PORTRAIT_ID).getName().value();
m.setText(portraitReverse);
}
}
currentState.getCurrentScale(), rotationId);
/* location correction */
- Rectangle monitorBounds = Display.getDefault()
- .getBounds();
+ Rectangle monitorBounds = Display.getDefault().getBounds();
Rectangle emulatorBounds = shell.getBounds();
shell.setLocation(
Math.max(emulatorBounds.x, monitorBounds.x),
return;
}
- final int scale = (Integer) item.getData(); /* percentage */
+ final int scale = (Integer)item.getData(); /* percentage */
shell.getDisplay().syncExec(new Runnable() {
@Override
currentState.getCurrentRotationId());
/* location correction */
- Rectangle monitorBounds = Display.getDefault()
- .getBounds();
+ Rectangle monitorBounds = Display.getDefault().getBounds();
Rectangle emulatorBounds = shell.getBounds();
shell.setLocation(
Math.max(emulatorBounds.x, monitorBounds.x),
boolean on = item.equals(popupMenu.interpolationHighItem);
isOnInterpolation = on;
- logger.info("Select scale interpolation : "
- + isOnInterpolation);
+ logger.info("Select scale interpolation : " + isOnInterpolation);
- communicator.sendToQEMU(
- SendCommand.SEND_INTERPOLATION_STATE,
- new BooleanData(on,
- SendCommand.SEND_INTERPOLATION_STATE
- .toString()), false);
+ communicator.sendToQEMU(SendCommand.SEND_INTERPOLATION_STATE,
+ new BooleanData(on, SendCommand.SEND_INTERPOLATION_STATE.toString()),
+ false);
}
}
};
MenuItem layoutSelected = (MenuItem) e.widget;
if (layoutSelected.getSelection() == true) {
- for (MenuItem layout : layoutSelected.getParent()
- .getItems()) {
+ for (MenuItem layout : layoutSelected.getParent().getItems()) {
if (layout != layoutSelected) {
/* uncheck other menu items */
layout.setSelection(false);
} else {
- int layoutIndex = getKeyWindowKeeper()
- .getLayoutIndex();
+ int layoutIndex = getKeyWindowKeeper().getLayoutIndex();
if (getKeyWindowKeeper().determineLayout() != layoutIndex) {
/* switch */
getKeyWindowKeeper().closeKeyWindow();
if (getKeyWindowKeeper().getKeyWindow() == null) {
if (getKeyWindowKeeper().getRecentlyDocked() != SWT.NONE) {
getKeyWindowKeeper().openKeyWindow(
- getKeyWindowKeeper().getRecentlyDocked(),
- false);
+ getKeyWindowKeeper().getRecentlyDocked(), false);
getKeyWindowKeeper().setRecentlyDocked(SWT.NONE);
} else {
/* opening for first time */
getKeyWindowKeeper().openKeyWindow(
- KeyWindowKeeper.DEFAULT_DOCK_POSITION,
- false);
+ KeyWindowKeeper.DEFAULT_DOCK_POSITION, false);
}
} else {
getKeyWindowKeeper().openKeyWindow(
@Override
public void widgetSelected(SelectionEvent e) {
// TODO:
- /*
- * if (!communicator.isSensorDaemonStarted()) {
- * SkinUtil.openMessage(shell, null,
- * "Host Keyboard is not ready.\n" +
- * "Please wait until the emulator is completely boot up.",
- * SWT.ICON_WARNING, config);
- * popupMenu.hostKbdOnItem.setSelection(isOnKbd);
- * popupMenu.hostKbdOffItem.setSelection(!isOnKbd);
- *
- * return; }
- */
+ /* if (!communicator.isSensorDaemonStarted()) {
+ SkinUtil.openMessage(shell, null,
+ "Host Keyboard is not ready.\n"
+ + "Please wait until the emulator is completely boot up.",
+ SWT.ICON_WARNING, config);
+ popupMenu.hostKbdOnItem.setSelection(isOnKbd);
+ popupMenu.hostKbdOffItem.setSelection(!isOnKbd);
+
+ return;
+ } */
MenuItem item = (MenuItem) e.getSource();
if (item.getSelection()) {
logger.info("Select host keyboard : " + isOnKbd);
- communicator.sendToQEMU(
- SendCommand.SEND_HOST_KBD_STATE,
- new BooleanData(on, SendCommand.SEND_HOST_KBD_STATE
- .toString()), false);
+ communicator.sendToQEMU(SendCommand.SEND_HOST_KBD_STATE,
+ new BooleanData(on, SendCommand.SEND_HOST_KBD_STATE.toString()), false);
}
}
};
public void widgetSelected(SelectionEvent e) {
logger.info("Open the about dialog");
- AboutDialog dialog = new AboutDialog(shell, config,
- imageRegistry);
+ AboutDialog dialog = new AboutDialog(shell, config, imageRegistry);
dialog.open();
}
};
if (communicator.isSdbDaemonStarted() == false) {
logger.warning("SDB is not ready.");
- SkinUtil.openMessage(
- shell,
- null,
+ SkinUtil.openMessage(shell, null,
"SDB is not ready.\n"
+ "Please wait until the emulator is completely boot up.",
SWT.ICON_WARNING, config);
File sdbFile = new File(sdbPath);
if (sdbFile.exists() == false) {
- logger.info("SDB file does not exist : "
- + sdbFile.getAbsolutePath());
+ logger.info("SDB file does not exist : " + sdbFile.getAbsolutePath());
try {
SkinUtil.openMessage(shell, null,
try {
SkinUtil.openMessage(shell, null,
"Control Panel file does not exist in the following path.\n"
- + ecpFile.getCanonicalPath(),
+ + ecpFile.getCanonicalPath(),
SWT.ICON_ERROR, config);
} catch (IOException ee) {
logger.log(Level.SEVERE, ee.getMessage(), ee);
}
return;
- }
+ }
String emulName = SkinUtil.getVmName(config);
int basePort = config.getArgInt(ArgsConstants.VM_BASE_PORT);
public void widgetSelected(SelectionEvent e) {
logger.info("Close menu is selected");
- communicator
- .sendToQEMU(SendCommand.SEND_CLOSE_REQ, null, false);
+ communicator.sendToQEMU(SendCommand.SEND_CLOSE_REQ, null, false);
}
};
}
}
- keyReleasedDelivery(data.keycode, data.stateMask,
- data.keyLocation, false);
+ keyReleasedDelivery(data.keycode,
+ data.stateMask, data.keyLocation, false);
logger.info("auto release : keycode=" + data.keycode
- + ", stateMask=" + data.stateMask + ", keyLocation="
- + data.keyLocation);
+ + ", stateMask=" + data.stateMask
+ + ", keyLocation=" + data.keyLocation);
}
}