import java.io.IOException;
import java.net.Socket;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinInfoConstants;
import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
import org.tizen.emulator.skin.dbi.EmulatorUI;
+import org.tizen.emulator.skin.dbi.RotationType;
+import org.tizen.emulator.skin.dbi.RotationsType;
import org.tizen.emulator.skin.exception.JaxbException;
import org.tizen.emulator.skin.image.ImageRegistry;
import org.tizen.emulator.skin.info.SkinInformation;
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.SkinRotation;
import org.tizen.emulator.skin.util.StringUtil;
import org.tizen.emulator.skin.util.SwtUtil;
logger.info("=======================================");
emulatorUI = JaxbUtil.unmarshal(bytes, EmulatorUI.class);
+
+ /* register rotation info */
+ RotationsType rotations = emulatorUI.getRotations();
+ if (rotations != null) {
+ List<RotationType> rotationList = rotations.getRotation();
+
+ for (RotationType rotation : rotationList) {
+ SkinRotation.put(rotation);
+ }
+ } else {
+ logger.severe("Fail to loading rotations element from XML");
+ }
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
} catch (JaxbException e) {
shell.setImage(parent.getImage());
/* load image for HW key button */
- imageNormal = imageRegistry.getGeneralKeyWindowImageData(
+ imageNormal = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.KEYBUTTON_NORMAL);
- imageHover = imageRegistry.getGeneralKeyWindowImageData(
+ imageHover = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.KEYBUTTON_HOVER);
- imagePushed = imageRegistry.getGeneralKeyWindowImageData(
+ imagePushed = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.KEYBUTTON_PUSHED);
/* calculate the key window size */
Image imagesScrollArrowUp[] = new Image[3];
Image imagesScrollArrowDown[] = new Image[3];
- imagesScrollArrowUp[0] = imageRegistry.getGeneralKeyWindowImageData(
+ imagesScrollArrowUp[0] = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_UPBUTTON_NORMAL);
- imagesScrollArrowUp[1] = imageRegistry.getGeneralKeyWindowImageData(
+ imagesScrollArrowUp[1] = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_UPBUTTON_HOVER);
- imagesScrollArrowUp[2] = imageRegistry.getGeneralKeyWindowImageData(
+ imagesScrollArrowUp[2] = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_UPBUTTON_PUSHED);
- imagesScrollArrowDown[0] = imageRegistry.getGeneralKeyWindowImageData(
+ imagesScrollArrowDown[0] = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_DOWNBUTTON_NORMAL);
- imagesScrollArrowDown[1] = imageRegistry.getGeneralKeyWindowImageData(
+ imagesScrollArrowDown[1] = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_DOWNBUTTON_HOVER);
- imagesScrollArrowDown[2] = imageRegistry.getGeneralKeyWindowImageData(
+ imagesScrollArrowDown[2] = imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_DOWNBUTTON_PUSHED);
CustomScrolledComposite compositeScroll =
new CustomScrolledComposite(shell, SWT.NONE,
imagesScrollArrowUp, imagesScrollArrowDown,
- imageRegistry.getGeneralKeyWindowImageData(
+ imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_THUMB),
- imageRegistry.getGeneralKeyWindowImageData(
+ imageRegistry.getKeyWindowImage(
GeneralKeyWindowImageName.SCROLL_SHAFT));
compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
this.imageRegistry = new SpecialKeyWindowImageRegistry(shell.getDisplay(), dbiContents, specialKeyWindowPath);
/* get keywindow image */
- keyWindowImage = imageRegistry.getSpecialKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL);
- keyWindowPressedImage = imageRegistry.getSpecialKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED);
+ keyWindowImage = imageRegistry.getKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL);
+ keyWindowPressedImage = imageRegistry.getKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED);
SpecialKeyWindowUtil.trimShell(shell, keyWindowImage);
SpecialKeyWindowUtil.trimShell(shell, keyWindowPressedImage);
package org.tizen.emulator.skin.image;
+import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
this.keyWindowImageMap = new HashMap<String, Image>();
}
- public Image getGeneralKeyWindowImageData(GeneralKeyWindowImageName name) {
+ public Image getKeyWindowImage(GeneralKeyWindowImageName name) {
if (keyWindowImageMap.size() == 0) {
/* load all of the images at once */
ClassLoader classLoader = this.getClass().getClassLoader();
GeneralKeyWindowImageName[] values = GeneralKeyWindowImageName.values();
for (GeneralKeyWindowImageName value : values) {
imageName = value.getName();
- imagePath = ImageRegistry.IMAGES_FOLDER + "/" +
- KEYWINDOW_FOLDER + "/" + imageName;
+ imagePath = ImageRegistry.IMAGES_FOLDER + File.separator
+ + KEYWINDOW_FOLDER + File.separator + imageName;
try {
is = classLoader.getResourceAsStream(imagePath);
--- /dev/null
+/**
+ * Image Resource Management For General-Purpose Skin
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * 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.image;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.util.IOUtil;
+
+public class GeneralSkinImageRegistry {
+ private static final String PATCH_IMAGES_PATH = "emul-window";
+
+ private static Logger logger = SkinLogger.getSkinLogger(
+ GeneralSkinImageRegistry.class).getLogger();
+
+ public enum GeneralSkinImageName {
+ TOGGLE_BUTTON_NORMAL("arrow_nml.png"),
+ TOGGLE_BUTTON_HOVER("arrow_hover.png"),
+ TOGGLE_BUTTON_PUSHED("arrow_pushed.png");
+
+ private String name;
+
+ private GeneralSkinImageName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ }
+
+ private Display display;
+ private Map<String, Image> skinImageMap;
+
+ /**
+ * Constructor
+ */
+ public GeneralSkinImageRegistry(Display display) {
+ this.display = display;
+ this.skinImageMap = new HashMap<String, Image>();
+ }
+
+ public Image getSkinImage(GeneralSkinImageName name) {
+ if (skinImageMap.size() == 0) {
+ /* load all of the images at once */
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ InputStream is = null;
+ String imageName, imagePath;
+
+ GeneralSkinImageName[] values = GeneralSkinImageName.values();
+ for (GeneralSkinImageName value : values) {
+ imageName = value.getName();
+ imagePath = ImageRegistry.IMAGES_FOLDER + File.separator
+ + PATCH_IMAGES_PATH + File.separator + imageName;
+
+ try {
+ is = classLoader.getResourceAsStream(imagePath);
+ if (null != is) {
+ logger.fine("KeyWindow image is loaded : " + imagePath);
+ skinImageMap.put(imageName, new Image(display, is));
+ } else {
+ logger.severe("missing image : " + imagePath);
+ }
+ } finally {
+ IOUtil.close(is);
+ }
+ }
+ }
+
+ return skinImageMap.get(name.getName());
+ }
+
+ public void dispose() {
+ if (null != skinImageMap) {
+ Image image = null;
+
+ Collection<Image> images = skinImageMap.values();
+ Iterator<Image> imageIterator = images.iterator();
+
+ while (imageIterator.hasNext()) {
+ image = imageIterator.next();
+ image.dispose();
+ }
+ }
+ }
+}
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.tizen.emulator.skin.config.EmulatorConfig;
-import org.tizen.emulator.skin.dbi.EmulatorUI;
-import org.tizen.emulator.skin.dbi.RotationType;
-import org.tizen.emulator.skin.dbi.RotationsType;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.util.IOUtil;
-import org.tizen.emulator.skin.util.SkinRotation;
/**
}
private Display display;
- private EmulatorUI dbiContents;
-
private Map<String, Image> resourceImageMap;
private Map<String, Image> iconImageMap;
- private String skinPath;
-
private static ImageRegistry instance;
private static boolean isInitialized;
isInitialized = true;
this.display = Display.getDefault();
-
- this.skinPath = skinPath;
- this.dbiContents = config.getDbiContents();
-
this.resourceImageMap = new HashMap<String, Image>();
this.iconImageMap = new HashMap<String, Image>();
-
- init(this.skinPath);
- }
-
- private void init(String argSkinPath) {
- RotationsType rotations = dbiContents.getRotations();
-
- if (null == rotations) {
- logger.severe("Fail to loading rotations element from dbi.");
- return;
- }
-
- List<RotationType> rotationList = rotations.getRotation();
-
- for (RotationType rotation : rotationList) {
- SkinRotation.put(rotation);
- }
}
public Image getResourceImage(ResourceImageName name) {
this.skinPath = skinPath;
this.dbiContents = dbiContents;
this.skinImageMap = new HashMap<String, Image>();
-
- initialize(skinPath);
- }
-
- private void initialize(String argSkinPath) {
- RotationsType rotations = dbiContents.getRotations();
-
- if (null == rotations) {
- logger.severe("Fail to loading rotations element from XML");
- return;
- }
-
- List<RotationType> rotationList = rotations.getRotation();
-
- for (RotationType rotation : rotationList) {
- SkinRotation.put(rotation);
- }
}
private String makeKey(Short id, SkinImageType imageType) {
return id + ":" + imageType.ordinal();
}
- public Image getSpecialKeyWindowImage(Short id, SpecailKeyWindowImageType imageType) {
+ public Image getKeyWindowImage(Short id, SpecailKeyWindowImageType imageType) {
Image image = keyWindowImageMap.get(makeKey(id, imageType));
if (image == null) {
import org.tizen.emulator.skin.custom.ColorTag;
import org.tizen.emulator.skin.custom.CustomButton;
import org.tizen.emulator.skin.custom.CustomProgressBar;
+import org.tizen.emulator.skin.image.GeneralSkinImageRegistry;
+import org.tizen.emulator.skin.image.GeneralSkinImageRegistry.GeneralSkinImageName;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.menu.PopupMenu;
public class GeneralPurposeSkinComposer implements ISkinComposer {
private static final String PATCH_IMAGES_PATH = "images/emul-window/";
- private static final String TOGGLE_BUTTON_NORMAL_IMG = "arrow_nml.png";
- private static final String TOGGLE_BUTTON_HOVER_IMG = "arrow_hover.png";
- private static final String TOGGLE_BUTTON_PUSHED_IMG = "arrow_pushed.png";
-
private static final int PAIR_TAG_POSITION_X = 26;
private static final int PAIR_TAG_POSITION_Y = 13;
private MouseMoveListener shellMouseMoveListener;
private MouseListener shellMouseListener;
+ private GeneralSkinImageRegistry imageRegistry;
private boolean isGrabbedShell;
private Point grabPosition;
this.isGrabbedShell= false;
this.grabPosition = new Point(0, 0);
+ this.imageRegistry =
+ new GeneralSkinImageRegistry(shell.getDisplay());
+
this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
this.backgroundColor = new Color(shell.getDisplay(), new RGB(38, 38, 38));
}
}
/* load image for toggle button of key window */
- ClassLoader loader = this.getClass().getClassLoader();
- Image imageNormal = new Image(shell.getDisplay(),
- loader.getResourceAsStream(PATCH_IMAGES_PATH + TOGGLE_BUTTON_NORMAL_IMG));
- Image imageHover = new Image(shell.getDisplay(),
- loader.getResourceAsStream(PATCH_IMAGES_PATH + TOGGLE_BUTTON_HOVER_IMG));
- Image imagePushed = new Image(shell.getDisplay(),
- loader.getResourceAsStream(PATCH_IMAGES_PATH + TOGGLE_BUTTON_PUSHED_IMG));
+ Image imageNormal = imageRegistry.getSkinImage(
+ GeneralSkinImageName.TOGGLE_BUTTON_NORMAL);
+ Image imageHover = imageRegistry.getSkinImage(
+ GeneralSkinImageName.TOGGLE_BUTTON_HOVER);
+ Image imagePushed = imageRegistry.getSkinImage(
+ GeneralSkinImageName.TOGGLE_BUTTON_PUSHED);
/* create a toggle button of key window */
toggleButton = new CustomButton(shell, SWT.DRAW_TRANSPARENT | SWT.NO_FOCUS,
shell.addMouseListener(shellMouseListener);
}
-// private void createHWKeyRegion() {
-// if (compositeBase != null) {
-// compositeBase.dispose();
-// compositeBase = null;
-// }
-//
-// List<KeyMapType> keyMapList =
-// SkinUtil.getHWKeyMapList(currentState.getCurrentRotationId());
-//
-// if (keyMapList != null && keyMapList.isEmpty() == false) {
-// compositeBase = new Composite(shell, SWT.NONE);
-// compositeBase.setLayout(new GridLayout(1, true));
-//
-// for (KeyMapType keyEntry : keyMapList) {
-// Button hardKeyButton = new Button(compositeBase, SWT.FLAT);
-// hardKeyButton.setText(keyEntry.getEventInfo().getKeyName());
-// hardKeyButton.setToolTipText(keyEntry.getTooltip());
-//
-// hardKeyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-//
-// final int keycode = keyEntry.getEventInfo().getKeyCode();
-// hardKeyButton.addMouseListener(new MouseListener() {
-// @Override
-// public void mouseDown(MouseEvent e) {
-// KeyEventData keyEventData = new KeyEventData(
-// KeyEventType.PRESSED.value(), keycode, 0, 0);
-// communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
-// }
-//
-// @Override
-// public void mouseUp(MouseEvent e) {
-// KeyEventData keyEventData = new KeyEventData(
-// KeyEventType.RELEASED.value(), keycode, 0, 0);
-// communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
-// }
-//
-// @Override
-// public void mouseDoubleClick(MouseEvent e) {
-// /* do nothing */
-// }
-// });
-// }
-//
-// FormData dataComposite = new FormData();
-// dataComposite.left = new FormAttachment(displayCanvas, 0);
-// dataComposite.top = new FormAttachment(0, 0);
-// compositeBase.setLayoutData(dataComposite);
-// }
-// }
-
@Override
public void composerFinalize() {
if (null != shellPaintListener) {
}
frameMaker.freePatches();
+ imageRegistry.dispose();
}
}