Ignore:
Timestamp:
2024-03-28T22:04:59+13:00 (6 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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());
Note: See TracChangeset for help on using the changeset viewer.