Re: SVGSerializer patch

2003-11-30 Thread Joerg Heinicke
On 24.11.2003 11:25, Borges Charles wrote:

I think that in cocoon 2.1.3 the sitemap parameters
are not available for serializers. They're always
set to empty parameters when the
SitemapModelComponent is a Serializer.
Is that correct?


It is correct that... you found a bug :-/

The sitemap engine wasn't updated to take into
account the ability for 
serializers to implement SitemapModelComponent.

I just fixed it in the CVS.

Sylvain



Given this bug fix, i propose a SVGSerializer patch
which support sitemap parameters (see attached files).
Your help is much appreciated. Please add the bug to bugzilla, so it 
won't get lost.

Thanks.

Joerg



Re: SVGSerializer patch

2003-11-24 Thread Borges Charles
> >I think that in cocoon 2.1.3 the sitemap parameters
> are not available for serializers. They're always
> set to empty parameters when the
> SitemapModelComponent is a Serializer.
> >Is that correct?
> >  
> >
> 
> It is correct that... you found a bug :-/
> 
> The sitemap engine wasn't updated to take into
> account the ability for 
> serializers to implement SitemapModelComponent.
> 
> I just fixed it in the CVS.
> 
> Sylvain
> 

Given this bug fix, i propose a SVGSerializer patch
which support sitemap parameters (see attached files).

Thus,

1. in the serializer configuration you define the
transcoding hints which can be overriden by the
sitemap parameters, say:

 


2. Override in a serialize node:

 
 


Charles

___
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.comIndex: SVGSerializer.java
===
RCS file: 
/home/cvspublic/cocoon-2.1/src/blocks/batik/java/org/apache/cocoon/serialization/SVGSerializer.java,v
retrieving revision 1.9
diff -u -r1.9 SVGSerializer.java
--- SVGSerializer.java  9 Oct 2003 15:26:54 -   1.9
+++ SVGSerializer.java  24 Nov 2003 10:17:39 -
@@ -51,7 +51,13 @@
 package org.apache.cocoon.serialization;
 
 import java.awt.Color;
+import java.io.IOException;
 import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.avalon.excalibur.pool.Poolable;
 import org.apache.avalon.framework.component.ComponentManager;
@@ -62,18 +68,22 @@
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.batik.transcoder.Transcoder;
+import org.apache.batik.transcoder.TranscoderException;
 import org.apache.batik.transcoder.TranscoderInput;
 import org.apache.batik.transcoder.TranscoderOutput;
 import org.apache.batik.transcoder.TranscodingHints;
-import org.apache.batik.transcoder.TranscoderException;
 import org.apache.batik.util.ParsedURL;
 import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.caching.CacheableProcessingComponent;
 import org.apache.cocoon.components.transcoder.ExtendableTranscoderFactory;
 import org.apache.cocoon.components.transcoder.TranscoderFactory;
 import org.apache.cocoon.components.url.ParsedContextURLProtocolHandler;
 import org.apache.cocoon.components.url.ParsedResourceURLProtocolHandler;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.sitemap.SitemapModelComponent;
 import org.apache.cocoon.util.ClassUtils;
 import org.apache.cocoon.xml.dom.SVGBuilder;
 import org.apache.excalibur.source.SourceValidity;
@@ -89,7 +99,7 @@
  * @version CVS $Id: SVGSerializer.java,v 1.9 2003/10/09 15:26:54 sylvain Exp $
  */
 public class SVGSerializer extends SVGBuilder
-implements Composable, Serializer, Configurable, Poolable, 
CacheableProcessingComponent, Contextualizable {
+implements Composable, Serializer, Configurable, Poolable, 
CacheableProcessingComponent, Contextualizable, SitemapModelComponent {
 
 /**
  * Get the context
@@ -112,7 +122,22 @@
 
 /** The Transcoder Factory to use */
 TranscoderFactory factory = 
ExtendableTranscoderFactory.getTranscoderFactoryImplementation();
-
+
+/** The current caching key */
+private Serializable cachingKey;
+
+/** The default Batik TranscodingHints set up in configuration step 
*/
+private TranscodingHints defaultTranscodingHints;
+
+/** The current Batik TranscodingHints can overrides the default one 
*/
+private TranscodingHints currentTranscodingHints;
+
+/** The map holding information for the Batik TranscodingHints.Keys 
*/
+private Map transcodingHintKeysInfo;
+
+/** Override default TranscodingHints with sitemap parameters? */
+private boolean overrideTranscodingHints = false;
+private boolean _overrideTranscodingHints = false;
 /**
  * Set the OutputStream where the XML should be serialized.
  */
@@ -157,8 +182,10 @@
 );
 }
 
-// Now run through the other parameters, using them as hints
-// to the transcoder
+// Now run through the other parameters, adding them to the 
+// default transcoding hints
+defaultTranscodingHints = new TranscodingHints();
+transcodingHintKeysInfo = new HashMap();
 for (int i = 0; i < parameters.length; i++ ) {
 String name = parameters[i].getAttribute("name");
 // Skip over the parameters we've dealt with. Ensure this
@@ -169,48 +196,93 

Re: SVGSerializer patch

2003-11-21 Thread Sylvain Wallez
Borges Charles wrote:

--- Vadim Gritsenko <[EMAIL PROTECTED]> a
écrit : > Borges Charles wrote:
 

Do you have an idea of how to do if you want to override parameters used to render an image like the indexed or quality parameters?
 

Pass via sitemap parameters; passing it via request parameters does not look like a safe approach to me.

Vadim

   

I think that in cocoon 2.1.3 the sitemap parameters are not available for serializers. They're always set to empty parameters when the SitemapModelComponent is a Serializer.
Is that correct?
 

It is correct that... you found a bug :-/

The sitemap engine wasn't updated to take into account the ability for 
serializers to implement SitemapModelComponent.

I just fixed it in the CVS.

Sylvain

--
Sylvain Wallez  Anyware Technologies
http://www.apache.org/~sylvain   http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Re: SVGSerializer patch

2003-11-21 Thread Borges Charles


 --- Vadim Gritsenko <[EMAIL PROTECTED]> a
écrit : > Borges Charles wrote:
> 
> >Do you have an idea of how to do if you want to
> >override parameters used to render an image like
> the
> >indexed or quality parameters?
> >  
> >
> 
> Pass via sitemap parameters; passing it via request
> parameters does not 
> look like a safe approach to me.
> 
> Vadim
> 

I think that in cocoon 2.1.3 the sitemap parameters
are not available for serializers. They're always set
to empty parameters when the SitemapModelComponent is
a Serializer.
Is that correct?

Thanks.


___
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com


Re: SVGSerializer patch

2003-11-21 Thread Vadim Gritsenko
Borges Charles wrote:

Do you have an idea of how to do if you want to
override parameters used to render an image like the
indexed or quality parameters?
 

Pass via sitemap parameters; passing it via request parameters does not 
look like a safe approach to me.

Vadim




Re: SVGSerializer patch

2003-11-20 Thread Borges Charles
 --- Tony Collen <[EMAIL PROTECTED]> a écrit : > Vadim
Gritsenko wrote:
> > Borges Charles wrote:
> > 
> >> Hi,
> >>
> >> Here's proposed SVGSerializer patch to support
> request
> >> parameters.
> >>  
> >>
> > ...
> > 
> >> or
> >>
>
samples/batik/batikLogo.png?width=200&height=100&indexed=2
> >> ... ugly!
> >>  
> >>
> > 
> > Or
> > samples/batik/batikLogo.png?width=1000&height=1000
> > samples/batik/batikLogo.png?width=1000&height=1001
> > samples/batik/batikLogo.png?width=1000&height=1002
> > ...
> > in the loop and your server is down.
> > 
> > No, thank you, I'll pass on this particular
> parameter!
> 
> Shouldn't this be a concern of a transformer or the
> generator, anyway, and not the serializer??
> 
> Just pass the request parameters to an XSLT to
> change the svg height or width, then output the
> image.
> 
> Tony
>  

I think this example with height and width wasn't a
good choice.
I agree with you, when it comes to change such
parameters which are specified in the svg (height,
width, background color...) it's wiser to go for an
XSLT.

Do you have an idea of how to do if you want to
override parameters used to render an image like the
indexed or quality parameters?

Thanks

___
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com


Re: SVGSerializer patch

2003-11-19 Thread Vadim Gritsenko
Tony Collen wrote:

Vadim Gritsenko wrote:

Borges Charles wrote:

Hi,

Here's proposed SVGSerializer patch to support request
parameters.
 

...

or
samples/batik/batikLogo.png?width=200&height=100&indexed=2
... ugly!
 

Or
samples/batik/batikLogo.png?width=1000&height=1000
samples/batik/batikLogo.png?width=1000&height=1001
samples/batik/batikLogo.png?width=1000&height=1002
...
in the loop and your server is down.
No, thank you, I'll pass on this particular parameter!


Shouldn't this be a concern of a transformer or the generator, anyway, 
and not the serializer??

Just pass the request parameters to an XSLT to change the svg height 
or width, then output the image.


Even better: pass via sitemap parameter (I like this way more :)

Vadim




Re: SVGSerializer patch

2003-11-19 Thread Tony Collen
Vadim Gritsenko wrote:
Borges Charles wrote:

Hi,

Here's proposed SVGSerializer patch to support request
parameters.
 

...

or
samples/batik/batikLogo.png?width=200&height=100&indexed=2
... ugly!
 

Or
samples/batik/batikLogo.png?width=1000&height=1000
samples/batik/batikLogo.png?width=1000&height=1001
samples/batik/batikLogo.png?width=1000&height=1002
...
in the loop and your server is down.
No, thank you, I'll pass on this particular parameter!
Shouldn't this be a concern of a transformer or the generator, anyway, and not the serializer??

Just pass the request parameters to an XSLT to change the svg height or width, then output the image.

Tony



Re: SVGSerializer patch

2003-11-19 Thread Vadim Gritsenko
Borges Charles wrote:

Hi,

Here's proposed SVGSerializer patch to support request
parameters.
 

...

or
samples/batik/batikLogo.png?width=200&height=100&indexed=2
... ugly!
 

Or
samples/batik/batikLogo.png?width=1000&height=1000
samples/batik/batikLogo.png?width=1000&height=1001
samples/batik/batikLogo.png?width=1000&height=1002
...
in the loop and your server is down.
No, thank you, I'll pass on this particular parameter!

Vadim





Re: SVGSerializer patch

2003-11-19 Thread Torsten Curdt
Borges Charles wrote:

Hi,

Here's proposed SVGSerializer patch to support request
parameters.
Thanks, but please file it into bugzilla
--
Torsten



SVGSerializer patch

2003-11-19 Thread Borges Charles
Hi,

Here's proposed SVGSerializer patch to support request
parameters.

The following changes have been made:

Configuration
=
1. 
The  tag is recognized to allow
the serializer to use request parameters.
if true ==> All the declared batik keys can be
overriden by request parameters.

3. 
The value attribute of the key now means it's a
default value and is not mandatory anymore.

4.
A default TranscodingHints is configured with all the
keys entries which have a default value

5.
A Map is used to keep information on batik transcoding
keys and their "types" (INTEGER, ...)

Processing
==

1.
The SVGSerializer implements the SitemapModelComponent

2.
A current TranscodingHints is built overriding the
default one and adding new key values if their "types"
can be resolved.

EXEMPLE
===

1.
in the batik block sitemap add this instead of the
current the svg2png serializer:


 true
 
 
 


2.
Try this:
samples/batik/batikLogo.png
... the normal logo
or
samples/batik/batikLogo.png?width=200&height=100
... small logo
or
samples/batik/batikLogo.png?width=200&height=100&indexed=2
... ugly!










=
BORGES C.

___
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.comIndex: SVGSerializer.java
===
RCS file: 
/home/cvspublic/cocoon-2.1/src/blocks/batik/java/org/apache/cocoon/serialization/SVGSerializer.java,v
retrieving revision 1.9
diff -u -r1.9 SVGSerializer.java
--- SVGSerializer.java  9 Oct 2003 15:26:54 -   1.9
+++ SVGSerializer.java  19 Nov 2003 17:44:26 -
@@ -51,7 +51,12 @@
 package org.apache.cocoon.serialization;
 
 import java.awt.Color;
+import java.io.IOException;
 import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.avalon.excalibur.pool.Poolable;
 import org.apache.avalon.framework.component.ComponentManager;
@@ -62,6 +67,7 @@
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.batik.transcoder.Transcoder;
 import org.apache.batik.transcoder.TranscoderInput;
 import org.apache.batik.transcoder.TranscoderOutput;
@@ -69,11 +75,16 @@
 import org.apache.batik.transcoder.TranscoderException;
 import org.apache.batik.util.ParsedURL;
 import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.caching.CacheableProcessingComponent;
 import org.apache.cocoon.components.transcoder.ExtendableTranscoderFactory;
 import org.apache.cocoon.components.transcoder.TranscoderFactory;
 import org.apache.cocoon.components.url.ParsedContextURLProtocolHandler;
 import org.apache.cocoon.components.url.ParsedResourceURLProtocolHandler;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.sitemap.SitemapModelComponent;
 import org.apache.cocoon.util.ClassUtils;
 import org.apache.cocoon.xml.dom.SVGBuilder;
 import org.apache.excalibur.source.SourceValidity;
@@ -89,7 +100,7 @@
  * @version CVS $Id: SVGSerializer.java,v 1.9 2003/10/09 15:26:54 sylvain Exp $
  */
 public class SVGSerializer extends SVGBuilder
-implements Composable, Serializer, Configurable, Poolable, 
CacheableProcessingComponent, Contextualizable {
+implements Composable, Serializer, Configurable, Poolable, 
CacheableProcessingComponent, Contextualizable, SitemapModelComponent {
 
 /**
  * Get the context
@@ -112,7 +123,22 @@
 
 /** The Transcoder Factory to use */
 TranscoderFactory factory = 
ExtendableTranscoderFactory.getTranscoderFactoryImplementation();
-
+
+/** The current caching key */
+private Serializable cachingKey;
+
+/** The default Batik TranscodingHints set up in configuration step 
*/
+private TranscodingHints defaultTranscodingHints;
+
+/** The current Batik TranscodingHints can overrides the default one 
*/
+private TranscodingHints currentTranscodingHints;
+
+/** The map holding information for the Batik TranscodingHints.Keys 
*/
+private Map transcodingHintKeysInfo;
+
+/** Override default TranscodingHints with request parameters? */
+private boolean overrideTranscodingHints = false;
+//private boolean _overrideTranscodingHints = false;
 /**
  * Set the OutputStream where the XML should be serialized.
  */
@@ -157,8 +183,10 @@
 );
 }
 
-// Now run through the other parameters, using them as hints
-// to the transcoder
+// Now run through the other parameters, adding them