xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: small patch for custom cursors
Date Tue, 08 Feb 2005 02:53:36 GMT
Hi George,

    First the formalities, do you have a CLA[*] on file with
Apache?  I just checked and I didn't see your name.

George Armhold wrote:

> There currently seems to be no way to replace the "default" cursor in
> the canvas; it can be replaced temporarily via
> UserAgent.setSVGCursor(), but the BridgeContext will replace it when
> the mouse crosses another SVG element.  Some discussion of this can be
> found in this thread:

    Yes, I agree this is a problem.  I don't think your patch quite
addresses the issue though.  In particular it appears that the
CursorManager class makes heavy use of 'static' values for
DEFAULT_CURSOR (used in a number of places) and in fact the
cursorMap is static as well.  So defining the cursor would
define it for all canvas's (which I don't think is the intent
in here).

    I would suggest removing the current static cursors from the
CursorManager class (have current references call
getPredefinedCursor, like you did for BridgeContext, I might
add a 'getDefaultCursor' call for efficiency, but it's not a
big deal).

    Then I would add a 'second level' cursorMap that is not static.
This second level Map would be used by defineCursor, 
getPredefinedCursor would then check if the second level map exists
and check it first for a cursor and if that fails have it call the
current static cursorMap (this saves overhead for the most common
situation).

    It didn't look like it would be a problem to have everyone
who currently calls the static method to get a reference to
the current cursorManager instance.

[*] CLA - Contributors License Agreement:
	http://www.apache.org/licenses/#clas


>   http://koala.ilog.fr/batik/mlists/batik-users/archives/msg05498.html
> 
> I've included a patch below that allows the user to (re)define the
> cursor mappings in CursorManager.  Also since BridgeContext was
> hardcoded to use the constants in CursorManager, there is a small
> modification for that class as well.
> 
> Thomas, would you consider accepting this patch?  I think I have
> followed the "spirit" of the current sources with this patch, but if
> not, of course feel free to make whatever changes you see fit.
> 
> Thanks.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: BridgeContext.java
> ===================================================================
> RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v
> retrieving revision 1.80
> diff -u -r1.80 BridgeContext.java
> --- BridgeContext.java  15 Dec 2004 10:50:29 -0000      1.80
> +++ BridgeContext.java  6 Feb 2005 22:50:00 -0000
> @@ -1178,12 +1178,12 @@
>          public void handleEvent(Event evt) {
>              MouseEvent me = (MouseEvent)evt;
>              Element newTarget = (Element)me.getRelatedTarget();
> -            Cursor cursor = CursorManager.DEFAULT_CURSOR;
> +           Cursor cursor = null;
>              if (newTarget != null)
>                  cursor = CSSUtilities.convertCursor
>                      (newTarget, BridgeContext.this);
> -            if (cursor == null)
> -                cursor = CursorManager.DEFAULT_CURSOR;
> +             if (cursor == null)
> +              cursor = cursorManager.getPredefinedCursor(SVGConstants.SVG_DEFAULT_VALUE);
> 
>              userAgent.setSVGCursor(cursor);
>          }
> Index: CursorManager.java
> ===================================================================
> RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/bridge/CursorManager.java,v
> retrieving revision 1.13
> diff -u -r1.13 CursorManager.java
> --- CursorManager.java  20 Aug 2004 19:29:46 -0000      1.13
> +++ CursorManager.java  6 Feb 2005 22:50:01 -0000
> @@ -158,6 +158,14 @@
>          return (Cursor)cursorMap.get(cursorName);
>      }
> 
> +   /**
> +    * Define (or replace) the named cursor.  To replace the "default"
> +    * cursor, use SVG_DEFAULT_VALUE as the cursorName.
> +    */
> +    public void defineCursor(String cursorName, Cursor c) {
> +      cursorMap.put(cursorName, c);
> +    }
> +
>      /**
>       * Returns the Cursor corresponding to the input element's cursor property
>       *
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


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


Mime
View raw message