[Bojangles-cvs] cvs: bojangles /widgets Page.java PictureButton.java TextButton.java Widget.java /x
Status: Alpha
Brought to you by:
nehresma
From: kai5263499 <boj...@li...> - 2002-08-22 13:43:32
|
kai5263499 Thu Aug 22 06:43:28 2002 EDT Modified files: /bojangles/widgets Page.java PictureButton.java TextButton.java Widget.java /bojangles/xml XmlHandler.java Log: Forgot to add this lastnight (would have saved Nathan all that work)... This includes unified header comments and initial support for GZIP. Index: bojangles/widgets/Page.java diff -u bojangles/widgets/Page.java:1.2 bojangles/widgets/Page.java:1.3 --- bojangles/widgets/Page.java:1.2 Sat Aug 3 15:26:08 2002 +++ bojangles/widgets/Page.java Thu Aug 22 06:43:26 2002 @@ -1,18 +1,16 @@ package bojangles.widgets; -/** - * <p>Title: </p> - * <p>Description: </p> - * <p>Copyright: Copyright (c) 2002</p> - * <p>Company: </p> - * @author unascribed - * @version 1.0 - */ - import bojangles.*; import bojangles.xml.*; import java.awt.*; import java.awt.event.*; + +/** + * <p>Title: Page</p> + * <p>Description: Page Widget (extention to Widget)</p> + * <p>Copyright: Copyright (c) 2002 under the GPL</p> + * @author Nathan + */ public class Page extends Widget { public Page(String path, XmlHandler xml, ElementFocusListener fl) { Index: bojangles/widgets/PictureButton.java diff -u bojangles/widgets/PictureButton.java:1.1 bojangles/widgets/PictureButton.java:1.2 --- bojangles/widgets/PictureButton.java:1.1 Tue Aug 20 15:37:15 2002 +++ bojangles/widgets/PictureButton.java Thu Aug 22 06:43:26 2002 @@ -1,10 +1,4 @@ -/* - * TextButton.java - * - * Created on July 6, 2002, 2:52 PM - */ - -package widgets; +package bojangles.widgets; import bojangles.*; import bojangles.xml.*; @@ -16,9 +10,12 @@ import java.util.*; /** - * - * @author nathan + * <p>Title: TextButton</p> + * <p>Description: Button that uses a user-supplied image file for the background</p> + * <p>Copyright: Copyright (c) 2002 under the GPL</p> + * @author Wes (Based on the textbutton) */ + public class PictureButton extends bojangles.widgets.Widget implements PropertiesTableListener { JButton button = new JButton(); @@ -26,8 +23,8 @@ public PictureButton(String path, XmlHandler xmlHandler, ElementFocusListener fl, String label) { super(path, xmlHandler, fl); setLayout(new BorderLayout()); - this.label = new JLabel(label, SwingConstants.CENTER); - add(this.label); + //this.label = new JLabel(label, SwingConstants.CENTER); + //add(this.label); button.setIcon(new ImageIcon("images/x.gif")); setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white, Color.black)); } @@ -44,7 +41,7 @@ setBounds(x.intValue(), y.intValue(), width.intValue(), height.intValue()); } else if (propertyName.equals("text")) { Hashtable h = xmlHandler.getProperties(path); - label.setText((String)h.get("text")); + // label.setText((String)h.get("text")); } } Index: bojangles/widgets/TextButton.java diff -u bojangles/widgets/TextButton.java:1.1.1.1 bojangles/widgets/TextButton.java:1.2 --- bojangles/widgets/TextButton.java:1.1.1.1 Sat Aug 3 08:42:37 2002 +++ bojangles/widgets/TextButton.java Thu Aug 22 06:43:26 2002 @@ -1,9 +1,3 @@ -/* - * TextButton.java - * - * Created on July 6, 2002, 2:52 PM - */ - package bojangles.widgets; import bojangles.*; @@ -16,9 +10,12 @@ import java.util.*; /** - * - * @author nathan + * <p>Title: TextButton</p> + * <p>Description: TextButton Widget (extention to Widget)</p> + * <p>Copyright: Copyright (c) 2002 under the GPL</p> + * @author Nathan */ + public class TextButton extends bojangles.widgets.Widget implements PropertiesTableListener { JLabel label = null; Index: bojangles/widgets/Widget.java diff -u bojangles/widgets/Widget.java:1.3 bojangles/widgets/Widget.java:1.4 --- bojangles/widgets/Widget.java:1.3 Tue Aug 20 15:37:15 2002 +++ bojangles/widgets/Widget.java Thu Aug 22 06:43:26 2002 @@ -9,12 +9,10 @@ import java.util.*; /** - * <p>Title: </p> - * <p>Description: </p> - * <p>Copyright: Copyright (c) 2002</p> - * <p>Company: </p> - * @author unascribed - * @version 1.0 + * <p>Title: Widget</p> + * <p>Description: Widget class</p> + * <p>Copyright: Copyright (c) 2002 under the GPL</p> + * @author Nathan */ public class Widget extends JPanel implements KeyListener, MouseListener, FocusListener, MouseMotionListener, ComponentListener { Index: bojangles/xml/XmlHandler.java diff -u bojangles/xml/XmlHandler.java:1.12 bojangles/xml/XmlHandler.java:1.13 --- bojangles/xml/XmlHandler.java:1.12 Wed Aug 21 19:38:54 2002 +++ bojangles/xml/XmlHandler.java Thu Aug 22 06:43:27 2002 @@ -2,11 +2,19 @@ import java.lang.*; import java.io.*; +import java.util.zip.*; import java.util.*; import java.awt.event.*; import org.dom4j.*; import org.dom4j.io.*; +/** + * <p>Title: XmlHandler</p> + * <p>Description: Widget XML handeling subroutienes</p> + * <p>Copyright: Copyright (c) 2002 under the GPL</p> + * @author Nathan + */ + public class XmlHandler extends Object { Document doc = null; Vector listeners = new Vector(); @@ -165,13 +173,26 @@ return l.size(); } - public void saveXML(File of) { + public void saveXML(File of, boolean wantCompressed) { try { - FileOutputStream outfile = new FileOutputStream(of); OutputFormat format = OutputFormat.createPrettyPrint(); - XMLWriter saver = new XMLWriter(outfile, format); - saver.write(this.doc); - } catch (Exception e) { + OutputStream outfileOrig = new FileOutputStream(of); + + if(wantCompressed) { + File nf = new File(of.getAbsolutePath() + of.getName() + ".gz"); + FileOutputStream newStream = new FileOutputStream(of); + OutputStream outfile = new GZIPOutputStream(newStream); + XMLWriter saver = new XMLWriter(outfile, format); + saver.write(this.doc); + System.out.println("Compressed to: " + of.getAbsolutePath() + of.getName() + ".gz"); + } + else { + XMLWriter saverOrig = new XMLWriter(outfileOrig, format); + saverOrig.write(this.doc); + } + + } + catch (Exception e) { e.printStackTrace(); } } |