PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/AppKit/rhino.platform/CPImage.j

http://github.com/polymar/polish
Unknown | 284 lines | 284 code | 0 blank | 0 comment | 0 complexity | d1b9d868f1a668d74df888e95528be09 MD5 | raw file
  1I;21;Foundation/CPBundle.jI;33;Foundation/CPNotificationCenter.jI;21;Foundation/CPObject.jI;22;Foundation/CPRunLoop.jI;21;Foundation/CPString.ji;12;CPGeometry.jc;8936;
  2CPImageLoadStatusInitialized=0;
  3CPImageLoadStatusLoading=1;
  4CPImageLoadStatusCompleted=2;
  5CPImageLoadStatusCancelled=3;
  6CPImageLoadStatusInvalidData=4;
  7CPImageLoadStatusUnexpectedEOF=5;
  8CPImageLoadStatusReadError=6;
  9CPImageDidLoadNotification="CPImageDidLoadNotification";
 10CPImageInBundle=function(_1,_2,_3){
 11if(!_3){
 12_3=objj_msgSend(CPBundle,"mainBundle");
 13}
 14if(_2){
 15return objj_msgSend(objj_msgSend(CPImage,"alloc"),"initWithContentsOfFile:size:",objj_msgSend(_3,"pathForResource:",_1),_2);
 16}
 17return objj_msgSend(objj_msgSend(CPImage,"alloc"),"initWithContentsOfFile:",objj_msgSend(_3,"pathForResource:",_1));
 18};
 19var _4=objj_getClass("CPBundle");
 20if(!_4){
 21objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPBundle\""));
 22}
 23var _5=_4.isa;
 24class_addMethods(_4,[new objj_method(sel_getUid("pathForResource:"),function(_6,_7,_8){
 25with(_6){
 26return objj_msgSend(_6,"resourcePath")+"/"+_8;
 27}
 28})]);
 29var _4=objj_allocateClassPair(CPObject,"CPImage"),_5=_4.isa;
 30class_addIvars(_4,[new objj_ivar("_size"),new objj_ivar("_filename"),new objj_ivar("_delegate"),new objj_ivar("_loadStatus"),new objj_ivar("_image")]);
 31objj_registerClassPair(_4);
 32objj_addClassForBundle(_4,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 33class_addMethods(_4,[new objj_method(sel_getUid("initByReferencingFile:size:"),function(_9,_a,_b,_c){
 34with(_9){
 35_9=objj_msgSendSuper({receiver:_9,super_class:objj_getClass("CPObject")},"init");
 36if(_9){
 37_size=CPSizeCreateCopy(_c);
 38_filename=_b;
 39_loadStatus=CPImageLoadStatusInitialized;
 40}
 41return _9;
 42}
 43}),new objj_method(sel_getUid("initWithContentsOfFile:size:"),function(_d,_e,_f,_10){
 44with(_d){
 45_d=objj_msgSend(_d,"initByReferencingFile:size:",_f,_10);
 46if(_d){
 47objj_msgSend(_d,"load");
 48}
 49return _d;
 50}
 51}),new objj_method(sel_getUid("initWithContentsOfFile:"),function(_11,_12,_13){
 52with(_11){
 53_11=objj_msgSend(_11,"initByReferencingFile:size:",_13,CGSizeMake(-1,-1));
 54if(_11){
 55objj_msgSend(_11,"load");
 56}
 57return _11;
 58}
 59}),new objj_method(sel_getUid("filename"),function(_14,_15){
 60with(_14){
 61return _filename;
 62}
 63}),new objj_method(sel_getUid("setSize:"),function(_16,_17,_18){
 64with(_16){
 65_size=CGSizeMakeCopy(_18);
 66}
 67}),new objj_method(sel_getUid("size"),function(_19,_1a){
 68with(_19){
 69return _size;
 70}
 71}),new objj_method(sel_getUid("setDelegate:"),function(_1b,_1c,_1d){
 72with(_1b){
 73_delegate=_1d;
 74}
 75}),new objj_method(sel_getUid("delegate"),function(_1e,_1f){
 76with(_1e){
 77return _delegate;
 78}
 79}),new objj_method(sel_getUid("loadStatus"),function(_20,_21){
 80with(_20){
 81return _loadStatus;
 82}
 83}),new objj_method(sel_getUid("load"),function(_22,_23){
 84with(_22){
 85if(_loadStatus==CPImageLoadStatusLoading||_loadStatus==CPImageLoadStatusCompleted){
 86return;
 87}
 88_loadStatus=CPImageLoadStatusLoading;
 89_image=new Image();
 90var _24=YES;
 91_image.onload=function(){
 92if(_24){
 93window.setTimeout(function(){
 94objj_msgSend(_22,"_imageDidLoad");
 95},0);
 96}else{
 97objj_msgSend(_22,"_imageDidLoad");
 98objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
 99}
100objj_msgSend(_22,"_derefFromImage");
101};
102_image.onerror=function(){
103if(_24){
104window.setTimeout(function(){
105objj_msgSend(_22,"_imageDidError");
106},0);
107}else{
108objj_msgSend(_22,"_imageDidError");
109objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
110}
111objj_msgSend(_22,"_derefFromImage");
112};
113_image.onabort=function(){
114if(_24){
115window.setTimeout(function(){
116objj_msgSend(_22,"_imageDidAbort");
117},0);
118}else{
119objj_msgSend(_22,"_imageDidAbort");
120objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
121}
122objj_msgSend(_22,"_derefFromImage");
123};
124_image.src=_filename;
125_24=NO;
126}
127}),new objj_method(sel_getUid("isThreePartImage"),function(_25,_26){
128with(_25){
129return NO;
130}
131}),new objj_method(sel_getUid("isNinePartImage"),function(_27,_28){
132with(_27){
133return NO;
134}
135}),new objj_method(sel_getUid("_derefFromImage"),function(_29,_2a){
136with(_29){
137_image.onload=null;
138_image.onerror=null;
139_image.onabort=null;
140}
141}),new objj_method(sel_getUid("_imageDidLoad"),function(_2b,_2c){
142with(_2b){
143_loadStatus=CPImageLoadStatusCompleted;
144if(!_size||(_size.width==-1&&_size.height==-1)){
145_size=CGSizeMake(_image.width,_image.height);
146}
147objj_msgSend(objj_msgSend(CPNotificationCenter,"defaultCenter"),"postNotificationName:object:",CPImageDidLoadNotification,_2b);
148if(objj_msgSend(_delegate,"respondsToSelector:",sel_getUid("imageDidLoad:"))){
149objj_msgSend(_delegate,"imageDidLoad:",_2b);
150}
151}
152}),new objj_method(sel_getUid("_imageDidError"),function(_2d,_2e){
153with(_2d){
154_loadStatus=CPImageLoadStatusReadError;
155if(objj_msgSend(_delegate,"respondsToSelector:",sel_getUid("imageDidError:"))){
156objj_msgSend(_delegate,"imageDidError:",_2d);
157}
158}
159}),new objj_method(sel_getUid("_imageDidAbort"),function(_2f,_30){
160with(_2f){
161_loadStatus=CPImageLoadStatusCancelled;
162if(objj_msgSend(_delegate,"respondsToSelector:",sel_getUid("imageDidAbort:"))){
163objj_msgSend(_delegate,"imageDidAbort:",_2f);
164}
165}
166})]);
167var _4=objj_getClass("CPImage");
168if(!_4){
169objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPImage\""));
170}
171var _5=_4.isa;
172class_addMethods(_4,[new objj_method(sel_getUid("initWithCoder:"),function(_31,_32,_33){
173with(_31){
174return objj_msgSend(_31,"initWithContentsOfFile:size:",objj_msgSend(_33,"decodeObjectForKey:","CPFilename"),objj_msgSend(_33,"decodeSizeForKey:","CPSize"));
175}
176}),new objj_method(sel_getUid("encodeWithCoder:"),function(_34,_35,_36){
177with(_34){
178objj_msgSend(_36,"encodeObject:forKey:",_filename,"CPFilename");
179objj_msgSend(_36,"encodeSize:forKey:",_size,"CPSize");
180}
181})]);
182var _4=objj_allocateClassPair(CPObject,"CPThreePartImage"),_5=_4.isa;
183class_addIvars(_4,[new objj_ivar("_imageSlices"),new objj_ivar("_isVertical")]);
184objj_registerClassPair(_4);
185objj_addClassForBundle(_4,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
186class_addMethods(_4,[new objj_method(sel_getUid("initWithImageSlices:isVertical:"),function(_37,_38,_39,_3a){
187with(_37){
188_37=objj_msgSendSuper({receiver:_37,super_class:objj_getClass("CPObject")},"init");
189if(_37){
190_imageSlices=_39;
191_isVertical=_3a;
192}
193return _37;
194}
195}),new objj_method(sel_getUid("filename"),function(_3b,_3c){
196with(_3b){
197return "";
198}
199}),new objj_method(sel_getUid("imageSlices"),function(_3d,_3e){
200with(_3d){
201return _imageSlices;
202}
203}),new objj_method(sel_getUid("isVertical"),function(_3f,_40){
204with(_3f){
205return _isVertical;
206}
207}),new objj_method(sel_getUid("isThreePartImage"),function(_41,_42){
208with(_41){
209return YES;
210}
211}),new objj_method(sel_getUid("isNinePartImage"),function(_43,_44){
212with(_43){
213return NO;
214}
215})]);
216var _45="CPThreePartImageImageSlicesKey",_46="CPThreePartImageIsVerticalKey";
217var _4=objj_getClass("CPThreePartImage");
218if(!_4){
219objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPThreePartImage\""));
220}
221var _5=_4.isa;
222class_addMethods(_4,[new objj_method(sel_getUid("initWithCoder:"),function(_47,_48,_49){
223with(_47){
224_47=objj_msgSendSuper({receiver:_47,super_class:objj_getClass("CPObject")},"init");
225if(_47){
226_imageSlices=objj_msgSend(_49,"decodeObjectForKey:",_45);
227_isVertical=objj_msgSend(_49,"decodeBoolForKey:",_46);
228}
229return _47;
230}
231}),new objj_method(sel_getUid("encodeWithCoder:"),function(_4a,_4b,_4c){
232with(_4a){
233objj_msgSend(_4c,"encodeObject:forKey:",_imageSlices,_45);
234objj_msgSend(_4c,"encodeBool:forKey:",_isVertical,_46);
235}
236})]);
237var _4=objj_allocateClassPair(CPObject,"CPNinePartImage"),_5=_4.isa;
238class_addIvars(_4,[new objj_ivar("_imageSlices")]);
239objj_registerClassPair(_4);
240objj_addClassForBundle(_4,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
241class_addMethods(_4,[new objj_method(sel_getUid("initWithImageSlices:"),function(_4d,_4e,_4f){
242with(_4d){
243_4d=objj_msgSendSuper({receiver:_4d,super_class:objj_getClass("CPObject")},"init");
244if(_4d){
245_imageSlices=_4f;
246}
247return _4d;
248}
249}),new objj_method(sel_getUid("filename"),function(_50,_51){
250with(_50){
251return "";
252}
253}),new objj_method(sel_getUid("imageSlices"),function(_52,_53){
254with(_52){
255return _imageSlices;
256}
257}),new objj_method(sel_getUid("isThreePartImage"),function(_54,_55){
258with(_54){
259return NO;
260}
261}),new objj_method(sel_getUid("isNinePartImage"),function(_56,_57){
262with(_56){
263return YES;
264}
265})]);
266var _58="CPNinePartImageImageSlicesKey";
267var _4=objj_getClass("CPNinePartImage");
268if(!_4){
269objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPNinePartImage\""));
270}
271var _5=_4.isa;
272class_addMethods(_4,[new objj_method(sel_getUid("initWithCoder:"),function(_59,_5a,_5b){
273with(_59){
274_59=objj_msgSendSuper({receiver:_59,super_class:objj_getClass("CPObject")},"init");
275if(_59){
276_imageSlices=objj_msgSend(_5b,"decodeObjectForKey:",_58);
277}
278return _59;
279}
280}),new objj_method(sel_getUid("encodeWithCoder:"),function(_5c,_5d,_5e){
281with(_5c){
282objj_msgSend(_5e,"encodeObject:forKey:",_imageSlices,_58);
283}
284})]);