View Javadoc

1   /**********************************************
2    * Copyright (C) 2009 Lukas Laag
3    * This file is part of lib-gwt-svg-samples.
4    * 
5    * libgwtsvg-samples is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * 
10   * libgwtsvg-samples is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License
16   * along with libgwtsvg-samples.  If not, see http://www.gnu.org/licenses/
17   **********************************************/
18  package org.vectomatic.svg.samples.client.features;
19  
20  import org.vectomatic.dom.svg.utils.DOMHelper;
21  import org.vectomatic.dom.svg.utils.SVGConstants;
22  import org.vectomatic.svg.samples.client.Main;
23  import org.vectomatic.svg.samples.client.Main.MainBundle;
24  import org.vectomatic.svg.samples.client.SampleBase;
25  
26  import com.google.gwt.core.client.GWT;
27  import com.google.gwt.dom.client.StyleInjector;
28  import com.google.gwt.uibinder.client.UiBinder;
29  import com.google.gwt.uibinder.client.UiField;
30  import com.google.gwt.user.client.ui.FlexTable;
31  import com.google.gwt.user.client.ui.TabLayoutPanel;
32  
33  public class FeaturesSample extends SampleBase {
34  	interface FeaturesSampleBinder extends UiBinder<TabLayoutPanel, FeaturesSample> {
35  	}
36  	private static FeaturesSampleBinder binder = GWT.create(FeaturesSampleBinder.class);
37  	private static final String[] features = {
38  		SVGConstants.SVG_FEATURE_ANIMATION,                                           
39  		SVGConstants.SVG_FEATURE_ANIMATION_EVENTS_ATTRIBUTE,                          
40  		SVGConstants.SVG_FEATURE_BASIC_CLIP,                                          
41  		SVGConstants.SVG_FEATURE_BASIC_FILTER,                                        
42  		SVGConstants.SVG_FEATURE_BASIC_FONT,                                          
43  		SVGConstants.SVG_FEATURE_BASIC_GRAPHICS_ATTRIBUTE,                            
44  		SVGConstants.SVG_FEATURE_BASIC_PAINT_ATTRIBUTE,                               
45  		SVGConstants.SVG_FEATURE_BASIC_STRUCTURE,                                     
46  		SVGConstants.SVG_FEATURE_BASIC_TEXT,                                          
47  		SVGConstants.SVG_FEATURE_CLIP,                                                
48  		SVGConstants.SVG_FEATURE_COLOR_PROFILE,
49  		SVGConstants.SVG_FEATURE_CONDITIONAL_PROCESSING,
50  		SVGConstants.SVG_FEATURE_CONTAINER_ATTRIBUTE,
51  		SVGConstants.SVG_FEATURE_CORE_ATTRIBUTE,
52  		SVGConstants.SVG_FEATURE_CURSOR,
53  		SVGConstants.SVG_FEATURE_DOCUMENT_EVENTS_ATTRIBUTE,
54  		SVGConstants.SVG_FEATURE_EXTENSIBILITY,
55  		SVGConstants.SVG_FEATURE_EXTERNAL_RESOURCES_REQUIRED,
56  		SVGConstants.SVG_FEATURE_FILTER,
57  		SVGConstants.SVG_FEATURE_FONT,
58  		SVGConstants.SVG_FEATURE_GRADIENT,
59  		SVGConstants.SVG_FEATURE_GRAPHICAL_EVENTS_ATTRIBUTE,
60  		SVGConstants.SVG_FEATURE_GRAPHICS_ATTRIBUTE,
61  		SVGConstants.SVG_FEATURE_HYPERLINKING,
62  		SVGConstants.SVG_FEATURE_IMAGE,
63  		SVGConstants.SVG_FEATURE_MARKER,
64  		SVGConstants.SVG_FEATURE_MASK,
65  		SVGConstants.SVG_FEATURE_OPACITY_ATTRIBUTE,
66  		SVGConstants.SVG_FEATURE_PAINT_ATTRIBUTE,
67  		SVGConstants.SVG_FEATURE_PATTERN,
68  		SVGConstants.SVG_FEATURE_SCRIPT,
69  		SVGConstants.SVG_FEATURE_SCRIPTING,
70  		SVGConstants.SVG_FEATURE_SHAPE,
71  		SVGConstants.SVG_FEATURE_STRUCTURE,
72  		SVGConstants.SVG_FEATURE_STYLE,
73  		SVGConstants.SVG_FEATURE_SVG,
74  		SVGConstants.SVG_FEATURE_SVG_ANIMATION,
75  		SVGConstants.SVG_FEATURE_SVGDOM,
76  		SVGConstants.SVG_FEATURE_SVGDOM_ANIMATION,
77  		SVGConstants.SVG_FEATURE_SVGDOM_DYNAMIC,
78  		SVGConstants.SVG_FEATURE_SVGDOM_STATIC,
79  		SVGConstants.SVG_FEATURE_SVG_DYNAMIC,
80  		SVGConstants.SVG_FEATURE_SVG_STATIC,
81  		SVGConstants.SVG_FEATURE_TEXT,
82  		SVGConstants.SVG_FEATURE_VIEW,
83  		SVGConstants.SVG_FEATURE_VIEWPORT_ATTRIBUTE,
84  		SVGConstants.SVG_FEATURE_XLINK_ATTRIBUTE,
85  		SVGConstants.SVG_FEATURE_TOUCH_EVENTS,
86  		SVGConstants.SVG_FEATURE_DND_EVENTS
87  	};
88  
89  	@UiField(provided=true)
90  	public static MainBundle mainBundle = Main.mainBundle;
91  	@UiField
92  	FlexTable table;
93  
94  	@Override
95  	public TabLayoutPanel getPanel() {
96  		if (tabPanel == null) {
97  			FeaturesCss css = FeaturesBundle.INSTANCE.getCss();
98  			
99  			// Inject CSS in the document headers
100 			StyleInjector.inject(css.getText());
101 			
102 			// Initialize the UI with UiBinder
103 			tabPanel = binder.createAndBindUi(this);
104 			tabPanel.setTabText(0, "Features");
105 			createCodeTabs("FeaturesSample");
106 			
107 			// Test all the feature names
108 			table.setText(0, 0, "Feature name");
109 			table.getCellFormatter().addStyleName(0, 0, css.header());
110 			table.setText(0, 1, "Supported");
111 			table.getCellFormatter().addStyleName(0, 1, css.header());
112 			for (int i = 0; i < features.length; i++) {
113 				table.setText(i + 1, 0, features[i]);
114 				boolean hasFeature = DOMHelper.hasFeature(features[i]);
115 				table.setText(i + 1, 1, hasFeature ? "yes" : "no");
116 				table.getCellFormatter().addStyleName(i + 1, 1, hasFeature ? css.supported() : css.unsupported());
117 			}
118 		}
119 		return tabPanel;
120 	}
121 
122 }
123