001 package org.apache.myfaces.tobago.renderkit; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020 import org.apache.myfaces.tobago.component.Attributes; 021 import org.apache.myfaces.tobago.config.Configurable; 022 import org.apache.myfaces.tobago.context.ClientProperties; 023 import org.apache.myfaces.tobago.layout.Measure; 024 import org.apache.myfaces.tobago.util.VariableResolverUtils; 025 026 import javax.faces.context.FacesContext; 027 028 public abstract class LayoutComponentRendererBase extends RendererBase implements LayoutComponentRenderer { 029 030 public Measure getCustomMeasure(FacesContext facesContext, Configurable component, String name) { 031 return getResourceManager().getThemeMeasure(facesContext, component, name); 032 } 033 034 public Measure getWidth(FacesContext facesContext, Configurable component) { 035 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.WIDTH); 036 } 037 038 public Measure getHeight(FacesContext facesContext, Configurable component) { 039 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.HEIGHT); 040 } 041 042 public Measure getMinimumWidth(FacesContext facesContext, Configurable component) { 043 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MINIMUM_WIDTH); 044 } 045 046 public Measure getMinimumHeight(FacesContext facesContext, Configurable component) { 047 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MINIMUM_HEIGHT); 048 } 049 050 public Measure getPreferredWidth(FacesContext facesContext, Configurable component) { 051 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PREFERRED_WIDTH); 052 } 053 054 public Measure getPreferredHeight(FacesContext facesContext, Configurable component) { 055 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PREFERRED_HEIGHT); 056 } 057 058 public Measure getMaximumWidth(FacesContext facesContext, Configurable component) { 059 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MAXIMUM_WIDTH); 060 } 061 062 public Measure getMaximumHeight(FacesContext facesContext, Configurable component) { 063 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MAXIMUM_HEIGHT); 064 } 065 066 public Measure getMarginLeft(FacesContext facesContext, Configurable component) { 067 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_LEFT); 068 } 069 070 public Measure getMarginRight(FacesContext facesContext, Configurable component) { 071 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_RIGHT); 072 } 073 074 public Measure getMarginTop(FacesContext facesContext, Configurable component) { 075 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_TOP); 076 } 077 078 public Measure getMarginBottom(FacesContext facesContext, Configurable component) { 079 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.MARGIN_BOTTOM); 080 } 081 082 public Measure getBorderLeft(FacesContext facesContext, Configurable component) { 083 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_LEFT); 084 } 085 086 public Measure getBorderRight(FacesContext facesContext, Configurable component) { 087 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_RIGHT); 088 } 089 090 public Measure getBorderTop(FacesContext facesContext, Configurable component) { 091 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_TOP); 092 } 093 094 public Measure getBorderBottom(FacesContext facesContext, Configurable component) { 095 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.BORDER_BOTTOM); 096 } 097 098 public Measure getPaddingLeft(FacesContext facesContext, Configurable component) { 099 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_LEFT); 100 } 101 102 public Measure getPaddingRight(FacesContext facesContext, Configurable component) { 103 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_RIGHT); 104 } 105 106 public Measure getPaddingTop(FacesContext facesContext, Configurable component) { 107 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_TOP); 108 } 109 110 public Measure getPaddingBottom(FacesContext facesContext, Configurable component) { 111 return getResourceManager().getThemeMeasure(facesContext, component, Attributes.PADDING_BOTTOM); 112 } 113 114 public Measure getVerticalScrollbarWeight(FacesContext facesContext, Configurable component) { 115 final ClientProperties clientProperties = VariableResolverUtils.resolveClientProperties(facesContext); 116 final Measure weight = clientProperties.getVerticalScrollbarWeight(); 117 if (weight != null) { 118 return weight; 119 } else { // default 120 return getResourceManager().getThemeMeasure(facesContext, component, "verticalScrollbarWeight"); 121 } 122 } 123 }