Changeset 38885
- Timestamp:
- 2024-03-28T00:03:56+13:00 (8 weeks ago)
- Location:
- main/trunk/greenstone3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/DisplayImages.java
r38881 r38885 92 92 super("DisplayImages"); 93 93 94 final int xDim_fallback = 600;95 final int yDim_fallback = 300;96 97 94 // parameters saved locally 98 95 app_ = app; … … 110 107 //app_y_dim_ = (app_.getHeight() == 0) ? yDim_fallback : app_.getHeight(); 111 108 app_x_dim_ = app_.getWidth(); 112 app_y_dim_ = app .getHeight();109 app_y_dim_ = app_.getHeight(); 113 110 114 111 System.err.println("@@@ xDim: " + app_x_dim_); … … 117 114 else 118 115 { 119 app_x_dim_ = xDim_fallback;120 app_y_dim_ = yDim_fallback;116 app_x_dim_ = app_.X_DIM; 117 app_y_dim_ = app_.Y_DIM; 121 118 } 122 119 -
main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/DownloadUrls.java
r38871 r38885 22 22 public class DownloadUrls extends Thread { 23 23 // for GS3 24 String gs3CollImgPath = null;25 24 String baseURL = null; 26 25 … … 106 105 "image_ignore_ "+ image_ignore+"\n"+ 107 106 "image_type_ "+ image_type+"\n"+ 108 "document root"+ document_root_107 "document_root_ "+ document_root_ 109 108 ); 110 109 … … 114 113 } 115 114 116 public void setupForGS3(String gs3CollImgPath, String baseURL)117 {118 this.gs3CollImgPath = gs3CollImgPath;119 this.baseURL = baseURL;120 }121 122 115 /** Determines whether or not a url has already been examined 123 116 * … … 431 424 432 425 // connect to the url 433 CURL curl = (app_.gsdlversion == 3) ? new CURL(new_url, this.baseURL) : new CURL(new_url);426 CURL curl = (app_.gsdlversion == 3) ? new CURL(new_url, app_.baseURL) : new CURL(new_url); 434 427 435 428 if (curl.connected_ok()) -
main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/GsdlCollageApplet.java
r38881 r38885 3 3 //import java.applet.Applet; 4 4 import javax.swing.JApplet; 5 //import javax.swing.SwingUtilities; 5 6 import java.awt.event.WindowAdapter; 6 7 import java.awt.event.WindowEvent; … … 28 29 29 30 public class GsdlCollageApplet extends JApplet { 31 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 30 35 // To run this GsdlCollageApplet as Application instead of as Applet 31 36 boolean isWebswingApplication = false; // if run as webswing *and* application (not applet) … … 38 43 // package access, used mainly for GS3 39 44 int gsdlversion = 2; 40 String site = null;41 String library = null;42 String collection = null;43 String gs3CollImgPath = null;44 45 String baseURL = null; 45 46 … … 118 119 Thread paint ; 119 120 120 public GsdlCollageApplet() { super(); } 121 122 //public GsdlCollageApplet(String[] args) { 123 124 //this.setPreferredSize(new Dimension(600, 300)); 125 //} 126 121 public GsdlCollageApplet() { 122 123 super(); 124 125 // status bar that applet has, but we want one also if we run JPhind as application 126 // And in fact, when webswing runs our applet, we never get a status bar. So we 127 // create a custom status bar now even if we're running as an applet. 128 // When this applet is run through the appletviewer we might end up with 2 status bars. 129 //setLayout(new BorderLayout()); 130 //if(!isRunAsApplet) { 131 statusBar = new JLabel(); 132 //this.add(statusBar, BorderLayout.SOUTH); 133 /* 134 Window win = SwingUtilities.getWindowAncestor(this); 135 if(win instanceof JFrame) { 136 JFrame topFrame = (JFrame)win; 137 topFrame.add(statusBar, BorderLayout.SOUTH); 138 } else { //AppletViewer or browser 139 this.add(statusBar, BorderLayout.SOUTH); 140 }*/ 141 142 //Dimension d = statusBar.getSize(); 143 //d.height = EXTRA_HEIGHT; 144 //statusBar.setPreferredSize(d); 145 //} 146 147 } 127 148 128 149 public void applicationPreInit(String[] args) { … … 131 152 // instead of as applet 132 153 this.isRunAsApplet = false; 133 try {134 this.docBaseURL = new URL(args[0]);135 } catch(MalformedURLException mue) {136 mue.printStackTrace();137 System.err.println("*** Unable to instantiate URL from parameter: " + args[0]);138 System.exit(-1);139 }140 154 141 155 appParams = new HashMap<String,String>((args.length+1)/2); 156 // For GS2, gwcgi = param gwcgi 157 // For GS3, gwcgi = param gwcgi + param library 158 // docBaseURL = starting_url/image_url = param gwcgi 142 159 143 160 String key = null; 144 161 String value = null; 145 for(int i = 1; i < args.length; i++) { // after arg0, have key-value pairs (params)146 if(i%2== 1) {162 for(int i = 0; i < args.length; i++) { 163 if(i%2==0) { 147 164 key = args[i].substring(2); // remove -- prefix of paramname 148 165 //System.err.println("got key: " + key); … … 176 193 } 177 194 } 178 195 179 196 isWebswingApplication = appParams.getOrDefault("webswing", "0").equals("1") ? true : false; 180 181 // manually calling (J)Applet method init() 182 init(); 183 start(); 197 try { 198 this.docBaseURL = new URL(appParams.get("baseurl")); 199 } catch(MalformedURLException mue) { 200 mue.printStackTrace(); 201 System.err.println("*** Unable to instantiate URL from parameter baseurl: " + appParams.get("baseurl")); 202 System.exit(-1); 203 } 204 184 205 } 185 206 … … 240 261 String caption_param = getParameter("caption"); 241 262 String document_root = getParameter("documentroot"); 242 String gwcgi = getParameter("gwcgi"); 263 String gwcgi = getParameter("gwcgi"); // for GS2 264 String baseurl = getParameter("baseurl"); // for GS3, URL before /library 243 265 244 266 String gsdlVersionStr = getParameter("gsdlversion"); … … 327 349 328 350 329 if (document_root !=null){ 330 if(this.gsdlversion == 2) { 331 document_root = document_root.substring(1); 332 333 if (document_root.indexOf("/") > 0 ){ 334 document_root = document_root.substring(0, document_root.indexOf("/")); 335 } 336 } 337 //else{ 338 //document_root = "greenstone3"; 339 //} 340 } 341 351 if (document_root !=null){ // e.g. "/greenstone/web/images" for GS2 352 if(document_root.indexOf("/") == 0) { 353 document_root = document_root.substring(1); // takes off first slash 354 } 355 if (document_root.indexOf("/") > 0 ){ // e.g we end up with "greenstone" for GS2, "greenstone3" for GS3 356 document_root = document_root.substring(0, document_root.indexOf("/")); 357 } 358 } 342 359 343 360 String image_url = getParameter("imageURL"); … … 349 366 if (image_url==null) 350 367 { 351 String gwcgi_param = getParameter("gwcgi");352 if(gsdlversion == 2) {353 gwcgi_param = tidy_URL(gwcgi_param, true); //true to append ? to URL354 } else {355 gwcgi_param = tidy_URL(gwcgi_param, false);356 }357 358 368 String collection_param = getParameter("collection"); 359 369 String classifier_param = getParameter("classifier"); … … 361 371 if(gsdlversion == 2) { 362 372 // GS2 way 373 String gwcgi_param = gwcgi; 374 gwcgi_param = tidy_URL(gwcgi_param, true); //true to append ? to URL 363 375 image_url = gwcgi_param + "a=d"; 364 376 image_url += "&c=" + collection_param; … … 366 378 } else { 367 379 // Try GS3 way 368 //image_url = gwcgi_param + "/collection/" + collection_param + "/browse/"; 369 image_url = gwcgi_param + "browse/"; 380 String library = getParameter("library"); 381 String site = getParameter("sitename"); 382 383 // starting URL (image_url) might not be base_url. We need to store base_url separately 384 baseURL = tidy_URL(baseurl, false); 385 if(!baseURL.endsWith("/")) { 386 baseURL += "/"; 387 } 388 389 // building up to baseURL/LIBNAME/collection/COLNAME/browse/ 390 image_url = baseURL + library + "/collection/" + collection_param + "/browse/"; 391 370 392 int index = classifier_param.indexOf("."); 371 393 if(index == -1) { … … 383 405 image_url = image_url + classifierSuffix; 384 406 } 385 386 this.library = getParameter("library"); 387 this.site = getParameter("sitename"); 388 this.collection = collection_param; 389 if(library != null && site != null && collection != null) { 390 this.gs3CollImgPath = library + "/sites/" + site + "/collect/" + collection; 407 408 if(library != null && site != null && collection_param != null) { 409 String gs3CollImgPath = library + "/sites/" + site + "/collect/" + collection_param; 391 410 if(href_musthave == null) { 392 href_musthave = this.gs3CollImgPath;411 href_musthave = gs3CollImgPath; 393 412 } else { 394 href_musthave += "%" + this.gs3CollImgPath;413 href_musthave += "%" + gs3CollImgPath; 395 414 } 396 415 if(verbosity_ >= 3) { … … 398 417 } 399 418 } 400 // starting URL (image_url) might not be base_url 401 this.baseURL = getParameter("baseurl"); 402 // TODO: is it not the other way: gwcgi should be param set to base_url 403 // and image_url/starting_url should be obtained from parameters also? 404 } 405 } 406 407 // status bar that applet has, but we want one also if we run JPhind as application 408 // And in fact, when webswing runs our applet, we never get a status bar. So we 409 // create a custom status bar now even if we're running as an applet. 410 // When this applet is run through the appletviewer we might end up with 2 status bars. 411 setLayout(new BorderLayout()); 412 //if(!isRunAsApplet) { 413 statusBar = new JLabel(); 414 this.add(statusBar, BorderLayout.SOUTH); 415 Dimension d = statusBar.getSize(); 416 d.height = 30; 417 statusBar.setPreferredSize(d); 418 //} 419 } 420 } 419 421 420 422 MediaTracker trk = new MediaTracker(this); … … 427 429 image_url, href_musthave, image_mustnothave, 428 430 image_ignore, imageType_,document_root,verbosity_,trk); 429 430 download_thread_.setupForGS3(this.gs3CollImgPath, this.baseURL);431 431 432 432 // starts the display image thread with the currently downloaded images … … 434 434 } 435 435 436 public JLabel getStatusBar() { 437 return this.statusBar; 438 } 439 436 440 437 441 /** Goes to the url associated with the image that is clicked on screen<br> … … 600 604 601 605 606 public static void printUsage() { 607 System.err.println("Params needed include: --gsdlversion <3/2> [--baseurl <GS3 DL baseURL>/--gwcgi <library.cgi URL>] --library l --sitename s --collection c --classifier cl --imageType \".jpg%.png\" --imageMustNotHave \"interfaces/\" --documentroot greenstone3 [--webswing <1/0>] [--verbosity <v>] --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --isJava2 auto --bgcolor \"#96c29a\" [--xtraParams <key1=value1&key2=value2&...]"); 608 } 609 602 610 // To also be able to run this applet as an application, need a main method 603 611 /** 604 * Try runningas:605 java -cp ./web/applet/GsdlCollageApplet.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet "http://localhost:8383/greenstone3/" --gwcgi "http://localhost:8383/greenstone3/library/collection/smallbea/" --library library --collection smallbea --gsdlversion 3 --baseurl "http://localhost:8383/greenstone3/" --sitename localsite --documentroot greenstone3 --verbosity 3 --imageType ".jpg%%.png" --imageMustNotHave "interfaces/" --classifier "CL2.3" --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --isJava2 auto --bgcolor "#96c29a"612 * After building the GS3 Multimedia collection, try running this Application as: 613 java -cp ./web/applet/GsdlCollageApplet.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet --baseurl "http://localhost:8383/greenstone3/" --library library --collection smallbea --gsdlversion 3 --sitename localsite --documentroot greenstone3 --verbosity 3 --imageType ".jpg%.png" --imageMustNotHave "interfaces/" --classifier "CL2.3" --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --isJava2 auto --bgcolor "#96c29a" 606 614 */ 607 615 public static void main(String[] args) { 608 if(args.length < 9) { 609 System.err.println("Need minimum --params: <baseURL> --library <library> --collection <collection> --classifier <classifier> --phindcgi <URL> --library <libURL> [--webswing <1/0>] [--backdrop <ImgURL>] [--xtraParams <key1=value1&key2=value2&...]"); 610 } 611 else { // collection fao.org, classifier 1, phindcgi url, library url, backdrop imgurl 616 if(args.length == 0) { 617 printUsage(); 618 } else if(args[0].equals("--help") || args[0].equals("-h")) { 619 printUsage(); 620 } else { 612 621 JFrame frame = new JFrame("Collage Applet as Application"); 613 622 GsdlCollageApplet collageApp = new GsdlCollageApplet(); 614 623 frame.getContentPane().add(collageApp, BorderLayout.CENTER); 615 frame.setSize(600,300); 624 frame.setSize(X_DIM, Y_DIM); //Y_DIM+EXTRA_HEIGHT); 625 frame.setVisible(true); 616 626 // https://stackoverflow.com/questions/19433358/difference-between-dispose-and-exit-on-close-in-java 617 627 // default: https://docs.oracle.com/javase/8/docs/api/javax/swing/JFrame.html#EXIT_ON_CLOSE 618 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // don't do EXIT_ON_CLOSE in Applets! 619 frame.setVisible(true); 628 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Running as an application. But don't do EXIT_ON_CLOSE in Applet mode! 629 630 // prepare to run the collage applet as an application 620 631 collageApp.applicationPreInit(args); 632 633 // status bar code. Not ideal, but had to add it here to get relative dimensions right 634 collageApp.setLayout(new BorderLayout()); 635 JLabel statusBar = collageApp.getStatusBar(); 636 frame.add(statusBar, BorderLayout.SOUTH); 637 Dimension d = statusBar.getSize(); 638 d.height = EXTRA_HEIGHT; 639 d.width = collageApp.getWidth(); 640 statusBar.setPreferredSize(d); 641 //statusBar.setPreferredSize(new Dimension(collageApp.getWidth(), EXTRA_HEIGHT)); 642 643 // Run it at last: manually calling (J)Applet methods init() and start() 644 collageApp.init(); 645 646 collageApp.showStatus("Collage application running"); 647 collageApp.start(); 648 649 // When we terminate the application, need to manually call the applet method stop() 621 650 //https://docs.oracle.com/javase/tutorial/uiswing/events/windowlistener.html#windowfocuslistener 622 651 frame.addWindowListener(new WindowAdapter() { 623 652 public void windowClosing(WindowEvent e) { 624 //collageApp.init(); 653 collageApp.showStatus("Stopping threads"); 654 System.err.println("\n\n*** Closing applet: stopping threads..."); 625 655 collageApp.stop(); 626 656 collageApp.destroy(); -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GsdlCollageBrowse.java
r38881 r38885 93 93 app_info +="<param name='collection' value='"; 94 94 app_info += this.cluster_name + "'/>"; 95 //app_info += "<param name='gwcgi' value='http://localhost:8383/greenstone3/library' /><param name='classifier' value='CL3.1' /><param name='hrefMustHave' value='CL3' /><param name='imageMustNotHave' value='hl=%x=%gt=%gc=%.pr' /><param name='imageType' value='.jpg%%.png' /><param name='maxDepth' value='500' /><param name='maxDisplay' value='25' /><param name='refreshDelay' value='1500' /><param name='isJava2' value='auto' /><param name='bgcolor' value='#96c29a' />The Collage Applet.</"+GSXML.APPLET_ELEM+">"; // TODO96 95 app_info += "<param name='gsdlversion' value='3' />"; 97 96 app_info += "<param name='baseurl' value='http://localhost:8383/greenstone3/' />"; 98 97 app_info += "<param name='sitename' value='localsite' />\n"; 98 99 //app_info += "<param name='gwcgi' value='http://localhost:8383/greenstone3/library' /><param name='classifier' value='CL3.1' /><param name='hrefMustHave' value='CL3' /><param name='imageMustNotHave' value='hl=%x=%gt=%gc=%.pr' /><param name='imageType' value='.jpg%%.png' /><param name='maxDepth' value='500' /><param name='maxDisplay' value='25' /><param name='refreshDelay' value='1500' /><param name='isJava2' value='auto' /><param name='bgcolor' value='#96c29a' />The Collage Applet.</"+GSXML.APPLET_ELEM+">"; // TODO 100 99 101 //app_info += "<param name='documentroot' value='library/collection/" + this.cluster_name + "/'/>"; 100 102 app_info += "<param name='documentroot' value='greenstone3'/>\n"; 101 103 app_info += "<param name='verbosity' value='3' />\n"; 102 app_info += "<param name='imageType' value='.jpg% %.png' />\n";104 app_info += "<param name='imageType' value='.jpg%.png' />\n"; 103 105 //app_info += "<param name='hrefMustHave' value='smallbea' />\n"; 104 //app_info += "<param name='imageMustNotHave' value='hl=%x=%gt=%gc=%.pr' />\n";105 106 app_info += "<param name='imageMustNotHave' value='interfaces/' />\n"; 106 app_info += "<param name=' gwcgi' value='http://localhost:8383/greenstone3/library/collection/smallbea/' /><param name='classifier' value='CL2.3' /><param name='maxDepth' value='500' /><param name='maxDisplay' value='25' /><param name='refreshDelay' value='1500' /><param name='isJava2' value='auto' /><param name='bgcolor' value='#96c29a' />The Collage Applet.</"+GSXML.APPLET_ELEM+">"; // TODO107 app_info += "<param name='classifier' value='CL2.3' /><param name='maxDepth' value='500' /><param name='maxDisplay' value='25' /><param name='refreshDelay' value='1500' /><param name='isJava2' value='auto' /><param name='bgcolor' value='#96c29a' />The Collage Applet.</"+GSXML.APPLET_ELEM+">"; // TODO 107 108 108 109 Document dom = this.converter.getDOM(app_info); -
main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl
r38884 r38885 163 163 <param name='gsdlversion' value='3' /> 164 164 <param name='baseurl' value='http://localhost:8383/greenstone3/' /> 165 <param name='sitename' value='localsite' /> 166 167 <param name="gwcgi" value="http://localhost:8383/greenstone3/library"/> 165 <param name='sitename' value='localsite' /> 168 166 <param name='library' value='library'/> 169 167 <param name="collection" value="smallbea"/>
Note:
See TracChangeset
for help on using the changeset viewer.