hillion 01/10/08 08:49:38 Modified: sources/org/apache/batik/apps/svgbrowser JSVGViewerFrame.java sources/org/apache/batik/bridge GVTBuilder.java UserAgent.java UserAgentAdapter.java sources/org/apache/batik/swing/svg JSVGComponent.java SVGUserAgent.java sources/org/apache/batik/transcoder/image ImageTranscoder.java sources/org/apache/batik/transcoder/print PrintTranscoder.java Log: Added support for CSS @media rules in the browser (the canvas is a "screen" medium, the print button is a "print" medium) and the transcoders (they now have a KEY_MEDIA optional hint). Revision Changes Path 1.53 +8 -1 xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java Index: JSVGViewerFrame.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- JSVGViewerFrame.java 2001/09/28 15:40:08 1.52 +++ JSVGViewerFrame.java 2001/10/08 15:49:37 1.53 @@ -153,7 +153,7 @@ * This class represents a SVG viewer swing frame. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: JSVGViewerFrame.java,v 1.52 2001/09/28 15:40:08 hillion Exp $ + * @version $Id: JSVGViewerFrame.java,v 1.53 2001/10/08 15:49:37 hillion Exp $ */ public class JSVGViewerFrame extends JFrame @@ -1735,6 +1735,13 @@ */ public String getXMLParserClassName() { return application.getXMLParserClassName(); + } + + /** + * Returns this user agent's CSS media. + */ + public String getMedia() { + return "screen"; } /** 1.12 +10 -1 xml-batik/sources/org/apache/batik/bridge/GVTBuilder.java Index: GVTBuilder.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/GVTBuilder.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- GVTBuilder.java 2001/09/10 12:26:07 1.11 +++ GVTBuilder.java 2001/10/08 15:49:37 1.12 @@ -10,6 +10,8 @@ import java.util.List; +import org.apache.batik.css.AbstractViewCSS; + import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.gvt.CanvasGraphicsNode; import org.apache.batik.gvt.CompositeGraphicsNode; @@ -22,11 +24,13 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.w3c.dom.views.DocumentView; + /** * This class is responsible for creating a GVT tree using an SVG DOM tree. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: GVTBuilder.java,v 1.11 2001/09/10 12:26:07 hillion Exp $ + * @version $Id: GVTBuilder.java,v 1.12 2001/10/08 15:49:37 hillion Exp $ */ public class GVTBuilder implements SVGConstants { @@ -44,6 +48,11 @@ * the GVT tree */ public GraphicsNode build(BridgeContext ctx, Document document) { + // set the media type + AbstractViewCSS view; + view = (AbstractViewCSS)((DocumentView)document).getDefaultView(); + view.setMedia(ctx.getUserAgent().getMedia()); + // inform the bridge context the builder to use ctx.setGVTBuilder(this); 1.17 +6 -1 xml-batik/sources/org/apache/batik/bridge/UserAgent.java Index: UserAgent.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UserAgent.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- UserAgent.java 2001/08/03 16:33:42 1.16 +++ UserAgent.java 2001/10/08 15:49:37 1.17 @@ -24,7 +24,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Christophe Jolif</a> * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: UserAgent.java,v 1.16 2001/08/03 16:33:42 vhardy Exp $ + * @version $Id: UserAgent.java,v 1.17 2001/10/08 15:49:37 hillion Exp $ */ public interface UserAgent { @@ -87,6 +87,11 @@ * applied to the drawing by the UserAgent. */ public AffineTransform getTransform(); + + /** + * Returns this user agent's CSS media. + */ + public String getMedia(); /** * Returns the location on the screen of the 1.4 +8 -1 xml-batik/sources/org/apache/batik/bridge/UserAgentAdapter.java Index: UserAgentAdapter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UserAgentAdapter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- UserAgentAdapter.java 2001/08/03 16:33:42 1.3 +++ UserAgentAdapter.java 2001/10/08 15:49:37 1.4 @@ -31,7 +31,7 @@ * the creation of UserAgent instances. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> - * @version $Id: UserAgentAdapter.java,v 1.3 2001/08/03 16:33:42 vhardy Exp $ + * @version $Id: UserAgentAdapter.java,v 1.4 2001/10/08 15:49:37 hillion Exp $ */ public class UserAgentAdapter implements UserAgent { protected Set FEATURES = new HashSet(); @@ -85,6 +85,13 @@ */ public String getLanguages() { return "en"; + } + + /** + * Returns this user agent's CSS media. + */ + public String getMedia() { + return "all"; } /** 1.27 +11 -1 xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java Index: JSVGComponent.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- JSVGComponent.java 2001/09/18 21:19:01 1.26 +++ JSVGComponent.java 2001/10/08 15:49:38 1.27 @@ -152,7 +152,7 @@ * building/rendering a document (invalid XML file, missing attributes...).</p> * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: JSVGComponent.java,v 1.26 2001/09/18 21:19:01 deweese Exp $ + * @version $Id: JSVGComponent.java,v 1.27 2001/10/08 15:49:38 hillion Exp $ */ public class JSVGComponent extends JGVTComponent { @@ -916,6 +916,16 @@ */ public AffineTransform getTransform() { return JSVGComponent.this.renderingTransform; + } + + /** + * Returns this user agent's CSS media. + */ + public String getMedia() { + if (svgUserAgent != null) { + return svgUserAgent.getMedia(); + } + return "screen"; } /** 1.5 +6 -1 xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgent.java Index: SVGUserAgent.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/SVGUserAgent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SVGUserAgent.java 2001/08/03 16:33:43 1.4 +++ SVGUserAgent.java 2001/10/08 15:49:38 1.5 @@ -15,7 +15,7 @@ * a JSVGComponent. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SVGUserAgent.java,v 1.4 2001/08/03 16:33:43 vhardy Exp $ + * @version $Id: SVGUserAgent.java,v 1.5 2001/10/08 15:49:38 hillion Exp $ */ public interface SVGUserAgent { @@ -55,6 +55,11 @@ * Returns the class name of the XML parser. */ String getXMLParserClassName(); + + /** + * Returns this user agent's CSS media. + */ + String getMedia(); /** * Opens a link in a new component. 1.30 +34 -1 xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java Index: ImageTranscoder.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- ImageTranscoder.java 2001/09/18 21:19:01 1.29 +++ ImageTranscoder.java 2001/10/08 15:49:38 1.30 @@ -102,7 +102,7 @@ * millimeter conversion factor. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: ImageTranscoder.java,v 1.29 2001/09/18 21:19:01 deweese Exp $ + * @version $Id: ImageTranscoder.java,v 1.30 2001/10/08 15:49:38 hillion Exp $ */ public abstract class ImageTranscoder extends XMLAbstractTranscoder { @@ -119,6 +119,8 @@ SVGConstants.SVG_SVG_TAG); hints.put(KEY_DOM_IMPLEMENTATION, ExtensibleSVGDOMImplementation.getDOMImplementation()); + hints.put(KEY_MEDIA, + "screen"); } /** @@ -389,6 +391,13 @@ } /** + * Returns this user agent's CSS media. + */ + public String getMedia() { + return (String)hints.get(KEY_MEDIA); + } + + /** * Unsupported operation. */ public EventDispatcher getEventDispatcher() { @@ -566,6 +575,30 @@ * </TABLE> */ public static final TranscodingHints.Key KEY_LANGUAGE + = new StringKey(); + + /** + * The language key. + * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH> + * <TD VALIGN="TOP">KEY_MEDIA</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH> + * <TD VALIGN="TOP">String</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH> + * <TD VALIGN="TOP">"screen"</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH> + * <TD VALIGN="TOP">No</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH> + * <TD VALIGN="TOP">Specify the media to use with CSS. + * </TD></TR> + * </TABLE> + */ + public static final TranscodingHints.Key KEY_MEDIA = new StringKey(); /** 1.16 +35 -1 xml-batik/sources/org/apache/batik/transcoder/print/PrintTranscoder.java Index: PrintTranscoder.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/print/PrintTranscoder.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- PrintTranscoder.java 2001/09/18 21:19:02 1.15 +++ PrintTranscoder.java 2001/10/08 15:49:38 1.16 @@ -109,7 +109,7 @@ * </ul> * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Hardy</a> - * @version $Id: PrintTranscoder.java,v 1.15 2001/09/18 21:19:02 deweese Exp $ + * @version $Id: PrintTranscoder.java,v 1.16 2001/10/08 15:49:38 hillion Exp $ */ public class PrintTranscoder extends XMLAbstractTranscoder implements Printable { @@ -131,6 +131,7 @@ public static final String KEY_USER_STYLESHEET_URI_STR = "userStylesheet"; public static final String KEY_WIDTH_STR = "width"; public static final String KEY_XML_PARSER_CLASSNAME_STR = "xmlParserClassName"; + public static final String VALUE_MEDIA_PRINT = "print"; public static final String VALUE_PAGE_ORIENTATION_LANDSCAPE = "landscape"; public static final String VALUE_PAGE_ORIENTATION_PORTRAIT = "portrait"; public static final String VALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE = "reverseLandscape"; @@ -196,6 +197,8 @@ SVGConstants.SVG_SVG_TAG); hints.put(KEY_DOM_IMPLEMENTATION, ExtensibleSVGDOMImplementation.getDOMImplementation()); + hints.put(KEY_MEDIA, + VALUE_MEDIA_PRINT); } public void transcode(TranscoderInput in, @@ -623,6 +626,30 @@ = new StringKey(); /** + * The CSS media. + * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH> + * <TD VALIGN="TOP">KEY_MEDIA</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH> + * <TD VALIGN="TOP">String</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH> + * <TD VALIGN="TOP">"print"</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH> + * <TD VALIGN="TOP">No</TD></TR> + * <TR> + * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH> + * <TD VALIGN="TOP">Specify the media to use with CSS. + * </TD></TR> + * </TABLE> + */ + public static final TranscodingHints.Key KEY_MEDIA + = new StringKey(); + + /** * The user stylesheet URI key. * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"> * <TR> @@ -809,6 +836,13 @@ } else { return XMLResourceDescriptor.getXMLParserClassName(); } + } + + /** + * Returns this user agent's CSS media. + */ + public String getMedia() { + return (String)hints.get(KEY_MEDIA); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]