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  import org.apache.myfaces.tobago.util.VariableResolverUtils;
27  
28  import javax.faces.context.FacesContext;
29  
30  public abstract class LayoutComponentRendererBase extends RendererBase implements LayoutComponentRenderer {
31  
32    public Measure getCustomMeasure(FacesContext facesContext, Configurable component, String name) {
33      return getResourceManager().getThemeMeasure(facesContext, component, name);
34    }
35  
36    public Measure getWidth(FacesContext facesContext, Configurable component) {
37      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.WIDTH);
38    }
39  
40    public Measure getHeight(FacesContext facesContext, Configurable component) {
41      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.HEIGHT);
42    }
43  
44    public Measure getMinimumWidth(FacesContext facesContext, Configurable component) {
45      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MINIMUM_WIDTH);
46    }
47  
48    public Measure getMinimumHeight(FacesContext facesContext, Configurable component) {
49      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MINIMUM_HEIGHT);
50    }
51  
52    public Measure getPreferredWidth(FacesContext facesContext, Configurable component) {
53      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PREFERRED_WIDTH);
54    }
55  
56    public Measure getPreferredHeight(FacesContext facesContext, Configurable component) {
57      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PREFERRED_HEIGHT);
58    }
59  
60    public Measure getMaximumWidth(FacesContext facesContext, Configurable component) {
61      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MAXIMUM_WIDTH);
62    }
63  
64    public Measure getMaximumHeight(FacesContext facesContext, Configurable component) {
65      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MAXIMUM_HEIGHT);
66    }
67  
68    public Measure getMarginLeft(FacesContext facesContext, Configurable component) {
69      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_LEFT);
70    }
71  
72    public Measure getMarginRight(FacesContext facesContext, Configurable component) {
73      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_RIGHT);
74    }
75  
76    public Measure getMarginTop(FacesContext facesContext, Configurable component) {
77      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_TOP);
78    }
79  
80    public Measure getMarginBottom(FacesContext facesContext, Configurable component) {
81      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_BOTTOM);
82    }
83  
84    public Measure getBorderLeft(FacesContext facesContext, Configurable component) {
85      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_LEFT);
86    }
87  
88    public Measure getBorderRight(FacesContext facesContext, Configurable component) {
89      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_RIGHT);
90    }
91  
92    public Measure getBorderTop(FacesContext facesContext, Configurable component) {
93      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_TOP);
94    }
95  
96    public Measure getBorderBottom(FacesContext facesContext, Configurable component) {
97      return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_BOTTOM);
98    }
99  
100   public Measure getPaddingLeft(FacesContext facesContext, Configurable component) {
101     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_LEFT);
102   }
103 
104   public Measure getPaddingRight(FacesContext facesContext, Configurable component) {
105     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_RIGHT);
106   }
107 
108   public Measure getPaddingTop(FacesContext facesContext, Configurable component) {
109     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_TOP);
110   }
111 
112   public Measure getPaddingBottom(FacesContext facesContext, Configurable component) {
113     return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_BOTTOM);
114   }
115 
116   public Measure getVerticalScrollbarWeight(FacesContext facesContext, Configurable component) {
117     final ClientProperties clientProperties = VariableResolverUtils.resolveClientProperties(facesContext);
118     final Measure weight = clientProperties.getVerticalScrollbarWeight();
119     if (weight != null) {
120       return weight;
121     } else { // default
122       return getResourceManager().getThemeMeasure(facesContext, component, "verticalScrollbarWeight");
123     }
124   }
125 }