equal
deleted
inserted
replaced
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 package com.nokia.mid.ui; |
17 package com.nokia.mid.ui; |
18 |
18 |
19 import javax.microedition.lcdui.Font; |
19 import javax.microedition.lcdui.Font; |
23 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker; |
23 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker; |
24 |
24 |
25 /** |
25 /** |
26 * DirectUtils class contains utility methods for lcdui classes. |
26 * DirectUtils class contains utility methods for lcdui classes. |
27 */ |
27 */ |
28 public final class DirectUtils { |
28 public final class DirectUtils |
|
29 { |
29 |
30 |
30 private DirectUtils() { |
31 private DirectUtils() |
|
32 { |
31 } |
33 } |
32 |
34 |
33 /** |
35 /** |
34 * Create mutable image by decoding image data array. |
36 * Create mutable image by decoding image data array. |
35 * |
37 * |
37 * @param imageOffset offset |
39 * @param imageOffset offset |
38 * @param imageLength length |
40 * @param imageLength length |
39 * @return mutable image |
41 * @return mutable image |
40 */ |
42 */ |
41 public static Image createImage(byte[] imageData, int imageOffset, |
43 public static Image createImage(byte[] imageData, int imageOffset, |
42 int imageLength) { |
44 int imageLength) |
|
45 { |
43 Image src = Image.createImage(imageData, imageOffset, imageLength); |
46 Image src = Image.createImage(imageData, imageOffset, imageLength); |
44 Image ret = Image.createImage(src.getWidth(), src.getHeight()); |
47 Image ret = Image.createImage(src.getWidth(), src.getHeight()); |
45 ret.getGraphics().drawImage(src, 0, 0, 0); |
48 ret.getGraphics().drawImage(src, 0, 0, 0); |
46 return ret; |
49 return ret; |
47 } |
50 } |
52 * @param width image width |
55 * @param width image width |
53 * @param height image height |
56 * @param height image height |
54 * @param argbColor fill color |
57 * @param argbColor fill color |
55 * @return mutable image |
58 * @return mutable image |
56 */ |
59 */ |
57 public static Image createImage(int width, int height, int argbColor) { |
60 public static Image createImage(int width, int height, int argbColor) |
|
61 { |
58 Image ret = Image.createImage(width, height); |
62 Image ret = Image.createImage(width, height); |
59 Graphics g = ret.getGraphics(); |
63 Graphics g = ret.getGraphics(); |
60 LCDUIInvoker.getDirectGraphics(g).setARGBColor(argbColor); |
64 LCDUIInvoker.getDirectGraphics(g).setARGBColor(argbColor); |
61 g.fillRect(0, 0, width, height); |
65 g.fillRect(0, 0, width, height); |
62 return ret; |
66 return ret; |
66 * Convert standard Graphics object to DirectGraphics. |
70 * Convert standard Graphics object to DirectGraphics. |
67 * |
71 * |
68 * @param g graphics object |
72 * @param g graphics object |
69 * @return DirectGraphics object |
73 * @return DirectGraphics object |
70 */ |
74 */ |
71 public static DirectGraphics getDirectGraphics(Graphics g) { |
75 public static DirectGraphics getDirectGraphics(Graphics g) |
|
76 { |
72 return LCDUIInvoker.getDirectGraphics(g); |
77 return LCDUIInvoker.getDirectGraphics(g); |
73 } |
78 } |
74 |
79 |
75 /** |
80 /** |
76 * Request Font instance with custom font height. |
81 * Request Font instance with custom font height. |
78 * @param face font face |
83 * @param face font face |
79 * @param style font style |
84 * @param style font style |
80 * @param height font height |
85 * @param height font height |
81 * @return custom font |
86 * @return custom font |
82 */ |
87 */ |
83 public static Font getFont(int face, int style, int height) { |
88 public static Font getFont(int face, int style, int height) |
|
89 { |
84 return LCDUIInvoker.getFreeSizedFont(face, style, height); |
90 return LCDUIInvoker.getFreeSizedFont(face, style, height); |
85 } |
91 } |
86 |
92 |
87 } |
93 } |