Project

General

Profile

1811q_diff_20150901_3.txt

Sergey Ivanovskiy, 09/01/2015 04:18 PM

Download (7.83 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java'
2
--- src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java	2015-09-01 18:27:30 +0000
3
+++ src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java	2015-09-01 20:02:46 +0000
4
@@ -348,7 +348,90 @@
5
          return screen().coordinates().rowToNative(height());
6
       }
7
    }
8
-   
9
+
10
+   /**
11
+    * Calculates the drawing parameters:
12
+    *     width  =  (Integer) drawingParameters[0];
13
+    *     height =  (Integer) drawingParameters[1];
14
+    *     offsetX = (Integer) drawingParameters[2];
15
+    *     offsetY = (Integer) drawingParameters[3];
16
+    *     transparent  = (Boolean) drawingParameters[4];
17
+    *     stretchToFit = (Boolean) drawingParameters[5];
18
+    *     retainShape  = (Boolean) drawingParameters[6];
19
+    *     convert3D    = (Boolean) drawingParameters[7];
20
+    *
21
+    * @return   The array filled with drawing parameters.
22
+    */
23
+   protected Object[] calculateDrawingParameters()
24
+   {
25
+      if (img == null)
26
+      {
27
+         return null;
28
+      }
29
+      CoordinatesConversion c = screen().coordinates();
30
+      
31
+      // get the current image config
32
+      ImageConfig icfg = (ImageConfig) config();
33
+
34
+      // the width and height in pixels or chars overridden by size phrase has higher priority
35
+      // than natural image size itself
36
+      int w = icfg.widthPixels > 0 ? icfg.widthPixels : icfg.widthChars > 0 ?
37
+                 c.widthToNative(icfg.widthChars) : c.widthToNative(width());
38
+      int h = icfg.heightPixels > 0 ? icfg.heightPixels : icfg.heightChars > 0 ?
39
+                 c.heightToNative(icfg.heightChars) : c.heightToNative(height());
40
+
41
+      // compute final image dimensions
42
+      int iw = 0;
43
+      int ih = 0;
44
+      
45
+      if (icfg.stretchToFit && !isIcon)
46
+      {
47
+         // need to fit the image to display area size
48
+         iw = w;
49
+         ih = h;
50
+      }
51
+      else
52
+      {
53
+         // take the final image size as minimum from requested and real image sizes
54
+         iw = Math.min(img.getWidth(), w);
55
+         ih = Math.min(img.getHeight(), h);
56
+      }
57
+      
58
+      // recalculate image offsets that can be changed
59
+      int offsetX = -1;
60
+      int offsetY = -1;
61
+      
62
+      // check if we have the offset variables changed
63
+      if (icfg.offsetX != -1)
64
+      {
65
+         offsetX = icfg.offsetX;
66
+      }
67
+      else if (icfg.offsetCol != 0.0)
68
+      {
69
+         offsetX = screen().coordinates().columnToNative(icfg.offsetCol);
70
+      }
71
+      else if (icfg.widthPixels != 0 || icfg.widthChars != 0.0)
72
+      {
73
+         offsetX = 0;
74
+      }
75
+      // Y coordinate
76
+      if (icfg.offsetY != -1)
77
+      {
78
+         offsetY = icfg.offsetY;
79
+      }
80
+      else if (icfg.offsetRow != 0.0)
81
+      {
82
+         offsetY = screen().coordinates().rowToNative(icfg.offsetRow);
83
+      }
84
+      else if (icfg.heightPixels != 0 || icfg.heightChars != 0.0)
85
+      {
86
+         offsetY = 0;
87
+      }
88
+
89
+      return new Object[] { iw, ih, offsetX, offsetY, icfg.transparent,
90
+               icfg.stretchToFit && !isIcon, icfg.retainShape, icfg.convert3D};
91
+   }
92
+
93
    /**
94
     * Draw this image.
95
     */
96
@@ -356,77 +439,18 @@
97
    {
98
       if (img != null)
99
       {
100
-         CoordinatesConversion c = screen().coordinates();
101
-         
102
-         // get the current image config
103
-         ImageConfig icfg = (ImageConfig) config();
104
-
105
-         // the width and height in pixels or chars overridden by size phrase has higher priority
106
-         // than natural image size itself
107
-         int w = icfg.widthPixels > 0 ? icfg.widthPixels : icfg.widthChars > 0 ?
108
-                    c.widthToNative(icfg.widthChars) : c.widthToNative(width());
109
-         int h = icfg.heightPixels > 0 ? icfg.heightPixels : icfg.heightChars > 0 ?
110
-                    c.heightToNative(icfg.heightChars) : c.heightToNative(height());
111
-
112
-         // compute final image dimensions
113
-         int iw = 0;
114
-         int ih = 0;
115
-         
116
-         if (icfg.stretchToFit && !isIcon)
117
-         {
118
-            // need to fit the image to display area size
119
-            iw = w;
120
-            ih = h;
121
-         }
122
-         else
123
-         {
124
-            // take the final image size as minimum from requested and real image sizes
125
-            iw = Math.min(img.getWidth(), w);
126
-            ih = Math.min(img.getHeight(), h);
127
-         }
128
-         
129
-         // recalculate image offsets that can be changed
130
-         int offsetX = -1;
131
-         int offsetY = -1;
132
-         
133
-         // check if we have the offset variables changed
134
-         if (icfg.offsetX != -1)
135
-         {
136
-            offsetX = icfg.offsetX;
137
-         }
138
-         else if (icfg.offsetCol != 0.0)
139
-         {
140
-            offsetX = screen().coordinates().columnToNative(icfg.offsetCol);
141
-         }
142
-         else if (icfg.widthPixels != 0 || icfg.widthChars != 0.0)
143
-         {
144
-            offsetX = 0;
145
-         }
146
-         // Y coordinate
147
-         if (icfg.offsetY != -1)
148
-         {
149
-            offsetY = icfg.offsetY;
150
-         }
151
-         else if (icfg.offsetRow != 0.0)
152
-         {
153
-            offsetY = screen().coordinates().rowToNative(icfg.offsetRow);
154
-         }
155
-         else if (icfg.heightPixels != 0 || icfg.heightChars != 0.0)
156
-         {
157
-            offsetY = 0;
158
-         }
159
-         /**
160
-          * Sets the window icon. The drawing parameters are due to the drawing operations are
161
-          * performed on the server side for the web rendering engine implementation.
162
-          */
163
-         if (isIcon)
164
-         {
165
-            gd.setIcon(img, 0, 0, iw, ih, offsetX, offsetY, icfg.transparent,
166
-                      icfg.stretchToFit && !isIcon, icfg.retainShape, icfg.convert3D);
167
-         }
168
+         Object[] drawingParameters = calculateDrawingParameters();
169
+         int iw = (Integer) drawingParameters[0];
170
+         int ih = (Integer) drawingParameters[1];
171
+         int offsetX = (Integer) drawingParameters[2];
172
+         int offsetY = (Integer) drawingParameters[3];
173
+         boolean transparent  = (Boolean) drawingParameters[4];
174
+         boolean stretchToFit = (Boolean) drawingParameters[5];
175
+         boolean retainShape  = (Boolean) drawingParameters[6];
176
+         boolean convert3D    = (Boolean) drawingParameters[7];
177
          // render image
178
-         gd.drawImage(img, 0, 0, iw, ih, offsetX, offsetY, icfg.transparent,
179
-                      icfg.stretchToFit && !isIcon, icfg.retainShape, icfg.convert3D);
180
+         gd.drawImage(img, 0, 0, iw, ih, offsetX, offsetY, transparent,
181
+                      stretchToFit, retainShape, convert3D);
182
       }
183
       
184
       return img != null;
185

    
186
=== modified file 'src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java'
187
--- src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java	2015-08-26 22:14:27 +0000
188
+++ src/com/goldencode/p2j/ui/client/gui/WindowTitleBar.java	2015-09-01 20:11:17 +0000
189
@@ -288,6 +288,24 @@
190
                       title.location().x         - 
191
                       c.widthFromNative(nativeInsets.right);
192
       title.setWidth(twidth);
193
+      if (icon != null && icon.img != null)
194
+      {
195
+         Object[] drawingParameters = icon.calculateDrawingParameters();
196
+         int iw = (Integer) drawingParameters[0];
197
+         int ih = (Integer) drawingParameters[1];
198
+         int offsetX = (Integer) drawingParameters[2];
199
+         int offsetY = (Integer) drawingParameters[3];
200
+         boolean transparent  = (Boolean) drawingParameters[4];
201
+         boolean stretchToFit = (Boolean) drawingParameters[5];
202
+         boolean retainShape  = (Boolean) drawingParameters[6];
203
+         boolean convert3D    = (Boolean) drawingParameters[7];
204
+         /**
205
+          * Sets the window icon. The drawing parameters are due to the drawing operations are
206
+          * performed on the server side for the web rendering engine implementation.
207
+          */
208
+         gd.setIcon(icon.img, 0, 0, iw, ih, offsetX, offsetY, transparent,
209
+                   stretchToFit, retainShape, convert3D);
210
+      }
211
    }
212
    
213
    /**
214