Changeset 38889


Ignore:
Timestamp:
2024-03-28T22:04:59+13:00 (4 weeks ago)
Author:
anupama
Message:
  1. width and height can now be passed in as parameters to the GsdlCollageApplet to customise its size. This makes sense when it is run as an application (I'm not sure if the dimensions of an applet can be controlled in the Java code that gets run after the applet element parameters are preconfigured, and I can't yet run this as a webswing-applet). 2. The width and height set on the webswing element in webswing-collage.xsl are now used to set the GsdlCollageApplet's width and height by passing it in as command line arguments.
Location:
main/trunk/greenstone3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/DisplayImages.java

    r38885 r38889  
    104104    if (is_java2_)
    105105    {
    106         //app_x_dim_  = (app_.getWidth() == 0) ? xDim_fallback : app_.getWidth();
    107         //app_y_dim_  = (app_.getHeight() == 0) ? yDim_fallback : app_.getHeight();
    108         app_x_dim_  = app_.getWidth();
    109         app_y_dim_  = app_.getHeight();
     106        //app_x_dim_  = app_.getWidth();
     107        //app_y_dim_  = app_.getHeight();
     108        app_x_dim_  = (app_.getWidth() <= 0) ? app_.X_DIM() : app_.getWidth();
     109        app_y_dim_  = (app_.getHeight() <= 0) ? app_.Y_DIM() : app_.getHeight();
    110110
    111111        System.err.println("@@@ xDim: " + app_x_dim_);
     
    114114    else
    115115    {
    116         app_x_dim_  = app_.X_DIM;
    117         app_y_dim_  = app_.Y_DIM;
     116        app_x_dim_  = app_.X_DIM();
     117        app_y_dim_  = app_.Y_DIM();
    118118    }
    119119
  • main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/GsdlCollageApplet.java

    r38888 r38889  
    3030public class GsdlCollageApplet extends JApplet {
    3131    static final int EXTRA_HEIGHT = 30; // for status bar or any extra elements
    32     static final int X_DIM = 600;
    33     static final int Y_DIM = 300;
    34    
     32    private int X_DIM = 600;
     33    private int Y_DIM = 300;
     34
     35    public int X_DIM() {
     36    return X_DIM;
     37    }
     38    public int Y_DIM() {
     39    return Y_DIM;
     40    }
     41
    3542    // To run this GsdlCollageApplet as Application instead of as Applet
    3643    boolean isWebswingApplication = false; // if run as webswing *and* application (not applet)
     
    195202   
    196203    isWebswingApplication = appParams.getOrDefault("webswing", "0").equals("1") ? true : false;
     204    // Need these parameters set before init(), so that the display works
     205    int w = this.getWidth();
     206    if(appParams.get("width") != null) {
     207        w = Integer.parseInt(appParams.get("width"));
     208    }
     209    int h = this.getHeight();
     210    if(appParams.get("height") != null) {
     211        h = Integer.parseInt(appParams.get("height"));
     212    }
     213    // For applet, w and h may now be set to a positive value. But if GsdlCollageApplet
     214    // is run as an application, it won't yet be visible and not have a non-zero dimension.
     215    // So use defaults here:
     216    this.X_DIM = (w <= 0) ? X_DIM : w;
     217    this.Y_DIM = (h <= 0) ? Y_DIM : h;
     218   
    197219    try {
    198220        this.docBaseURL = new URL(appParams.get("baseurl"));
     
    619641    /**
    620642     * After building the GS3 Multimedia collection, try running this Application as:
    621 java -cp ./web/applet/GsdlCollageApplet.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet --statusbar 1 --baseurl "http://localhost:8383/greenstone3/" --library library --collection smallbea --gsdlversion 3 --hrefMustHave "library/sites/localsite/collect/smallbea" --documentroot greenstone3 --verbosity 3 --imageType ".jpg%.png" --imageMustNotHave "interfaces/" --classifier "CL2.3" --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --isJava2 auto --bgcolor "#96c29a"
     643java -cp ./web/applet/GsdlCollageApplet.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet --statusbar 0 --baseurl "http://localhost:8383/greenstone3/" --library library --collection smallbea --gsdlversion 3 --hrefMustHave "library/sites/localsite/collect/smallbea" --documentroot greenstone3 --verbosity 3 --imageType ".jpg%.png" --imageMustNotHave "interfaces/" --classifier "CL2.3" --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --isJava2 auto --bgcolor "#96c29a" --width 645 --height 780
    622644     */
    623645    public static void main(String[] args) {
     
    630652        GsdlCollageApplet collageApp = new GsdlCollageApplet();
    631653        frame.getContentPane().add(collageApp, BorderLayout.CENTER);
    632         frame.setSize(X_DIM, Y_DIM); //Y_DIM+EXTRA_HEIGHT);
     654        //frame.setSize(X_DIM, Y_DIM); //Y_DIM+EXTRA_HEIGHT);
    633655        frame.setVisible(true);
    634656        // https://stackoverflow.com/questions/19433358/difference-between-dispose-and-exit-on-close-in-java
     
    638660        // prepare to run the collage applet as an application
    639661        collageApp.applicationPreInit(args);
    640 
     662        // It's now figured out the dimensions based on anything specified, so set frame size
     663        frame.setSize(collageApp.X_DIM(), collageApp.Y_DIM()); //Y_DIM+EXTRA_HEIGHT);
    641664        // status bar code. Not ideal, but had to add it here to get relative dimensions right
    642665        collageApp.setLayout(new BorderLayout());
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/webswing-collage.xsl

    r38888 r38889  
    8383      <link rel="stylesheet" href="/webswing-server/css/style.css" />
    8484
    85       <div id="webswing-collage" class="webswing-element" data-webswing-instance="webswingInstance0" style="width: 645px; height: 780px;">
     85      <div id="webswing-collage" class="webswing-element" data-webswing-instance="webswingInstance0" style="width: 800px; height: 400px;">
    8686        <div id="loading" class="ws-modal-container">
    8787              <div class="ws-login">
     
    163163       webswingInstance0.options.args += " --imageType " + "\".jpg%.png\"";
    164164       webswingInstance0.options.args += " --classifier \"CL2.3\"";
    165        webswingInstance0.options.args += " --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --bgcolor \"#96c29a\"";
     165       webswingInstance0.options.args += " --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --bgcolor \"#96c29a\"";       
     166
     167       // Control the width and height of the Java application launched with webswing
     168       // by passing width and height params set to the attributes of the webswing element
     169       // https://stackoverflow.com/questions/21851633/get-height-from-style-attribute
     170       var w = document.getElementById("webswing-collage").style.width;
     171       var suffixIndex = 0;
     172       if(w) {       
     173       suffixIndex = w.indexOf("px");
     174       if(suffixIndex>0) {
     175          w = w.substring(0, suffixIndex);
     176       }
     177       webswingInstance0.options.args += " --width " + w;
     178       }
     179       var h = document.getElementById("webswing-collage").style.height;
     180       if(h) {
     181       suffixIndex = h.indexOf("px");
     182       if(suffixIndex>0) {
     183          h = h.substring(0, suffixIndex);
     184       }
     185       webswingInstance0.options.args += " --height " + h;
     186       }
    166187       
    167188       //console.log("args: " +  webswingInstance0.options.args);
Note: See TracChangeset for help on using the changeset viewer.