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/03/18 17:29:24 UTC
cvs commit: xml-batik/sources/org/apache/batik/util/gui LanguageDialog.java URIChooser.java UserStyleDialog.java LanguageChangeHandler.java
hillion 01/03/18 08:29:23
Modified: resources/org/apache/batik/apps/svgbrowser/resources
GUI.properties
samples/tests index.svg index2.svg thumbnails.svg
sources/org/apache/batik/apps/svgbrowser
JSVGViewerFrame.java StatusBar.java
sources/org/apache/batik/css AbstractViewCSS.java
CSSOMReadOnlyStyleDeclaration.java
sources/org/apache/batik/swing/gvt JGVTComponent.java
sources/org/apache/batik/util/gui LanguageDialog.java
URIChooser.java UserStyleDialog.java
Removed: resources/org/apache/batik/apps/svgviewer/resources
asf-logo.svg authors.svg usage.svg
resources/org/apache/batik/test/script test.js test.py
test.tcl
samples/tests textPath.svg
sources/org/apache/batik/util/gui LanguageChangeHandler.java
Log:
- few browser enhancements,
- indexes in samples/tests/ are now up-to-date,
- CSS engine minor cleanup,
- removed unused files in resources/
Revision Changes Path
1.7 +13 -6 xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties
Index: GUI.properties
===================================================================
RCS file: /home/cvs/xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GUI.properties 2001/03/14 15:20:29 1.6
+++ GUI.properties 2001/03/18 16:29:20 1.7
@@ -9,7 +9,7 @@
# The viewer's GUI resources.
#
# Author: stephane@hillion.org
-# $Id: GUI.properties,v 1.6 2001/03/14 15:20:29 hillion Exp $
+# $Id: GUI.properties,v 1.7 2001/03/18 16:29:20 hillion Exp $
#
ViewSource.width = 750
@@ -38,7 +38,7 @@
MenuBar = File View Processing Options Tools
# File menu ################
-File = Open NewWindow - Print ExportAs - Reload - Close Exit
+File = Open OpenLocation NewWindow Reload - Print ExportAs - Close Exit
File.type = MENU
File.text = File
File.mnemonic = F
@@ -50,8 +50,15 @@
Open.action = OpenAction
Open.accelerator = Ctrl+F
+OpenLocation.type = ITEM
+OpenLocation.text = Open Location...
+OpenLocation.icon = resources/blank.gif
+OpenLocation.mnemonic = L
+OpenLocation.action = OpenLocationAction
+OpenLocation.accelerator = Ctrl+A
+
NewWindow.type = ITEM
-NewWindow.text = New Window...
+NewWindow.text = Create New Window...
NewWindow.icon = resources/blank.gif
NewWindow.mnemonic = N
NewWindow.action = NewWindowAction
@@ -65,7 +72,7 @@
Close.accelerator = Ctrl+W
Reload.type = ITEM
-Reload.text = Reload File...
+Reload.text = Reload Document
Reload.icon = resources/reload.gif
Reload.mnemonic = R
Reload.action = ReloadAction
@@ -183,14 +190,14 @@
DoubleBuffer.selected = false
Language.type = ITEM
-Language.text = Language
+Language.text = Choose User Languages
Language.icon = resources/language.gif
Language.mnemonic = L
Language.action = LanguageAction
Language.accelerator = Ctrl+L
StyleSheet.type = ITEM
-StyleSheet.text = Choose User Style-sheet
+StyleSheet.text = Choose User Stylesheet
StyleSheet.icon = resources/blank.gif
StyleSheet.mnemonic = C
StyleSheet.action = StyleSheetAction
1.8 +23 -23 xml-batik/samples/tests/index.svg
Index: index.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/tests/index.svg,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- index.svg 2000/12/01 10:14:34 1.7
+++ index.svg 2001/03/18 16:29:21 1.8
@@ -14,7 +14,7 @@
<!-- This tests validates linking and provides an index for text files. -->
<!-- -->
<!-- @author stephane@hillion.org -->
-<!-- @version $Id: index.svg,v 1.7 2000/12/01 10:14:34 vhardy Exp $ -->
+<!-- @version $Id: index.svg,v 1.8 2001/03/18 16:29:21 hillion Exp $ -->
<!-- ========================================================================= -->
<svg id="body" width="450" height="500">
@@ -38,7 +38,7 @@
}
text.link {
fill: rgb(103, 103, 153);
- font-size: 16;
+ font-size: 14;
font-family: 'SunSansCondensed-Normal';
text-decoration: underline;
text-anchor: middle;
@@ -46,7 +46,7 @@
text.link2 {
fill: black;
- font-size: 16;
+ font-size: 14;
font-family: 'SunSansCondensed-Normal';
text-decoration: underline;
text-anchor: middle;
@@ -80,76 +80,76 @@
</a>
<rect x="5" y="95" width="440" height="30" style="fill:rgb(203, 203, 255)"/>
- <a xlink:href="feTurbulence.svg" xlink:show="new">
+ <a xlink:href="colorProfile.svg" xlink:show="new">
<text class="link" x="50%" y="115">
- feTurbulence Effect (feTurbulence.svg)
+ Color Profile (colorProfile.svg)
</text>
</a>
<rect x="5" y="130" width="440" height="30" style="fill:rgb(153, 153, 203)"/>
- <a xlink:href="feColorMatrix.svg" xlink:show="new">
+ <a xlink:href="dataProtocol.svg" xlink:show="new">
<text class="link2" x="50%" y="150">
- feColorMatrix Effect (feColorMatrix.svg)
+ Data Protocol (dataProtocol.svg)
</text>
</a>
<rect x="5" y="165" width="440" height="30"
style="fill:rgb(203, 203, 255)"/>
- <a xlink:href="feComponentTransfer.svg" xlink:show="new">
+ <a xlink:href="enableBackground.svg" xlink:show="new">
<text class="link" x="50%" y="185">
- feComponentTransfer Effect (feComponentTransfer.svg)
+ enable-background (enableBackground.svg)
</text>
</a>
<rect x="5" y="200" width="440" height="30" style="fill:rgb(153, 153, 203)"/>
- <a xlink:href="feComponentTransfer2.svg" xlink:show="new">
+ <a xlink:href="feConvolveMatrix.svg" xlink:show="new">
<text class="link2" x="50%" y="220">
- feComponentTransfer Effect (feComponentTransfer2.svg)
+ feConvolveMatrix Effect (feConvolveMatrix.svg)
</text>
</a>
<rect x="5" y="235" width="440" height="30"
style="fill:rgb(203, 203, 255)"/>
- <a xlink:href="opacity.svg" xlink:show="new">
+ <a xlink:href="markersMisc.svg" xlink:show="new">
<text class="link" x="50%" y="255">
- Opacity (opacity.svg)
+ Markers (markersMisc.svg)
</text>
</a>
<rect x="5" y="270" width="440" height="30" style="fill:rgb(153, 153, 203)"/>
- <a xlink:href="opacity2.svg" xlink:show="new">
+ <a xlink:href="markersOrientA.svg" xlink:show="new">
<text class="link2" x="50%" y="290">
- Opacity on Group (opacity2.svg)
+ Markers Orientation (markersOrientA.svg)
</text>
</a>
<rect x="5" y="305" width="440" height="30"
style="fill:rgb(203, 203, 255)"/>
- <a xlink:href="filterRegions.svg" xlink:show="new">
+ <a xlink:href="markersOrientB.svg" xlink:show="new">
<text class="link" x="50%" y="325">
- Filter Regions (filterRegions.svg)
+ Markers Orientation 2 (markersOrientB.svg)
</text>
</a>
<rect x="5" y="340" width="440" height="30" style="fill:rgb(153, 153, 203)"/>
- <a xlink:href="feMorphology.svg" xlink:show="new">
+ <a xlink:href="markersPreserveAspectRatio.svg" xlink:show="new">
<text class="link2" x="50%" y="360">
- Morphology Effect (feMorphology.svg)
+ Markers PreserveAspectRatio (markersPreserveAspectRatio.svg)
</text>
</a>
<rect x="5" y="375" width="440" height="30"
style="fill:rgb(203, 203, 255)"/>
- <a xlink:href="mask.svg" xlink:show="new">
+ <a xlink:href="markersShapes.svg" xlink:show="new">
<text class="link" x="50%" y="395">
- Masking (mask.svg)
+ Markers Shapes (markersShapes.svg)
</text>
</a>
<rect x="5" y="410" width="440" height="30" style="fill:rgb(153, 153, 203)"/>
- <a xlink:href="textPath.svg" xlink:show="new">
+ <a xlink:href="paintOpacity.svg" xlink:show="new">
<text class="link2" x="50%" y="430">
- Text on a Path (textPath.svg)
+ Paint Opacity (paintOpacity.svg)
</text>
</a>
1.11 +68 -26 xml-batik/samples/tests/index2.svg
Index: index2.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/tests/index2.svg,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- index2.svg 2001/03/08 03:04:49 1.10
+++ index2.svg 2001/03/18 16:29:21 1.11
@@ -14,7 +14,7 @@
<!-- This tests validates linking and provides an index for text files. -->
<!-- -->
<!-- @author stephane@hillion.org -->
-<!-- @version $Id: index2.svg,v 1.10 2001/03/08 03:04:49 hillion Exp $ -->
+<!-- @version $Id: index2.svg,v 1.11 2001/03/18 16:29:21 hillion Exp $ -->
<!-- ========================================================================= -->
<svg id="body" width="450" height="500" viewBox="0 0 450 500">
@@ -34,7 +34,7 @@
}
text.previous {
stroke-width: 1;
- font-size: 32;
+ font-size: 28;
text-anchor: start;
text-decoration: underline;
}
@@ -46,7 +46,7 @@
}
text.link {
fill: white;
- font-size: 18;
+ font-size: 14;
font-family: SunSansCondensed-Heavy;
}
]]>
@@ -93,69 +93,99 @@
Test Files 2
</text>
- <a xlink:href="clip.svg" xlink:show="new">
+ <a xlink:href="image.svg" xlink:show="new">
<text class="link" x="70" y="0"
- transform="translate(0, 250) rotate(-45)">
- Clip Path (clip.svg)
+ transform="translate(0, 250) rotate(-55)">
+ Images (image.svg)
</text>
</a>
<a xlink:href="textFeatures.svg" xlink:show="new">
<text class="link" x="70" y="0"
- transform="translate(0, 250) rotate(-35)">
+ transform="translate(0, 250) rotate(-47)">
Text (textFeatures.svg)
</text>
</a>
+
+ <a xlink:href="textProperties.svg" xlink:show="new">
+ <text class="link" x="70" y="0"
+ transform="translate(0, 250) rotate(-39)">
+ Text 2 (textProperties.svg)
+ </text>
+ </a>
+
+ <a xlink:href="patternRegionA.svg" xlink:show="new">
+ <text class="link" x="70" y="0"
+ transform="translate(0, 250) rotate(-31)">
+ Pattern Region A (patternRegionA.svg)
+ </text>
+ </a>
- <a xlink:href="dataProtocol.svg" xlink:show="new">
+ <a xlink:href="patternRegionB.svg" xlink:show="new">
<text class="link" x="70" y="0"
- transform="translate(0, 250) rotate(-25)">
- Data Protocol (dataProtocol.svg)
+ transform="translate(0, 250) rotate(-23)">
+ Pattern Region B (patternRegionB.svg)
</text>
</a>
- <a xlink:href="feComposite.svg" xlink:show="new">
+ <a xlink:href="systemColors.svg" xlink:show="new">
<text class="link" x="70" y="0"
transform="translate(0, 250) rotate(-15)">
- feComposite (feComposite.svg)
+ System Colors (systemColors.svg)
</text>
</a>
- <a xlink:href="feTileTarget.svg" xlink:show="new">
+ <a xlink:href="textBidi.svg" xlink:show="new">
<text class="link" x="70" y="0"
- transform="translate(0, 250) rotate(-5)">
- feTileTarget (feTileTarget.svg)
+ transform="translate(0, 250) rotate(-7)">
+ Bidirectional Text (textBidi.svg)
</text>
</a>
- <a xlink:href="image.svg" xlink:show="new">
+ <a xlink:href="percentagesAndUnits.svg" xlink:show="new">
+ <text class="link" x="70" y="0"
+ transform="translate(0, 250) rotate(1)">
+ Percentages & Units (percentagesAndUnits.svg)
+ </text>
+ </a>
+
+ <a xlink:href="textStyles.svg" xlink:show="new">
<text class="link" x="70" y="0"
- transform="translate(0, 250) rotate(5)">
- SVG Images (image.svg)
+ transform="translate(0, 250) rotate(9)">
+ Text Styles (textStyles.svg)
</text>
</a>
+
- <a xlink:href="thumbnails.svg" xlink:show="new">
+ <a xlink:href="textLayout.svg" xlink:show="new">
<text class="link" x="70" y="0"
- transform="translate(0, 250) rotate(15)">
- External References (thumbnails.svg)
+ transform="translate(0, 250) rotate(17)">
+ Text Layout (textLayout.svg)
</text>
</a>
- <a xlink:href="feDisplacementMap.svg" xlink:show="new">
+ <a xlink:href="patternPreserveAspectRatioA.svg" xlink:show="new">
<text class="link" x="70" y="0"
transform="translate(0, 250) rotate(25)">
- feDisplacementMap (feDisplacementMap.svg)
+ Pattern PreserveAspectRatio (patternPreserveAspectRatioA.svg)
+ </text>
+ </a>
+
+ <a xlink:href="textLayout2.svg" xlink:show="new">
+ <text class="link" x="70" y="0"
+ transform="translate(0, 250) rotate(33)">
+ Text Layout 2 (textLayout2.svg)
</text>
</a>
- <a xlink:href="feTile.svg" xlink:show="new">
+ <a xlink:href="visibility.svg" xlink:show="new">
<text class="link" x="70" y="0"
- transform="translate(0, 250) rotate(35)">
- feTile (feTile.svg)
+ transform="translate(0, 250) rotate(41)">
+ Visibility (visibility.svg)
</text>
</a>
+
<a xlink:href="index.svg">
<text class="headfoot previous" style="fill:white; filter:url(#blur);" x="20" y="480" transform="translate(0, 0)">
Previous
@@ -165,6 +195,18 @@
</text>
<text class="headfoot previous" x="20" y="480">
Previous
+ </text>
+ </a>
+
+ <a xlink:href="thumbnails.svg">
+ <text class="headfoot previous" style="fill:white; filter:url(#blur);" x="350" y="480" transform="translate(0, 0)">
+ Next
+ </text>
+ <text class="headfoot previous" style="fill:white; filter:url(#blur);" x="350" y="480" transform="translate(0, 0)">
+ Next
+ </text>
+ <text class="headfoot previous" x="350" y="480">
+ Next
</text>
</a>
</svg>
1.7 +12 -11 xml-batik/samples/tests/thumbnails.svg
Index: thumbnails.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/tests/thumbnails.svg,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- thumbnails.svg 2000/12/01 16:35:01 1.6
+++ thumbnails.svg 2001/03/18 16:29:22 1.7
@@ -13,7 +13,7 @@
<!-- ========================================================================= -->
<!-- This file shows a thumbnail of the other files in the directory. -->
<!-- @author vhardy@eng.sun.com -->
-<!-- @version $Id: thumbnails.svg,v 1.6 2000/12/01 16:35:01 tkormann Exp $ -->
+<!-- @version $Id: thumbnails.svg,v 1.7 2001/03/18 16:29:22 hillion Exp $ -->
<!-- ========================================================================= -->
<?xml-stylesheet type="text/css" href="test.css" ?>
@@ -238,16 +238,17 @@
</g>
<!-- ======================== -->
- <!-- textPath -->
+ <!-- feDisplacementMap -->
<!-- ======================== -->
<g transform="translate(300, 0) scale(1.5, 1.5)">
- <symbol id="textPath" viewBox="0 0 450 500">
- <use xlink:href="textPath.svg#body"/>
+ <!-- The <svg> element in a symbol to be able to resize it -->
+ <symbol id="feDisplacementMap" viewBox="0 0 450 500">
+ <use xlink:href="feDisplacementMap.svg#body"/>
</symbol>
- <use xlink:href="#textPath" width="45" height="50"/>
+ <use xlink:href="#feDisplacementMap" width="45" height="50"/>
- <a xlink:href="textPath.svg" xlink:show="new">
+ <a xlink:href="feDisplacementMap.svg" xlink:show="new">
<rect width="45" height="50"
style="fill-opacity:0;"/>
</a>
@@ -312,17 +313,17 @@
</g>
<!-- ======================== -->
- <!-- feDisplacementMap -->
+ <!-- index2 -->
<!-- ======================== -->
<g transform="translate(300, 0) scale(1.5, 1.5)">
<!-- The <svg> element in a symbol to be able to resize it -->
- <symbol id="feDisplacementMap" viewBox="0 0 450 500">
- <use xlink:href="feDisplacementMap.svg#body"/>
+ <symbol id="index2" viewBox="0 0 450 500">
+ <use xlink:href="index2.svg#body"/>
</symbol>
- <use xlink:href="#feDisplacementMap" width="45" height="50"/>
+ <use xlink:href="#index2" width="45" height="50"/>
- <a xlink:href="feDisplacementMap.svg" xlink:show="new">
+ <a xlink:href="index2.svg">
<rect width="45" height="50"
style="fill-opacity:0;"/>
</a>
1.6 +96 -61 xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
Index: JSVGViewerFrame.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JSVGViewerFrame.java 2001/03/14 15:20:30 1.5
+++ JSVGViewerFrame.java 2001/03/18 16:29:22 1.6
@@ -96,10 +96,10 @@
import org.apache.batik.transcoder.print.PrintTranscoder;
import org.apache.batik.util.gui.DOMViewer;
-import org.apache.batik.util.gui.LanguageChangeHandler;
import org.apache.batik.util.gui.LanguageDialog;
import org.apache.batik.util.gui.LocationBar;
import org.apache.batik.util.gui.MemoryMonitor;
+import org.apache.batik.util.gui.URIChooser;
import org.apache.batik.util.gui.UserStyleDialog;
import org.apache.batik.util.gui.resource.ActionMap;
@@ -118,7 +118,7 @@
* This class represents a SVG viewer swing frame.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: JSVGViewerFrame.java,v 1.5 2001/03/14 15:20:30 hillion Exp $
+ * @version $Id: JSVGViewerFrame.java,v 1.6 2001/03/18 16:29:22 hillion Exp $
*/
public class JSVGViewerFrame
extends JFrame
@@ -135,6 +135,7 @@
// The actions names.
public final static String OPEN_ACTION = "OpenAction";
+ public final static String OPEN_LOCATION_ACTION = "OpenLocationAction";
public final static String NEW_WINDOW_ACTION = "NewWindowAction";
public final static String RELOAD_ACTION = "ReloadAction";
public final static String PRINT_ACTION = "PrintAction";
@@ -233,6 +234,11 @@
protected SVGDocument svgDocument;
/**
+ * The URI chooser.
+ */
+ protected URIChooser uriChooser;
+
+ /**
* The DOM viewer.
*/
protected DOMViewer domViewer;
@@ -290,6 +296,7 @@
});
listeners.put(OPEN_ACTION, new OpenAction());
+ listeners.put(OPEN_LOCATION_ACTION, new OpenLocationAction());
listeners.put(NEW_WINDOW_ACTION, new NewWindowAction());
listeners.put(RELOAD_ACTION, new ReloadAction());
listeners.put(PRINT_ACTION, new PrintAction());
@@ -510,7 +517,7 @@
}
/**
- * To open a new document.
+ * To open a new file.
*/
public class OpenAction extends AbstractAction {
public OpenAction() {}
@@ -536,6 +543,39 @@
}
/**
+ * To open a new document.
+ */
+ public class OpenLocationAction extends AbstractAction {
+ public OpenLocationAction() {}
+ public void actionPerformed(ActionEvent e) {
+ if (uriChooser == null) {
+ uriChooser = new URIChooser(JSVGViewerFrame.this);
+ uriChooser.setFileFilter(new SVGFileFilter());
+ uriChooser.pack();
+ Rectangle fr = getBounds();
+ Dimension sd = uriChooser.getSize();
+ uriChooser.setLocation(fr.x + (fr.width - sd.width) / 2,
+ fr.y + (fr.height - sd.height) / 2);
+ }
+ if (uriChooser.showDialog() == URIChooser.OK_OPTION) {
+ String text = uriChooser.getText();
+ try {
+ File f = new File(text);
+ URL u = null;
+ if (f.exists() && !f.isDirectory()) {
+ u = f.toURL();
+ } else {
+ u = new URL(text);
+ }
+ svgCanvas.loadSVGDocument(u.toString());
+ } catch (Exception ex) {
+ // !!! Error dialog
+ }
+ }
+ }
+ }
+
+ /**
* To open a new window.
*/
public class NewWindowAction extends AbstractAction {
@@ -690,24 +730,31 @@
return;
}
+ URL tu = null;
+ try {
+ tu = new URL(((SVGOMDocument)svgDocument).getURLObject(), "");
+ } catch (MalformedURLException ex) {
+ // Can't happen
+ throw new InternalError(ex.getMessage());
+ }
+ final URL u = tu;
+
+ final JFrame fr = new JFrame(u.toString());
+ fr.setSize(resources.getInteger("ViewSource.width"),
+ resources.getInteger("ViewSource.height"));
+ final JTextArea ta = new JTextArea();
+ ta.setLineWrap(true);
+ ta.setFont(new Font("monospaced", Font.PLAIN, 12));
+
+ JScrollPane scroll = new JScrollPane();
+ scroll.getViewport().add(ta);
+ scroll.setVerticalScrollBarPolicy
+ (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ fr.getContentPane().add(scroll, BorderLayout.CENTER);
+
new Thread() {
public void run() {
char [] buffer = new char[4096];
-
- URL u = ((SVGOMDocument)svgDocument).getURLObject();
-
- JFrame fr = new JFrame(u.toString());
- fr.setSize(resources.getInteger("ViewSource.width"),
- resources.getInteger("ViewSource.height"));
- JTextArea ta = new JTextArea();
- ta.setLineWrap(true);
- ta.setFont(new Font("monospaced", Font.PLAIN, 12));
-
- JScrollPane scroll = new JScrollPane();
- scroll.getViewport().add(ta);
- scroll.setVerticalScrollBarPolicy
- (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- fr.getContentPane().add(scroll, BorderLayout.CENTER);
try {
Document doc = new PlainDocument();
@@ -731,16 +778,12 @@
// try default encoding...
doc = new PlainDocument();
is = u.openStream();
- try {
- Reader in = new InputStreamReader(is);
- int nch;
- while ((nch = in.read(buffer, 0, buffer.length))!=-1){
- doc.insertString(doc.getLength(),
- new String(buffer, 0, nch), null);
- }
- } catch (Exception ex) {
- // !!! TODO : dialog
- System.err.println(ex.toString());
+
+ Reader in = new InputStreamReader(is);
+ int nch;
+ while ((nch = in.read(buffer, 0, buffer.length))!=-1){
+ doc.insertString(doc.getLength(),
+ new String(buffer, 0, nch), null);
}
}
@@ -882,36 +925,16 @@
public void actionPerformed(ActionEvent e) {
if (languageDialog == null) {
languageDialog = new LanguageDialog(JSVGViewerFrame.this);
- languageDialog.setLanguageChangeHandler
- (new LanguageChangeHandler() {
- public void languageChanged(String lang) {
- userLanguages = lang;
- }
- });
+
Rectangle fr = getBounds();
Dimension ld = languageDialog.getSize();
languageDialog.setLocation(fr.x + (fr.width - ld.width) / 2,
fr.y + (fr.height - ld.height) / 2);
languageDialog.setLanguages(userLanguages);
}
- languageDialog.show();
- }
- }
-
- /**
- * To display the memory monitor.
- */
- public class MonitorAction extends AbstractAction {
- public MonitorAction() {}
- public void actionPerformed(ActionEvent e) {
- if (memoryMonitorFrame == null) {
- memoryMonitorFrame = new MemoryMonitor();
- Rectangle fr = getBounds();
- Dimension md = memoryMonitorFrame.getSize();
- memoryMonitorFrame.setLocation(fr.x + (fr.width - md.width) / 2,
- fr.y + (fr.height - md.height) / 2);
+ if (languageDialog.showDialog() == LanguageDialog.OK_OPTION) {
+ userLanguages = languageDialog.getLanguages();
}
- memoryMonitorFrame.show();
}
}
@@ -923,20 +946,32 @@
public void actionPerformed(ActionEvent e) {
if (styleSheetDialog == null) {
styleSheetDialog = new UserStyleDialog(JSVGViewerFrame.this);
- styleSheetDialog.setChangeHandler
- (new UserStyleDialog.ChangeHandler() {
- public void userStyleSheetURIChanged(String s) {
- userStyleSheetURI = s;
- }
- });
styleSheetDialog.pack();
Rectangle fr = getBounds();
Dimension sd = styleSheetDialog.getSize();
styleSheetDialog.setLocation(fr.x + (fr.width - sd.width) / 2,
fr.y + (fr.height - sd.height) / 2);
+ }
+ if (styleSheetDialog.showDialog() == UserStyleDialog.OK_OPTION) {
+ userStyleSheetURI = styleSheetDialog.getPath();
}
- styleSheetDialog.pack();
- styleSheetDialog.show();
+ }
+ }
+
+ /**
+ * To display the memory monitor.
+ */
+ public class MonitorAction extends AbstractAction {
+ public MonitorAction() {}
+ public void actionPerformed(ActionEvent e) {
+ if (memoryMonitorFrame == null) {
+ memoryMonitorFrame = new MemoryMonitor();
+ Rectangle fr = getBounds();
+ Dimension md = memoryMonitorFrame.getSize();
+ memoryMonitorFrame.setLocation(fr.x + (fr.width - md.width) / 2,
+ fr.y + (fr.height - md.height) / 2);
+ }
+ memoryMonitorFrame.show();
}
}
@@ -1212,14 +1247,14 @@
* The given message is typically displayed in a status bar.
*/
public void displayMessage(String message) {
- System.out.println(message);
+ statusBar.setMessage(message);
}
/**
* Returns a customized the pixel to mm factor.
*/
public float getPixelToMM() {
- return 0.264583333333333333333f; // 72 dpi
+ return 0.264583333333333333333f; // 96 dpi
}
/**
1.2 +16 -3 xml-batik/sources/org/apache/batik/apps/svgbrowser/StatusBar.java
Index: StatusBar.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/StatusBar.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StatusBar.java 2001/03/08 01:21:06 1.1
+++ StatusBar.java 2001/03/18 16:29:22 1.2
@@ -38,7 +38,7 @@
* This class represents a viewer status bar.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: StatusBar.java,v 1.1 2001/03/08 01:21:06 hillion Exp $
+ * @version $Id: StatusBar.java,v 1.2 2001/03/18 16:29:22 hillion Exp $
*/
public class StatusBar extends JPanel {
@@ -88,6 +88,11 @@
protected String mainMessage;
/**
+ * The current display thread.
+ */
+ protected Thread displayThread;
+
+ /**
* Creates a new status bar
* @param rm the resource manager that finds the message
*/
@@ -183,9 +188,13 @@
* @param s the message
*/
public void setMessage(String s) {
- message.setText(s);
setPreferredSize(new Dimension(0, getPreferredSize().height));
- new DisplayThread().start();
+ if (displayThread != null) {
+ displayThread.interrupt();
+ }
+ displayThread = new DisplayThread();
+ displayThread.start();
+ message.setText(s);
}
/**
@@ -195,6 +204,10 @@
public void setMainMessage(String s) {
mainMessage = s;
message.setText(mainMessage = s);
+ if (displayThread != null) {
+ displayThread.interrupt();
+ displayThread = null;
+ }
setPreferredSize(new Dimension(0, getPreferredSize().height));
}
1.10 +2 -2 xml-batik/sources/org/apache/batik/css/AbstractViewCSS.java
Index: AbstractViewCSS.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/AbstractViewCSS.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractViewCSS.java 2001/03/15 13:59:24 1.9
+++ AbstractViewCSS.java 2001/03/18 16:29:22 1.10
@@ -41,7 +41,7 @@
* {@link org.w3c.dom.css.ViewCSS} interface.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: AbstractViewCSS.java,v 1.9 2001/03/15 13:59:24 hillion Exp $
+ * @version $Id: AbstractViewCSS.java,v 1.10 2001/03/18 16:29:22 hillion Exp $
*/
public abstract class AbstractViewCSS implements ViewCSS {
/**
@@ -222,7 +222,7 @@
val = null;
}
rd.setPropertyCSSValue(prop, val, "",
- CSSOMReadOnlyStyleDeclaration.USER_AGENT_ORIGIN);
+ CSSOMReadOnlyStyleDeclaration.AUTHOR_ORIGIN);
if (val != null) {
rvr.resolveValue(e, pe, this, rd, val, prio, orig);
}
1.10 +63 -8 xml-batik/sources/org/apache/batik/css/CSSOMReadOnlyStyleDeclaration.java
Index: CSSOMReadOnlyStyleDeclaration.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/CSSOMReadOnlyStyleDeclaration.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CSSOMReadOnlyStyleDeclaration.java 2001/03/15 15:36:46 1.9
+++ CSSOMReadOnlyStyleDeclaration.java 2001/03/18 16:29:22 1.10
@@ -29,7 +29,7 @@
* interface.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: CSSOMReadOnlyStyleDeclaration.java,v 1.9 2001/03/15 15:36:46 hillion Exp $
+ * @version $Id: CSSOMReadOnlyStyleDeclaration.java,v 1.10 2001/03/18 16:29:22 hillion Exp $
*/
public class CSSOMReadOnlyStyleDeclaration implements CSSStyleDeclaration {
/**
@@ -181,8 +181,7 @@
String imp,
int orig) {
/*ValueEntry ve = (ValueEntry)*/
- properties.put(propertyName, createValueEntry((CSSOMReadOnlyValue)v,
- imp, orig));
+ properties.put(propertyName, (CSSOMReadOnlyValue)v, imp, orig);
}
/**
@@ -294,7 +293,7 @@
/**
* Creates a new value entry.
*/
- protected ValueEntry createValueEntry(CSSOMReadOnlyValue v, String s, int p) {
+ protected static ValueEntry createValueEntry(CSSOMReadOnlyValue v, String s, int p) {
switch (p) {
case USER_AGENT_ORIGIN:
if (s.length() == 0) {
@@ -587,14 +586,27 @@
* Sets a new value for the given variable
* @return the old value or null
*/
- public void put(String key, ValueEntry valueEntry) {
+ public void put(String key, CSSOMReadOnlyValue v, String imp, int orig) {
int hash = key.hashCode() & 0x7FFFFFFF;
int index = hash % table.length;
+ ValueEntry prev = null;
for (ValueEntry e = table[index]; e != null; e = e.next) {
if ((e.hash == hash) && e.key == key) {
- e.value = valueEntry.value;
+ if (e.getPriority().equals(imp) && e.getOrigin() == orig) {
+ e.value = v;
+ } else {
+ ValueEntry ve = createValueEntry(v, imp, orig);
+ ve.initialize(hash, key, e.next);
+ if (prev == null) {
+ table[index] = ve;
+ } else {
+ prev.next = ve;
+ }
+ }
+ return;
}
+ prev = e;
}
// The key is not in the hash table
@@ -604,8 +616,51 @@
index = hash % table.length;
}
- valueEntry.initialize(hash, key, table[index]);
- table[index] = valueEntry;
+ ValueEntry ve = createValueEntry(v, imp, orig);
+ ve.initialize(hash, key, table[index]);
+ table[index] = ve;
+ }
+
+ /**
+ * Sets a new value for the given variable
+ * @return the old value or null
+ */
+ public void put(String key, ValueEntry ve) {
+ int hash = key.hashCode() & 0x7FFFFFFF;
+ int index = hash % table.length;
+
+ ValueEntry prev = null;
+ for (ValueEntry e = table[index]; e != null; e = e.next) {
+ if ((e.hash == hash) && e.key == key) {
+ if (e.getPriority().equals(ve.getPriority()) &&
+ e.getOrigin() == ve.getOrigin()) {
+ e.value = ve.value;
+ } else {
+ ValueEntry ventry = createValueEntry(ve.value, ve.getPriority(),
+ ve.getOrigin());
+ ve.initialize(hash, key, e.next);
+ if (prev == null) {
+ table[index] = ventry;
+ } else {
+ prev.next = ventry;
+ }
+ }
+ return;
+ }
+ prev = e;
+ }
+
+ // The key is not in the hash table
+ int len = table.length;
+ if (count++ >= (len * 3) >>> 2) {
+ rehash();
+ index = hash % table.length;
+ }
+
+ ValueEntry ventry = createValueEntry(ve.value, ve.getPriority(),
+ ve.getOrigin());
+ ventry.initialize(hash, key, table[index]);
+ table[index] = ventry;
}
/**
1.3 +2 -2 xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java
Index: JGVTComponent.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JGVTComponent.java 2001/03/14 14:16:24 1.2
+++ JGVTComponent.java 2001/03/18 16:29:22 1.3
@@ -52,7 +52,7 @@
* This class represents a component which can display a GVT tree.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: JGVTComponent.java,v 1.2 2001/03/14 14:16:24 hillion Exp $
+ * @version $Id: JGVTComponent.java,v 1.3 2001/03/18 16:29:22 hillion Exp $
*/
public class JGVTComponent extends JComponent {
@@ -502,7 +502,7 @@
try {
while (!isInterrupted()) {
repaint();
- sleep(100);
+ sleep(200);
}
} catch (InterruptedException e) {
}
1.4 +28 -9 xml-batik/sources/org/apache/batik/util/gui/LanguageDialog.java
Index: LanguageDialog.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/gui/LanguageDialog.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LanguageDialog.java 2001/01/29 15:58:55 1.3
+++ LanguageDialog.java 2001/03/18 16:29:23 1.4
@@ -55,9 +55,20 @@
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
- * @version $Id: LanguageDialog.java,v 1.3 2001/01/29 15:58:55 cjolif Exp $
+ * @version $Id: LanguageDialog.java,v 1.4 2001/03/18 16:29:23 hillion Exp $
*/
public class LanguageDialog extends JDialog implements ActionMap {
+
+ /**
+ * The return value if 'OK' is chosen.
+ */
+ public final static int OK_OPTION = 0;
+
+ /**
+ * The return value if 'Cancel' is chosen.
+ */
+ public final static int CANCEL_OPTION = 1;
+
/**
* The resource file name
*/
@@ -90,9 +101,9 @@
protected Panel panel = new Panel();
/**
- * The language change handler.
+ * The last return code.
*/
- protected LanguageChangeHandler languageChangeHandler;
+ protected int returnCode;
/**
* Creates a new LanguageDialog object.
@@ -112,10 +123,12 @@
}
/**
- * Sets a language change handler.
+ * Shows the dialog.
+ * @return OK_CANCEL or CANCEL_OPTION.
*/
- public void setLanguageChangeHandler(LanguageChangeHandler lch) {
- languageChangeHandler = lch;
+ public int showDialog() {
+ show();
+ return returnCode;
}
/**
@@ -125,6 +138,13 @@
panel.setLanguages(s);
}
+ /**
+ * Returns the user languages.
+ */
+ public String getLanguages() {
+ return panel.getLanguages();
+ }
+
// ActionMap implementation ///////////////////////////////////////
/**
@@ -603,9 +623,7 @@
*/
protected class OKButtonAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
- if (languageChangeHandler != null) {
- languageChangeHandler.languageChanged(panel.getLanguages());
- }
+ returnCode = OK_OPTION;
dispose();
}
}
@@ -615,6 +633,7 @@
*/
protected class CancelButtonAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
+ returnCode = CANCEL_OPTION;
dispose();
}
}
1.3 +43 -18 xml-batik/sources/org/apache/batik/util/gui/URIChooser.java
Index: URIChooser.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/gui/URIChooser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- URIChooser.java 2000/10/13 13:20:41 1.2
+++ URIChooser.java 2001/03/18 16:29:23 1.3
@@ -48,10 +48,21 @@
* This class is a dialog used to enter an URI or to choose a local file
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: URIChooser.java,v 1.2 2000/10/13 13:20:41 hillion Exp $
+ * @version $Id: URIChooser.java,v 1.3 2001/03/18 16:29:23 hillion Exp $
*/
public class URIChooser extends JDialog implements ActionMap {
+
+ /**
+ * The return value if 'OK' is chosen.
+ */
+ public final static int OK_OPTION = 0;
+
/**
+ * The return value if 'Cancel' is chosen.
+ */
+ public final static int CANCEL_OPTION = 1;
+
+ /**
* The resource file name
*/
protected final static String RESOURCES =
@@ -92,11 +103,6 @@
protected JButton clearButton;
/**
- * The external action associated with the ok button
- */
- protected Action okAction;
-
- /**
* The current path.
*/
protected String currentPath = ".";
@@ -107,13 +113,22 @@
protected FileFilter fileFilter;
/**
+ * The last return code.
+ */
+ protected int returnCode;
+
+ /**
+ * The last chosen path.
+ */
+ protected String chosenPath;
+
+ /**
* Creates a new URIChooser
* @param d the parent dialog
- * @param okAction the action to associate to the ok button
*/
- public URIChooser(JDialog d, Action okAction) {
+ public URIChooser(JDialog d) {
super(d);
- initialize(okAction);
+ initialize();
}
/**
@@ -121,16 +136,26 @@
* @param f the parent frame
* @param okAction the action to associate to the ok button
*/
- public URIChooser(JFrame f, Action okAction) {
+ public URIChooser(JFrame f) {
super(f);
- initialize(okAction);
+ initialize();
+ }
+
+ /**
+ * Shows the dialog.
+ * @return OK_OPTION or CANCEL_OPTION.
+ */
+ public int showDialog() {
+ pack();
+ show();
+ return returnCode;
}
/**
- * Returns the text contained in the text field
+ * Returns the text entered by the user.
*/
public String getText() {
- return textField.getText();
+ return chosenPath;
}
/**
@@ -143,8 +168,7 @@
/**
* Initializes the dialog
*/
- protected void initialize(Action okAction) {
- this.okAction = okAction;
+ protected void initialize() {
setModal(true);
listeners.put("BrowseButtonAction", new BrowseButtonAction());
@@ -272,9 +296,9 @@
*/
protected class OKButtonAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
- okAction.actionPerformed(e);
+ returnCode = OK_OPTION;
+ chosenPath = textField.getText();
dispose();
- textField.setText("");
}
}
@@ -283,8 +307,9 @@
*/
protected class CancelButtonAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
+ returnCode = CANCEL_OPTION;
dispose();
- textField.setText("");
+ textField.setText(chosenPath);
}
}
1.2 +41 -27 xml-batik/sources/org/apache/batik/util/gui/UserStyleDialog.java
Index: UserStyleDialog.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/gui/UserStyleDialog.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UserStyleDialog.java 2000/10/23 09:45:02 1.1
+++ UserStyleDialog.java 2001/03/18 16:29:23 1.2
@@ -48,10 +48,21 @@
* This class represents a dialog to select the user style sheet.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: UserStyleDialog.java,v 1.1 2000/10/23 09:45:02 hillion Exp $
+ * @version $Id: UserStyleDialog.java,v 1.2 2001/03/18 16:29:23 hillion Exp $
*/
public class UserStyleDialog extends JDialog implements ActionMap {
- /**
+
+ /**
+ * The return value if 'OK' is chosen.
+ */
+ public final static int OK_OPTION = 0;
+
+ /**
+ * The return value if 'Cancel' is chosen.
+ */
+ public final static int CANCEL_OPTION = 1;
+
+ /**
* The resource file name
*/
protected final static String RESOURCES =
@@ -78,11 +89,16 @@
protected Panel panel;
/**
- * The change handler.
+ * The chosen path.
*/
- protected ChangeHandler changeHandler;
+ protected String chosenPath;
/**
+ * The last return code.
+ */
+ protected int returnCode;
+
+ /**
* Creates a new user style dialog.
*/
public UserStyleDialog(JFrame f) {
@@ -99,6 +115,23 @@
}
/**
+ * Shows the dialog.
+ * @return OK_OPTION or CANCEL_OPTION.
+ */
+ public int showDialog() {
+ pack();
+ show();
+ return returnCode;
+ }
+
+ /**
+ * Returns the chosen path or null.
+ */
+ public String getPath() {
+ return chosenPath;
+ }
+
+ /**
* Creates the OK/Cancel buttons panel
*/
protected JPanel createButtonsPanel() {
@@ -132,32 +165,23 @@
} else {
path = "file:" + path;
}
- }
- if (changeHandler != null) {
- changeHandler.userStyleSheetURIChanged(path);
}
+ chosenPath = path;
}
} else {
- if (changeHandler != null) {
- changeHandler.userStyleSheetURIChanged(null);
- }
+ chosenPath = null;
}
+ returnCode = OK_OPTION;
dispose();
}
}
/**
- * Sets the change handler.
- */
- public void setChangeHandler(ChangeHandler ch) {
- changeHandler = ch;
- }
-
- /**
* The action associated with the 'Cancel' button
*/
protected class CancelButtonAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
+ returnCode = CANCEL_OPTION;
dispose();
}
}
@@ -175,16 +199,6 @@
*/
public Action getAction(String key) throws MissingListenerException {
return (Action)listeners.get(key);
- }
-
- /**
- * To handle a change in this dialog.
- */
- public interface ChangeHandler {
- /**
- * Called when the user stylesheet has changed.
- */
- void userStyleSheetURIChanged(String s);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org