You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by de...@apache.org on 2006/04/22 18:05:18 UTC

svn commit: r396138 [3/3] - in /xmlgraphics/batik/trunk/sources/org/apache/batik: apps/rasterizer/ apps/svgbrowser/ bridge/ css/dom/ css/engine/ css/engine/value/ dom/svg/ ext/awt/image/rendered/ extension/ gvt/event/ swing/gvt/ swing/svg/ transcoder/p...

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java?rev=396138&r1=396137&r2=396138&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java Sat Apr 22 09:05:15 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2001-2003  The Apache Software Foundation 
+   Copyright 2001-2003  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -256,7 +256,7 @@
     }
 
     /**
-     * Returns true if all 'interactor' objects 
+     * Returns true if all 'interactor' objects
      * (pan, zoom, etc) are disabled.
      */
     public boolean getDisableInteractions() {
@@ -514,10 +514,10 @@
         if (EventQueue.isDispatchThread()) {
             Rectangle visRect = getRenderRect();
             if (doubleBufferedRendering)
-                repaint(visRect.x,     visRect.y, 
+                repaint(visRect.x,     visRect.y,
                         visRect.width, visRect.height);
             else
-                paintImmediately(visRect.x,     visRect.y, 
+                paintImmediately(visRect.x,     visRect.y,
                                  visRect.width, visRect.height);
         } else {
             try {
@@ -525,10 +525,10 @@
                         public void run() {
                             Rectangle visRect = getRenderRect();
                             if (doubleBufferedRendering)
-                                repaint(visRect.x,     visRect.y, 
+                                repaint(visRect.x,     visRect.y,
                                         visRect.width, visRect.height);
                             else
-                                paintImmediately(visRect.x,    visRect.y, 
+                                paintImmediately(visRect.x,    visRect.y,
                                                  visRect.width,visRect.height);
                         }
                     });
@@ -548,7 +548,7 @@
         Rectangle visRect = getRenderRect();
         g2d.setComposite(AlphaComposite.SrcOver);
         g2d.setPaint(getBackground());
-        g2d.fillRect(visRect.x,     visRect.y, 
+        g2d.fillRect(visRect.x,     visRect.y,
                      visRect.width, visRect.height);
 
         if (image != null) {
@@ -590,7 +590,7 @@
         setRenderingTransform(at, true);
     }
 
-    public void setRenderingTransform(AffineTransform at, 
+    public void setRenderingTransform(AffineTransform at,
                                       boolean performRedraw) {
         renderingTransform = new AffineTransform(at);
         suspendInteractions = true;
@@ -704,7 +704,7 @@
         try {
             inv = renderingTransform.createInverse();
         } catch (NoninvertibleTransformException e) {
-            throw new InternalError(e.getMessage());
+            throw new IllegalStateException( "NoninvertibleTransformEx:" + e.getMessage() );
         }
         Shape s = inv.createTransformedShape(visRect);
 
@@ -847,7 +847,7 @@
                                         if (progressivePaintThread ==
                                             thisThread) {
                                             Rectangle vRect = getRenderRect();
-                                            repaint(vRect.x,     vRect.y, 
+                                            repaint(vRect.x,     vRect.y,
                                                     vRect.width, vRect.height);
                                         }
                                     }
@@ -1064,7 +1064,7 @@
                          e.getY(),
                          e.getClickCount(),
                          e.isPopupTrigger());
-							
+
                     mouseClicked(click);
                 }
             }
@@ -1210,9 +1210,9 @@
         }
     }
 
-    protected class UnixTextSelectionListener 
+    protected class UnixTextSelectionListener
         extends SelectionAdapter {
-        
+
         public void selectionDone(SelectionEvent evt) {
             if (!useUnixTextSelection) return;
 

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/TextSelectionManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/TextSelectionManager.java?rev=396138&r1=396137&r2=396138&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/TextSelectionManager.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/TextSelectionManager.java Sat Apr 22 09:05:15 2006
@@ -1,18 +1,18 @@
 /*
 
-   Copyright 1999-2003  The Apache Software Foundation 
+Copyright 1999-2003  The Apache Software Foundation 
 
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 
 */
 
@@ -142,14 +142,14 @@
      * @param color the new color of the selection overlay
      */
     public void setSelectionOverlayColor(Color color) {
-	this.selectionOverlayColor = color;
+        this.selectionOverlayColor = color;
     }
 
     /**
      * Returns the color of the selection overlay.
      */
     public Color getSelectionOverlayColor() {
-	return selectionOverlayColor;
+        return selectionOverlayColor;
     }
 
     /**
@@ -159,14 +159,14 @@
      * @param color the new color of the outline of the selection overlay 
      */
     public void setSelectionOverlayStrokeColor(Color color) {
-	this.selectionOverlayStrokeColor = color;
+        this.selectionOverlayStrokeColor = color;
     }
 
     /**
      * Returns the color of the outline of the selection overlay.
      */
     public Color getSelectionOverlayStrokeColor() {
-	return selectionOverlayStrokeColor;
+        return selectionOverlayStrokeColor;
     }
 
     /**
@@ -176,7 +176,7 @@
      * @param state true implies the selection overlay will be in XOR mode 
      */
     public void setSelectionOverlayXORMode(boolean state) {
-	this.xorMode = state;
+        this.xorMode = state;
     }
 
     /**
@@ -184,7 +184,7 @@
      * otherwise.
      */
     public boolean isSelectionOverlayXORMode() {
-	return xorMode;
+        return xorMode;
     }
 
     /**
@@ -212,7 +212,7 @@
      * Clears the selection.
      */
     public void clearSelection() {
-	textSelector.clearSelection();
+        textSelector.clearSelection();
     }
 
     /**
@@ -338,19 +338,19 @@
                 Shape s = at.createTransformedShape(selectionHighlight);
 
                 Graphics2D g2d = (Graphics2D)g;
-		if (xorMode) {
-		    g2d.setColor(Color.black);
-		    g2d.setXORMode(Color.white);
-		    g2d.fill(s);
-		} else {
-		    g2d.setColor(selectionOverlayColor);
-		    g2d.fill(s);
-		    if (selectionOverlayStrokeColor != null) {
-			g2d.setStroke(new java.awt.BasicStroke(1.0f));
-			g2d.setColor(selectionOverlayStrokeColor);
-			g2d.draw(s);
-		    }
-		}
+                if (xorMode) {
+                    g2d.setColor(Color.black);
+                    g2d.setXORMode(Color.white);
+                    g2d.fill(s);
+                } else {
+                    g2d.setColor(selectionOverlayColor);
+                    g2d.fill(s);
+                    if (selectionOverlayStrokeColor != null) {
+                        g2d.setStroke(new java.awt.BasicStroke(1.0f));
+                        g2d.setColor(selectionOverlayStrokeColor);
+                        g2d.draw(s);
+                    }
+                }
             }
         }
     }

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java?rev=396138&r1=396137&r2=396138&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java Sat Apr 22 09:05:15 2006
@@ -359,6 +359,17 @@
     protected boolean isInteractiveDocument;
 
     /**
+     * Set to true before component calls setDisableInteractors
+     * so it knows that the users isn't the one calling it.
+     */
+    protected boolean selfCallingDisableInteractions = false;
+
+    /**
+     * Set to true if the user ever calls setDisableInteractions
+     */
+    protected boolean userSetDisableInteractions = false;
+
+    /**
      * The document state.
      */
     protected int documentState;
@@ -406,6 +417,42 @@
         setSVGDocument(null);
     }
 
+    public void setDisableInteractions(boolean b) {
+        super.setDisableInteractions(b);
+        if (!selfCallingDisableInteractions)
+            userSetDisableInteractions = true;
+    }
+
+    /**
+     * Clears the boolean that indicates the 'user'
+     * has set disable interactions so that the canvas
+     * uses the value from documents.
+     */
+    public void clearUserSetDisableInteractions() {
+        userSetDisableInteractions = false;
+        updateZoomAndPanEnable(svgDocument);
+    }
+
+    /**
+     * Enables/Disables Zoom And Pan based on the zoom and
+     * pan attribute of the currently installed document,
+     * Unless the user has set the Interactions State.
+     */
+    public void updateZoomAndPanEnable(Document doc) {
+        if (userSetDisableInteractions) return;
+        if (doc == null) return;
+        try {
+            Element root = doc.getDocumentElement();
+            String znp = root.getAttributeNS
+                (null, SVGConstants.SVG_ZOOM_AND_PAN_ATTRIBUTE);
+            boolean enable = SVGConstants.SVG_MAGNIFY_VALUE.equals(znp);
+            selfCallingDisableInteractions = true;
+            setDisableInteractions(!enable);
+        } finally {
+            selfCallingDisableInteractions = false;
+        }
+    }
+
     /**
      * Indicates if the canvas should recenter the content after
      * the canvas is resized.  If true it will try and keep the
@@ -704,11 +751,7 @@
                 bridgeContext.setDynamicState(BridgeContext.INTERACTIVE);
         }
 
-        Element root = doc.getDocumentElement();
-        String znp = root.getAttributeNS
-            (null, SVGConstants.SVG_ZOOM_AND_PAN_ATTRIBUTE);
-
-        setDisableInteractions(!znp.equals(SVGConstants.SVG_MAGNIFY_VALUE));
+        updateZoomAndPanEnable(doc);
 
         nextGVTTreeBuilder = new GVTTreeBuilder(doc, bridgeContext);
         nextGVTTreeBuilder.setPriority(Thread.MIN_PRIORITY);

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/print/PrintTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/print/PrintTranscoder.java?rev=396138&r1=396137&r2=396138&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/print/PrintTranscoder.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/print/PrintTranscoder.java Sat Apr 22 09:05:15 2006
@@ -243,6 +243,10 @@
             pageFormat = tmpPageFormat;
         }
 
+        // Set printable before showing printer dialog so
+        // it can update the pageFormat if it wishes...
+        printerJob.setPrintable(this, pageFormat);
+
         //
         // If required, pop up a dialog to select the printer
         //
@@ -257,7 +261,6 @@
         }
 
         // Print now
-        printerJob.setPrintable(this, pageFormat);
         printerJob.print();
 
     }

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/xml/XMLScanner.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/xml/XMLScanner.java?rev=396138&r1=396137&r2=396138&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/xml/XMLScanner.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/xml/XMLScanner.java Sat Apr 22 09:05:15 2006
@@ -1,6 +1,6 @@
 /*
 
-   Copyright 2002-2003  The Apache Software Foundation 
+   Copyright 2002-2003  The Apache Software Foundation
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -137,7 +137,7 @@
      * The localizable support.
      */
     protected LocalizableSupport localizableSupport =
-        new LocalizableSupport(BUNDLE_CLASSNAME, 
+        new LocalizableSupport(BUNDLE_CLASSNAME,
                                XMLScanner.class.getClassLoader());
 
     /**
@@ -507,7 +507,7 @@
                 return nextInEnumeration();
 
             default:
-                throw new InternalError();
+                throw new IllegalArgumentException("unexpected ctx:" + ctx );
             }
         } catch (IOException e) {
             throw new XMLException(e);
@@ -566,7 +566,7 @@
 		    throw createXMLException("xml.reserved");
 		}
 		return LexicalUnits.PI_START;
-                
+
             case '!':
                 switch (nextChar()) {
                 case '-':
@@ -590,7 +590,7 @@
 
         case -1:
             return LexicalUnits.EOF;
-            
+
         default:
             if (depth == 0) {
                 throw createXMLException("invalid.character");
@@ -742,7 +742,7 @@
 		case '&':
                     context = ATTRIBUTE_VALUE_CONTEXT;
                     return LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT;
-                    
+
 		case '<':
                     throw createXMLException("invalid.character");
 
@@ -765,7 +765,7 @@
 		case '&':
                     context = ATTRIBUTE_VALUE_CONTEXT;
                     return LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT;
-                    
+
 		case '<':
                     throw createXMLException("invalid.character");
 
@@ -929,7 +929,7 @@
 	    context = CONTENT_CONTEXT;
 	    return LexicalUnits.SECTION_END;
 	}
-	
+
 	while (current != -1) {
 	    while (current != ']' && current != -1) {
 		nextChar();
@@ -1349,7 +1349,7 @@
 	    nextChar();
 	    context = DTD_DECLARATIONS_CONTEXT;
 	    return type = LexicalUnits.END_CHAR;
-	    
+
 	case '%':
 	    int t = readName(LexicalUnits.PARAMETER_ENTITY_REFERENCE);
 	    if (current != ';') {
@@ -1382,7 +1382,7 @@
 		    nextChar();
 		} while (current != -1 &&
                          XMLUtilities.isXMLNameCharacter((char)current));
-		return LexicalUnits.NAME; 
+		return LexicalUnits.NAME;
 	    }
 	    nextChar();
 	    if (current == -1 ||
@@ -1517,7 +1517,7 @@
                         nextChar();
                     } while (current != -1 &&
                              XMLUtilities.isXMLNameCharacter((char)current));
-                    return LexicalUnits.NAME; 
+                    return LexicalUnits.NAME;
                 }
                 nextChar();
                 if (current == -1 ||
@@ -1550,7 +1550,7 @@
 		    nextChar();
 		} while (current != -1 &&
                          XMLUtilities.isXMLNameCharacter((char)current));
-		return LexicalUnits.NAME; 
+		return LexicalUnits.NAME;
 	    }
 	    nextChar();
 	    if (current == -1 ||
@@ -1574,7 +1574,7 @@
 		    nextChar();
 		} while (current != -1 &&
                          XMLUtilities.isXMLNameCharacter((char)current));
-		return type = LexicalUnits.NAME; 
+		return type = LexicalUnits.NAME;
 	    }
 	    nextChar();
 	    if (current == -1 ||
@@ -1604,7 +1604,7 @@
 			nextChar();
 		    } while (current != -1 &&
                              XMLUtilities.isXMLNameCharacter((char)current));
-		    return LexicalUnits.NAME; 
+		    return LexicalUnits.NAME;
 		}
 		nextChar();
 		if (current == -1 ||
@@ -1629,7 +1629,7 @@
 		    nextChar();
 		} while (current != -1 &&
                          XMLUtilities.isXMLNameCharacter((char)current));
-		return LexicalUnits.NAME; 
+		return LexicalUnits.NAME;
 	    }
 
 	case '"':
@@ -1804,7 +1804,7 @@
 	    if (current == -1) {
 		throw createXMLException("unexpected.eof");
 	    }
-            
+
 	    if (current != '"' && current != '&' && current != '%') {
 		do {
 		    nextChar();
@@ -1834,7 +1834,7 @@
 	    if (current == -1) {
 		throw createXMLException("unexpected.eof");
 	    }
-            
+
 	    if (current != '\'' && current != '&' && current != '%') {
 		do {
 		    nextChar();
@@ -1900,7 +1900,7 @@
 	    return LexicalUnits.FIRST_ATTRIBUTE_FRAGMENT;
 	}
     }
-    
+
     /**
      * Returns the next lexical unit in the context of a notation type.
      */