You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by hi...@apache.org on 2001/05/18 08:20:45 UTC
cvs commit: xml-batik/sources/org/apache/batik/dom AbstractDocument.java AbstractElement.java AbstractParentNode.java
hillion 01/05/17 23:20:45
Modified: sources/org/apache/batik/apps/svgbrowser Main.java
sources/org/apache/batik/dom AbstractDocument.java
AbstractElement.java AbstractParentNode.java
Log:
- bug #1792 fixed,
- preferences now saved in home.dir/.batik/preferences.xml,
- fixed a bug with preferences loading.
Revision Changes Path
1.14 +57 -45 xml-batik/sources/org/apache/batik/apps/svgbrowser/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/Main.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Main.java 2001/05/15 16:42:54 1.13
+++ Main.java 2001/05/18 06:20:43 1.14
@@ -45,7 +45,7 @@
* This class contains the main method of an SVG viewer.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: Main.java,v 1.13 2001/05/15 16:42:54 hillion Exp $
+ * @version $Id: Main.java,v 1.14 2001/05/18 06:20:43 hillion Exp $
*/
public class Main implements Application {
@@ -89,6 +89,11 @@
(Main.class.getResource(resources.getString("Frame.icon")));
/**
+ * The preference manager.
+ */
+ protected XMLPreferenceManager preferenceManager;
+
+ /**
* The arguments.
*/
protected String[] arguments;
@@ -119,6 +124,34 @@
arguments = args;
CSSDocumentHandler.setParserClassName
(resources.getString(CSS_PARSER_CLASS_NAME_KEY));
+
+ Map defaults = new HashMap(11);
+
+ defaults.put(PreferenceDialog.PREFERENCE_KEY_LANGUAGES,
+ Locale.getDefault().getLanguage());
+ defaults.put(PreferenceDialog.PREFERENCE_KEY_SHOW_RENDERING,
+ Boolean.FALSE);
+ defaults.put(PreferenceDialog.PREFERENCE_KEY_AUTO_ADJUST_WINDOW,
+ Boolean.TRUE);
+ defaults.put(PreferenceDialog.PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING,
+ Boolean.TRUE);
+ defaults.put(PreferenceDialog.PREFERENCE_KEY_SHOW_DEBUG_TRACE,
+ Boolean.FALSE);
+ defaults.put(PreferenceDialog.PREFERENCE_KEY_PROXY_HOST,
+ "");
+ defaults.put(PreferenceDialog.PREFERENCE_KEY_PROXY_PORT,
+ "");
+
+ try {
+ preferenceManager = new XMLPreferenceManager("preferences.xml",
+ defaults);
+ String dir = System.getProperty("user.home");
+ File f = new File(dir, ".batik");
+ f.mkdir();
+ preferenceManager.setPreferenceDirectory(f.getCanonicalPath());
+ preferenceManager.load();
+ } catch (Exception e) {
+ }
}
/**
@@ -287,6 +320,7 @@
mainFrame.setTitle(resources.getString("Frame.title"));
mainFrame.show();
viewerFrames.add(mainFrame);
+ setPreferences(mainFrame);
return mainFrame;
}
@@ -332,64 +366,42 @@
*/
public void showPreferenceDialog(JSVGViewerFrame f) {
if (preferenceDialog == null) {
- Map defaults = new HashMap(11);
-
- defaults.put(PreferenceDialog.PREFERENCE_KEY_LANGUAGES,
- Locale.getDefault().getLanguage());
- defaults.put(PreferenceDialog.PREFERENCE_KEY_SHOW_RENDERING,
- Boolean.FALSE);
- defaults.put(PreferenceDialog.PREFERENCE_KEY_AUTO_ADJUST_WINDOW,
- Boolean.TRUE);
- defaults.put(PreferenceDialog.PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING,
- Boolean.TRUE);
- defaults.put(PreferenceDialog.PREFERENCE_KEY_SHOW_DEBUG_TRACE,
- Boolean.FALSE);
- defaults.put(PreferenceDialog.PREFERENCE_KEY_PROXY_HOST,
- "");
- defaults.put(PreferenceDialog.PREFERENCE_KEY_PROXY_PORT,
- "");
-
- XMLPreferenceManager manager;
- manager = new XMLPreferenceManager("batik-preferences.xml", defaults);
- try {
- manager.load();
- setPreferences(manager);
- } catch (Exception e) {
- }
- preferenceDialog = new PreferenceDialog(manager);
+ preferenceDialog = new PreferenceDialog(preferenceManager);
}
if (preferenceDialog.showDialog() == PreferenceDialog.OK_OPTION) {
- PreferenceManager manager = preferenceDialog.getPreferenceManager();
try {
- manager.save();
- setPreferences(manager);
+ preferenceManager.save();
+ setPreferences();
} catch (Exception e) {
}
}
}
- private void setPreferences(PreferenceManager manager) {
+ private void setPreferences() {
Iterator it = viewerFrames.iterator();
while (it.hasNext()) {
- JSVGViewerFrame vf = (JSVGViewerFrame)it.next();
- boolean db = manager.getBoolean
- (PreferenceDialog.PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING);
- vf.getJSVGCanvas().setDoubleBufferedRendering(db);
- boolean sr = manager.getBoolean
- (PreferenceDialog.PREFERENCE_KEY_SHOW_RENDERING);
- vf.getJSVGCanvas().setProgressivePaint(sr);
- boolean d = manager.getBoolean
- (PreferenceDialog.PREFERENCE_KEY_SHOW_DEBUG_TRACE);
- vf.setDebug(d);
- boolean aa = manager.getBoolean
- (PreferenceDialog.PREFERENCE_KEY_AUTO_ADJUST_WINDOW);
- vf.setAutoAdjust(aa);
+ setPreferences((JSVGViewerFrame)it.next());
}
- System.setProperty("proxyHost", manager.getString
+ System.setProperty("proxyHost", preferenceManager.getString
(PreferenceDialog.PREFERENCE_KEY_PROXY_HOST));
- System.setProperty("proxyPort", manager.getString
+ System.setProperty("proxyPort", preferenceManager.getString
(PreferenceDialog.PREFERENCE_KEY_PROXY_PORT));
+ }
+
+ private void setPreferences(JSVGViewerFrame vf) {
+ boolean db = preferenceManager.getBoolean
+ (PreferenceDialog.PREFERENCE_KEY_ENABLE_DOUBLE_BUFFERING);
+ vf.getJSVGCanvas().setDoubleBufferedRendering(db);
+ boolean sr = preferenceManager.getBoolean
+ (PreferenceDialog.PREFERENCE_KEY_SHOW_RENDERING);
+ vf.getJSVGCanvas().setProgressivePaint(sr);
+ boolean d = preferenceManager.getBoolean
+ (PreferenceDialog.PREFERENCE_KEY_SHOW_DEBUG_TRACE);
+ vf.setDebug(d);
+ boolean aa = preferenceManager.getBoolean
+ (PreferenceDialog.PREFERENCE_KEY_AUTO_ADJUST_WINDOW);
+ vf.setAutoAdjust(aa);
}
/**
1.5 +7 -3 xml-batik/sources/org/apache/batik/dom/AbstractDocument.java
Index: AbstractDocument.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractDocument.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractDocument.java 2001/01/23 09:30:31 1.4
+++ AbstractDocument.java 2001/05/18 06:20:44 1.5
@@ -40,7 +40,7 @@
* This class implements the {@link org.w3c.dom.Document} interface.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: AbstractDocument.java,v 1.4 2001/01/23 09:30:31 hillion Exp $
+ * @version $Id: AbstractDocument.java,v 1.5 2001/05/18 06:20:44 hillion Exp $
*/
public abstract class AbstractDocument
extends AbstractParentNode
@@ -194,7 +194,9 @@
if (e == null) {
return EMPTY_NODE_LIST;
}
- return e.getElementsByTagName(tagname);
+ Nodes result = new Nodes();
+ getElementsByTagName(e, tagname, result);
+ return result;
}
/**
@@ -219,7 +221,9 @@
if (e == null) {
return EMPTY_NODE_LIST;
}
- return e.getElementsByTagNameNS(namespaceURI, localName);
+ Nodes result = new Nodes();
+ getElementsByTagNameNS(e, namespaceURI, localName, result);
+ return result;
}
/**
1.9 +9 -56 xml-batik/sources/org/apache/batik/dom/AbstractElement.java
Index: AbstractElement.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractElement.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AbstractElement.java 2001/02/14 16:33:51 1.8
+++ AbstractElement.java 2001/05/18 06:20:44 1.9
@@ -29,7 +29,7 @@
* This class implements the {@link org.w3c.dom.Element} interface.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: AbstractElement.java,v 1.8 2001/02/14 16:33:51 hillion Exp $
+ * @version $Id: AbstractElement.java,v 1.9 2001/05/18 06:20:44 hillion Exp $
*/
public abstract class AbstractElement
extends AbstractParentChildNode
@@ -189,7 +189,10 @@
return EMPTY_NODE_LIST;
}
Nodes result = new Nodes();
- getElementsByTagName(this, name, result);
+ while (n != null) {
+ getElementsByTagName(n, name, result);
+ n = n.getNextSibling();
+ }
return result;
}
@@ -294,7 +297,10 @@
return EMPTY_NODE_LIST;
}
Nodes result = new Nodes();
- getElementsByTagNameNS(this, namespaceURI, localName, result);
+ while (n != null) {
+ getElementsByTagNameNS(n, namespaceURI, localName, result);
+ n = n.getNextSibling();
+ }
return result;
}
@@ -303,59 +309,6 @@
*/
protected NamedNodeMap createAttributes() {
return new NamedNodeHashMap();
- }
-
- /**
- * An auxiliary method of getElementsByTagName.
- */
- protected static void getElementsByTagName(Node node, String name,
- Nodes list) {
- if (node.getNodeType() == ELEMENT_NODE) {
- if (name.equals("*") || name.equals(node.getNodeName())) {
- list.append(node);
- }
- }
- for (Node n = node.getFirstChild();
- n != null;
- n = n.getNextSibling()) {
- getElementsByTagName(n, name, list);
- }
- }
-
- /**
- * An auxiliary method for getElementsByTagNameNS.
- */
- protected static void getElementsByTagNameNS(Node node,
- String ns,
- String name,
- Nodes list) {
- if (node.getNodeType() == ELEMENT_NODE) {
- if (stringMatches(ns, node.getNamespaceURI()) &&
- (name.equals("*") || name.equals(node.getLocalName()))) {
- list.append(node);
- }
- }
- for (Node n = node.getFirstChild();
- n != null;
- n = n.getNextSibling()) {
- getElementsByTagNameNS(n, ns, name, list);
- }
- }
-
- /**
- * String matching for getElementsByTagNameNS function.
- */
- private static boolean stringMatches(String s1, String s2) {
- if (s1 == null && s2 == null) {
- return true;
- }
- if (s1 == null || s2 == null) {
- return false;
- }
- if (s1.equals("*")) {
- return true;
- }
- return s1.equals(s2);
}
/**
1.8 +54 -1 xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java
Index: AbstractParentNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AbstractParentNode.java 2001/05/17 16:36:39 1.7
+++ AbstractParentNode.java 2001/05/18 06:20:44 1.8
@@ -24,7 +24,7 @@
* This class implements the Node interface with support for children.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: AbstractParentNode.java,v 1.7 2001/05/17 16:36:39 hillion Exp $
+ * @version $Id: AbstractParentNode.java,v 1.8 2001/05/18 06:20:44 hillion Exp $
*/
public abstract class AbstractParentNode extends AbstractNode {
@@ -260,6 +260,59 @@
((AbstractNode)n).fireDOMNodeRemovedFromDocumentEvent();
}
}
+ }
+
+ /**
+ * An auxiliary method of getElementsByTagName.
+ */
+ protected static void getElementsByTagName(Node node, String name,
+ Nodes list) {
+ if (node.getNodeType() == ELEMENT_NODE) {
+ if (name.equals("*") || name.equals(node.getNodeName())) {
+ list.append(node);
+ }
+ }
+ for (Node n = node.getFirstChild();
+ n != null;
+ n = n.getNextSibling()) {
+ getElementsByTagName(n, name, list);
+ }
+ }
+
+ /**
+ * An auxiliary method for getElementsByTagNameNS.
+ */
+ protected static void getElementsByTagNameNS(Node node,
+ String ns,
+ String name,
+ Nodes list) {
+ if (node.getNodeType() == ELEMENT_NODE) {
+ if (stringMatches(ns, node.getNamespaceURI()) &&
+ (name.equals("*") || name.equals(node.getLocalName()))) {
+ list.append(node);
+ }
+ }
+ for (Node n = node.getFirstChild();
+ n != null;
+ n = n.getNextSibling()) {
+ getElementsByTagNameNS(n, ns, name, list);
+ }
+ }
+
+ /**
+ * String matching for getElementsByTagNameNS function.
+ */
+ private static boolean stringMatches(String s1, String s2) {
+ if (s1 == null && s2 == null) {
+ return true;
+ }
+ if (s1 == null || s2 == null) {
+ return false;
+ }
+ if (s1.equals("*")) {
+ return true;
+ }
+ return s1.equals(s2);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org