Changeset 29906


Ignore:
Timestamp:
2015-05-20T23:25:37+12:00 (6 years ago)
Author:
davidb
Message:

Changes resulting from writing the TPDL submission

Location:
other-projects/nz-flag-design/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • other-projects/nz-flag-design/trunk/main-form/choose-canvas.html

    r29811 r29906  
    5151    <script src="../similarity-2d/flag-processing.js"></script>
    5252
    53     <scriptXXX src="choose-canvas.js" />
     53    <style>
     54      a[href^="http://"]:after,
     55      a[href^="https://"]:after {
     56        content: url(http://upload.wikimedia.org/wikipedia/commons/6/64/Icon_External_Link.png);
     57        margin: 0 0 0 5px;
     58      }
     59    </style>
    5460
    5561    <script type="text/javascript">
     
    6470                               colourPots: colourPotSwatch.slice(0,3)
    6571                             };
     72    var isoCountryCode = null;
     73
    6674
    6775
     
    287295        // now change the flag tooltip labels into their country names
    288296        $.getJSON( "../similarity-2d/iso-3166-keyed-by-alpha-2-countrycodes.json", function(data) {
    289        
     297        isoCountryCodes = data;
     298
    290299            $.each( data, function( iso2_key, country_name ) {
    291300        var $img = $('#aspect-ratio-'+iso2_key.toLowerCase());
  • other-projects/nz-flag-design/trunk/main-form/choose-palette.html

    r29813 r29906  
    9494     
    9595            if (typeof flagCanvasSettings !== 'undefined') {
    96                 console.log("**** cp changed, !! selectedColourPotID = " + selectedColourPotID + " typeof = " + typeof(selectedColourPotID));
    97                 //var colour_pot_pos = selectedColourPotID.substring(10); // strip off 'colour-pos'
    9896                var colour_pot_pos = selectedColourPotID.replace("colour-pot","");
    99                 //colour_pot_pos = 0;
    100                 console.log("**** done replace");                   
    10197                flagCanvasSettings.colourPots[colour_pot_pos] = colour.toHexString();
    10298        }
     
    240236      selectedColourPot = colourPotElem;
    241237      selectedColourPotID = colourPotElem.id;
    242       console.log("**** cp clicked, selectedColourPotID = " + selectedColourPotID);                 
    243238      selectedColourPickerID = selectedColourPotID.replace("colour-pot","colour-picker");
    244239      selectedColourPickerDivID = selectedColourPotID.replace("colour-pot","colour-picker-div");
  • other-projects/nz-flag-design/trunk/main-form/iterative-design.html

    r29811 r29906  
    4646
    4747                                <li>
    48                                     <h2><span title="Click to Open/Close">Flag Similarity</span></h2>
     48                                    <h2><span title="Compare with world flags: click to open/close">World Flags Similarity</span></h2>
    4949
    5050                                    <div id="similarity-2d-div">
     
    5454                                    </div>
    5555                                </li>
     56
     57
     58                                <li>
     59                                    <h2><span title="Compare with alternative NZ flag designs: click to open/close">Alternative NZ Flags Designs</span></h2>
     60
     61                                    <div id="similarity-2d-nz-div">
     62                                        <iframe src="../similarity-2d/display-flags.jsp?imagesDir=import-nz&mode=nz"
     63                                        style="width: 100%; height: 100%"
     64                                        id="similarity-2d-nz-iframe" ></iframe>
     65                                    </div>
     66                                </li>
     67
     68
    5669                                <li>
    5770                                    <h2><span title="Click to Open/Close">Render 3D</span></h2>
     
    130143
    131144                function reconfigureSvgCanvas(settings) {
    132                     console.log("*** entered reconfigureSvgCanvas");
    133                     console.log("*** settings: background=" + settings.backgroundColor);
    134                     console.log("*** settings: w x h = " + settings.width + " x " + settings.height);
     145                    //console.log("*** entered reconfigureSvgCanvas");
     146                    //console.log("*** settings: background=" + settings.backgroundColor);
     147                    //console.log("*** settings: w x h = " + settings.width + " x " + settings.height);
    135148
    136149                    var design_frame = document.getElementById('design-2d-iframe');
     
    270283                    $('#design-2d-iframe').attr("src","svg-edit-trunk/editor/svg-editor.html?noStorageOnLoad=1");
    271284                    $('#design-2d-iframe').load(function() {
    272                         console.log("*** loaded sgv iframe: " + this);
     285                        console.log("*** loaded svg iframe: " + this);
    273286
    274287                        var design_frame = document.getElementById('design-2d-iframe');
     
    281294                    //if (typeof flagCanvasSettings !== 'undefined') {
    282295                setTimeout(function() {
    283                   console.log("**** design frame = " + design_frame);
    284                   console.log("**** design frame content window = " + design_frame.contentWindow);
     296                  //console.log("**** design frame = " + design_frame);
     297                  //console.log("**** design frame content window = " + design_frame.contentWindow);
    285298                  design_frame.contentWindow.setSVGEditorColourPalette(flagCanvasSettings);
    286299                }, 500);
  • other-projects/nz-flag-design/trunk/similarity-2d/display-flags.jsp

    r29784 r29906  
    6262   <div id="flagArea"></div>
    6363
     64   <div id="go-to-dl" style="display: none;">
     65     Visit the digital library collection of all the world's flags: <a href="/greenstone3/library/collection/world-flags/browse/CL1" target="dl">more ...</a>
     66   </div>
     67
     68   <div id="go-to-nz-dl" style="display: none;">
     69     Visit the digital library collection of alternative New Zealand flag deisgns: <a href="http://localhost:8383/greenstone3/library/collection/aotearoa/browse/CL1" target="dl">more ...</a>
     70   </div>
     71
    6472
    6573    <script>
     74function getParameterByName(name) {
     75    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
     76    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
     77        results = regex.exec(location.search);
     78    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
     79}
    6680
     81      //var mode = $.urlParam('mode');
     82      var mode = getParameterByName('mode');
     83
     84      console.log("*** mode = " + mode);
     85      if (mode && mode == "nz") {
     86        document.getElementById('go-to-nz-dl').style.display="block";
     87        //$('#go-to-nz-dl').show();
     88      }
     89      else {
     90        document.getElementById('go-to-dl').style.display="block";
     91        //$('#go-to-dl').show();
     92      }     
    6793
    6894    </script>
  • other-projects/nz-flag-design/trunk/similarity-2d/flag-functions.jsp

    r29784 r29906  
    1919    return fileList;
    2020    }
     21
     22
     23    ArrayList<File> listFilesForFolderRE(final File folder, String matchExtRE) {
     24        ArrayList<File> fileList = new ArrayList<File>();
     25
     26        for (final File fileEntry : folder.listFiles()) {
     27            if (fileEntry.isFile()) {
     28             if (fileEntry.getName().toLowerCase().matches(matchExtRE)) {
     29                fileList.add(fileEntry);
     30         }
     31            }
     32        }
     33
     34    return fileList;
     35    }
     36
    2137
    2238    ArrayList<File> listFilesForFolderRecursive(final File folder, String matchExt) {
  • other-projects/nz-flag-design/trunk/similarity-2d/flag-processing.js

    r29806 r29906  
    251251    }
    252252
    253     console.log("Product for HSL histogram: " + quant_product);
     253    //console.log("Product for HSL histogram: " + quant_product);
    254254
    255255    return quant_product;
     
    283283   
    284284    var imageObj = new Image();
     285
    285286    imageObj.onload = function() {
    286287        callback_count++;
     
    333334        if (clicked_on_count==2) {
    334335            // trigger comparison
    335             alert("Similarity score: " + quantizedColourHistogramComparison(flag_comparison_array[0],flag_comparison_array[1]));
     336            alert("Similarity score: " + quantizedColourHistogramComparison(flag_comparison_array[0],flag_comparison_array[1]) + "%");
    336337            clicked_on_count=0;
    337338        }
     
    346347   
    347348   
    348     imageObj.src   = img_url;
    349     imageObj.title = title.toUpperCase();
     349    imageObj.src     = img_url;
     350        imageObj.height  = 216;
     351    imageObj.title   = title.toUpperCase();
    350352    imageObj.country = imageObj.title;
    351     imageObj.id    = "flag-img-" + i;
     353    imageObj.id      = "flag-img-" + i;
    352354
    353355    $displayDiv.append(imageObj);
     
    358360
    359361
     362function calcSimilarityValuesChain(newFlagQuantHSLHist,
     363                   chain_count, img_obj_list, img_obj_list_len,
     364                   progressVal, progress_step,
     365                   $progressArea,$progressBar)
     366{
     367    var imgObj = img_obj_list[chain_count];
     368
     369    var existingQuantHSLHist = imgObj.quantHSLHist;
     370
     371    var similarity_score = quantizedColourHistogramComparison(newFlagQuantHSLHist,existingQuantHSLHist);
     372    similarity_score = Math.round(similarity_score * 100) / 100; // round to 2 decimal places
     373    similarity_score *= 100; // express as percentage
     374
     375    imgObj.similarityScore = similarity_score;
     376        var img_title = imgObj.country;
     377
     378        if (isoCountryCodes != null) {
     379        var country_code = imgObj.country;
     380        img_title = isoCountryCodes[country_code] + " (" + country_code + ")";
     381    }
     382    imgObj.title = img_title + ", Similarity score: " + similarity_score + "%";
     383    if (similarity_score>50) {
     384        //imgObj.style.display = "block";
     385        //imgObj.style.visibility = "visible";
     386    }
     387    else {
     388        //imgObj.style.display = "none";
     389        //imgObj.style.visibility = "hidden";
     390    }
     391
     392
     393
     394    if (chain_count < img_obj_list_len-1) {
     395    progressVal += progress_step;   
     396    if ($progressBar.progressbar) {
     397        $progressBar.progressbar('value',progressVal);
     398    }
     399
     400    setTimeout(function()
     401           { calcSimilarityValuesChain(newFlagQuantHSLHist,
     402                           chain_count+1,img_obj_list, img_obj_list_len,
     403                           progressVal, progress_step,
     404                           $progressArea,$progressBar)
     405               }
     406           ,1 // any time delay causes break in 'rendering' thread, even 0!
     407           );
     408
     409    }
     410    else {
     411    // done
     412    $progressArea.find('span:first').text("Done.");
     413    if (img_obj_list_len>show_progress) {
     414        progressVal = 100;
     415        if ($progressBar.progressbar) {
     416        $progressBar.progressbar('value',progressVal);
     417        }
     418        $progressArea.slideUp();
     419    }
     420    }
     421
     422}
    360423
    361424function calcSimilarityValues(newFlagQuantHSLHist, $displayDiv,$progressArea,$progressBar)
     
    368431
    369432    var img_obj_list_len = img_obj_list.length;
     433    console.log("*** img obj list len = " + img_obj_list_len);
    370434
    371435    if (img_obj_list_len==0) {
     
    377441    }
    378442
    379     var progress_step = 100.0 / img_obj_list_len;
    380    
    381443    for (var i=0; i<img_obj_list.length; i++) {
    382444    var imgObj = img_obj_list[i];
     445    imgObj.style.display = "inline";
     446    //imgObj.style.visibility = "visible";
     447    }
     448
     449    var progress_step = 100.0 / img_obj_list_len;
     450/*
     451    var chain_count=0;
     452
     453    setTimeout(function() {
     454    calcSimilarityValuesChain(newFlagQuantHSLHist,
     455                  chain_count, img_obj_list, img_obj_list_len,
     456                  progressVal, progress_step,
     457                  $progressArea,$progressBar)
     458        }
     459    ,100
     460    );
     461*/
     462   
     463
     464    for (var i=0; i<img_obj_list.length; i++) {
     465    var imgObj = img_obj_list[i];
    383466
    384467    var existingQuantHSLHist = imgObj.quantHSLHist;
    385468
    386469    var similarity_score = quantizedColourHistogramComparison(newFlagQuantHSLHist,existingQuantHSLHist);
     470    similarity_score = Math.round(similarity_score * 100) / 100; // round to 2 decimal places
     471    similarity_score *= 100; // express as percentage
     472
    387473    imgObj.similarityScore = similarity_score;
    388     imgObj.title = imgObj.country + ", Similarity score: " + similarity_score;
     474        var img_title = imgObj.country;
     475
     476        if (isoCountryCodes != null) {
     477        var country_code = imgObj.country;
     478        img_title = isoCountryCodes[country_code] + " (" + country_code + ")";
     479    }
     480    imgObj.title = img_title + ", Similarity score: " + similarity_score + "%";
     481    if (similarity_score>50) {
     482        //imgObj.style.display = "inline";
     483        //imgObj.style.visibility = "visible";
     484    }
     485    else {
     486        //imgObj.style.display = "none";
     487        //imgObj.style.visibility = "hidden";
     488    }
    389489
    390490    progressVal += progress_step;   
    391     console.log("*** i = " + i);
    392     console.log("*** pbar = " + $progressBar.progressbar);
     491    //console.log("*** i = " + i);
     492    //console.log("*** pbar = " + $progressBar.progressbar);
    393493    if ($progressBar.progressbar) {
    394494        $progressBar.progressbar('value',progressVal);
     
    402502    $progressArea.slideUp();
    403503    }
     504
     505
    404506}
    405507
  • other-projects/nz-flag-design/trunk/similarity-2d/list-flags.jsp

    r29787 r29906  
    66      File imagesDir = new File(similarityDir,imagesStr);
    77
    8       ArrayList<File> imageFileList = listFilesForFolder(imagesDir,".gif");
     8      ArrayList<File> imageFileList = listFilesForFolderRE(imagesDir,".*\\.(gif|jpg|jpeg|png)$");
    99
    1010      File imageUrlBase = new File(imagesStr);
Note: See TracChangeset for help on using the changeset viewer.