xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dao <dao.ho...@gmail.com>
Subject Re: My canvas does not display some changes
Date Sat, 16 Jan 2010 18:22:47 GMT
well I hope this is my last question...

I take the same code and insteed of setting the visibility on/off, I want a
smoother rendering.

I decide to add an animate element on the opacity attribute.

I do this:
first add a new element to the mask
...

Element animElement = createOpacityAnimElement(0,0);

animElement.setAttributeNS(null,"id",mask.getAttribute("id")+"anim");

mask.appendChild(animElement);

 private Element createOpacityAnimElement(float from, float to) {

Element anim = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, "animate"
);

anim.setAttributeNS(null,"attributeType","CSS");

anim.setAttributeNS(null,"attributeName","opacity");

anim.setAttributeNS(null,"from",Float.toString(from));

anim.setAttributeNS(null,"to",Float.toString(to));

anim.setAttributeNS(null,"dur","1");

anim.setAttributeNS(null,"repeatCount","1");

return anim;

}


And then, I modify the setVisible method like this:

public void setVisible(final Element elt, boolean b) {

final Element mask = elt2mask.get(elt);

final SVGAnimationElement anim = (SVGAnimationElement)
mask.getElementsByTagNameNS(SVGConstants.SVG_NAMESPACE_URI, "animate"
).item(0);


 if (b) {

canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(newRunnable() {

 @Override

public void run() {

anim.setAttribute("from", "0");

anim.setAttribute("to", "0.5");

anim.beginElement();

mask.setAttribute("opacity", "0.5");


 }

});

} else {

canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(newRunnable() {

 @Override

public void run() {

anim.setAttribute("from", "0.5");

anim.setAttribute("to", "0");

anim.beginElement();

mask.setAttribute("opacity", "0");

}

});


 }


 }



With this, I can't the opacity switches directly without the fade away I
want. When I put the visible.svg and hidden.svg files in squiggle, I have
the animation running as I want. what's wrong?

In squiggle, it seems that for example, if I want the opacity from 0 to 0.5,
it blinks like 0.5, then 0 then smoothly 0.5. How can I do to avoid this?

I have put the whole code in attachement to launch the same way as in y
previous mail.





On Sat, Jan 16, 2010 at 5:03 PM, dao <dao.hodac@gmail.com> wrote:

> ahhhhhh!
>
> thank you, I will sleep well tonight!
>
> I works now.
>
>
>
> On Sat, Jan 16, 2010 at 2:09 PM, <thomas.deweese@kodak.com> wrote:
>
>> Hi Olivier,
>>
>> dao <dao.hodac@gmail.com> wrote on 01/16/2010 07:03:08 AM:
>>
>>
>> > I have reduced the problem. here are the 3 java files to use with batik
>> 1.7.
>>
>>
>> [...]
>>
>> > I am very interested in knowing if it is a mistake from me or if I
>> > am sitting on a bug.
>>
>>    It is a mistake in your code.  Unfortunately I think I caused it ;)
>> Do you remember when you asked:
>>
>> >> Actually, I created the anim elements with the namespace
>> >> "*http://www.w3.org/2000/svg* <http://www.w3.org/2000/svg>".
>> >> It is in fact null... how can I know which element belongs to which
>> namespace?
>>
>> And I responded:
>>
>> >   Attributes that don't have a prefix (i.e. xlink:) should
>> > be in the null namespace.  Attributes that have a prefix should be
>> > in the namespace associated with that prefix.  In SVG this means that
>> > essentially only the xlink attributes need namespaces.
>>
>>     Note that you asked about 'elements' and I responded about
>> 'attributes'.
>> Elements are things like: 'svg', 'g', 'path', etc.  Attributes are the
>> values
>> associated those elements like: 'viewBox', 'x', 'y', 'width', 'height',
>> etc.
>>
>>     Your problem is that you took my answer about attributes and applied
>> it
>> to Elements.  So in SvgMaskLayer if you replace all the
>> createElementNS(null, ...)
>> with createElementNS(SVGConstants.SVG_NAMESPACE_URI, ...) it will work.
>>
>>     So then to actually answer your original question of how to know what
>> namespace to create _elements_ with in Batik all the elements of interest
>> are in the SVG namespace.  There are a few elements that are in a private
>> Batik namespace (and of course you can create your own elements in any
>> namespace
>> you like) but in general you probably won't use those.
>>
>>
>> > 2010/1/16 Helder Magalhães <helder.magalhaes@gmail.com>
>> > Hi Dao,
>> >
>> >
>> > > Sorry about the confusion. It is not a mask in SVG terms. The maskfor
>> me is
>> > > just a business term.
>>
>> > Oops... ;-)
>> >
>> >
>> > > Technically, it is just an element, like an other which is in a <g>
>> appended
>> > > before the first rendering. It is appended directly to the SVG root
>> element
>>
>> > Yeah, when Thomas recalled about the referenced content (mask, in this
>> > case) not being updated live it seemed like the best hint. If you
>> > state it's just a usual element and that it's already in the document
>> > tree when the first rendering is done, then it's weird... :-|
>> >
>> > Can you create and attach a reduced test case which reproduces this
>> > symptom? (Apparently it would need to be Java application code, as
>> > you've stated that it opens in Squiggle as expected -- else I'd
>> > suggest only attaching the SVG source.) Although probably not part of
>> > the cause, please state your environment as well (Java version, OS,
>> > Batik version or revision, ...).
>> >
>> >
>> > Cheers,
>> >  Helder
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail:
>> batik-users-help@xmlgraphics.apache.org
>>
>> >
>> >
>> >
>> > --
>> > Dao Hodac[attachment "wspTmp.zip" deleted by Thomas E.
>> DeWeese/449433/EKC]
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail:
>> batik-users-help@xmlgraphics.apache.org
>>
>>
>
>
> --
> Dao Hodac
>



-- 
Dao Hodac

Mime
View raw message