/**
- *
+ * Shutdown Hook
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
logger.info("EmulatorShutdownhook run by a signal.");
communicator.terminate();
}
-
}
/**
- *
+ * Abstract Data
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*
*/
public abstract class AbstractSendData implements ISendData {
-
private DataOutputStream dos;
private ByteArrayOutputStream bao;
public AbstractSendData() {
bao = new ByteArrayOutputStream();
- dos = new DataOutputStream( bao );
+ dos = new DataOutputStream(bao);
}
-
+
protected abstract void write() throws IOException ;
-
+
@Override
public byte[] serialize() throws IOException {
write();
return bao.toByteArray();
}
- protected void writeShort ( int val ) throws IOException {
- dos.writeShort( val );
+ protected void writeShort(int val) throws IOException {
+ dos.writeShort(val);
}
- protected void writeInt ( int val ) throws IOException {
- dos.writeInt( val );
+ protected void writeInt(int val) throws IOException {
+ dos.writeInt(val);
}
- protected void writeLong ( long val ) throws IOException {
- dos.writeLong( val );
+ protected void writeLong(long val) throws IOException {
+ dos.writeLong(val);
}
- protected void writeBoolean ( boolean val ) throws IOException {
- dos.writeBoolean( val );
+ protected void writeBoolean(boolean val) throws IOException {
+ dos.writeBoolean(val);
}
- protected void writeChar ( char val ) throws IOException {
- dos.writeChar( val );
+ protected void writeChar(char val) throws IOException {
+ dos.writeChar(val);
}
-
}
/**
- *
+ * Boolean Data
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*
*/
public class BooleanData extends AbstractSendData {
-
private boolean booleanValue;
private String dataName;
- public BooleanData( boolean booleanValue ) {
+ public BooleanData(boolean booleanValue) {
this.booleanValue = booleanValue;
}
- public BooleanData( boolean booleanValue, String dataName) {
+ public BooleanData(boolean booleanValue, String dataName) {
this.booleanValue = booleanValue;
this.dataName = dataName;
}
*/
@Override
protected void write() throws IOException {
- writeBoolean( booleanValue );
+ writeBoolean(booleanValue);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append( "BooleanData [booleanValue=" );
- builder.append( booleanValue );
- builder.append( ", dataName=" );
- builder.append( dataName );
- builder.append( "]" );
+ builder.append("BooleanData [booleanValue=");
+ builder.append(booleanValue);
+ builder.append(", dataName=");
+ builder.append(dataName);
+ builder.append("]");
+
return builder.toString();
}
-
}
/**
- *
+ * Display State Data
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*
*/
public class DisplayStateData extends AbstractSendData {
-
int scale;
short rotation;
-
+
public DisplayStateData(int scale, short rotation) {
this.scale = scale;
this.rotation = rotation;
builder.append(", rotation=");
builder.append(rotation);
builder.append("]");
+
return builder.toString();
}
-
}
/**
- *
+ * Key Event Data
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*
*/
public class KeyEventData extends AbstractSendData {
-
public int eventType;
public int keycode;
public int stateMask;
this.stateMask = stateMask;
this.keyLocation = keyLocation;
}
-
+
@Override
protected void write() throws IOException {
writeInt(eventType);
writeInt(stateMask);
writeInt(keyLocation);
}
-
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(", keyLocation=");
builder.append(keyLocation);
builder.append("]");
+
return builder.toString();
}
-
}
/**
- *
+ * Mouse Event Data
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*
*/
public class MouseEventData extends AbstractSendData {
-
int mouseButton;
int eventType;
int hostX;
builder.append(", id=");
builder.append(z);
builder.append("]");
+
return builder.toString();
}
-
}
/**
- * initial data for Qemu
+ * Initial Data From Skin
*
* Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
builder.append(", blank guide=");
builder.append(isBlankGuide);
builder.append("]");
+
return builder.toString();
}
-
}
}
if (skinProperties.containsKey(
- SkinPropertiesConstants.WINDOW_Y ) == true) {
+ SkinPropertiesConstants.WINDOW_Y) == true) {
String y = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_Y);
int yy = 0;
/**
- *
+ * JAXB Utilities
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*
*/
public class JaxbUtil {
-
- private JaxbUtil(){}
+ private JaxbUtil() {
+ /* do nothing */
+ }
- public static <T> T unmarshal( byte[] inputBytes, Class<T> clazz ) throws JaxbException {
- return unmarshal( new ByteArrayInputStream( inputBytes ), clazz );
+ public static <T> T unmarshal(
+ byte[] inputBytes, Class<T> clazz) throws JaxbException {
+ return unmarshal(new ByteArrayInputStream(inputBytes), clazz);
}
- public static <T> T unmarshal( InputStream in, Class<T> clazz ) throws JaxbException {
-
- try{
-
+ public static <T> T unmarshal(
+ InputStream in, Class<T> clazz) throws JaxbException {
+ try {
Unmarshaller u = getContext(clazz).createUnmarshaller();
- JAXBElement<T> element = u.unmarshal( new StreamSource(in), clazz );
-
+ JAXBElement<T> element = u.unmarshal(new StreamSource(in), clazz);
+
return element.getValue();
-
} catch (JAXBException e) {
throw new JaxbException(e);
} catch (Throwable e) {
throw new JaxbException(e);
}
-
}
-
- public static void marshal( Object object, OutputStream out ) throws JaxbException {
-
- try{
-
+
+ public static void marshal(
+ Object object, OutputStream out) throws JaxbException {
+ try {
Marshaller m = getContext(object.getClass()).createMarshaller();
-
+
m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-
+
m.marshal(object, out);
-
} catch (JAXBException e) {
throw new JaxbException(e);
} catch (Throwable e) {
throw new JaxbException(e);
}
-
}
-
+
private static JAXBContext getContext(Class<?> clazz) throws JaxbException {
-
- try{
-
+ try {
String qualifier = clazz.getCanonicalName();
int index = qualifier.lastIndexOf('.');
- if ( - 1!= index) {
- qualifier = qualifier.substring( 0, index );
+ if (-1 != index) {
+ qualifier = qualifier.substring(0, index);
}
-
- return JAXBContext.newInstance( qualifier, clazz.getClassLoader() );
-
+
+ return JAXBContext.newInstance(qualifier, clazz.getClassLoader());
} catch (JAXBException e) {
throw new JaxbException(e);
}
-
}
-
}
/**
- *
+ * Rotation Utilities
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*
*/
public class SkinRotation {
-
private static Map<Short, RotationType> rotationMap;
private static Map<Short, RotationInfo> angleMap;
-
- private SkinRotation(){}
-
+
+ private SkinRotation() {
+ /* do nothing */
+ }
+
static {
rotationMap = new LinkedHashMap<Short, RotationType>();
angleMap = new HashMap<Short, RotationInfo>();
}
-
- public static void put(RotationType rotation ) {
- if ( RotationInfo.PORTRAIT.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.PORTRAIT.id(), rotation );
- angleMap.put( RotationInfo.PORTRAIT.id(), RotationInfo.PORTRAIT );
- } else if ( RotationInfo.LANDSCAPE.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.LANDSCAPE.id(), rotation );
- angleMap.put( RotationInfo.LANDSCAPE.id(), RotationInfo.LANDSCAPE );
- } else if ( RotationInfo.REVERSE_PORTRAIT.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.REVERSE_PORTRAIT.id(), rotation );
- angleMap.put( RotationInfo.REVERSE_PORTRAIT.id(), RotationInfo.REVERSE_PORTRAIT );
- } else if ( RotationInfo.REVERSE_LANDSCAPE.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.REVERSE_LANDSCAPE.id(), rotation );
- angleMap.put( RotationInfo.REVERSE_LANDSCAPE.id(), RotationInfo.REVERSE_LANDSCAPE );
+ public static void put(RotationType rotation) {
+ if (RotationInfo.PORTRAIT.value()
+ .equalsIgnoreCase(rotation.getName().value()))
+ {
+ rotationMap.put(RotationInfo.PORTRAIT.id(), rotation);
+ angleMap.put(RotationInfo.PORTRAIT.id(), RotationInfo.PORTRAIT);
+ }
+ else if (RotationInfo.LANDSCAPE.value()
+ .equalsIgnoreCase(rotation.getName().value()))
+ {
+ rotationMap.put(RotationInfo.LANDSCAPE.id(), rotation);
+ angleMap.put(RotationInfo.LANDSCAPE.id(), RotationInfo.LANDSCAPE);
+ }
+ else if (RotationInfo.REVERSE_PORTRAIT.value()
+ .equalsIgnoreCase(rotation.getName().value()))
+ {
+ rotationMap.put(RotationInfo.REVERSE_PORTRAIT.id(), rotation);
+ angleMap.put(RotationInfo.REVERSE_PORTRAIT.id(), RotationInfo.REVERSE_PORTRAIT);
+ }
+ else if (RotationInfo.REVERSE_LANDSCAPE.value()
+ .equalsIgnoreCase(rotation.getName().value()))
+ {
+ rotationMap.put(RotationInfo.REVERSE_LANDSCAPE.id(), rotation);
+ angleMap.put(RotationInfo.REVERSE_LANDSCAPE.id(), RotationInfo.REVERSE_LANDSCAPE);
}
-
}
- public static int getAngle( Short rotationId ) {
+ public static int getAngle(Short rotationId) {
RotationInfo rotationInfo = angleMap.get(rotationId);
- if( null != rotationInfo ) {
+ if (null != rotationInfo) {
return rotationInfo.angle();
- }else {
+ } else {
return 0;
}
}
- public static RotationType getRotation( Short rotationId ) {
+ public static RotationType getRotation(Short rotationId) {
return rotationMap.get(rotationId);
}
- public static Iterator<Entry<Short, RotationType>>getRotationIterator() {
+ public static Iterator<Entry<Short, RotationType>> getRotationIterator() {
return rotationMap.entrySet().iterator();
}
-
}
/**
- *
+ * String Utilities
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
/**
- *
+ * SWT Utilities
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
*/
public class SwtUtil {
private SwtUtil() {
+ /* do nothing */
}
public static boolean isLinuxPlatform() {
- return "gtk".equalsIgnoreCase( SWT.getPlatform() );
+ return "gtk".equalsIgnoreCase(SWT.getPlatform());
}
public static boolean isWindowsPlatform() {
- return "win32".equalsIgnoreCase( SWT.getPlatform() ); //win32-win32-x86_64
+ return "win32".equalsIgnoreCase(SWT.getPlatform()); /* win32-win32-x86_64 */
}
public static boolean isMacPlatform() {
- return "cocoa".equalsIgnoreCase( SWT.getPlatform() );
+ return "cocoa".equalsIgnoreCase(SWT.getPlatform());
}
}