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/08/14 12:00:44 UTC

svn commit: r804149 - in /myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout: ./ math/

Author: lofwyr
Date: Fri Aug 14 10:00:43 2009
New Revision: 804149

URL: http://svn.apache.org/viewvc?rev=804149&view=rev
Log:
TOBAGO-606: Layout-Manager
 - add more information for debugging (id of the UIComponent)

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/AbstractEquation.java
      - copied, changed from r803589, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/Equation.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.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/math/CombinationEquation.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationManager.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/FixedEquation.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/PartitionEquation.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ProportionEquation.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/RemainderEquation.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java Fri Aug 14 10:00:43 2009
@@ -22,6 +22,6 @@
   public static final AutoLayoutToken INSTANCE = new AutoLayoutToken();
 
   public String toString() {
-    return "fixed";
+    return "auto";
   }
 }

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=804149&r1=804148&r2=804149&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 Fri Aug 14 10:00:43 2009
@@ -45,10 +45,10 @@
     vertical.addComponentRoot();
 
     if (container.getWidth() != null) {
-      horizontal.setFixedLength(0, container.getWidth(), container.getClass().getSimpleName());
+      horizontal.setFixedLength(0, container.getWidth(), container);
     }
     if (container.getHeight() != null) {
-      vertical.setFixedLength(0, container.getHeight(), container.getClass().getSimpleName());
+      vertical.setFixedLength(0, container.getHeight(), container);
     }
 
     container.getLayoutManager().collect(this, container, 0, 0);

Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/AbstractEquation.java (from r803589, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/Equation.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/AbstractEquation.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/AbstractEquation.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/Equation.java&r1=803589&r2=804149&rev=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/Equation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/AbstractEquation.java Fri Aug 14 10:00:43 2009
@@ -1,5 +1,8 @@
 package org.apache.myfaces.tobago.layout.math;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -17,18 +20,26 @@
  * limitations under the License.
  */
 
-public interface Equation {
+public abstract class AbstractEquation implements Equation {
+
+  public Object debug;
 
-  /**
-   * The row has the format: index 0 to n-2 are the factors and index n-1 is the result.
-   * @param length The length of the array which has to be created.
-   */
-  double[] fillRow(int length);
-
-  /**
-   * Priority for sorting.
-   * @return Large values represent a high priority
-   */
-  int priority();
+  protected AbstractEquation(Object debug) {
+    this.debug = debug;
+  }
 
+  public void appendDebug(StringBuilder builder) {
+    if (debug instanceof UIComponent) {
+      UIComponent component = (UIComponent) debug;
+      builder.append(" (");
+      builder.append(component.getClass().getSimpleName());
+      builder.append(", id=");
+      builder.append(component.getClientId(FacesContext.getCurrentInstance()));
+      builder.append(")");
+    } else {
+      builder.append(" (");
+      builder.append(debug);
+      builder.append(")");
+    }
+  }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/CombinationEquation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/CombinationEquation.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/CombinationEquation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/CombinationEquation.java Fri Aug 14 10:00:43 2009
@@ -25,13 +25,12 @@
  * In this example are: begin=4, end=6, parent=2, span=1
  * Because of the algorithm we have indices without gap.
  */
-public final class CombinationEquation implements Equation {
+public final class CombinationEquation extends AbstractEquation {
 
   private int newIndex;
   private int parent;
   private int span;
   private Measure spacing;
-  private String component;
 
   /**
    * @param newIndex new index
@@ -39,12 +38,12 @@
    * @param span     number of parent cells
    * @param spacing  space between two cells inside the span
    */
-  public CombinationEquation(int newIndex, int parent, int span, Measure spacing, String component) {
+  public CombinationEquation(int newIndex, int parent, int span, Measure spacing, Object debug) {
+    super(debug);
     this.newIndex = newIndex;
     this.parent = parent;
     this.span = span;
     this.spacing = spacing;
-    this.component = component;
   }
 
   public double[] fillRow(int length) {
@@ -122,9 +121,7 @@
     builder.append("x_");
     builder.append(newIndex);
 
-    builder.append(" (");
-    builder.append(component);
-    builder.append(")");
+    appendDebug(builder);
 
     return builder.toString();
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationManager.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationManager.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationManager.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationManager.java Fri Aug 14 10:00:43 2009
@@ -32,40 +32,40 @@
     return 0;
   }
 
-  public void setFixedLength(int index, Measure length, String component) {
-    equations.addEqualsEquation(new FixedEquation(index, length, component));
+  public void setFixedLength(int index, Measure length, Object debug) {
+    equations.addEqualsEquation(new FixedEquation(index, length, debug));
   }
 
   public int[] partition(
-      int index, int number, Measure spacing, Measure beginOffset, Measure endOffset, String component) {
+      int index, int number, Measure spacing, Measure beginOffset, Measure endOffset, Object debug) {
 
     assert number > 0;
 
     int[] newIndices = equations.addVariables(number + 1);
     equations.addEqualsEquation(
-        new PartitionEquation(newIndices[0], number, index, spacing, beginOffset, endOffset, component));
+        new PartitionEquation(newIndices[0], number, index, spacing, beginOffset, endOffset, debug));
     equations.addEqualsEquation(
-        new RemainderEquation(newIndices[number], component));
+        new RemainderEquation(newIndices[number], debug));
     return newIndices;
   }
 
-  public int combine(int index, int span, Measure spacing, String component) {
+  public int combine(int index, int span, Measure spacing, Object debug) {
 
     assert span > 0;
 
     int[] newIndices = equations.addVariables(1);
-    equations.addEqualsEquation(new CombinationEquation(newIndices[0], index, span, spacing, component));
+    equations.addEqualsEquation(new CombinationEquation(newIndices[0], index, span, spacing, debug));
     return newIndices[0];
   }
 
-  public void proportionate(int index1, int index2, int factor1, int factor2, String component) {
+  public void proportionate(int index1, int index2, int factor1, int factor2, Object debug) {
 
     assert index1 >= 0;
     assert index2 >= 0;
     assert factor1 > 0;
     assert factor2 > 0;
 
-    equations.addEqualsEquation(new ProportionEquation(index1, index2, factor1, factor2, component));
+    equations.addEqualsEquation(new ProportionEquation(index1, index2, factor1, factor2, debug));
   }
 
   public void solve() {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/FixedEquation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/FixedEquation.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/FixedEquation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/FixedEquation.java Fri Aug 14 10:00:43 2009
@@ -21,16 +21,15 @@
 
 import java.util.Arrays;
 
-public final class FixedEquation implements Equation {
+public final class FixedEquation extends AbstractEquation {
 
   private int index;
   private Measure result;
-  private String component;
 
-  public FixedEquation(int index, Measure result, String component) {
+  public FixedEquation(int index, Measure result, Object debug) {
+    super(debug);
     this.index = index;
     this.result = result;
-    this.component = component;
   }
 
   public double[] fillRow(int length) {
@@ -47,6 +46,14 @@
 
   @Override
   public String toString() {
-    return "FixedEquation:        x_" + index + " = " + result + " (" + component + ")";
+    StringBuilder builder = new StringBuilder();
+    builder.append("FixedEquation:        x_");
+    builder.append(index);
+    builder.append(" = ");
+    builder.append(result);
+
+    appendDebug(builder);
+
+    return builder.toString();
   }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/PartitionEquation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/PartitionEquation.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/PartitionEquation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/PartitionEquation.java Fri Aug 14 10:00:43 2009
@@ -26,7 +26,7 @@
  * In this example are: begin=4, end=6, parent=2, span=1
  * Because of the algorithm we have indices without gap.
  */
-public final class PartitionEquation implements Equation {
+public final class PartitionEquation extends AbstractEquation {
 
   private int begin;
   private int count;
@@ -34,11 +34,10 @@
   private Measure spacing;
   private Measure beginOffset;
   private Measure endOffset;
-  private String component;
 
   @Deprecated
-  public PartitionEquation(int begin, int count, int parent, Measure spacing, String component) {
-    this(begin, count, parent, spacing, PixelMeasure.ZERO, PixelMeasure.ZERO, component);
+  public PartitionEquation(int begin, int count, int parent, Measure spacing, Object debug) {
+    this(begin, count, parent, spacing, PixelMeasure.ZERO, PixelMeasure.ZERO, debug);
   }
 
   /**
@@ -48,10 +47,11 @@
    * @param spacing space between two cells of the partition
    * @param beginOffset offset before the first cell
    * @param endOffset offset after the last cell
-   * @param component
+   * @param debug Logging information
    */
   public PartitionEquation(
-      int begin, int count, int parent, Measure spacing, Measure beginOffset, Measure endOffset, String component) {
+      int begin, int count, int parent, Measure spacing, Measure beginOffset, Measure endOffset, Object debug) {
+    super(debug);
 
     assert spacing != null;
     assert beginOffset != null;
@@ -63,7 +63,6 @@
     this.spacing = spacing;
     this.beginOffset = beginOffset;
     this.endOffset = endOffset;
-    this.component = component;
 
     assert begin >= 0 && count > 0 && parent >= 0;
     assert parent <= begin;
@@ -152,9 +151,7 @@
     builder.append(" + x_");
     builder.append(begin + count);
 
-    builder.append(" (");
-    builder.append(component);
-    builder.append(")");
+    appendDebug(builder);
 
     return builder.toString();
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ProportionEquation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ProportionEquation.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ProportionEquation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ProportionEquation.java Fri Aug 14 10:00:43 2009
@@ -17,20 +17,19 @@
  * limitations under the License.
  */
 
-public final class ProportionEquation implements Equation {
+public final class ProportionEquation extends AbstractEquation {
 
   private int index1;
   private int index2;
   private double factor1;
   private double factor2;
-  private String component;
 
-  public ProportionEquation(int index1, int index2, double factor1, double factor2, String component) {
+  public ProportionEquation(int index1, int index2, double factor1, double factor2, Object debug) {
+    super(debug);
     this.index1 = index1;
     this.index2 = index2;
     this.factor1 = factor1;
     this.factor2 = factor2;
-    this.component = component;
   }
 
   public double[] fillRow(int length) {
@@ -68,9 +67,7 @@
     builder.append(" x_");
     builder.append(index2);
 
-    builder.append(" (");
-    builder.append(component);
-    builder.append(")");
+    appendDebug(builder);
 
     return builder.toString();
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/RemainderEquation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/RemainderEquation.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/RemainderEquation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/RemainderEquation.java Fri Aug 14 10:00:43 2009
@@ -19,14 +19,13 @@
 
 import java.util.Arrays;
 
-public final class RemainderEquation implements Equation {
+public final class RemainderEquation extends AbstractEquation {
 
   private int index;
-  private String component;
 
-  public RemainderEquation(int index, String component) {
+  public RemainderEquation(int index, Object debug) {
+    super(debug);
     this.index = index;
-    this.component = component;
   }
 
   public double[] fillRow(int length) {
@@ -42,6 +41,13 @@
 
   @Override
   public String toString() {
-    return "RemainderEquation:    x_" + index + " = 0 (" + component + ")";
+    StringBuilder builder = new StringBuilder();
+    builder.append("RemainderEquation:    x_");
+    builder.append(index);
+    builder.append(" = 0px");
+
+    appendDebug(builder);
+
+    return builder.toString();
   }
 }
\ No newline at end of file

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java?rev=804149&r1=804148&r2=804149&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/SystemOfEquations.java Fri Aug 14 10:00:43 2009
@@ -177,6 +177,9 @@
           swapRow(j, nonZeroIndex);
           factor = data[j][j];
         } else {
+          LOG.error("No Not unique solvable: " + this);
+          continue;
+/*
           int fullZeroIndex = findFullZero();
           if (fullZeroIndex != -1) {
             swapRow(j, fullZeroIndex);
@@ -187,6 +190,7 @@
           } else {
             LOG.error("Not unique solvable: " + this);
           }
+*/
         }
       }
       divideRow(j, factor);