You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/11/11 14:08:12 UTC

svn commit: r834868 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/layout/ core/src/main/java/org/apache/myfaces/tobago/layout/grid/ extension/math/src/main/java/org/apac...

Author: lofwyr
Date: Wed Nov 11 13:08:11 2009
New Revision: 834868

URL: http://svn.apache.org/viewvc?rev=834868&view=rev
Log:
TOBAGO-606: Layout Manager: replace boolean with enum Orientation

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Orientation.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISheetLayout.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroupLayout.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Interval.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContext.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutManager.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/OriginCell.java
    myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIGridLayout.java Wed Nov 11 13:08:11 2009
@@ -31,6 +31,7 @@
 import org.apache.myfaces.tobago.layout.LayoutTokens;
 import org.apache.myfaces.tobago.layout.LayoutUtils;
 import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.Orientation;
 import org.apache.myfaces.tobago.layout.PixelLayoutToken;
 import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
@@ -66,7 +67,7 @@
     }
   }
 
-  public void fixRelativeInsideAuto(boolean orientation, boolean auto) {
+  public void fixRelativeInsideAuto(Orientation orientation, boolean auto) {
 
     LayoutTokens tokens = grid.getTokens(orientation);
 
@@ -80,7 +81,7 @@
     }
 
     for (int i = 0; i < tokens.getSize(); i++) {
-      for (int j = 0; j < grid.getTokens(!orientation).getSize(); j++) {
+      for (int j = 0; j < grid.getTokens(orientation.other()).getSize(); j++) {
         Cell cell = grid.getCell(i, j, orientation);
         if (cell instanceof OriginCell) {
           OriginCell origin = (OriginCell) cell;
@@ -96,7 +97,7 @@
     }
   }
 
-  public void preProcessing(boolean orientation) {
+  public void preProcessing(Orientation orientation) {
 
     // process auto tokens
     int i = 0;
@@ -108,7 +109,7 @@
       }
 
       IntervalList intervals = new IntervalList();
-      for (int j = 0; j < grid.getTokens(!orientation).getSize(); j++) {
+      for (int j = 0; j < grid.getTokens(orientation.other()).getSize(); j++) {
         Cell cell = grid.getCell(i, j, orientation);
         if (cell instanceof OriginCell) {
           OriginCell origin = (OriginCell) cell;
@@ -155,7 +156,7 @@
     }
   }
 
-  public void mainProcessing(boolean orientation) {
+  public void mainProcessing(Orientation orientation) {
 
     // find *
     FactorList list = new FactorList();
@@ -198,7 +199,7 @@
 
     // call manage sizes for all sub-layout-managers
     for (int i = 0; i < grid.getTokens(orientation).getSize(); i++) {
-      for (int j = 0; j < grid.getTokens(!orientation).getSize(); j++) {
+      for (int j = 0; j < grid.getTokens(orientation.other()).getSize(); j++) {
         Cell cell = grid.getCell(i, j, orientation);
         if (cell instanceof OriginCell) {
           LayoutComponent component = cell.getComponent();
@@ -229,11 +230,11 @@
     }
   }
 
-  public void postProcessing(boolean orientation) {
+  public void postProcessing(Orientation orientation) {
 
     // call manage sizes for all sub-layout-managers
     for (int i = 0; i < grid.getTokens(orientation).getSize(); i++) {
-      for (int j = 0; j < grid.getTokens(!orientation).getSize(); j++) {
+      for (int j = 0; j < grid.getTokens(orientation.other()).getSize(); j++) {
         Cell cell = grid.getCell(i, j, orientation);
         if (cell instanceof OriginCell) {
           LayoutComponent component = cell.getComponent();
@@ -252,7 +253,7 @@
             }
             position = position.add(getSpacing(orientation));
           }
-          if (orientation) {
+          if (orientation == Orientation.HORIZONTAL) {
             component.setLeft(position);
           } else {
             component.setTop(position);
@@ -278,8 +279,8 @@
     return grid;
   }
 
-  public Measure getSpacing(boolean horizontal) {
-    return horizontal ? getColumnSpacing() : getRowSpacing();
+  public Measure getSpacing(Orientation orientation) {
+    return orientation == Orientation.HORIZONTAL ? getColumnSpacing() : getRowSpacing();
   }
 
   public abstract String getRows();

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java Wed Nov 11 13:08:11 2009
@@ -20,7 +20,6 @@
 import org.apache.commons.collections.KeyValue;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.compat.InvokeOnComponent;
 import org.apache.myfaces.tobago.layout.Box;
@@ -48,7 +47,9 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
-public abstract class AbstractUIPage extends AbstractUIForm 
+import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
+
+public abstract class AbstractUIPage extends AbstractUIForm
     implements OnComponentPopulated, InvokeOnComponent, LayoutContainer, DeprecatedDimension {
 
   private static final Log LOG = LogFactory.getLog(AbstractUIPage.class);
@@ -87,40 +88,19 @@
   public void encodeBegin(FacesContext facesContext) throws IOException {
 
     super.encodeBegin(facesContext);
-
-    UILayout layoutManager = (UILayout) getLayoutManager();
-    if (layoutManager != null) {
-      layoutManager.encodeBegin(facesContext);
-    } else {
-      // todo: later: LOG.debug or remove
-      LOG.warn("no layout manager found");
-    }
+    ((UILayout) getLayoutManager()).encodeBegin(facesContext);
   }
 
   @Override
   public void encodeChildren(FacesContext facesContext) throws IOException {
 
-    UILayout layoutManager = (UILayout) getLayoutManager();
-    if (layoutManager != null) {
-      layoutManager.encodeChildren(facesContext);
-    } else {
-      // todo: later: LOG.debug or remove
-      LOG.warn("no layout manager found");
-      super.encodeChildren(facesContext);
-    }
+    ((UILayout) getLayoutManager()).encodeChildren(facesContext);
   }
 
   @Override
   public void encodeEnd(FacesContext facesContext) throws IOException {
 
-    UILayout layoutManager = (UILayout) getLayoutManager();
-    if (layoutManager != null) {
-      layoutManager.encodeEnd(facesContext);
-    } else {
-      // todo: later: LOG.debug or remove
-      LOG.warn("no layout manager found");
-    }
-
+    ((UILayout) getLayoutManager()).encodeEnd(facesContext);
     super.encodeEnd(facesContext);
   }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java Wed Nov 11 13:08:11 2009
@@ -28,7 +28,7 @@
 import java.io.IOException;
 import java.util.List;
 
-public abstract class AbstractUIPanel extends UIPanelBase 
+public abstract class AbstractUIPanel extends UIPanelBase
     implements OnComponentPopulated, LayoutContainer, LayoutComponent {
 
   private static final Log LOG = LogFactory.getLog(AbstractUIPanel.class);
@@ -37,40 +37,19 @@
   public void encodeBegin(FacesContext facesContext) throws IOException {
 
     super.encodeBegin(facesContext);
-
-    UILayout layoutManager = (UILayout) getLayoutManager();
-    if (layoutManager != null) {
-      layoutManager.encodeBegin(facesContext);
-    } else {
-      // todo: later: LOG.debug or remove
-      LOG.warn("no layout manager found");
-    }
+    ((UILayout) getLayoutManager()).encodeBegin(facesContext);
   }
 
   @Override
   public void encodeChildren(FacesContext facesContext) throws IOException {
 
-    UILayout layoutManager = (UILayout) getLayoutManager();
-    if (layoutManager != null) {
-      layoutManager.encodeChildren(facesContext);
-    } else {
-      // todo: later: LOG.debug or remove
-      LOG.warn("no layout manager found");
-      super.encodeChildren(facesContext);
-    }
+    ((UILayout) getLayoutManager()).encodeChildren(facesContext);
   }
 
   @Override
   public void encodeEnd(FacesContext facesContext) throws IOException {
 
-    UILayout layoutManager = (UILayout) getLayoutManager();
-    if (layoutManager != null) {
-      layoutManager.encodeEnd(facesContext);
-    } else {
-      // todo: later: LOG.debug or remove
-      LOG.warn("no layout manager found");
-    }
-
+    ((UILayout) getLayoutManager()).encodeEnd(facesContext);
     super.encodeEnd(facesContext);
   }
 
@@ -80,7 +59,7 @@
           facesContext, ComponentTypes.GRID_LAYOUT, RendererTypes.GRID_LAYOUT));
     }
   }
-  
+
   public List<LayoutComponent> getComponents() {
     return LayoutUtils.findLayoutChildren(this);
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISheetLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISheetLayout.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISheetLayout.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUISheetLayout.java Wed Nov 11 13:08:11 2009
@@ -27,6 +27,7 @@
 import org.apache.myfaces.tobago.layout.LayoutManager;
 import org.apache.myfaces.tobago.layout.LayoutUtils;
 import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.Orientation;
 
 public abstract class AbstractUISheetLayout extends UILayout implements LayoutManager {
 
@@ -43,9 +44,9 @@
     }
   }
 
-  public void fixRelativeInsideAuto(boolean orientation, boolean auto) {
+  public void fixRelativeInsideAuto(Orientation orientation, boolean auto) {
 
-    if (orientation) {
+    if (orientation == Orientation.HORIZONTAL) {
       horizontalAuto = auto;
     } else {
       verticalAuto = auto;
@@ -58,7 +59,7 @@
     }
   }
 
-  public void preProcessing(boolean orientation) {
+  public void preProcessing(Orientation orientation) {
 
     // process auto tokens
     int i = 0;
@@ -69,7 +70,8 @@
         ((LayoutContainer) component).getLayoutManager().preProcessing(orientation);
       }
 
-      if (orientation && horizontalAuto || !orientation && verticalAuto) {
+      if (orientation == Orientation.HORIZONTAL && horizontalAuto 
+          || orientation == Orientation.VERTICAL && verticalAuto) {
         intervals.add(new Interval(component, orientation));
       }
     }
@@ -82,10 +84,11 @@
     }
   }
 
-  public void mainProcessing(boolean orientation) {
+  public void mainProcessing(Orientation orientation) {
 
     // find *
-    if (orientation && !horizontalAuto || !orientation && !verticalAuto) {
+    if (orientation == Orientation.HORIZONTAL && !horizontalAuto 
+        || orientation == Orientation.VERTICAL && !verticalAuto) {
       // find rest
       LayoutContainer container = getLayoutContainer();
       Measure available = LayoutUtils.getSize(orientation, container);
@@ -110,7 +113,7 @@
     }
   }
 
-  public void postProcessing(boolean orientation) {
+  public void postProcessing(Orientation orientation) {
 
     // set positions to all sub-layout-managers
 
@@ -120,7 +123,7 @@
 
       // compute the position of the cell
       Measure position = LayoutUtils.getBeginOffset(orientation, getLayoutContainer());
-      if (orientation) {
+      if (orientation == Orientation.HORIZONTAL) {
         component.setLeft(position);
       } else {
         component.setTop(position);

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroupLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroupLayout.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroupLayout.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroupLayout.java Wed Nov 11 13:08:11 2009
@@ -27,6 +27,7 @@
 import org.apache.myfaces.tobago.layout.LayoutManager;
 import org.apache.myfaces.tobago.layout.LayoutUtils;
 import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.Orientation;
 
 public abstract class AbstractUITabGroupLayout extends UILayout implements LayoutManager {
 
@@ -43,9 +44,9 @@
     }
   }
 
-  public void fixRelativeInsideAuto(boolean orientation, boolean auto) {
+  public void fixRelativeInsideAuto(Orientation orientation, boolean auto) {
 
-    if (orientation) {
+    if (orientation == Orientation.HORIZONTAL) {
       horizontalAuto = auto;
     } else {
       verticalAuto = auto;
@@ -58,7 +59,7 @@
     }
   }
 
-  public void preProcessing(boolean orientation) {
+  public void preProcessing(Orientation orientation) {
 
     // process auto tokens
     int i = 0;
@@ -69,7 +70,8 @@
         ((LayoutContainer) component).getLayoutManager().preProcessing(orientation);
       }
 
-      if (orientation && horizontalAuto || !orientation && verticalAuto) {
+      if (orientation == Orientation.HORIZONTAL && horizontalAuto 
+          || orientation == Orientation.VERTICAL && verticalAuto) {
         intervals.add(new Interval(component, orientation));
       }
     }
@@ -82,10 +84,11 @@
     }
   }
 
-  public void mainProcessing(boolean orientation) {
+  public void mainProcessing(Orientation orientation) {
 
     // find *
-    if (orientation && !horizontalAuto || !orientation && !verticalAuto) {
+    if (orientation == Orientation.HORIZONTAL && !horizontalAuto 
+        || orientation == Orientation.VERTICAL && !verticalAuto) {
       // find rest
       LayoutContainer container = getLayoutContainer();
       Measure available = LayoutUtils.getSize(orientation, container);
@@ -110,7 +113,7 @@
     }
   }
 
-  public void postProcessing(boolean orientation) {
+  public void postProcessing(Orientation orientation) {
 
     // set positions to all sub-layout-managers
 
@@ -120,7 +123,7 @@
 
       // compute the position of the cell
       Measure position = LayoutUtils.getBeginOffset(orientation, getLayoutContainer());
-      if (orientation) {
+      if (orientation == Orientation.HORIZONTAL) {
         component.setLeft(position);
       } else {
         component.setTop(position);

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Interval.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Interval.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Interval.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Interval.java Wed Nov 11 13:08:11 2009
@@ -27,12 +27,12 @@
 
   private Measure fixed;
 
-  public Interval(LayoutComponent component, boolean horizontal) {
+  public Interval(LayoutComponent component, Orientation orientation) {
     this(
-        horizontal ? component.getMinimumWidth() : component.getMinimumHeight(),
-        horizontal ? component.getPreferredWidth() : component.getPreferredHeight(),
-        horizontal ? component.getMaximumWidth() : component.getMaximumHeight(),
-        horizontal ? component.getWidth() : component.getHeight());
+        orientation == Orientation.HORIZONTAL ? component.getMinimumWidth() : component.getMinimumHeight(),
+        orientation == Orientation.HORIZONTAL ? component.getPreferredWidth() : component.getPreferredHeight(),
+        orientation == Orientation.HORIZONTAL ? component.getMaximumWidth() : component.getMaximumHeight(),
+        orientation == Orientation.HORIZONTAL ? component.getWidth() : component.getHeight());
   }
 
   public Interval(Measure minimum, Measure preferred, Measure maximum, Measure fixed) {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContext.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContext.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContext.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutContext.java Wed Nov 11 13:08:11 2009
@@ -57,14 +57,14 @@
 
     LayoutManager layoutManager = container.getLayoutManager();
     layoutManager.init();
-    layoutManager.fixRelativeInsideAuto(true, false);
-    layoutManager.fixRelativeInsideAuto(false, false);
-    layoutManager.preProcessing(true);
-    layoutManager.preProcessing(false);
-    layoutManager.mainProcessing(true);
-    layoutManager.mainProcessing(false);
-    layoutManager.postProcessing(true);
-    layoutManager.postProcessing(false);
+    layoutManager.fixRelativeInsideAuto(Orientation.HORIZONTAL, false);
+    layoutManager.fixRelativeInsideAuto(Orientation.VERTICAL, false);
+    layoutManager.preProcessing(Orientation.HORIZONTAL);
+    layoutManager.preProcessing(Orientation.VERTICAL);
+    layoutManager.mainProcessing(Orientation.HORIZONTAL);
+    layoutManager.mainProcessing(Orientation.VERTICAL);
+    layoutManager.postProcessing(Orientation.HORIZONTAL);
+    layoutManager.postProcessing(Orientation.VERTICAL);
 
     StringBuffer buffer = new StringBuffer("\n");
     debug(buffer, container, 0);

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutManager.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutManager.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutManager.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutManager.java Wed Nov 11 13:08:11 2009
@@ -21,11 +21,11 @@
 
   void init();
 
-  void fixRelativeInsideAuto(boolean orientation, boolean auto);
+  void fixRelativeInsideAuto(Orientation orientation, boolean auto);
 
-  void preProcessing(boolean orientation);
+  void preProcessing(Orientation orientation);
 
-  void mainProcessing(boolean orientation);
+  void mainProcessing(Orientation orientation);
 
-  void postProcessing(boolean orientation);
+  void postProcessing(Orientation orientation);
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutUtils.java Wed Nov 11 13:08:11 2009
@@ -119,21 +119,20 @@
     }
   }
 
-  public static Measure getEndOffset(boolean orientation, LayoutContainer container) {
-    return orientation ? container.getRightOffset() : container.getBottomOffset();
+  public static Measure getEndOffset(Orientation orientation, LayoutContainer container) {
+    return orientation == Orientation.HORIZONTAL ? container.getRightOffset() : container.getBottomOffset();
   }
 
-  public static Measure getBeginOffset(boolean orientation, LayoutContainer container) {
-    return orientation ? container.getLeftOffset() : container.getTopOffset();
+  public static Measure getBeginOffset(Orientation orientation, LayoutContainer container) {
+    return orientation == Orientation.HORIZONTAL ? container.getLeftOffset() : container.getTopOffset();
   }
 
-  public static Measure getSize(boolean orientation, LayoutContainer container) {
-    Measure available = orientation ? container.getWidth() : container.getHeight();
-    return available;
+  public static Measure getSize(Orientation orientation, LayoutContainer container) {
+    return orientation == Orientation.HORIZONTAL ? container.getWidth() : container.getHeight();
   }
 
-  public static void setSize(boolean orientation, LayoutObject component, Measure size) {
-    if (orientation) {
+  public static void setSize(Orientation orientation, LayoutObject component, Measure size) {
+    if (orientation == Orientation.HORIZONTAL) {
       if (component.getWidth() != null) { // to not override set sizes
         return;
       }

Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Orientation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Orientation.java?rev=834868&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Orientation.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/Orientation.java Wed Nov 11 13:08:11 2009
@@ -0,0 +1,32 @@
+package org.apache.myfaces.tobago.layout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public enum Orientation {
+  
+  HORIZONTAL,
+  VERTICAL;
+  
+  public Orientation other() {
+    if (this == HORIZONTAL) {
+      return VERTICAL;
+    } else {
+      return HORIZONTAL;
+    }
+  }
+}

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/Grid.java Wed Nov 11 13:08:11 2009
@@ -21,6 +21,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.layout.AutoLayoutToken;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
+import org.apache.myfaces.tobago.layout.Orientation;
 import org.apache.myfaces.tobago.layout.PixelMeasure;
 
 import java.util.ArrayList;
@@ -33,7 +34,7 @@
 
   // TODO: check if it is faster with arrays.
   /**
-   * The rectangular data as a 1-dim list;
+   * The rectangular data as a 1-dim list
    */
   private List<Cell> cells;
   private LayoutTokens columns;
@@ -109,8 +110,8 @@
     findNextFreeCell();
   }
 
-  public Cell getCell(int i, int j, boolean horizontal) {
-    return horizontal ? getCell(i, j) : getCell(j, i);
+  public Cell getCell(int i, int j, Orientation orientation) {
+    return orientation == Orientation.HORIZONTAL ? getCell(i, j) : getCell(j, i);
   }
 
   public Cell getCell(int column, int row) {
@@ -142,8 +143,8 @@
     }
   }
 
-  public LayoutTokens getTokens(boolean horizontal) {
-    return horizontal ? getColumns() : getRows();
+  public LayoutTokens getTokens(Orientation orientation) {
+    return orientation == Orientation.HORIZONTAL ? getColumns() : getRows();
   }
 
   public LayoutTokens getColumns() {
@@ -470,8 +471,8 @@
     this.verticalIndices = verticalIndices;
   }
 
-  public PixelMeasure[] getSizes(boolean horizontal) {
-    return horizontal ? getWidths() : getHeights();
+  public PixelMeasure[] getSizes(Orientation orientation) {
+    return orientation == Orientation.HORIZONTAL ? getWidths() : getHeights();
   }
 
   public PixelMeasure[] getWidths() {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/OriginCell.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/OriginCell.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/OriginCell.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/grid/OriginCell.java Wed Nov 11 13:08:11 2009
@@ -18,6 +18,7 @@
  */
 
 import org.apache.myfaces.tobago.layout.LayoutComponent;
+import org.apache.myfaces.tobago.layout.Orientation;
 
 public class OriginCell implements Cell {
 
@@ -45,8 +46,8 @@
     return true;
   }
 
-  public int getSpan(boolean horizontal) {
-    return horizontal ? getColumnSpan() : getRowSpan();
+  public int getSpan(Orientation orientation) {
+    return orientation == Orientation.HORIZONTAL ? getColumnSpan() : getRowSpan();
   }
 
   public int getColumnSpan() {

Modified: myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java?rev=834868&r1=834867&r2=834868&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java (original)
+++ myfaces/tobago/trunk/extension/math/src/main/java/org/apache/myfaces/tobago/component/AbstractUIEquationGridLayout.java Wed Nov 11 13:08:11 2009
@@ -27,6 +27,7 @@
 import org.apache.myfaces.tobago.layout.LayoutToken;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
 import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.Orientation;
 import org.apache.myfaces.tobago.layout.PixelLayoutToken;
 import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
@@ -264,19 +265,19 @@
     }
   }
 
-  public void fixRelativeInsideAuto(boolean orientation, boolean auto) {
+  public void fixRelativeInsideAuto(Orientation orientation, boolean auto) {
     //To change body of implemented methods use File | Settings | File Templates.
   }
 
-  public void preProcessing(boolean orientation) {
+  public void preProcessing(Orientation orientation) {
     //To change body of implemented methods use File | Settings | File Templates.
   }
 
-  public void mainProcessing(boolean orientation) {
+  public void mainProcessing(Orientation orientation) {
     //To change body of implemented methods use File | Settings | File Templates.
   }
 
-  public void postProcessing(boolean orientation) {
+  public void postProcessing(Orientation orientation) {
     //To change body of implemented methods use File | Settings | File Templates.
   }