You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Maik Schürer proveo GmbH <Ma...@proveo.de> on 2004/10/25 13:18:49 UTC

tooltips / Re: MouseEvents do not occur...

interesting to read about tooltips via <title> and <desc> ...

is it possible to customize the tooltip box ?

changing the font size works using UIManager, but font name (SansSerif e.g.)
and background color seems to be not changeable ...
   Font font = new Font("SansSerif", Font.PLAIN, 24); // only size shows an
effect
   FontUIResource fontRes = new FontUIResource(font);
   UIManager.put("ToolTip.font", fontRes);
   UIManager.put("Tooltip.background", new ColorUIResource(Color.CYAN)); //
shows no effect

Maik

----- Original Message ----- 
From: "Thomas DeWeese" <Th...@Kodak.com>
To: "Batik Users" <ba...@xml.apache.org>
Sent: Monday, October 25, 2004 12:20 PM
Subject: Re: MouseEvents do not occur if <desc> section is missing in SVG
docu ment


Stoeckle, Yvonne wrote:

> I have a simple SVG document and want to receive MouseEvents in my Java
> code when a mouse click occurs on an element of the document. This
> works, as long as I have either a <desc> section or an <animateMotion
> ..> section in the document.

   Do let the JSVGCanvas know that you want the document
built as a 'dynamic' document?  If you don't then without
the 'desc' this will appear to be a totally static document[*],
try:

canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);

[*] You may wonder why 'desc' makes it not 'totally static' the
answer is because we support using 'desc' and 'title' elements as
tool-tips when you hover over the associated content.  In this case
we disable desc and title for the root since they would always pop
up and would be fairly annoying (although we still turn on the
desc/title handling - always room for improvement).

> I tried this even with the following sample from the W3C SVG sites,
> because I first thought that my document has been wrong.
>
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
>   " http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
> <http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd> ">
> <svg width="5cm" height="5cm" version="1.1"
>      xmlns="http://www.w3.org/2000/svg">
>   <desc>Two groups, each of two rectangles
>   </desc>
>   <g id="group1" fill="red" >
>     <rect x="1cm" y="1cm" width="1cm" height="1cm" />
>     <rect x="3cm" y="1cm" width="1cm" height="1cm" />
>   </g>
>   <g id="group2" fill="blue" >
>     <rect x="1cm" y="3cm" width="1cm" height="1cm" />
>     <rect x="3cm" y="3cm" width="1cm" height="1cm" />
>   </g>
>   <!-- Show outline of canvas using 'rect' element -->
>   <rect x=".01cm" y=".01cm" width="4.98cm" height="4.98cm"
>         fill="none" stroke="blue" stroke-width=".02cm" />
> </svg>
>
> I have added a mouse listener to the group1 with:
>
>                 SVGGElement group1 =
> (SVGGElement)svgDocument.getElementById("group1");
>                 group1.addEventListener("click", new
> MouseClickListener(), false);
>
> If I remove <desc> section in the document, the mouse events do no
> longer arrive in my code.
> Does anyone have an idea about that ?
>
> */ Yvonne Stöckle /*
> * ___________________________________ *
>
>
>



---------------------------------------------------------------------
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


Re: tooltips / Re: MouseEvents do not occur...

Posted by Thomas DeWeese <Th...@Kodak.com>.
 >> Maik Schürer proveo GmbH wrote:

>>>what would you suggest to change Font, font color and background color (of
>>>the tooltip) ?

> On Mon, 2004-10-25 at 10:42, Thomas DeWeese wrote:

>>    If the above doesn't fix it (which I think it will), then you could
>>subclass the JSVGCanvas and provide a custom 'createToolTip' method.

Robert Marcano wrote:

> Or getTooltipText, making it return an HTML formated string like the
> accepted by label components

    This BTW is _really_ easy to do.  We already provide an HTML string
and it's formatted from a resources file:
     resources/org/apache/batik/swing/resources/Messages.properties



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


Re: tooltips / Re: MouseEvents do not occur...

Posted by Robert Marcano <ro...@marcanoonline.com>.
On Mon, 2004-10-25 at 10:42, Thomas DeWeese wrote:
> Hi Maik,
> 
> Maik Schürer proveo GmbH wrote:
> 
> > but it is the same (no effect) when I use the 'base' classes:
> >    UIManager.put("ToolTip.font", new Font("Arial", Font.PLAIN, 24));
> >    UIManager.put("Tooltip.background", Color.CYAN);
>                          ^
> I just noticed:         +  Not a capital 'T'.
> 
> > what would you suggest to change Font, font color and background color (of
> > the tooltip) ?
> 
>     If the above doesn't fix it (which I think it will), then you could
> subclass the JSVGCanvas and provide a custom 'createToolTip' method.

Or getTooltipText, making it return an HTML formated string like the
accepted by label components

> 
> > ----- Original Message ----- 
> > From: "Thomas DeWeese" <Th...@Kodak.com>
> > To: "Batik Users" <ba...@xml.apache.org>
> > Sent: Monday, October 25, 2004 4:13 PM
> > Subject: Re: tooltips / Re: MouseEvents do not occur...
> > 
> > 
> > Hi Maik,
> > 
> >    Well, I'm really not familiar with the UIManager stuff, so
> > this is from quickly looking at the JavaDocs.  the FontUIResource
> > is a derived class from Font, similarly for ColorUIResource.
> > Looking at the UIManager it treats the value differently if it
> > is a 'UIResource' vs if it is the baseclass (Font, Color).
> > 
> >    On first reading it appears that when the value is a UIResource
> > it checks the parent component for the value.  But I could easily
> > be missing something.
> > 

________________________________________
Robert Marcano


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


Re: tooltips / Re: MouseEvents do not occur...

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Maik,

Maik Schürer proveo GmbH wrote:

> but it is the same (no effect) when I use the 'base' classes:
>    UIManager.put("ToolTip.font", new Font("Arial", Font.PLAIN, 24));
>    UIManager.put("Tooltip.background", Color.CYAN);
                         ^
I just noticed:         +  Not a capital 'T'.

> what would you suggest to change Font, font color and background color (of
> the tooltip) ?

    If the above doesn't fix it (which I think it will), then you could
subclass the JSVGCanvas and provide a custom 'createToolTip' method.

> ----- Original Message ----- 
> From: "Thomas DeWeese" <Th...@Kodak.com>
> To: "Batik Users" <ba...@xml.apache.org>
> Sent: Monday, October 25, 2004 4:13 PM
> Subject: Re: tooltips / Re: MouseEvents do not occur...
> 
> 
> Hi Maik,
> 
>    Well, I'm really not familiar with the UIManager stuff, so
> this is from quickly looking at the JavaDocs.  the FontUIResource
> is a derived class from Font, similarly for ColorUIResource.
> Looking at the UIManager it treats the value differently if it
> is a 'UIResource' vs if it is the baseclass (Font, Color).
> 
>    On first reading it appears that when the value is a UIResource
> it checks the parent component for the value.  But I could easily
> be missing something.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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


Re: tooltips / Re: MouseEvents do not occur...

Posted by Maik Schürer proveo GmbH <Ma...@proveo.de>.
but it is the same (no effect) when I use the 'base' classes:
   UIManager.put("ToolTip.font", new Font("Arial", Font.PLAIN, 24));
   UIManager.put("Tooltip.background", Color.CYAN);

what would you suggest to change Font, font color and background color (of
the tooltip) ?

Thanks
Maik

----- Original Message ----- 
From: "Thomas DeWeese" <Th...@Kodak.com>
To: "Batik Users" <ba...@xml.apache.org>
Sent: Monday, October 25, 2004 4:13 PM
Subject: Re: tooltips / Re: MouseEvents do not occur...


Hi Maik,

   Well, I'm really not familiar with the UIManager stuff, so
this is from quickly looking at the JavaDocs.  the FontUIResource
is a derived class from Font, similarly for ColorUIResource.
Looking at the UIManager it treats the value differently if it
is a 'UIResource' vs if it is the baseclass (Font, Color).

   On first reading it appears that when the value is a UIResource
it checks the parent component for the value.  But I could easily
be missing something.




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


Re: tooltips / Re: MouseEvents do not occur...

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Maik,

   Well, I'm really not familiar with the UIManager stuff, so
this is from quickly looking at the JavaDocs.  the FontUIResource
is a derived class from Font, similarly for ColorUIResource.
Looking at the UIManager it treats the value differently if it
is a 'UIResource' vs if it is the baseclass (Font, Color).

   On first reading it appears that when the value is a UIResource
it checks the parent component for the value.  But I could easily
be missing something.

Maik Schürer proveo GmbH wrote:

>>Are you sure you want to use the 'UIResource' versions of these?
>>I would suspect that you would want to just use Color/Font (since you
>>want to override the parent).
> 
> 
> what do you mean with 'UIResource versions' ? there are other versions too ?
> is there something wrong with my code ?
> 
> Font font = new Font("SansSerif", Font.PLAIN, 24); // only size shows an
> effect
> FontUIResource fontRes = new FontUIResource(font);
> UIManager.put("ToolTip.font", fontRes);
> UIManager.put("Tooltip.background", new ColorUIResource(Color.CYAN)); //
> shows no effect
> 
> Maik
> 
> 
>>----- Original Message ----- 
>>From: "Thomas DeWeese" <Th...@Kodak.com>
>>To: "Batik Users" <ba...@xml.apache.org>
>>Sent: Monday, October 25, 2004 12:20 PM
>>Subject: Re: MouseEvents do not occur if <desc> section is missing in SVG
>>docu ment
>>
>>
>>Stoeckle, Yvonne wrote:
>>
>>
>>
>>>I have a simple SVG document and want to receive MouseEvents in my Java
>>>code when a mouse click occurs on an element of the document. This
>>>works, as long as I have either a <desc> section or an <animateMotion
>>>..> section in the document.
>>
>>
>>   Do let the JSVGCanvas know that you want the document
>>built as a 'dynamic' document?  If you don't then without
>>the 'desc' this will appear to be a totally static document[*],
>>try:
>>
>>canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>>
>>[*] You may wonder why 'desc' makes it not 'totally static' the
>>answer is because we support using 'desc' and 'title' elements as
>>tool-tips when you hover over the associated content.  In this case
>>we disable desc and title for the root since they would always pop
>>up and would be fairly annoying (although we still turn on the
>>desc/title handling - always room for improvement).
>>
>>
>>
>>>I tried this even with the following sample from the W3C SVG sites,
>>>because I first thought that my document has been wrong.
>>>
>>><?xml version="1.0" standalone="no"?>
>>><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
>>> " http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
>>><http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd> ">
>>><svg width="5cm" height="5cm" version="1.1"
>>>    xmlns="http://www.w3.org/2000/svg">
>>> <desc>Two groups, each of two rectangles
>>> </desc>
>>> <g id="group1" fill="red" >
>>>   <rect x="1cm" y="1cm" width="1cm" height="1cm" />
>>>   <rect x="3cm" y="1cm" width="1cm" height="1cm" />
>>> </g>
>>> <g id="group2" fill="blue" >
>>>   <rect x="1cm" y="3cm" width="1cm" height="1cm" />
>>>   <rect x="3cm" y="3cm" width="1cm" height="1cm" />
>>> </g>
>>> <!-- Show outline of canvas using 'rect' element -->
>>> <rect x=".01cm" y=".01cm" width="4.98cm" height="4.98cm"
>>>       fill="none" stroke="blue" stroke-width=".02cm" />
>>></svg>
>>>
>>>I have added a mouse listener to the group1 with:
>>>
>>>               SVGGElement group1 =
>>>(SVGGElement)svgDocument.getElementById("group1");
>>>               group1.addEventListener("click", new
>>>MouseClickListener(), false);
>>>
>>>If I remove <desc> section in the document, the mouse events do no
>>>longer arrive in my code.
>>>Does anyone have an idea about that ?
>>>
>>>*/ Yvonne Stöckle /*
>>>* ___________________________________ *
>>>
>>>
>>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>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
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 



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


Re: tooltips / Re: MouseEvents do not occur...

Posted by Maik Schürer proveo GmbH <Ma...@proveo.de>.
> Are you sure you want to use the 'UIResource' versions of these?
> I would suspect that you would want to just use Color/Font (since you
> want to override the parent).

what do you mean with 'UIResource versions' ? there are other versions too ?
is there something wrong with my code ?

Font font = new Font("SansSerif", Font.PLAIN, 24); // only size shows an
effect
FontUIResource fontRes = new FontUIResource(font);
UIManager.put("ToolTip.font", fontRes);
UIManager.put("Tooltip.background", new ColorUIResource(Color.CYAN)); //
shows no effect

Maik

> ----- Original Message ----- 
> From: "Thomas DeWeese" <Th...@Kodak.com>
> To: "Batik Users" <ba...@xml.apache.org>
> Sent: Monday, October 25, 2004 12:20 PM
> Subject: Re: MouseEvents do not occur if <desc> section is missing in SVG
> docu ment
>
>
> Stoeckle, Yvonne wrote:
>
>
>>I have a simple SVG document and want to receive MouseEvents in my Java
>>code when a mouse click occurs on an element of the document. This
>>works, as long as I have either a <desc> section or an <animateMotion
>>..> section in the document.
>
>
>    Do let the JSVGCanvas know that you want the document
> built as a 'dynamic' document?  If you don't then without
> the 'desc' this will appear to be a totally static document[*],
> try:
>
> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>
> [*] You may wonder why 'desc' makes it not 'totally static' the
> answer is because we support using 'desc' and 'title' elements as
> tool-tips when you hover over the associated content.  In this case
> we disable desc and title for the root since they would always pop
> up and would be fairly annoying (although we still turn on the
> desc/title handling - always room for improvement).
>
>
>>I tried this even with the following sample from the W3C SVG sites,
>>because I first thought that my document has been wrong.
>>
>><?xml version="1.0" standalone="no"?>
>><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
>>  " http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
>><http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd> ">
>><svg width="5cm" height="5cm" version="1.1"
>>     xmlns="http://www.w3.org/2000/svg">
>>  <desc>Two groups, each of two rectangles
>>  </desc>
>>  <g id="group1" fill="red" >
>>    <rect x="1cm" y="1cm" width="1cm" height="1cm" />
>>    <rect x="3cm" y="1cm" width="1cm" height="1cm" />
>>  </g>
>>  <g id="group2" fill="blue" >
>>    <rect x="1cm" y="3cm" width="1cm" height="1cm" />
>>    <rect x="3cm" y="3cm" width="1cm" height="1cm" />
>>  </g>
>>  <!-- Show outline of canvas using 'rect' element -->
>>  <rect x=".01cm" y=".01cm" width="4.98cm" height="4.98cm"
>>        fill="none" stroke="blue" stroke-width=".02cm" />
>></svg>
>>
>>I have added a mouse listener to the group1 with:
>>
>>                SVGGElement group1 =
>>(SVGGElement)svgDocument.getElementById("group1");
>>                group1.addEventListener("click", new
>>MouseClickListener(), false);
>>
>>If I remove <desc> section in the document, the mouse events do no
>>longer arrive in my code.
>>Does anyone have an idea about that ?
>>
>>*/ Yvonne Stöckle /*
>>* ___________________________________ *
>>
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> 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
>



---------------------------------------------------------------------
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


Re: tooltips / Re: MouseEvents do not occur...

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Maik,

Maik Schürer proveo GmbH wrote:
> interesting to read about tooltips via <title> and <desc> ...
> 
> is it possible to customize the tooltip box ?

    Well, we play some tricks, but in the end we use setToolTipText
to set the text and have the tool tip popup.

> changing the font size works using UIManager, but font name (SansSerif e.g.)
> and background color seems to be not changeable ...

    Are you sure you want to use the 'UIResource' versions of these?
I would suspect that you would want to just use Color/Font (since you
want to override the parent).

>    Font font = new Font("SansSerif", Font.PLAIN, 24); // only size shows an
> effect
>    FontUIResource fontRes = new FontUIResource(font);
>    UIManager.put("ToolTip.font", fontRes);
>    UIManager.put("Tooltip.background", new ColorUIResource(Color.CYAN)); //
> shows no effect
> 
> Maik
> 
> ----- Original Message ----- 
> From: "Thomas DeWeese" <Th...@Kodak.com>
> To: "Batik Users" <ba...@xml.apache.org>
> Sent: Monday, October 25, 2004 12:20 PM
> Subject: Re: MouseEvents do not occur if <desc> section is missing in SVG
> docu ment
> 
> 
> Stoeckle, Yvonne wrote:
> 
> 
>>I have a simple SVG document and want to receive MouseEvents in my Java
>>code when a mouse click occurs on an element of the document. This
>>works, as long as I have either a <desc> section or an <animateMotion
>>..> section in the document.
> 
> 
>    Do let the JSVGCanvas know that you want the document
> built as a 'dynamic' document?  If you don't then without
> the 'desc' this will appear to be a totally static document[*],
> try:
> 
> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> 
> [*] You may wonder why 'desc' makes it not 'totally static' the
> answer is because we support using 'desc' and 'title' elements as
> tool-tips when you hover over the associated content.  In this case
> we disable desc and title for the root since they would always pop
> up and would be fairly annoying (although we still turn on the
> desc/title handling - always room for improvement).
> 
> 
>>I tried this even with the following sample from the W3C SVG sites,
>>because I first thought that my document has been wrong.
>>
>><?xml version="1.0" standalone="no"?>
>><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
>>  " http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd
>><http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd> ">
>><svg width="5cm" height="5cm" version="1.1"
>>     xmlns="http://www.w3.org/2000/svg">
>>  <desc>Two groups, each of two rectangles
>>  </desc>
>>  <g id="group1" fill="red" >
>>    <rect x="1cm" y="1cm" width="1cm" height="1cm" />
>>    <rect x="3cm" y="1cm" width="1cm" height="1cm" />
>>  </g>
>>  <g id="group2" fill="blue" >
>>    <rect x="1cm" y="3cm" width="1cm" height="1cm" />
>>    <rect x="3cm" y="3cm" width="1cm" height="1cm" />
>>  </g>
>>  <!-- Show outline of canvas using 'rect' element -->
>>  <rect x=".01cm" y=".01cm" width="4.98cm" height="4.98cm"
>>        fill="none" stroke="blue" stroke-width=".02cm" />
>></svg>
>>
>>I have added a mouse listener to the group1 with:
>>
>>                SVGGElement group1 =
>>(SVGGElement)svgDocument.getElementById("group1");
>>                group1.addEventListener("click", new
>>MouseClickListener(), false);
>>
>>If I remove <desc> section in the document, the mouse events do no
>>longer arrive in my code.
>>Does anyone have an idea about that ?
>>
>>*/ Yvonne Stöckle /*
>>* ___________________________________ *
>>
>>
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 



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