OptionsDialog.java
资源名称:picweb.zip [点击查看]
上传用户:shengda799
上传日期:2007-01-10
资源大小:68k
文件大小:9k
源码类别:
图片显示
开发平台:
Java
- import java.awt.*;
- import java.io.*;
- /**
- * OptionsDialog - this code used to be in the clss PicWeb (removed to
- * a separate class in Version 7, using package wide access [i.e., not private
- * or protected] of class PicWeb option variables).
- */
- public class OptionsDialog extends Dialog implements java.io.Serializable {
- private Button close;
- private TextArea text;
- private DialogFrame my_frame;
- private PicWeb picweb;
- private Options options;
- private Checkbox cbShowLogo;
- private Checkbox cbFileNames;
- private Checkbox cbSkipDirs;
- private Checkbox cbSkipFiles;
- private Checkbox cbSort;
- private Checkbox cbThumbs;
- private Choice choice;
- private TextField html_filename;
- OptionsDialog(DialogFrame parent, PicWeb picweb, Options options) {
- super(parent, "Options Dialog", true);
- my_frame = parent;
- this.picweb = picweb;
- this.options = options;
- my_frame.setLayout(null);
- my_frame.setOptions(this);
- my_frame.setTitle("PicWeb " + picweb.version + " - Options");
- options.updateFromFile();
- cbShowLogo = new Checkbox("Show images while calculated", options.showLogo);
- cbFileNames= new Checkbox("Include image file names in HTML documents", options.fileNamesFlag);
- cbSkipDirs = new Checkbox("Skip already processed sub-directories", options.skipProcessedDirs);
- cbSkipFiles = new Checkbox("Skip already processed files", options.skipProcessedFiles);
- cbSort = new Checkbox("Sort files and directories", options.sort);
- cbThumbs = new Checkbox("Make thumb nail images", options.thumbs);
- Label l1 = new Label("Set options");
- l1.setFont(new Font("Dialog", Font.BOLD, options.fontSizes[3]));
- my_frame.add(l1);
- l1.setBounds(5, 180, 480, 28);
- my_frame.add(cbShowLogo);
- cbShowLogo.setBounds(5, 210, 480, 28);
- my_frame.add(cbFileNames);
- cbFileNames.setBounds(5, 240, 480, 28);
- my_frame.add(cbSkipDirs);
- cbSkipDirs.setBounds(5, 270, 480, 28);
- my_frame.add(cbSkipFiles);
- cbSkipFiles.setBounds(5, 300, 480, 28);
- my_frame.add(cbSort);
- cbSort.setBounds(5, 330, 480, 28);
- my_frame.add(cbThumbs);
- cbThumbs.setBounds(5, 360, 480, 28);
- choice = new Choice();
- choice.add("generate small size thumbnail images");
- choice.add("generate medium size thumbnail images");
- choice.add("generate large size thumbnail images");
- choice.add("generate extra large size thumbnail images");
- choice.select(options.imageSizeChoice);
- my_frame.add(choice);
- choice.setBounds(5, 390, 300, 28);
- // (ta 4.1) allow the HTML filename to be selected...
- Label html = new Label("HTML Filename:");
- my_frame.add(html);
- html.setBounds(5, 425, 100, 30);
- html_filename = new TextField(options.HTMLFilename, 15);
- my_frame.add(html_filename);
- html_filename.setBounds(110, 425, 180, 28);
- String str =
- "PicWeb(tm) Copyright 1997-1999 by Mark Watson." + nl + nl + "ALL RIGHTS RESERVED" +
- nl + "Single User License." + nl +
- "The JpegEncoder class is Copyright (C) 1998, James R. Weeks and BioElectroMech" + nl +
- "And is based on the work of the Independent JPEG Group" + nl +
- "and was inspired by the original Java port by Florian Raemy." + nl +
- "Please see the source code file JpegEncoder.java for full copyright" + nl +
- "and license information." + nl + nl +
- "THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''" + nl +
- "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO," + nl +
- "THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR" + nl +
- "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR" + nl +
- "OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT," + nl +
- "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING," + nl +
- "BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF" + nl +
- "USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER" + nl +
- "CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT," + nl +
- "STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)" + nl +
- "ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF" + nl +
- "ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + nl + nl +
- "Visit my We site for update information: www.markwatson.com" + nl + nl +
- // (ta 4.1) ...
- "Also, thanks to:" + nl +
- "Achille Petrilli <Achille.Petrilli@cern.ch> (directory pop-up, new fonts, larger icons)" + nl +
- "Tony Allan <tony@apms.com.au> (sorted files, selectable html filename, saved options)" + nl + nl +
- "NOTICE: THIS SOFTWARE CAN NOT BE USED FOR ANY ILLEGAL OR NON-PEACEFUL PURPOSE" + nl + nl +
- "-----------------------------------------------------------------------" + nl + nl +
- "HELP" + nl + nl +
- "Use the forward slash: / as a file separator. If possible, use a Java" + nl +
- "runtime system with a just in time compiler to decrease the runtime for" + nl +
- "generating many thumbnail image files." + nl + nl +
- "In the 'Browse...' file selection dialog, you must select a file (or just leave the 'dummy'" + nl +
- "file) in order to change the directory." + nl + nl +
- "If the sort option is selected, and directories contain dates, it is better to specify" + nl +
- "dates with year first (i.e. 1998-12-25)." + nl +
- nl;
- Label l = new Label("Copyright information and help");
- l.setFont(new Font("Dialog", Font.BOLD, options.fontSizes[4]));
- my_frame.add(l);
- l.setBounds(5, 25, 480, 30);
- text = new TextArea(str, 7, 72);
- text.setEditable(false);
- text.setFont(new Font("Dialog", Font.PLAIN, options.fontSizes[0]));
- text.setEditable(false);
- my_frame.add(text);
- text.setBounds(5, 60, 480, 110);
- Label l9 = new Label("Close this window to save options!");
- l9.setFont(new Font("Dialog", Font.BOLD, options.fontSizes[3]));
- my_frame.add(l9);
- l9.setBounds(5, 470, 480, 25);
- my_frame.setBounds(100, 100, 515, 490);
- my_frame.pack();
- my_frame.setSize(500, 520);
- myself=this;
- }
- public void setVisible(boolean b) {
- my_frame.setVisible(b);
- }
- private OptionsDialog myself;
- public void saveOptions() {
- boolean changed = false;
- if (options.showLogo != cbShowLogo.getState()) {
- options.showLogo = cbShowLogo.getState();
- options.ini.put("showLogo", (new Boolean(options.showLogo)).toString());
- changed = true;
- }
- if (options.fileNamesFlag != cbFileNames.getState()) {
- options.fileNamesFlag = cbFileNames.getState();
- options.ini.put("fileNamesFlag", (new Boolean(options.fileNamesFlag)).toString());
- changed = true;
- }
- if (options.skipProcessedDirs != cbSkipDirs.getState()) {
- options.skipProcessedDirs = cbSkipDirs.getState();
- options.ini.put("skipProcessedDirs", (new Boolean(options.skipProcessedDirs)).toString());
- changed = true;
- }
- if (options.skipProcessedFiles != cbSkipFiles.getState()) {
- options.skipProcessedFiles = cbSkipFiles.getState();
- options.ini.put("skipProcessedFiles", (new Boolean(options.skipProcessedFiles)).toString());
- changed = true;
- }
- if (options.sort != cbSort.getState()) {
- options.sort = cbSort.getState();
- options.ini.put("sort", (new Boolean(options.sort)).toString());
- changed = true;
- }
- if (options.thumbs != cbThumbs.getState()) {
- options.thumbs = cbThumbs.getState();
- options.ini.put("thumbs", (new Boolean(options.thumbs)).toString());
- changed = true;
- }
- if (options.imageSizeChoice != choice.getSelectedIndex()) {
- options.imageSizeChoice = choice.getSelectedIndex();
- options.ini.put("imageSizeChoice", Integer.toString(options.imageSizeChoice));
- changed = true;
- }
- System.out.println("options="+options);
- System.out.println("html_filename="+html_filename);
- if (!options.HTMLFilename.equals(html_filename.getText().trim())) {
- options.HTMLFilename = html_filename.getText().trim();
- options.ini.put("HTMLFilename", options.HTMLFilename);
- changed = true;
- }
- if (changed) {
- try {
- OutputStream out = new BufferedOutputStream(new FileOutputStream(options.iniFile));
- options.ini.store(out, "PicWeb (" + picweb.version + ") properties");
- out.close();
- } catch (IOException e) {System.out.println(e);}
- picweb.print(options.iniFile + " updated." + nl);
- }
- myself.setVisible(false);
- }
- /** The 'nl' and 'fs' objects are define for string constants
- * instead of using literal strings in order to pass the
- * "100% Pure" Java certification by Key Labs
- */
- private String nl = System.getProperty("line.separator");
- private String fs = System.getProperty("file.separator");
- }
English
