Project

General

Profile

1811q_diff_20150901_2.txt

Sergey Ivanovskiy, 09/01/2015 02:39 PM

Download (10.6 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java'
2
--- src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java	2015-05-18 20:48:28 +0000
3
+++ src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java	2015-09-01 18:03:50 +0000
4
@@ -415,6 +415,15 @@
5
          {
6
             offsetY = 0;
7
          }
8
+         /**
9
+          * Sets the window icon. The drawing parameters are due to the drawing operations are
10
+          * performed on the server side for the web rendering engine implementation.
11
+          */
12
+         if (isIcon)
13
+         {
14
+            gd.setIcon(img, 0, 0, iw, ih, offsetX, offsetY, icfg.transparent,
15
+                      icfg.stretchToFit && !isIcon, icfg.retainShape, icfg.convert3D);
16
+         }
17
          // render image
18
          gd.drawImage(img, 0, 0, iw, ih, offsetX, offsetY, icfg.transparent,
19
                       icfg.stretchToFit && !isIcon, icfg.retainShape, icfg.convert3D);
20

    
21
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java'
22
--- src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2015-09-01 15:52:56 +0000
23
+++ src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2015-09-01 18:07:39 +0000
24
@@ -931,17 +931,7 @@
25
                          boolean      convert3D)
26
    {
27
       PaintStructure ps = new PaintStructure(PaintPrimitives.DRAW_IMAGE);
28
-      ps.x = x;
29
-      ps.y = y;
30
-      ps.width = w;
31
-      ps.height = h;
32
-      ps.xOffset = xoff;
33
-      ps.yOffset = yoff;
34
-      ps.transparent = transparent;
35
-      ps.stretchToFit = stretch;
36
-      ps.retainShape = retain;
37
-      ps.convert3D = convert3D;
38
-      ps.img = img;
39
+      fillPaintStructure(ps, img, x, y, w, h, xoff, yoff, transparent, stretch, retain, convert3D);
40
 
41
       ews.offer(ps);
42
    }
43
@@ -1015,21 +1005,105 @@
44
     * 
45
     * @param    icon
46
     *           The wrapped icon.
47
+    * @param    x
48
+    *           The icon left location.
49
+    * @param    y
50
+    *           The icon top location.
51
     * @param    width
52
-    *           the icon width.
53
+    *           The icon width.
54
     * @param    height
55
-    *           the icon height.
56
+    *           The icon height.
57
+    * @param    xoff
58
+    *           x offset inside image of the icon to select drawing region.
59
+    * @param    yoff
60
+    *           y offset inside image of the icon to select drawing region.
61
+    * @param    transparent
62
+    *           Flag indicating to use lower-left pixel as color marker to draw part of image as
63
+    *           transparent.
64
+    * @param    stretch
65
+    *           Flag indicating stretch or shrink the image to fit display area.
66
+    * @param    retain
67
+    *           Flag indicating keep original image aspect ratio when stretching the image.
68
+    * @param    convert3D
69
+    *           Flag indicating autoconvert some image colors to the corresponding system wide 3D
70
+    *           colors.
71
     */
72
    @Override
73
-   public void setIcon(ImageWrapper<BufferedImage> icon, int width, int height)
74
+   public void setIcon(ImageWrapper<BufferedImage> icon,
75
+                         int             x,
76
+                         int             y,
77
+                         int             width,
78
+                         int             height,
79
+                         int             xoff,
80
+                         int             yoff,
81
+                         boolean         transparent,
82
+                         boolean         stretch,
83
+                         boolean         retain,
84
+                         boolean         convert3D)
85
    {
86
       PaintStructure ps = new PaintStructure(PaintPrimitives.SET_ICON);
87
-      ps.img    = icon;
88
-      ps.width  = width;
89
-      ps.height = height;
90
+      fillPaintStructure(ps, icon, x, y, width, height, xoff, yoff, transparent, stretch, retain,
91
+               convert3D);
92
 
93
       ews.offer(ps);
94
    }
95
+   
96
+   /**
97
+    * Fills the helper paint structure with target values.
98
+    * 
99
+    * @param    ps
100
+    *           The paint structure to be filled with the provided values.
101
+    * @param    img
102
+    *           The wrapped image.
103
+    * @param    x
104
+    *           The image left location.
105
+    * @param    y
106
+    *           The image top location.
107
+    * @param    w
108
+    *           The image width.
109
+    * @param    h
110
+    *           The image height.
111
+    * @param    xoff
112
+    *           x offset inside image to select the drawing region.
113
+    * @param    yoff
114
+    *           y offset inside image to select the drawing region.
115
+    * @param    transparent
116
+    *           Flag indicating to use lower-left pixel as color marker to draw part of image as
117
+    *           transparent.
118
+    * @param    stretch
119
+    *           Flag indicating stretch or shrink the image to fit display area.
120
+    * @param    retain
121
+    *           Flag indicating keep original image aspect ratio when stretching the image.
122
+    * @param    convert3D
123
+    *           Flag indicating autoconvert some image colors to the corresponding system wide 3D
124
+    *           colors.
125
+    */
126
+   private static void fillPaintStructure(
127
+                        PaintStructure ps,
128
+                        ImageWrapper<BufferedImage> img,
129
+                        int             x,
130
+                        int             y,
131
+                        int             w,
132
+                        int             h,
133
+                        int             xoff,
134
+                        int             yoff,
135
+                        boolean         transparent,
136
+                        boolean         stretch,
137
+                        boolean         retain,
138
+                        boolean         convert3D)
139
+   {
140
+      ps.x = x;
141
+      ps.y = y;
142
+      ps.width = w;
143
+      ps.height = h;
144
+      ps.xOffset = xoff;
145
+      ps.yOffset = yoff;
146
+      ps.transparent = transparent;
147
+      ps.stretchToFit = stretch;
148
+      ps.retainShape = retain;
149
+      ps.convert3D = convert3D;
150
+      ps.img = img;
151
+   }
152
 
153
    /**
154
     * Set current font used on draw operations.
155

    
156
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/EmulatedWindowState.java'
157
--- src/com/goldencode/p2j/ui/client/gui/driver/EmulatedWindowState.java	2015-09-01 15:52:56 +0000
158
+++ src/com/goldencode/p2j/ui/client/gui/driver/EmulatedWindowState.java	2015-09-01 18:07:39 +0000
159
@@ -474,6 +474,7 @@
160
                               ps.height,
161
                               ps.arcDiameter);
162
                      break;
163
+                  case SET_ICON:
164
                   case DRAW_RECT:
165
                   case FILL_RECT:
166
                   case DRAW_IMAGE:
167

    
168
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java'
169
--- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java	2015-09-01 12:47:54 +0000
170
+++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java	2015-09-01 17:41:20 +0000
171
@@ -964,10 +964,38 @@
172
     * 
173
     * @param    icon
174
     *           The wrapped icon.
175
+    * @param    x
176
+    *           The icon left location.
177
+    * @param    y
178
+    *           The icon top location.
179
     * @param    width
180
-    *           the icon width.
181
+    *           The icon width.
182
     * @param    height
183
-    *           the icon height.
184
+    *           The icon height.
185
+    * @param    xoff
186
+    *           x offset inside image of the icon to select drawing region.
187
+    * @param    yoff
188
+    *           y offset inside image of the icon to select drawing region.
189
+    * @param    transparent
190
+    *           Flag indicating to use lower-left pixel as color marker to draw part of image as
191
+    *           transparent.
192
+    * @param    stretch
193
+    *           Flag indicating stretch or shrink the image to fit display area.
194
+    * @param    retain
195
+    *           Flag indicating keep original image aspect ratio when stretching the image.
196
+    * @param    convert3D
197
+    *           Flag indicating autoconvert some image colors to the corresponding system wide 3D
198
+    *           colors.
199
     */
200
-   public void setIcon(ImageWrapper<I> icon, int width, int height);
201
+   public void setIcon(ImageWrapper<I> icon,
202
+                         int             x,
203
+                         int             y,
204
+                         int             width,
205
+                         int             height,
206
+                         int             xoff,
207
+                         int             yoff,
208
+                         boolean         transparent,
209
+                         boolean         stretch,
210
+                         boolean         retain,
211
+                         boolean         convert3D);
212
 }
213

    
214
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java'
215
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2015-09-01 15:52:56 +0000
216
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2015-09-01 18:19:43 +0000
217
@@ -401,12 +401,13 @@
218
             break;
219
          case SET_ICON:
220
             {
221
-               ImageWrapper wrappedImage = ps.img;
222
-               Object[] imageEncodedPacket = encodeImage(0, 0, wrappedImage);
223
+               ImageWrapper wrappedImage = drawHelper.processImage(ps);
224
+               Object[] imageEncodedPacket = encodeImage(ps.x, ps.y, wrappedImage);
225
                int imageHash = (Integer) imageEncodedPacket[0];
226
                ImageEncoding encoding = (ImageEncoding) imageEncodedPacket[1];
227
                byte[] encodedImage = (byte[]) imageEncodedPacket[2];
228
-               websock.setIconImage(ps.width, ps.height, encoding, imageHash, encodedImage);
229
+               websock.setIconImage(wrappedImage.getWidth(), wrappedImage.getHeight(), encoding,
230
+                        imageHash, encodedImage);
231
             }
232
             break;
233
          default:
234

    
235
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
236
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-09-01 15:52:56 +0000
237
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-09-01 18:07:39 +0000
238
@@ -1151,6 +1151,7 @@
239
             case ops.SET_ICON:
240
                var iconWidth  = p2j.socket.readInt32BinaryMessage(message, idx + 1);
241
                var iconHeight = p2j.socket.readInt32BinaryMessage(message, idx + 5);
242
+               extra = " x = 0; y = 0; width = " + iconWidth + "; height = " + iconHeight;
243
                var encoding = message[idx + 9];
244
                var key = p2j.socket.readInt32BinaryMessage(message, idx + 10);
245
                var pixelsInBytes = iconWidth * iconHeight * 4;
246
@@ -1165,6 +1166,7 @@
247
                   this.iconWidth  = iconWidth;
248
                   this.iconHeight = iconHeight;
249
                }
250
+               
251
                break;
252
             default:
253
                if (typeof type !== "undefined")
254