View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.renderkit;
21  
22  import org.apache.myfaces.tobago.component.Attributes;
23  import org.apache.myfaces.tobago.config.Configurable;
24  import org.apache.myfaces.tobago.context.ClientProperties;
25  import org.apache.myfaces.tobago.layout.Measure;
26  
27  import javax.faces.context.FacesContext;
28  
29  public abstract class LayoutComponentRendererBase extends RendererBase implements LayoutComponentRenderer {
30  
31    public Measure getCustomMeasure(final FacesContext facesContext, final Configurable component, final String name) {
32      return getResourceManager().getThemeMeasure(facesContext, component, name);
33    }
34  
35    public Measure getWidth(final FacesContext facesContext, final Configurable component) {
36      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.WIDTH);
37    }
38  
39    public Measure getHeight(final FacesContext facesContext, final Configurable component) {
40      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.HEIGHT);
41    }
42  
43    public Measure getMinimumWidth(final FacesContext facesContext, final Configurable component) {
44      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MINIMUM_WIDTH);
45    }
46  
47    public Measure getMinimumHeight(final FacesContext facesContext, final Configurable component) {
48      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MINIMUM_HEIGHT);
49    }
50  
51    public Measure getPreferredWidth(final FacesContext facesContext, final Configurable component) {
52      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PREFERRED_WIDTH);
53    }
54  
55    public Measure getPreferredHeight(final FacesContext facesContext, final Configurable component) {
56      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PREFERRED_HEIGHT);
57    }
58  
59    public Measure getMaximumWidth(final FacesContext facesContext, final Configurable component) {
60      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MAXIMUM_WIDTH);
61    }
62  
63    public Measure getMaximumHeight(final FacesContext facesContext, final Configurable component) {
64      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MAXIMUM_HEIGHT);
65    }
66  
67    public Measure getMarginLeft(final FacesContext facesContext, final Configurable component) {
68      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_LEFT);
69    }
70  
71    public Measure getMarginRight(final FacesContext facesContext, final Configurable component) {
72      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_RIGHT);
73    }
74  
75    public Measure getMarginTop(final FacesContext facesContext, final Configurable component) {
76      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_TOP);
77    }
78  
79    public Measure getMarginBottom(final FacesContext facesContext, final Configurable component) {
80      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_BOTTOM);
81    }
82  
83    public Measure getBorderLeft(final FacesContext facesContext, final Configurable component) {
84      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_LEFT);
85    }
86  
87    public Measure getBorderRight(final FacesContext facesContext, final Configurable component) {
88      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_RIGHT);
89    }
90  
91    public Measure getBorderTop(final FacesContext facesContext, final Configurable component) {
92      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_TOP);
93    }
94  
95    public Measure getBorderBottom(final FacesContext facesContext, final Configurable component) {
96      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_BOTTOM);
97    }
98  
99    public Measure getPaddingLeft(final FacesContext facesContext, final Configurable component) {
100     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_LEFT);
101   }
102 
103   public Measure getPaddingRight(final FacesContext facesContext, final Configurable component) {
104     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_RIGHT);
105   }
106 
107   public Measure getPaddingTop(final FacesContext facesContext, final Configurable component) {
108     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_TOP);
109   }
110 
111   public Measure getPaddingBottom(final FacesContext facesContext, final Configurable component) {
112     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_BOTTOM);
113   }
114 
115   public Measure getVerticalScrollbarWeight(final FacesContext facesContext, final Configurable component) {
116     final ClientProperties clientProperties = ClientProperties.getInstance(facesContext);
117     final Measure weight = clientProperties.getVerticalScrollbarWeight();
118     if (weight != null) {
119       return weight;
120     } else { // default
121       return getResourceManager().getThemeMeasure(facesContext, component, "verticalScrollbarWeight");
122     }
123   }
124 }