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 Eli Gordon <el...@hotmail.com> on 2001/07/20 20:28:45 UTC

Modified Stroke

I don't know whether this is normal behaviour or not, but I've run into a 
problem with GraphicsNode's paint() method not preserving my Graphic's 
current Stroke. I've worked around it by just saving the stroke and 
re-applying it when the paint() method is finished, but it seems to me that 
the GraphicsNode should handle that internally.

Thanks,

-Eli

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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


Modified Stroke

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "EG" == Eli Gordon <el...@hotmail.com> writes:

EG> [...] I've run into a problem with GraphicsNode's paint() method
EG> not preserving my Graphic's current Stroke. I've worked around it
EG> by just saving the stroke and re-applying it when the paint()
EG> method is finished, but it seems to me that the GraphicsNode
EG> should handle that internally.

    Hmm, do you have any compelling reason that the GraphicsNode
should handle it internally?  

    I'll admit that the GraphicsNode would be a 'better neighbor' if
it did, but for example currently the 'paint' call in most AWT
components doesn't bother to be this nice.

    Also you would end up doing lots of unneeded getting and setting
of stroke/fill/clip/... since the next node simply wants to set it's
own stroke/fill/clip...:

    X= getStroke();
    setStroke(Y);
    // paint
    setStroke(X);

    X = getStroke();
    setStroke(Z);
    // paint
    setStroke(X);

    // ....

    I don't have strong feelings about this, but in general if you
pass a mutable object (which a Graphics2D is) into a method I think
it's ok for the method to change the state of the object...

    I think your solution is the correct one, if you need to preserve
the state of the object for your case than do so.

    Other opinions welcome.

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


RE: Modified Stroke

Posted by Edison Too <ed...@yahoo.com.sg>.
Hi,

I'm not sure if this will answer your question cos' I may not understand
your question very well.

If you are using GraphicsNode, it does not work in the same way as using
java.awt.Graphics to draw a Shape. That is why there is no such this as the
'current' stroke. You have to set the stroke of the GraphicsNode and that
will be used each time it is painted. You can do this in the following way.

If your shape has an outline, but no fill, create a new StrokeShapePainter
and call the ShapeNode's SetShapePainter() with this FillShapePainter. You
can specify the stroke and paint of the stroke in the Constructor.

If your shape has only fill, no outline, use FillShapePainter.

If your shape has both fill and outline, create one each of
StrokeShapePainter and FillShapePainter. Create a CompositeShapePainter and
use AddShapePainter() to add both to it. Then set the ShapeNode to use the
CompositeShapePainter.

Hope this answers your question.

Cheers,
Edison

> -----Original Message-----
> From: Eli Gordon [mailto:eli_gordon@hotmail.com]
> Sent: Saturday, July 21, 2001 2:29 AM
> To: batik-users@xml.apache.org
> Subject: Modified Stroke
>
>
> I don't know whether this is normal behaviour or not, but I've run into a
> problem with GraphicsNode's paint() method not preserving my Graphic's
> current Stroke. I've worked around it by just saving the stroke and
> re-applying it when the paint() method is finished, but it seems
> to me that
> the GraphicsNode should handle that internally.
>
> Thanks,
>
> -Eli


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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