From: <gu...@us...> - 2007-09-12 02:50:09
|
Revision: 8253 http://jmol.svn.sourceforge.net/jmol/?rev=8253&view=rev Author: gutow Date: 2007-09-11 19:49:51 -0700 (Tue, 11 Sep 2007) Log Message: ----------- New Features: textboxes for entry of author name and title for browser window, persistence across launches of authorname and applet size, automatic gzip of large structure/quantum files. Bug? fix: attempt to update the page templates to XHTML 1.1 Minor fixes to instruction .html files. Modified Paths: -------------- branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_instructions.html branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_template.html branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/script_button_instructions.html Modified: branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java =================================================================== --- branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java 2007-09-11 20:22:38 UTC (rev 8252) +++ branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebExport.java 2007-09-12 02:49:51 UTC (rev 8253) @@ -56,7 +56,9 @@ historyFile = hFile; appletPath = historyFile.getProperty("webMakerAppletPath", ".."); + pageAuthorName = historyFile.getProperty("webMakerPageAuthorName", "Jmol Web Export"); + //Define the tabbed pane JTabbedPane mainTabs = new JTabbedPane(); @@ -166,7 +168,8 @@ prop.setProperty("webMakerInfoWidth", "" + webPanels[0].getInfoWidth()); prop.setProperty("webMakerInfoHeight", "" + webPanels[0].getInfoHeight()); prop.setProperty("webMakerAppletPath", appletPath); - historyFile.addProperties(prop); + prop.setProperty("webMakerPageAuthorName", pageAuthorName); + historyFile.addProperties(prop); } static String appletPath; @@ -184,4 +187,18 @@ prop.setProperty("webMakerAppletPath", appletPath); historyFile.addProperties(prop); } + + static String pageAuthorName; + + static String getPageAuthorName() { + return pageAuthorName; + } + + static void setWebPageAuthor(String pageAuthor) { + if (pageAuthor == null) + pageAuthor = "Jmol Web Export"; + pageAuthorName = pageAuthor; + prop.setProperty("webMakerPageAuthorName", pageAuthorName); + historyFile.addProperties(prop); + } } Modified: branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java =================================================================== --- branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java 2007-09-11 20:22:38 UTC (rev 8252) +++ branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/WebPanel.java 2007-09-12 02:49:51 UTC (rev 8253) @@ -33,6 +33,7 @@ import java.awt.event.ActionEvent; import java.net.URL; import java.util.ArrayList; +import java.util.zip.*; import javax.swing.*; @@ -63,7 +64,7 @@ private JScrollPane editorScrollPane; private JButton saveButton, addInstanceButton; private JButton deleteInstanceButton, showInstanceButton; - private JTextField appletPath; + private JTextField appletPath, pageAuthorName, webPageTitle; private JFileChooser fc; private JList instanceList; private JmolViewer viewer; @@ -76,10 +77,16 @@ this.fc = fc; this.webPanels = webPanels; this.panelIndex = panelIndex; - //Create the text field for the path to the Jmol applet + //Create the text fields for the path to the Jmol applet, page author(s) name(s) and web page title. appletPath = new JTextField(20); appletPath.addActionListener(this); appletPath.setText(WebExport.getAppletPath()); + pageAuthorName= new JTextField(20); + pageAuthorName.addActionListener(this); + pageAuthorName.setText(WebExport.getPageAuthorName()); + webPageTitle = new JTextField(20); + webPageTitle.addActionListener(this); + webPageTitle.setText("A web page containing Jmol applets"); } //Need the panel maker and the action listener. @@ -220,13 +227,32 @@ pathPanel.setBorder(BorderFactory .createTitledBorder("Relative Path to Jmol Applet:")); pathPanel.add(appletPath, BorderLayout.NORTH); - pathPanel.add(savePanel, BorderLayout.SOUTH); + + //Page Author Panel + JPanel authorPanel = new JPanel(); + authorPanel.setBorder(BorderFactory + .createTitledBorder("Author (your name):")); + authorPanel.add(pageAuthorName, BorderLayout.NORTH); + + //Page Title Panel + JPanel titlePanel = new JPanel(); + titlePanel.setLayout(new BorderLayout()); + titlePanel.setBorder(BorderFactory + .createTitledBorder("Browser window title for this web page:")); + titlePanel.add(webPageTitle, BorderLayout.NORTH); + titlePanel.add(savePanel, BorderLayout.SOUTH); + + JPanel settingsPanel = new JPanel(); + settingsPanel.setLayout(new BorderLayout()); + settingsPanel.add(pathPanel, BorderLayout.NORTH); + settingsPanel.add(authorPanel, BorderLayout.CENTER); + settingsPanel.add(titlePanel, BorderLayout.SOUTH); //Combine previous three panels into one JPanel leftpanel = new JPanel(); leftpanel.setLayout(new BorderLayout()); leftpanel.add(editorScrollPane, BorderLayout.CENTER); - leftpanel.add(pathPanel, BorderLayout.SOUTH); + leftpanel.add(settingsPanel, BorderLayout.SOUTH); return leftpanel; } @@ -347,7 +373,9 @@ try { String path = appletPath.getText(); WebExport.setAppletPath(path); - retVal = fileWriter(file, instanceList, path); + String authorName = pageAuthorName.getText(); + WebExport.setWebPageAuthor(authorName); + retVal = fileWriter(file, instanceList); } catch (IOException IOe) { LogPanel.log(IOe.getMessage()); } @@ -365,7 +393,7 @@ return (instance == null ? "" : instance.name); } - boolean fileWriter(File file, JList InstanceList, String appletPath) + boolean fileWriter(File file, JList InstanceList) throws IOException { //returns true if successful. useAppletJS = JmolViewer.checkOption(viewer, "webMakerCreateJS"); // JOptionPane.showMessageDialog(null, "Creating directory for data..."); @@ -428,6 +456,7 @@ //Get the path to the file from the Jmol String structureFile = thisInstance.file; + long structureFileSize = (new File(structureFile).length()); String extension = structureFile.substring(structureFile .lastIndexOf(".") + 1, structureFile.length()); String newName = lastName; @@ -438,7 +467,17 @@ LogPanel .log(" ...copying " + newName + " from " + structureFile); String data = viewer.getFileAsString(structureFile); + if (structureFileSize > 32000){ //gzip it! + outfilename = outfilename+".gz"; + newName = newName+".gz"; + GZIPOutputStream gzFile = new GZIPOutputStream(new FileOutputStream(outfilename)); + gzFile.write(data.getBytes()); + gzFile.close(); + LogPanel + .log(" ...compressing large file "+structureFile); + } else { viewer.createImage(outfilename, data, Integer.MIN_VALUE, 0, 0); + } lastFile = structureFile; lastName = newName; } else { @@ -476,7 +515,9 @@ for (int i = 0; i < listModel.getSize(); i++) html = getAppletDefs(i, html, appletDefs, (JmolInstance) listModel .getElementAt(i)); - html = TextFormat.simpleReplace(html, "@APPLETPATH@", appletPath); + html = TextFormat.simpleReplace(html, "@AUTHOR@", pageAuthorName.getText()); + html = TextFormat.simpleReplace(html, "@TITLE@", webPageTitle.getText()); + html = TextFormat.simpleReplace(html, "@APPLETPATH@", appletPath.getText()); html = TextFormat.simpleReplace(html, "@DATADIRNAME@", datadirName); if (appletInfoDivs.length() > 0) appletInfoDivs = "\n<div style='display:none'>\n" + appletInfoDivs Modified: branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_instructions.html =================================================================== --- branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_instructions.html 2007-09-11 20:22:38 UTC (rev 8252) +++ branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_instructions.html 2007-09-12 02:49:51 UTC (rev 8253) @@ -1,86 +1,74 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <meta content="text/html; charset=ISO-8859-1" - http-equiv="content-type"> - <title>Pop-In Jmol Instructions</title> -</head> -<body> -This tab is -designed to produce a web page template (no explanatory text) that -displays images of Jmol graphics, each of which can be converted to a -live Jmol display by the user. This makes initial loading of the -page faster. The image and initial Jmol setup for each occurence -can be chosen by setting up the Jmol viewer the way you wish. You -add the text later in your favorite web editor. An example picture of -such a page is shown below:<br> -<img style="border: 1px solid ; width: 250px; height: 268px;" - alt="picture of a pop in web page" src="pop_in.png"><br> -<br><br> - -This panel can be opened once and returned to anytime. - -<br><br> - -<b><i>Instructions </i></b> - -<br><br> - -1) Set the relative path to the Jmol applet on you web site from where -you will put the folder (directory) containing the files created by -this program. Each "../" means step up one directory level. -Do not forget to account for the fact that the page produced by this -program is inside a folder (directory) that you will be adding to your -web site. Example: Jmol applet is in directory -/www/applets/java/jmol and your web site is in the directory -/www/yourname. You will be adding one more level for this page -(e.g. /www/yourname/thispage). The correct path to the Jmol -applet is ../../applets/java/jmol. - -<br><br> - -2) Open the first file you want to appear in your page using the -File..Open.. menu in the Jmol viewer. If you will be using more than one model, -open the models one at a time (<b>not using load append</b>), and follow steps -(3) - (5) for each individual model. - -<br><br> - -3) Set the state of the model -(zoom, rotate, select, change colors, add orbitals, set the molecule -spinning, etc.)exactly the way you want it to appear on the web page. - -<br><br> - -4) Set the width and height for the model on this tab. There is no need to resize the application window itself. - -<br><br> - -5) Click on the "Add Present Jmol State as Instance" button and select a name for this applet instance. - -<br><br> - -6) Repeat for as many different displays as you wish. Because of -the memory constraints of web browsers, it is probably best to limit -yourself to no more than a few instances of Jmol on a single web -page. The larger the applet size, the more of a problem this will be. -However, you can certainly create a page with several applets and then split it later into multiple web pages. - -<br><br> - -7) When you are done, click on "Save HTML as..." Provide either the name of a new directory for this page or -the name of the HTML file (.htm or .html) you want to create or replace. All necessary files will be created -in the same directory. These include the HTML page itself, the JavaScript file JmolPopin.js, and three files for each model: a data file, a Jmol script, and a PNG image. -If a new directory is indicated, the HTML file will be created in that directory -and have the same name, with ".html" appended. - -<br><br> - -8) Open the HTML file in your favorite web editor and add you -explanatory text and anything else you wish. As long as you do -not alter the inside of the tables where Jmol will be displayed, you -should be able to change the page without disrupting the JavaScript -that controls the behavior of Jmol. - -</body> -</html> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <meta content="text/html; charset=iso-8859-1" http-equiv="content-type"> + <title>Pop-In Jmol Instructions</title> +</head> + +<body> +This tab is designed to produce a web page template (no explanatory text) +that displays images of Jmol graphics, each of which can be converted to a +live Jmol display by the user.\xA0 This makes initial loading of the page +faster.\xA0 The image and initial Jmol setup for each occurence can be chosen by +setting up the Jmol viewer the way you wish.\xA0 You add the text later in your +favorite web editor. This panel can be opened once and returned to anytime. +An example picture of such a page is shown below:<br> +<img style="border: 1px solid ; width: 250px; height: 268px;" +alt="picture of a pop in web page" src="pop_in.png"><br> +<br> +<b><i>Instructions </i></b> <br> +<br> +1) Set the relative path to the Jmol applet on you web site from where you +will put the folder (directory) containing the files created by this +program.\xA0 Each "../" means step up one directory level.\xA0 Do not forget to +account for the fact that the page produced by this program is inside a +folder (directory) that you will be adding to your web site.\xA0 Example: Jmol +applet is in directory /www/applets/java/jmol and your web site is in the +directory /www/yourname.\xA0 You will be adding one more level for this page +(e.g. /www/yourname/thispage).\xA0 The correct path to the Jmol applet is +../../applets/java/jmol. <br> + + +<p>2) Put your name(s) in the Author space. This will add you as the author +in the page meta data that is used for searching.</p> + +<p>3) Add the title you want to appear in the browser window title bar. This +does not have to be the same as the title you will use for the page.</p> + +<p>4) If not already done, open the first file you want to appear in your +page using the File..Open.. menu in the Jmol viewer. If you will be using +more than one model, open the models one at a time (<b>not using load +append</b>), and follow steps (5) - (7) for each individual model. <br> +<br> +5) Set the state of the model (zoom, rotate, select, change colors, add +orbitals, set the molecule spinning, etc.)exactly the way you want it to +appear on the web page. <br> +<br> +6) Set the width and height for the model on this tab. There is no need to +resize the application window itself. <br> +<br> +7) Click on the "Add Present Jmol State as Instance" button and select a name +for this applet instance. <br> +<br> +6) Repeat for as many different displays as you wish. Because of the memory +constraints of web browsers, it is probably best to limit yourself to no more +than a few instances of Jmol on a single web page. The larger the applet +size, the more of a problem this will be. However, you can certainly create a +page with several applets and then split it later into multiple web pages. +<br> +<br> +7) When you are done, click on "Save HTML as..." Provide either the name of a +new directory for this page or the name of the HTML file (.htm or .html) you +want to create or replace. All necessary files will be created in the same +directory. These include the HTML page itself, the JavaScript file +JmolPopin.js, and three files for each model: a data file, a Jmol script, and +a PNG image. If a new directory is indicated, the HTML file will be created +in that directory and have the same name, with ".html" appended. <br> +<br> +8) Open the HTML file in your favorite web editor and add you explanatory +text and anything else you wish.\xA0 As long as you do not alter the inside of +the tables where Jmol will be displayed, you should be able to change the +page without disrupting the JavaScript that controls the behavior of Jmol. +</p> +</body> +</html> Modified: branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_template.html =================================================================== --- branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_template.html 2007-09-11 20:22:38 UTC (rev 8252) +++ branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/pop_in_template.html 2007-09-12 02:49:51 UTC (rev 8253) @@ -39,10 +39,10 @@ <body> <div id="introdiv" style="text-align: left;"> <div id="titlediv" style="text-align: center;"> -<Insert Your TITLE HERE> +Insert Your TITLE HERE <br /> </div> -<Insert Your INTRODUCTION HERE> +Insert Your INTRODUCTION HERE </div> @APPLETINFO@ @@ -60,7 +60,7 @@ <div id="creationdiv" style="text-align: right;"> @CREATIONDATA@ </div> -<div id="logdiv" style="text-align: right;"> +<div id="logdiv" style="text-align: right; display:none"> @LOGDATA@ </div> Modified: branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/script_button_instructions.html =================================================================== --- branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/script_button_instructions.html 2007-09-11 20:22:38 UTC (rev 8252) +++ branches/gutow-webmaker/Jmol/src/org/openscience/jmol/app/webexport/script_button_instructions.html 2007-09-12 02:49:51 UTC (rev 8253) @@ -1,83 +1,72 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <meta content="text/html; charset=ISO-8859-1" - http-equiv="content-type"> - <title>ScriptButton Instructions</title> - <meta content="J. Gutow" name="author"> - <meta - content="Instructions for the script button tab in Jmol_Web_Page_Maker" - name="description"> -</head> -<body> -This tab is -designed to produce a web page template (no explanatory text) that -displays a single resizable Jmol applet alongside a scrolling pane containing text and -Jmol script buttons. The buttons can change what is displayed in -the Jmol applet. What they do can be defined by setting up Jmol -with the view you want the user to see. An example picture of -such a page is shown below:<br> -<img style="border: 1px solid ; width: 250px; height: 199px;" - alt="picture of a Resizable web page" src="script_button.png"><br> -<br> -<br><br> - -<b><i>Instructions</i></b> - -<br><br> - -1) Set the relative path to the Jmol applet on you web site from where -you will put the folder (directory) containing the files created by -this program. Each "../" means step up one directory level. -Do not forget to account for the fact that the page produced by this -program is inside a folder (directory) that you will be adding to your -web site. Example: Jmol applet is in directory -/www/applets/java/jmol and your web site is in the directory -/www/yourname. You will be adding one more level for this page -(e.g. /www/yourname/thispage). The correct path to the Jmol -applet is ../../applets/java/jmol. - -<br><br> - -2) Set the percentage of the window width that you want Jmol to occupy. - -<br><br> - -3) Open the first file you want to appear in your page using the -File..Open.. menu in the Jmol viewer. - -<br><br> - -4) Set the state of the model -(zoom, rotate, select, change colors, add orbitals, set the molecule -spinning, etc.)exactly the way you want it to appear on the web page. - -<br><br> - -5) Click on the "Add Present Jmol State as Instance" button. - -<br><br> - -6) Repeat for as many different displays as you wish. A button will be -added to the web page that will create each display when the user -clicks on them. You do not need to load a new file each time if -you are just modifying the way the previous one is displayed. - -<br><br> - -7) When you are done, click on "Save HTML as..." Provide either the name of a new directory for this page or -the name of the HTML file (.htm or .html) you want to create or replace. All necessary files will be created -in the same directory. These include the HTML page itself, the JavaScript file JmolPopin.js, and three files for each model: a data file, a Jmol script, and a PNG image. -If a new directory is indicated, the HTML file will be created in that directory -and have the same name, with ".html" appended. - -<br><br> - -8) Open the HTML file in your favorite web editor and add you -explanatory text and anything else you wish. As long as you do -not alter the inside of the tables where Jmol will be displayed, you -should be able to change the page without disrupting the JavaScript -that controls the behavior of Jmol. - -</body> -</html> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <meta content="text/html; charset=iso-8859-1" http-equiv="content-type"> + <title>ScriptButton Instructions</title> + <meta content="J. Gutow" name="author"> + <meta + content="Instructions for the script button tab in Jmol_Web_Page_Maker" + name="description"> +</head> + +<body> +This tab is designed to produce a web page template (no explanatory text) +that displays a single resizable Jmol applet alongside a scrolling pane +containing text and Jmol script buttons. The buttons can change what is +displayed in the Jmol applet. What they do can be defined by setting up Jmol +with the view you want the user to see. This panel can be opened once and +returned to anytime. An example picture of such a page is shown below:<br> +<img style="border: 1px solid ; width: 250px; height: 199px;" +alt="picture of a Resizable web page" src="script_button.png"><br> +<br> +<b><i>Instructions</i></b> <br> +<br> +1) Set the relative path to the Jmol applet on you web site from where you +will put the folder (directory) containing the files created by this +program.\xA0 Each "../" means step up one directory level.\xA0 Do not forget to +account for the fact that the page produced by this program is inside a +folder (directory) that you will be adding to your web site.\xA0 Example: Jmol +applet is in directory /www/applets/java/jmol and your web site is in the +directory /www/yourname.\xA0 You will be adding one more level for this page +(e.g. /www/yourname/thispage).\xA0 The correct path to the Jmol applet is +../../applets/java/jmol. <br> + + +<p>2) Put your name(s) in the Author space. This will add you as the author +in the page meta data that is used for searching.</p> + +<p>3) Add the title you want to appear in the browser window title bar. This +does not have to be the same as the title you will use for the page.</p> + +<p>4) Set the percentage of the window width that you want Jmol to occupy. +<br> +<br> +5) If not already done, open the first file you want to appear in your page +using the File..Open.. menu in the Jmol viewer. <br> +<br> +6) Set the state of the model (zoom, rotate, select, change colors, add +orbitals, set the molecule spinning, etc.)exactly the way you want it to +appear on the web page. <br> +<br> +7) Click on the "Add Present Jmol State as Instance" button. <br> +<br> +8) Repeat for as many different displays as you wish. A button will be added +to the web page that will create each display when the user clicks on them. +You do not need to load a new file each time if you are just modifying the +way the previous one is displayed. <br> +<br> +9) When you are done, click on "Save HTML as..." Provide either the name of a +new directory for this page or the name of the HTML file (.htm or .html) you +want to create or replace. All necessary files will be created in the same +directory. These include the HTML page itself, the JavaScript file +JmolPopin.js, and three files for each model: a data file, a Jmol script, and +a PNG image. If a new directory is indicated, the HTML file will be created +in that directory and have the same name, with ".html" appended. <br> +<br> +10) Open the HTML file in your favorite web editor and add you explanatory +text and anything else you wish. As long as you do not alter the inside of +the tables where Jmol will be displayed, you should be able to change the +page without disrupting the JavaScript that controls the behavior of Jmol. +</p> +</body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |