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 10:09:58 UTC

cvs commit: xml-batik/sources/org/apache/batik/swing/svg JSVGComponent.java SVGUserAgent.java

hillion     01/05/18 01:09:57

  Modified:    sources/org/apache/batik/apps/svgbrowser
                        JSVGViewerFrame.java
               sources/org/apache/batik/swing/svg JSVGComponent.java
                        SVGUserAgent.java
  Log:
  - SVGUserAgent.openLink() is always called when a link must be activated,
  - The title bar now displays the title of the SVG document.
  
  Revision  Changes    Path
  1.43      +21 -11    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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- JSVGViewerFrame.java	2001/05/16 13:23:12	1.42
  +++ JSVGViewerFrame.java	2001/05/18 08:09:49	1.43
  @@ -133,7 +133,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.42 2001/05/16 13:23:12 tkormann Exp $
  + * @version $Id: JSVGViewerFrame.java,v 1.43 2001/05/18 08:09:49 hillion Exp $
    */
   public class JSVGViewerFrame
       extends    JFrame
  @@ -1364,16 +1364,22 @@
           if (title == null) {
               title = getTitle();
           }
  -        int i = s.lastIndexOf("/");
  -        if (i == -1) {
  -            i = s.lastIndexOf("\\");
  +
  +        String dt = svgDocument.getTitle();
  +        if (dt.length() != 0) {
  +            setTitle(title + ":" + dt);
  +        } else {
  +            int i = s.lastIndexOf("/");
               if (i == -1) {
  -                setTitle(title + ":" + s);
  +                i = s.lastIndexOf("\\");
  +                if (i == -1) {
  +                    setTitle(title + ":" + s);
  +                } else {
  +                    setTitle(title + ":" + s.substring(i + 1));
  +                }
               } else {
                   setTitle(title + ":" + s.substring(i + 1));
               }
  -        } else {
  -            setTitle(title + ":" + s.substring(i + 1));
           }
   
           localHistory.update(s);
  @@ -1649,12 +1655,16 @@
           }
   
           /**
  -         * Opens a link in a new component.
  -         * @param doc The current document.
  +         * Opens a link.
            * @param uri The document URI.
  +         * @param newc Whether the link should be activated in a new component.
            */
  -        public void openLink(String uri) {
  -            application.openLink(uri);
  +        public void openLink(String uri, boolean newc) {
  +            if (newc) {
  +                application.openLink(uri);
  +            } else {
  +                svgCanvas.loadSVGDocument(uri);
  +            }
           }
   
           /**
  
  
  
  1.21      +11 -5     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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JSVGComponent.java	2001/05/16 14:03:30	1.20
  +++ JSVGComponent.java	2001/05/18 08:09:54	1.21
  @@ -65,7 +65,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.20 2001/05/16 14:03:30 tkormann Exp $
  + * @version $Id: JSVGComponent.java,v 1.21 2001/05/18 08:09:54 hillion Exp $
    */
   public class JSVGComponent extends JGVTComponent {
   
  @@ -741,6 +741,7 @@
               String href = elt.getHref().getBaseVal();
   
               if (show.equals("new")) {
  +                fireLinkActivatedEvent(elt, href);
                   if (svgUserAgent != null) {
                       URL oldURI = ((SVGOMDocument)svgDocument).getURLObject();
                       URL newURI = null;
  @@ -753,10 +754,11 @@
   
                       href = newURI.toString();
   
  -                    svgUserAgent.openLink(href);
  -                    fireLinkActivatedEvent(elt, href);
  -                    return;
  +                    svgUserAgent.openLink(href, true);
  +                } else {
  +                    JSVGComponent.this.loadSVGDocument(href);
                   }
  +                return;
               }
   
               // Avoid reloading if possible.
  @@ -782,7 +784,11 @@
                   }
               }
               fireLinkActivatedEvent(elt, href);
  -            JSVGComponent.this.loadSVGDocument(href);
  +            if (svgUserAgent != null) {
  +                svgUserAgent.openLink(href, false);
  +            } else {
  +                JSVGComponent.this.loadSVGDocument(href);
  +            }
           }
   
           /**
  
  
  
  1.3       +3 -2      xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgent.java
  
  Index: SVGUserAgent.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SVGUserAgent.java	2001/04/18 13:51:06	1.2
  +++ SVGUserAgent.java	2001/05/18 08:09:55	1.3
  @@ -13,7 +13,7 @@
    * a JSVGComponent.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: SVGUserAgent.java,v 1.2 2001/04/18 13:51:06 hillion Exp $
  + * @version $Id: SVGUserAgent.java,v 1.3 2001/05/18 08:09:55 hillion Exp $
    */
   public interface SVGUserAgent {
       
  @@ -57,8 +57,9 @@
       /**
        * Opens a link in a new component.
        * @param uri The document URI.
  +     * @param newc Whether the link should be activated in a new component.
        */
  -    void openLink(String uri);
  +    void openLink(String uri, boolean newc);
   
       /**
        * Tells whether the given extension is supported by this
  
  
  

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