hillion     01/09/28 08:40:08

  Modified:    resources/org/apache/batik/apps/svgbrowser/resources
                        GUI.properties
               sources/org/apache/batik/apps/svgbrowser
                        JSVGViewerFrame.java
               sources/org/apache/batik/css AbstractViewCSS.java
               sources/org/apache/batik/dom AbstractAttr.java
               sources/org/apache/batik/dom/svg SVGDOMImplementation.java
                        SVGExternalResourcesRequiredSupport.java
                        SVGOMDocument.java
                        SVGOMFEConvolveMatrixElement.java
               sources/org/apache/batik/util SVGConstants.java
  Added:       sources/org/apache/batik/dom/svg SVGOMAnimatedBoolean.java
  Log:
  - Applied the bug # 3389 patch (UI for aternate style-sheets).
  - Preliminary tests with live attribute values in SVG DOM.
  
  Revision  Changes    Path
  1.31      +12 -4     
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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- GUI.properties    2001/07/18 22:04:53     1.30
  +++ GUI.properties    2001/09/28 15:40:08     1.31
  @@ -9,7 +9,7 @@
   # The viewer's GUI resources.
   #
   # Author: [EMAIL PROTECTED]
  -# $Id: GUI.properties,v 1.30 2001/07/18 22:04:53 deweese Exp $
  +# $Id: GUI.properties,v 1.31 2001/09/28 15:40:08 hillion Exp $
   #
   
   ViewSource.width = 750
  @@ -159,10 +159,8 @@
   
   
   # View menu ################
  -View = ResetTransform ZoomIn ZoomOut - PreviousTransform NextTransform SetTransform 
- ThumbnailDialog ViewSource
  +View = ResetTransform ZoomIn ZoomOut - UseStylesheet - PreviousTransform 
NextTransform SetTransform - ThumbnailDialog ViewSource
   
  -#View = ResetTransform ZoomIn ZoomOut - PreviousTransform NextTransform 
SetTransform - ViewSource
  -
   View.type = MENU
   View.text = View
   View.mnemonic = V
  @@ -194,6 +192,16 @@
   ZoomOut.mnemonic    = O
   ZoomOut.action      = ZoomOutAction
   ZoomOut.accelerator = Ctrl+O
  +
  +UseStylesheet        = DefaultStylesheet
  +UseStylesheet.type   = MENU
  +UseStylesheet.text   = Use Stylesheet
  +UseStylesheet.icon   = resources/blank.gif
  +UseStylesheet.action = UseStylesheetAction
  +
  +DefaultStylesheet.type     = RADIO
  +DefaultStylesheet.text     = Default
  +DefaultStylesheet.selected = true
   
   PreviousTransform.type        = ITEM
   PreviousTransform.text        = Previous Transform
  
  
  
  1.52      +110 -1    
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.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- JSVGViewerFrame.java      2001/09/19 11:16:37     1.51
  +++ JSVGViewerFrame.java      2001/09/28 15:40:08     1.52
  @@ -61,6 +61,7 @@
   import javax.swing.AbstractAction;
   import javax.swing.Action;
   import javax.swing.BorderFactory;
  +import javax.swing.ButtonGroup;
   import javax.swing.JCheckBoxMenuItem;
   import javax.swing.JComponent;
   import javax.swing.JDialog;
  @@ -69,6 +70,7 @@
   import javax.swing.JMenuBar;
   import javax.swing.JOptionPane;
   import javax.swing.JPanel;
  +import javax.swing.JRadioButtonMenuItem;
   import javax.swing.JScrollPane;
   import javax.swing.JTextArea;
   import javax.swing.JToolBar;
  @@ -78,8 +80,13 @@
   import javax.swing.text.Document;
   import javax.swing.text.PlainDocument;
   
  +import org.apache.batik.dom.StyleSheetProcessingInstruction;
  +
   import org.apache.batik.dom.svg.SVGOMDocument;
   
  +import org.apache.batik.dom.util.HashTable;
  +import org.apache.batik.dom.util.DOMUtilities;
  +
   import org.apache.batik.swing.gvt.AbstractImageZoomInteractor;
   import org.apache.batik.swing.gvt.AbstractPanInteractor;
   import org.apache.batik.swing.gvt.AbstractRotateInteractor;
  @@ -129,7 +136,15 @@
   import org.apache.batik.xml.XMLUtilities;
   
   import org.w3c.dom.Element;
  +import org.w3c.dom.Node;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.ProcessingInstruction;
   
  +import org.w3c.dom.stylesheets.DocumentStyle;
  +import org.w3c.dom.stylesheets.StyleSheetList;
  + 
  +import org.w3c.dom.css.CSSStyleSheet;
  +
   import org.w3c.dom.css.ViewCSS;
   
   import org.w3c.dom.svg.SVGDocument;
  @@ -138,7 +153,7 @@
    * This class represents a SVG viewer swing frame.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: JSVGViewerFrame.java,v 1.51 2001/09/19 11:16:37 vhardy Exp $
  + * @version $Id: JSVGViewerFrame.java,v 1.52 2001/09/28 15:40:08 hillion Exp $
    */
   public class JSVGViewerFrame
       extends    JFrame
  @@ -175,6 +190,7 @@
       public final static String ZOOM_OUT_ACTION = "ZoomOutAction";
       public final static String PREVIOUS_TRANSFORM_ACTION = 
"PreviousTransformAction";
       public final static String NEXT_TRANSFORM_ACTION = "NextTransformAction";
  +    public final static String USE_STYLESHEET_ACTION = "UseStylesheetAction";
       public final static String STOP_ACTION = "StopAction";
       public final static String MONITOR_ACTION = "MonitorAction";
       public final static String DOM_VIEWER_ACTION = "DOMViewerAction";
  @@ -262,6 +278,12 @@
           new NextTransformAction();
   
       /**
  +     * The use (author) stylesheet action
  +     */
  +    protected UseStylesheetAction useStylesheetAction =
  +        new UseStylesheetAction();
  +
  +    /**
        * The debug flag.
        */
       protected boolean debug;
  @@ -372,6 +394,7 @@
    
           listeners.put(PREVIOUS_TRANSFORM_ACTION, previousTransformAction);
           listeners.put(NEXT_TRANSFORM_ACTION, nextTransformAction);
  +        listeners.put(USE_STYLESHEET_ACTION, useStylesheetAction);
           listeners.put(STOP_ACTION, stopAction);
           listeners.put(MONITOR_ACTION, new MonitorAction());
           listeners.put(DOM_VIEWER_ACTION, new DOMViewerAction());
  @@ -1142,6 +1165,90 @@
       }
   
       /**
  +     * To apply the selected author stylesheet
  +     */
  +    public class UseStylesheetAction extends    AbstractAction
  +                                     implements JComponentModifier {
  +
  +        List components = new LinkedList();
  +
  +        public UseStylesheetAction() {}
  +
  +        public void actionPerformed(ActionEvent e) {
  +        }
  +
  +        public void addJComponent(JComponent c) {
  +            components.add(c);
  +            c.setEnabled(false);
  +        }
  +
  +        protected void update() {
  +            Iterator it = components.iterator();
  +            if (it.hasNext()) {
  +
  +                JComponent stylesheetMenu = (JComponent)it.next();
  +                stylesheetMenu.removeAll();
  +                stylesheetMenu.setEnabled(false);
  +
  +                SVGDocument doc = svgCanvas.getSVGDocument();
  +                NodeList children = doc.getChildNodes();
  +                ButtonGroup buttonGroup = new ButtonGroup();
  +                HashTable stylesheetTitles = new HashTable();
  +
  +                // !!! The traversal should be recursive
  +                for (int ix=0; ix < children.getLength(); ix++) {
  +                    Node n = children.item(ix);
  +                    if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE &&
  +                        n instanceof StyleSheetProcessingInstruction) {
  +
  +                        String data = ((ProcessingInstruction)n).getData();
  +
  +                        HashTable attrs = new HashTable();
  +                        attrs.put("alternate", "no");
  +
  +                        DOMUtilities.parseStyleSheetPIData(data, attrs);
  +                        final String title = (String)attrs.get("title");
  +
  +                        // If no title is specified, then the stylesheet should
  +                        // always be applied
  +                        
  +                        // If the title has already been found, then it is part
  +                        // of a group, and no new menu option is needed
  +                        if (title != null && stylesheetTitles.get(title) == null)  {
  +                            stylesheetTitles.put(title, title);
  +
  +                            JRadioButtonMenuItem button;
  +                            button = new JRadioButtonMenuItem(title);
  +                            if (((String)attrs.get("alternate")).equals("no")) {
  +                                button.setSelected(true);
  +                            }
  +                            button.addActionListener
  +                                (new java.awt.event.ActionListener() {
  +                                    public void actionPerformed (ActionEvent e) {
  +                                        SVGDocument doc = 
svgCanvas.getSVGDocument();
  +                                        StyleSheetList l;
  +                                        l = ((DocumentStyle)doc).getStyleSheets();
  +                                        for (int i = 0; i < l.getLength(); i++) {
  +                                            CSSStyleSheet ss;
  +                                            ss = (CSSStyleSheet)l.item(i);
  +                                            
ss.setDisabled(!title.equals(ss.getTitle()));
  +                                        }
  +                                        ((SVGOMDocument)doc).clearViewCSS();
  +                                        svgCanvas.setSVGDocument(doc);
  +                                    }
  +                                });
  +  
  +                            buttonGroup.add(button);
  +                            stylesheetMenu.add(button);
  +                            stylesheetMenu.setEnabled(true);
  +                        }
  +                    }
  +                }
  +            }
  +        }
  +    }
  +
  +    /**
        * To stop the current processing.
        */
       public class StopAction extends    AbstractAction
  @@ -1363,6 +1470,8 @@
           transformHistory = new TransformHistory();
           previousTransformAction.update();
           nextTransformAction.update();
  +
  +        useStylesheetAction.update();
       }
   
       /**
  
  
  
  1.16      +8 -5      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AbstractViewCSS.java      2001/06/19 14:27:18     1.15
  +++ AbstractViewCSS.java      2001/09/28 15:40:08     1.16
  @@ -44,7 +44,7 @@
    * {@link org.w3c.dom.css.ViewCSS} interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: AbstractViewCSS.java,v 1.15 2001/06/19 14:27:18 hillion Exp $
  + * @version $Id: AbstractViewCSS.java,v 1.16 2001/09/28 15:40:08 hillion Exp $
    */
   public abstract class AbstractViewCSS implements ViewCSS {
   
  @@ -362,10 +362,13 @@
               CSSOMRuleList authorRules = new CSSOMRuleList();
               StyleSheetList l = ((DocumentStyle)document).getStyleSheets();
               for (int i = 0; i < l.getLength(); i++) {
  -                addMatchingRules(((CSSStyleSheet)l.item(i)).getCssRules(),
  -                                 e,
  -                                 pe,
  -                                 authorRules);
  +                CSSStyleSheet ss = (CSSStyleSheet)l.item(i);
  +                if (!ss.getDisabled()) {
  +                    addMatchingRules(((CSSStyleSheet)l.item(i)).getCssRules(),
  +                                     e,
  +                                     pe,
  +                                     authorRules);
  +                }
               }
               authorRules = sortRules(authorRules, e, pe);
               for (int i = 0; i < authorRules.getLength(); i++) {
  
  
  
  1.5       +5 -5      xml-batik/sources/org/apache/batik/dom/AbstractAttr.java
  
  Index: AbstractAttr.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractAttr.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractAttr.java 2001/09/27 09:57:13     1.4
  +++ AbstractAttr.java 2001/09/28 15:40:08     1.5
  @@ -20,7 +20,7 @@
    * This class implements the {@link org.w3c.dom.Attr} interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: AbstractAttr.java,v 1.4 2001/09/27 09:57:13 hillion Exp $
  + * @version $Id: AbstractAttr.java,v 1.5 2001/09/28 15:40:08 hillion Exp $
    */
   public abstract class AbstractAttr extends AbstractParentNode implements Attr {
       /**
  @@ -124,17 +124,17 @@
            removeChild(n);
        }
   
  +        String val = (nodeValue == null) ? "" : nodeValue;
  +
        // Create and append a new child.
  -     n = getOwnerDocument().createTextNode((nodeValue == null)
  -                                              ? ""
  -                                              : nodeValue);
  +     n = getOwnerDocument().createTextNode(val);
        appendChild(n);
   
           if (ownerElement != null) {
               ownerElement.fireDOMAttrModifiedEvent(nodeName,
                                                     this,
                                                     s,
  -                                                  nodeValue,
  +                                                  val,
                                                     MutationEvent.MODIFICATION);
           }
       }
  
  
  
  1.15      +7 -1      
xml-batik/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java
  
  Index: SVGDOMImplementation.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SVGDOMImplementation.java 2001/09/12 16:57:07     1.14
  +++ SVGDOMImplementation.java 2001/09/28 15:40:08     1.15
  @@ -54,7 +54,7 @@
    * It provides support the SVG 1.0 documents.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: SVGDOMImplementation.java,v 1.14 2001/09/12 16:57:07 hillion Exp $
  + * @version $Id: SVGDOMImplementation.java,v 1.15 2001/09/28 15:40:08 hillion Exp $
    */
   public class SVGDOMImplementation
       extends    AbstractDOMImplementation
  @@ -216,6 +216,7 @@
                   String title = (String)attrs.get("title");
                   String media = (String)attrs.get("media");
                   String href  = (String)attrs.get("href");
  +                String alternate = (String)attrs.get("alternate");
   
                   SVGOMDocument doc = (SVGOMDocument)n.getOwnerDocument();
                   URL url = new URL(doc.getURLObject(), href);
  @@ -231,6 +232,11 @@
                        CSSDocumentHandler.createParser());
   
                   CSSDocumentHandler.parseStyleSheet(ss, url.toString());
  +                if (title == null || alternate.equals("no")) {
  +                   ss.setDisabled (false);
  +                } else {
  +                   ss.setDisabled (true);
  +                }
                   return ss;
               } catch (Exception e) {
               }
  
  
  
  1.3       +17 -7     
xml-batik/sources/org/apache/batik/dom/svg/SVGExternalResourcesRequiredSupport.java
  
  Index: SVGExternalResourcesRequiredSupport.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGExternalResourcesRequiredSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SVGExternalResourcesRequiredSupport.java  2001/09/10 12:26:07     1.2
  +++ SVGExternalResourcesRequiredSupport.java  2001/09/28 15:40:08     1.3
  @@ -8,23 +8,33 @@
   
   package org.apache.batik.dom.svg;
   
  -import org.w3c.dom.Element;
  +import org.apache.batik.util.SVGConstants;
  +
   import org.w3c.dom.svg.SVGAnimatedBoolean;
  -import org.w3c.dom.svg.SVGExternalResourcesRequired;
   
   /**
    * Provides support for the SVGExternalResourcesRequired interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: SVGExternalResourcesRequiredSupport.java,v 1.2 2001/09/10 12:26:07 
hillion Exp $
  + * @version $Id: SVGExternalResourcesRequiredSupport.java,v 1.3 2001/09/28 15:40:08 
hillion Exp $
    */
  -public class SVGExternalResourcesRequiredSupport {
  +public class SVGExternalResourcesRequiredSupport implements SVGConstants {
  +
  +    private final static String ATTR_NAME = 
SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE;
   
       /**
        * To implement {@link
  -     * SVGExternalResourcesRequired#getExternalResourcesRequired()}.
  +     * org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
        */
  -    public static SVGAnimatedBoolean getExternalResourcesRequired(Element elt) {
  -        throw new RuntimeException("!!! TODO getExternalResourcesRequired()");
  +    public static SVGAnimatedBoolean getExternalResourcesRequired(AbstractElement 
elt) {
  +        LiveAttributeValue lav;
  +        lav = elt.getLiveAttributeValue(null, ATTR_NAME);
  +        if (lav == null) {
  +            lav = new SVGOMAnimatedBoolean(elt, null, ATTR_NAME,
  +                                           elt.getAttributeNodeNS(null, ATTR_NAME),
  +                                           "false");
  +            elt.putLiveAttributeValue(null, ATTR_NAME, lav);
  +        }
  +        return (SVGAnimatedBoolean)lav;
       }
   }
  
  
  
  1.39      +8 -1      xml-batik/sources/org/apache/batik/dom/svg/SVGOMDocument.java
  
  Index: SVGOMDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGOMDocument.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- SVGOMDocument.java        2001/09/12 16:57:07     1.38
  +++ SVGOMDocument.java        2001/09/28 15:40:08     1.39
  @@ -69,7 +69,7 @@
    * This class implements {@link SVGDocument}.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: SVGOMDocument.java,v 1.38 2001/09/12 16:57:07 hillion Exp $
  + * @version $Id: SVGOMDocument.java,v 1.39 2001/09/28 15:40:08 hillion Exp $
    */
   public class SVGOMDocument
       extends    AbstractDocument
  @@ -439,6 +439,13 @@
                   (impl.getUserAgentStyleSheet());
           }
           return defaultView;
  +    }
  +
  +    /**
  +     * Clears the view CSS.
  +     */
  +    public void clearViewCSS() {
  +        defaultView = null;
       }
   
       // DocumentCSS ////////////////////////////////////////////////////////////
  
  
  
  1.9       +11 -2     
xml-batik/sources/org/apache/batik/dom/svg/SVGOMFEConvolveMatrixElement.java
  
  Index: SVGOMFEConvolveMatrixElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGOMFEConvolveMatrixElement.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SVGOMFEConvolveMatrixElement.java 2001/09/10 12:26:08     1.8
  +++ SVGOMFEConvolveMatrixElement.java 2001/09/28 15:40:08     1.9
  @@ -25,7 +25,7 @@
    * This class implements {@link SVGFEConvolveMatrixElement}.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: SVGOMFEConvolveMatrixElement.java,v 1.8 2001/09/10 12:26:08 
hillion Exp $
  + * @version $Id: SVGOMFEConvolveMatrixElement.java,v 1.9 2001/09/28 15:40:08 
hillion Exp $
    */
   public class SVGOMFEConvolveMatrixElement
       extends    SVGOMFilterPrimitiveStandardAttributes
  @@ -150,7 +150,16 @@
        * org.w3c.dom.svg.SVGFEConvolveMatrixElement#getPreserveAlpha()}.
        */
       public SVGAnimatedBoolean getPreserveAlpha() {
  -        throw new RuntimeException("!!! TODO: getPreserveAlpha()");
  +        LiveAttributeValue lav;
  +        lav = getLiveAttributeValue(null, SVG_PRESERVE_ALPHA_ATTRIBUTE);
  +        if (lav == null) {
  +            lav = new SVGOMAnimatedBoolean
  +                (this, null, SVG_PRESERVE_ALPHA_ATTRIBUTE,
  +                 getAttributeNodeNS(null, SVG_PRESERVE_ALPHA_ATTRIBUTE),
  +                 "false");
  +            putLiveAttributeValue(null, SVG_PRESERVE_ALPHA_ATTRIBUTE, lav);
  +        }
  +        return (SVGAnimatedBoolean)lav;
       }
   
       /**
  
  
  
  1.3       +85 -28    
xml-batik/sources/org/apache/batik/dom/svg/SVGOMAnimatedBoolean.java
  
  
  
  
  1.59      +2 -1      xml-batik/sources/org/apache/batik/util/SVGConstants.java
  
  Index: SVGConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/SVGConstants.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- SVGConstants.java 2001/09/10 13:17:20     1.58
  +++ SVGConstants.java 2001/09/28 15:40:08     1.59
  @@ -14,7 +14,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
    * @author <a href="[EMAIL PROTECTED]">Vincent Hardy</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: SVGConstants.java,v 1.58 2001/09/10 13:17:20 hillion Exp $
  + * @version $Id: SVGConstants.java,v 1.59 2001/09/28 15:40:08 hillion Exp $
    */
   public interface SVGConstants extends CSSConstants {
   
  @@ -163,6 +163,7 @@
       String SVG_ELEVATION_ATTRIBUTE = "elevation";
       String SVG_ENABLE_BACKGROUND_ATTRIBUTE = CSS_ENABLE_BACKGROUND_PROPERTY;
       String SVG_EXPONENT_ATTRIBUTE = "exponent";
  +    String SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE = "externalResourcesRequired";
       String SVG_FILL_ATTRIBUTE = CSS_FILL_PROPERTY;
       String SVG_FILL_OPACITY_ATTRIBUTE = CSS_FILL_OPACITY_PROPERTY;
       String SVG_FILL_RULE_ATTRIBUTE = CSS_FILL_RULE_PROPERTY;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to