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/07 19:34:40 UTC

cvs commit: xml-batik/sources/org/apache/batik/transcoder/svg2svg OutputManager.java

hillion     01/05/07 10:34:38

  Modified:    sources/org/apache/batik/apps/svgbrowser
                        JSVGViewerFrame.java
               sources/org/apache/batik/swing/svg
                        GVTTreeBuilderListener.java JSVGComponent.java
               sources/org/apache/batik/transcoder/svg2svg
                        OutputManager.java
  Log:
  local links are now added to the document's history.
  
  Revision  Changes    Path
  1.33      +24 -2     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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- JSVGViewerFrame.java	2001/05/04 17:04:18	1.32
  +++ JSVGViewerFrame.java	2001/05/07 17:34:13	1.33
  @@ -89,6 +89,8 @@
   
   import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
   import org.apache.batik.swing.svg.GVTTreeBuilderListener;
  +import org.apache.batik.swing.svg.LinkActivationEvent;
  +import org.apache.batik.swing.svg.LinkActivationListener;
   import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
   import org.apache.batik.swing.svg.SVGDocumentLoaderListener;
   import org.apache.batik.swing.svg.SVGFileFilter;
  @@ -131,14 +133,15 @@
    * This class represents a SVG viewer swing frame.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: JSVGViewerFrame.java,v 1.32 2001/05/04 17:04:18 tkormann Exp $
  + * @version $Id: JSVGViewerFrame.java,v 1.33 2001/05/07 17:34:13 hillion Exp $
    */
   public class JSVGViewerFrame
       extends    JFrame
       implements ActionMap,
                  SVGDocumentLoaderListener,
                  GVTTreeBuilderListener,
  -               GVTTreeRendererListener {
  +               GVTTreeRendererListener,
  +               LinkActivationListener {
   
       /**
        * The gui resources file name
  @@ -430,6 +433,7 @@
           svgCanvas.addSVGDocumentLoaderListener(this);
           svgCanvas.addGVTTreeBuilderListener(this);
           svgCanvas.addGVTTreeRendererListener(this);
  +        svgCanvas.addLinkActivationListener(this);
   
           svgCanvas.addMouseMotionListener(new MouseMotionAdapter() {
                   public void mouseMoved(MouseEvent e) {
  @@ -1591,6 +1595,24 @@
           statusBar.setMainMessage("");
           stopAction.update(false);
           svgCanvas.setCursor(DEFAULT_CURSOR);
  +    }
  +
  +    // LinkActivationListener /////////////////////////////////////////
  +
  +    /**
  +     * Called when a link was activated.
  +     */
  +    public void linkActivated(LinkActivationEvent e) {
  +        String s = e.getReferencedURI();
  +        if (s.indexOf("#") != -1) {
  +            localHistory.update(e.getReferencedURI());
  +            backAction.update();
  +            forwardAction.update();
  +
  +            transformHistory = new TransformHistory();
  +            previousTransformAction.update();
  +            nextTransformAction.update();
  +        }
       }
   
       /**
  
  
  
  1.2       +1 -2      xml-batik/sources/org/apache/batik/swing/svg/GVTTreeBuilderListener.java
  
  Index: GVTTreeBuilderListener.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/GVTTreeBuilderListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GVTTreeBuilderListener.java	2001/03/08 01:21:09	1.1
  +++ GVTTreeBuilderListener.java	2001/05/07 17:34:24	1.2
  @@ -12,13 +12,12 @@
    * This interface represents a listener to the GVTTreeBuilderEvent events.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: GVTTreeBuilderListener.java,v 1.1 2001/03/08 01:21:09 hillion Exp $
  + * @version $Id: GVTTreeBuilderListener.java,v 1.2 2001/05/07 17:34:24 hillion Exp $
    */
   public interface GVTTreeBuilderListener {
   
       /**
        * Called when a build started.
  -     * The data of the event is initialized to the old document.
        */
       void gvtBuildStarted(GVTTreeBuilderEvent e);
   
  
  
  
  1.17      +40 -1     xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java
  
  Index: JSVGComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JSVGComponent.java	2001/04/23 12:19:38	1.16
  +++ JSVGComponent.java	2001/05/07 17:34:26	1.17
  @@ -62,7 +62,7 @@
    * This class represents a Swing component which can display SVG.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: JSVGComponent.java,v 1.16 2001/04/23 12:19:38 tkormann Exp $
  + * @version $Id: JSVGComponent.java,v 1.17 2001/05/07 17:34:26 hillion Exp $
    */
   public class JSVGComponent extends JGVTComponent {
   
  @@ -107,6 +107,11 @@
       protected List gvtTreeBuilderListeners = new LinkedList();
   
       /**
  +     * The link activation listeners.
  +     */
  +    protected List linkActivationListeners = new LinkedList();
  +
  +    /**
        * The user agent.
        */
       protected UserAgent userAgent;
  @@ -365,6 +370,20 @@
       }
   
       /**
  +     * Adds a LinkActivationListener to this component.
  +     */
  +    public void addLinkActivationListener(LinkActivationListener l) {
  +        linkActivationListeners.add(l);
  +    }
  +
  +    /**
  +     * Removes a LinkActivationListener from this component.
  +     */
  +    public void removeLinkActivationListener(LinkActivationListener l) {
  +        linkActivationListeners.remove(l);
  +    }
  +
  +    /**
        * Creates an instance of Listener.
        */
       protected Listener createListener() {
  @@ -725,6 +744,7 @@
                       href = newURI.toString();
   
                       svgUserAgent.openLink(href);
  +                    fireLinkActivatedEvent(elt, href);
                       return;
                   }
               }
  @@ -747,10 +767,29 @@
                           fragmentIdentifier = s;
                           computeRenderingTransform();
                       }
  +                    fireLinkActivatedEvent(elt, newURI.toString());
                       return;
                   }
               }
  +            fireLinkActivatedEvent(elt, href);
               JSVGComponent.this.loadSVGDocument(href);
  +        }
  +
  +        /**
  +         * Fires a LinkActivatedEvent.
  +         */
  +        protected void fireLinkActivatedEvent(SVGAElement elt, String href) {
  +            Object[] ll = linkActivationListeners.toArray();
  +            
  +            if (ll.length > 0) {
  +                LinkActivationEvent ev;
  +                ev = new LinkActivationEvent(JSVGComponent.this, elt, href);
  +
  +                for (int i = 0; i < ll.length; i++) {
  +                    LinkActivationListener l = (LinkActivationListener)ll[i];
  +                    l.linkActivated(ev);
  +                }
  +            }
           }
   
           /**
  
  
  
  1.4       +4 -3      xml-batik/sources/org/apache/batik/transcoder/svg2svg/OutputManager.java
  
  Index: OutputManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/svg2svg/OutputManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OutputManager.java	2001/03/30 15:59:03	1.3
  +++ OutputManager.java	2001/05/07 17:34:34	1.4
  @@ -21,7 +21,7 @@
    * This class is responsible of the output of XML constructs.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: OutputManager.java,v 1.3 2001/03/30 15:59:03 hillion Exp $
  + * @version $Id: OutputManager.java,v 1.4 2001/05/07 17:34:34 hillion Exp $
    */
   public class OutputManager {
   
  @@ -520,8 +520,9 @@
           level--;
           if (name != null) {
               if (prettyPrinter.getFormat()) {
  -                if (line != ((Integer)startingLines.get(0)).intValue() ||
  -                    column + name.length + 3 >= prettyPrinter.getDocumentWidth()) {
  +                if (xmlSpace.get(0) != Boolean.TRUE &&
  +                    (line != ((Integer)startingLines.get(0)).intValue() ||
  +                     column + name.length + 3 >= prettyPrinter.getDocumentWidth())) {
                       printNewline();
                       printString(margin.toString());
                   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org