import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.image.ImageRegistry;
+import org.tizen.emulator.skin.image.ImageRegistry.ResourceImageName;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.util.IOUtil;
import org.tizen.emulator.skin.util.StringUtil;
private Image aboutImage;
private EmulatorConfig config;
+ private ImageRegistry imageRegistry;
/**
* Constructor
*/
- public AboutDialog(Shell parent, EmulatorConfig config) {
+ public AboutDialog(Shell parent,
+ EmulatorConfig config, ImageRegistry imageRegistry) {
super(parent, "About Tizen Emulator",
SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
this.config = config;
+ this.imageRegistry = imageRegistry;
}
private GridLayout getNopaddedGridLayout(int numColumns, boolean makeColumnEqualWidth) {
compositeLeft.setLayout(getNopaddedGridLayout(1, false));
Label imageLabel = new Label(compositeLeft, SWT.NONE);
- aboutImage = new Image(shell.getDisplay(),
- this.getClass().getClassLoader().getResourceAsStream("images/about_Tizen_SDK.png"));
+ aboutImage = imageRegistry.getResourceImage(ResourceImageName.RESOURCE_ABOUT);
imageLabel.setImage(aboutImage);
/* right side */
/* SDK version */
Text versionText = new Text(compositeRight, SWT.NONE);
- /*String version = getValue(properties, PROP_KEY_VERSION);
- if (version.isEmpty()) {
- version = "Not identified";
- }*/
String version = config.getSkinProperty(
EmulatorConfig.SkinInfoConstants.SDK_VERSION_NAME);
visit.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
- //do nothing
+ /* do nothing */
}
@Override
return id + ":" + imageType.ordinal();
}
- public ImageData getSkinImageData(Short id, ImageType imageType) {
+ public Image getSkinImage(Short id, ImageType imageType) {
Image image = skinImageMap.get(makeKey(id, imageType));
- if (null != image) {
- return image.getImageData();
- } else {
+ if (image == null) {
RotationsType rotations = dbiContents.getRotations();
if (null == rotations) {
return null;
}
- logger.info("get image data of skin from " + skinPath);
+ logger.info("get skin image from " + skinPath);
RotationType targetRotation = SkinRotation.getRotation(id);
List<RotationType> rotationList = rotations.getRotation();
}
}
- Image registeredImage = skinImageMap.get(makeKey(id, imageType));
-
- if (null != registeredImage) {
- return registeredImage.getImageData();
- }
+ image = skinImageMap.get(makeKey(id, imageType));
}
- return null;
+ return image;
}
public Image getResourceImage(ResourceImageName name) {
return false;
}
- public static void trimShell( Shell shell, Image image ) {
-
- // trim transparent pixels in image. especially, corner round areas.
-
- if ( null == image ) {
+ public static void trimShell(Shell shell, Image image) {
+ /* trim transparent pixels in image.
+ * especially, corner round areas. */
+ if (null == image) {
return;
}
int height = imageData.height;
Region region = new Region();
- region.add( new Rectangle( 0, 0, width, height ) );
+ region.add(new Rectangle(0, 0, width, height));
- for ( int i = 0; i < width; i++ ) {
- for ( int j = 0; j < height; j++ ) {
- int alpha = imageData.getAlpha( i, j );
- if ( 0 == alpha ) {
- region.subtract( i, j, 1, 1 );
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < height; j++) {
+ int alpha = imageData.getAlpha(i, j);
+ if (0 == alpha) {
+ region.subtract(i, j, 1, 1);
}
}
}
- shell.setRegion( region );
-
+ shell.setRegion(region);
}
public static void trimShell(Shell shell, Image image,
int left, int top, int width, int height) {
-
if (null == image) {
return;
}
public static Image createScaledImage(ImageRegistry imageRegistry,
Shell shell, short rotationId, int scale, ImageType type) {
- ImageData originalImageData = imageRegistry.getSkinImageData( rotationId, type );
-
- if ( null == originalImageData ) {
+ Image imageOrigin = imageRegistry.getSkinImage(rotationId, type);
+ if (imageOrigin == null) {
return null;
}
- ImageData imageData = (ImageData) originalImageData.clone();
+ ImageData imageDataSrc = imageOrigin.getImageData();
+ ImageData imageDataDst = (ImageData) imageDataSrc.clone();
- float convertedScale = convertScale( scale );
-
- int width = (int) ( originalImageData.width * convertedScale );
- int height = (int) ( originalImageData.height * convertedScale );
- imageData = imageData.scaledTo( width, height );
+ float convertedScale = convertScale(scale);
- Image image = new Image( shell.getDisplay(), imageData );
- return image;
+ int width = (int) (imageDataSrc.width * convertedScale);
+ int height = (int) (imageDataSrc.height * convertedScale);
+ imageDataDst = imageDataDst.scaledTo(width, height);
+ return new Image(shell.getDisplay(), imageDataDst);
}
- public static float convertScale( int scale ) {
+ public static float convertScale(int scale) {
return (float) scale / SCALE_CONVERTER;
}