Changeset 19

Show
Ignore:
Timestamp:
01/24/07 01:43:14 (2 years ago)
Author:
mikel
Message:

new zoomify code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • worldkit/com/brainoff/worldkitConfig.as

    r14 r19  
    106106    var zoomc:Number; 
    107107    var zoomifydir:String; 
    108     var zoomifynav:Boolean; 
    109108    var zoomselect:Boolean; 
    110109    var zoomto:worldkitConfigCat; 
     
    173172        zoomc = 1.5; 
    174173        zoomifydir = "."; 
    175         zoomifynav = true; 
    176174        zoomselect = false; 
    177175         
     
    328326        case "maxzoom": 
    329327        case "toolbar": 
    330         case "zoomifynav": 
    331328        case "track": 
    332329        case "uniqueurls": 
     
    536533        //args passed in on url override config file 
    537534        parseArgs(); 
    538          
    539         loaded = true; 
    540         main.signalDone("CONFIG"); 
     535 
     536        if (loadZoomifyConfig()) { 
     537                return; /* waiting for ImageProperties.xml to load, that will signalDone */ 
     538        } else { 
     539                loaded = true; 
     540                main.signalDone("CONFIG"); 
     541        } 
    541542    } 
    542543 
     
    602603                    swftemplate[ id ].spanx = Math.ceil( (east - west ) / tiledeg ); 
    603604                    swftemplate[ id ].spany = Math.ceil( (north - south) / tiledeg ); 
    604                     swftemplate[ id ].extent = west + "," + (90 - (tiledeg * swftemplate[ id ].spany)) + "," + (-180 + (tiledeg * swftemplate[ id ].spanx)) + "," + north; 
     605                    swftemplate[ id ].extent = west + "," + (90 - (tiledeg * swftemplate[ id ].spany)) + "," + (-180 + (tiledeg * swftemplate[ id ].spanx)) + "," + north; /* BUG HERE in extent?? */ 
    605606                } else { 
    606607                    swftemplate[ id ].extent = west + "," + south + "," + east + "," + north; 
     
    615616    } 
    616617 
     618    private function loadZoomifyConfig():Boolean { 
     619        if (displaytype == "zoomify") { 
     620            if (zoomifydir.charAt(zoomifydir.length-1) != "/") { zoomifydir = zoomifydir + "/"; } 
     621            displaytype = "day"; 
     622            dayimg = ""; 
     623            var config:worldkitConfig = this; 
     624            var loader:XML = new XML(); 
     625            loader.ignoreWhite = true; 
     626            loader.onLoad = function(success) { config.onZoomifyConfig(this,success); }; 
     627            loader.load( zoomifydir + "ImageProperties.xml" );  
     628            return true; 
     629        } else { 
     630            return false; 
     631        } 
     632    } 
     633         
     634    public function onZoomifyConfig(xml:XML,success:Boolean):Void {  
     635        var val,i,node; 
     636        var zoomwidth, zoomheight, tilesize; 
     637        if (success) { 
     638            for (i = 0; i < xml.childNodes.length; i++) { 
     639                if (xml.childNodes[i].nodeName == "IMAGE_PROPERTIES") { 
     640                    node = xml.childNodes[i]; 
     641                    zoomwidth = node.attributes["WIDTH"]; 
     642                    zoomheight = node.attributes["HEIGHT"]; 
     643                    tilesize = node.attributes["TILESIZE"];     
     644                } 
     645            } 
     646 
     647            var levelwidth = zoomwidth; 
     648            var levelheight = zoomheight; 
     649            while (((levelwidth / 2) > tilesize) || ((levelheight / 2) > tilesize)) { 
     650                levelwidth = levelwidth / 2; 
     651                levelheight = levelheight / 2; 
     652            } 
     653            var level = 1; 
     654 
     655            var usewidth; 
     656            var useheight; 
     657            var spanx, spany; 
     658            var id; 
     659            var wklevel = 1; 
     660            var tilecount = 1;           
     661            var tiledegw; 
     662            var tiledegh; 
     663 
     664            while ((levelwidth <= zoomwidth) && (levelheight <= zoomheight)) { 
     665 
     666                usewidth = levelwidth; //Math.floor(levelwidth); 
     667                useheight = levelheight; //Math.floor(levelheight); 
     668                spanx = Math.ceil( usewidth / tilesize); 
     669                spany = Math.ceil( useheight / tilesize); 
     670                tiledegw = tilesize * (east - west) / usewidth; 
     671                tiledegh = tilesize * (north - south)  /useheight; 
     672 
     673                if (levelwidth >= this.w && levelheight >= this.h) { 
     674                         
     675                        id = "zoomify" + level;                  
     676                        swftemplate[ id ] = new Object(); 
     677                        swftemplate[ id ].tilewidth = tilesize; 
     678                        swftemplate[ id ].tileheight = tilesize; 
     679                        swftemplate[ id ].url = zoomifydir; 
     680                        swftemplate[ id ].zoomify = level; 
     681                        swftemplate[ id ].tilecount = tilecount; 
     682                        swftemplate[ id ].minscale = Math.pow(2, (wklevel - 1)); 
     683                        swftemplate[ id ].maxscale = maxscale; 
     684                        swftemplate[ id ].minview = Math.pow(2, (wklevel - 1)); 
     685                        swftemplate[ id ].maxview = maxscale; 
     686                        swftemplate[ id ].spanx = spanx; 
     687                        swftemplate[ id ].spany = spany; 
     688                        swftemplate[ id ].extent = west + "," + (north - (tiledegh * spany)) + "," + (west + (tiledegw * spanx)) + "," + north; 
     689                        swftemplate[ id ].category = "zoomify"; 
     690                        swftemplate[ id ].layer = swftemplatelayer; swftemplatelayer++; 
     691 
     692                        wklevel++; 
     693                } 
     694 
     695                levelwidth = levelwidth * 2; 
     696                levelheight = levelheight * 2; 
     697                level++; 
     698 
     699                tilecount = tilecount + ( spanx * spany );  
     700             } 
     701        } 
     702        loaded = true; 
     703        main.signalDone("CONFIG");       
     704    } 
     705 
     706 
    617707    public function getConfBySubject(option:String,cats:Array) { 
    618708        for (var i=0; i<cats.length; i++) { 
  • worldkit/com/brainoff/worldkitImages.as

    r14 r19  
    1717    private var startLoading:Number; 
    1818    private var loaderId:Number; 
    19  
    20     private var zmcb:Number; 
    2119 
    2220    public function worldkitImages(main:worldkitMain) { 
     
    3735        loadinglist = new Object(); 
    3836        loadinglist.size = 0; 
     37 
    3938    } 
    4039 
     
    5554                layer++; 
    5655            } 
    57             break; 
    58         case("zoomify"): 
    59             loadImage(imagemc, "day", conf.zoomifydir + "/zoomifyViewer.swf", layer, "Zoomify", 0, 0, undefined, undefined, undefined, true); 
    60             layer++; 
    6156            break; 
    6257        case("daynight"): 
     
    170165        loadinglist.size++; 
    171166        if (loaderId == -1) { 
    172             loaderId = setInterval( this, "MovieClipLoaderInterval", 250 ); 
     167            var i = 250; 
     168            loaderId = setInterval( this, "MovieClipLoaderInterval", i ); 
    173169        } 
    174170    } 
     
    287283    } 
    288284 
    289     public function Zoomify(mc:MovieClip, id:String):Void { 
    290         mc[id].ToolbarStandardInstance._visible = 0; 
    291         mc[id].ZoomifyViewerInstance.zoomifySplash_mc._visible = 0; 
    292         mc[id].toolbarIcon_btn._visible = 0; 
    293         mc[id].NavWindowInstance.navigationImage.zoomifySplash_mc._visible = false; 
    294         if (conf.zoomifynav == false) { 
    295             mc[id].NavWindowInstance._visible = 0; 
    296         } 
    297         mc[id].ZoomifyViewerInstance._x = conf.w / 2; 
    298         mc[id].ZoomifyViewerInstance._y = conf.h / 2; 
    299         mc[id].ZoomifyViewerInstance.setSize(conf.w,conf.h); 
    300         mc[id].ZoomifyViewerInstance.setEnabled(false); 
    301         mc[id].ZoomifyViewerInstance.setImagePath(conf.zoomifydir); 
    302         mc[id].ZoomifyViewerInstance.worldKitImg = this; 
    303         mc[id].ZoomifyViewerInstance.worldKitCb = function(t,p) {  
    304             t.unregisterCallback("DownloadComplete", t.zmcb); 
    305             t.worldKitImg.Pan(); 
    306         } 
    307         var cb = targetPath(mc[id]) + ".ZoomifyViewerInstance.worldKitCb"; 
    308         mc[id].ZoomifyViewerInstance.zmcb = mc[id].ZoomifyViewerInstance.registerCallback("DownloadComplete", cb); 
    309         mc[id].ZoomifyViewerInstance.updateView(); 
    310     } 
    311285 
    312286    public function MakeInvisible(mc:MovieClip, id:String):Void { 
     
    341315            mc[ id ]._visible = false; 
    342316        } 
    343     } 
    344  
    345  
    346  
    347     /* 
    348       Called when model changes... 
    349     */ 
    350      
    351     private function checkZoomify():Void { 
    352         var id = "day"; 
    353         if (imagemc[id].ZoomifyViewerInstance == undefined) { return; } 
    354         imagemc[id].ZoomifyViewerInstance.setEnabled(true); 
    355         var w = imagemc[id].ZoomifyViewerInstance.getImageWidth(); 
    356         var h = imagemc[id].ZoomifyViewerInstance.getImageHeight(); 
    357         imagemc[id].ZoomifyViewerInstance.setZoom( interact.scale * 100 * conf.w / w ); 
    358         imagemc[id].ZoomifyViewerInstance.setX( .5 -  interact.centerx / conf.w ); 
    359         imagemc[id].ZoomifyViewerInstance.setY( .5 -  interact.centery / conf.h ); 
    360         imagemc[id].ZoomifyViewerInstance.setEnabled(false); 
    361         imagemc[id].ZoomifyViewerInstance.updateView(); 
    362317    } 
    363318 
     
    459414                if (conf.swftemplate[id].tilemap) { 
    460415                        tileurl = tileurl + Math.log(conf.swftemplate[id].minscale)/Math.log(2) + "/" +  i + "/" + (conf.swftemplate[id].spany - j - 1) + ".jpg"; 
     416                } else if (conf.swftemplate[id].zoomify != undefined) { 
     417                        var group = Math.floor((conf.swftemplate[id].tilecount + i + (j * conf.swftemplate[id].spanx)) / 256); 
     418                        tileurl = tileurl + "TileGroup" + group + "/" + conf.swftemplate[id].zoomify + "-" + i + "-" + j + ".jpg"; 
     419                        trace(tileurl); 
    461420                } else { 
    462421                        tileurl = worldkitUtil.myreplace(tileurl,"NORTH",tilenorth); 
     
    590549         
    591550    public function Pan():Void { 
    592         if (conf.displaytype == "zoomify") { 
    593             checkZoomify(); 
    594         } else { 
    595             interact.scaleAndPosition(imagemc,"day"); 
    596         } 
     551        interact.scaleAndPosition(imagemc,"day"); 
    597552        if (conf.displaytype == "daynight") { 
    598553            interact.scaleAndPosition(imagemc,"night"); 
  • worldkit/com/brainoff/worldkitInteraction.as

    r18 r19  
    147147 
    148148        var maskx, masky; 
    149         if (conf.displaytype == "zoomify") { 
    150             maskx = conf.w; 
    151             masky = conf.h; 
    152         } else { 
    153  
    154             maskx=100, masky=100; 
    155             if (ratio >= 1) { 
     149        maskx=100, masky=100; 
     150        if (ratio >= 1) { 
    156151                main.parent._xscale = conf.w/ratio; 
    157152                main.parent._yscale = conf.h; 
     
    164159 
    165160                maskx = 100 * ratio; 
    166             } else { 
     161         } else { 
    167162                main.parent._xscale = conf.w; 
    168163                main.parent._yscale = conf.h*ratio; 
     
    175170 
    176171                masky = 100 * ratio; 
    177             } 
    178  
    179         } 
     172        } 
     173 
    180174         
    181175        main.parent.worldkitMask.beginFill(0x000000); 
     
    194188        componentScaleAndPosition("toolbar",conf.controlscale,0); 
    195189 
    196         if (conf.toolbar == true || (conf.displaytype == "zoomify" && conf.toolbar == undefined)) { 
     190        if (conf.toolbar == true) { 
    197191            var b = new Array("Up","In","Out","Down","Left","Right"); 
    198192            for (var i=0; i<b.length; i++) { 
     
    312306            mc.grabber.origx = mc.grabber._xmouse; 
    313307            mc.grabber.origy = mc.grabber._ymouse; 
    314             if (conf.displaytype == "zoomify") { 
    315                 mc.grabber.origwidth = conf.w; 
    316                 mc.grabber.origheight = conf.h; 
    317             } else if (conf.w > conf.h) { 
     308            if (conf.w > conf.h) { 
    318309                mc.grabber.origwidth = (conf.w/conf.h) * 100; 
    319310                mc.grabber.origheight = 100; 
     
    354345            var offsetx = 0; 
    355346            var offsety = 0; 
    356             if (conf.displaytype != "zoomify") { 
    357                 if (ratio > 1) { 
    358                     zoomboxw = 100 * ratio; zoomboxh = 100; 
    359                 } else { 
    360                     zoomboxw = 100; zoomboxh = 100 / ratio; 
    361                 } 
    362                 offsetx = (zoomboxw - 100); 
    363                 offsety = (zoomboxh - 100); 
    364             } 
     347            if (ratio > 1) { 
     348                zoomboxw = 100 * ratio; zoomboxh = 100; 
     349            } else { 
     350                zoomboxw = 100; zoomboxh = 100 / ratio; 
     351            } 
     352            offsetx = (zoomboxw - 100); 
     353            offsety = (zoomboxh - 100); 
    365354 
    366355            var zoomxscale = scale * ( zoomboxw / Math.abs(mc.zoombox.origx - mc.zoombox._xmouse)); 
     
    602591        if (args == undefined) { 
    603592            var w, h, xoffset=0, yoffset=0; 
    604             if (conf.displaytype == "zoomify") { 
    605                 w = conf.w; 
    606                 h = conf.h; 
    607             } else { 
    608                 if (ratio > 1) { 
     593            if (ratio > 1) { 
    609594                    w = 100 * ratio; h = 100; 
    610595                    xoffset = (w - h) / 2; 
    611                } else { 
     596            } else { 
    612597                    h = 100 / ratio; w = 100; 
    613598                    yoffset = (h - w) / 2; 
    614                 } 
    615599            } 
    616600            var lon = ((x + xoffset)/w) * (ceast - cwest) + cwest; 
     
    894878        var wfactor, hfactor; 
    895879         
    896         if (conf.displaytype == "zoomify") { 
    897             w = conf.w; 
    898             h = conf.h; 
    899             wfactor = conf.w; 
    900             hfactor = conf.h; 
    901         } else { 
    902             if (ratio > 1) { 
     880        if (ratio > 1) { 
    903881                w = 100 * ratio; h = 100; 
    904             } else { 
     882        } else { 
    905883                h = 100 / ratio; w = 100; 
    906             } 
    907             wfactor = 100; 
    908             hfactor = 100; 
    909         } 
     884        } 
     885        wfactor = 100; 
     886        hfactor = 100; 
    910887         
    911888        var wanother = 1; 
     
    955932        var h = conf.h; 
    956933 
    957         if (conf.displaytype != "zoomify") { 
    958             if (ratio > 1) { 
     934        if (ratio > 1) { 
    959935                scalew = 100 * ratio / conf.w; 
    960936                scaleh = 100 / conf.h; 
    961             } else { 
     937        } else { 
    962938                scalew = 100 / conf.w; 
    963939                scaleh = 100 / (conf.h * ratio); 
    964             } 
    965             w = 100; 
    966             h = 100; 
    967         } 
     940        } 
     941        w = 100; 
     942        h = 100; 
    968943     
    969944        mc[id]._xscale = sc * scalew; 
  • worldkit/com/brainoff/worldkitMain.as

    r18 r19  
    77 
    88class com.brainoff.worldkitMain { 
    9     static var version:String = "3.1-20070102"; 
     9    static var version:String = "3.1-20070123"; 
    1010 
    1111    var conf:worldkitConfig;