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/05 13:48:53 UTC
svn commit: r801140 [1/2] - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/component/
core/src/main/java/org/apache/myfaces/tobago/config/
core/src/main/java/org/apache/myfaces/tobago/context/
core/src/main/java/org/apache/myfac...
Author: lofwyr
Date: Wed Aug 5 11:48:51 2009
New Revision: 801140
URL: http://svn.apache.org/viewvc?rev=801140&view=rev
Log:
TOBAGO-606: Layout-Manager
- first steps for fixed/auto support
- first steps for preferred support
- tc:image is now layoutable
- example/test: use images for scalable examples instead of in (because of the fixed height of a tc:in)
Added:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIImage.java
- copied, changed from r799324, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIOut.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java (contents, props changed)
- copied, changed from r799324, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FixedLayoutToken.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationComparator.java
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/auto-vertical-in+in.xhtml
- copied, changed from r799324, myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-2x2.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/image/
myfaces/tobago/trunk/example/test/src/main/webapp/tc/image/image.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/label/
myfaces/tobago/trunk/example/test/src/main/webapp/tc/label/label.xhtml
myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/
myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/property/tobago-theme-config.properties
- copied, changed from r799565, myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties
Removed:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FixedLayoutToken.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/config/ThemeConfig.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.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/LayoutObject.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutTokens.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/Equation.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/MathUtils.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/SystemOfEquations.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ZeroEquation.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ImageTagDeclaration.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponent.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponentWithDeprecatedDimension.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/Deprecation.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterWrapper.java
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/MathUtilsUnitTest.java
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java
myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
myfaces/tobago/trunk/example/test/src/main/resources/log4j.xml
myfaces/tobago/trunk/example/test/src/main/webapp/navigation.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/cell/3x3-center.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/cell/position-4x4-span-steps.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/nested.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-10x10-span.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-2x2-span-bottom.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-2x2-span-left.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-2x2-span-right.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-2x2-span-top.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-2x2.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/position-4x4-span-steps.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-not-exact-4x4.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/size-not-exact.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/spacing-nested.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/gridLayout/spacing-simple.xhtml
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/property/tobago-theme-config.properties
myfaces/tobago/trunk/theme/speyside/src/main/resources/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/style.css
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=801140&r1=801139&r2=801140&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 Aug 5 11:48:51 2009
@@ -17,11 +17,11 @@
* limitations under the License.
*/
+import org.apache.commons.lang.ClassUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.OnComponentCreated;
import org.apache.myfaces.tobago.layout.Display;
-import org.apache.myfaces.tobago.layout.FixedLayoutToken;
import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutContainer;
import org.apache.myfaces.tobago.layout.LayoutContext;
@@ -75,12 +75,14 @@
EquationManager horizontal = layoutContext.getHorizontal();
int[] horizontalIndices = horizontal.partition(
horizontalIndex, columnTokens.getSize(),
- getColumnSpacing(), container.getLeftOffset(), container.getRightOffset());
+ getColumnSpacing(), container.getLeftOffset(), container.getRightOffset(),
+ container.getClass().getSimpleName());
// vertical
EquationManager vertical = layoutContext.getVertical();
int[] verticalIndices = vertical.partition(
- verticalIndex, rowTokens.getSize(), getRowSpacing(), container.getTopOffset(), container.getBottomOffset());
+ verticalIndex, rowTokens.getSize(), getRowSpacing(),
+ container.getTopOffset(), container.getBottomOffset(), container.getClass().getSimpleName());
List<LayoutComponent> components = container.getComponents();
for (LayoutComponent c : components) {
@@ -88,7 +90,7 @@
LOG.debug("\n" + grid);
}
- addFixedConstraints(layoutContext, horizontalIndex + 1, verticalIndex + 1);
+ addPixelConstraints(layoutContext, horizontalIndex + 1, verticalIndex + 1);
addRelativeConstraints(layoutContext, horizontalIndex + 1, verticalIndex + 1);
for (int j = 0; j < grid.getRowCount(); j++) {
@@ -99,17 +101,28 @@
LayoutComponent component = temp.getComponent();
// horizontal
- int hIndex = horizontal.combine(horizontalIndices[i], cell.getColumnSpan(), getColumnSpacing());
+ int hIndex = horizontal.combine(horizontalIndices[i], cell.getColumnSpan(), getColumnSpacing(), component.getClass().getSimpleName());
cell.getComponent().setHorizontalIndex(hIndex);
// vertical
- int vIndex = vertical.combine(verticalIndices[j], cell.getRowSpan(), getRowSpacing());
+ int vIndex = vertical.combine(verticalIndices[j], cell.getRowSpan(), getRowSpacing(), component.getClass().getSimpleName());
cell.getComponent().setVerticalIndex(vIndex);
if (component instanceof LayoutContainer) {
LayoutContainer subContainer = (LayoutContainer) component;
LayoutManager layoutManager = subContainer.getLayoutManager();
layoutManager.collect(layoutContext, subContainer, hIndex, vIndex);
+ } else {
+ // XXX is this a good idea?
+
+ Measure preferredWidth = component.getPreferredWidth();
+ if (preferredWidth != null) {
+ horizontal.setFixedLength(hIndex, preferredWidth, component.getClass().getSimpleName());
+ }
+ Measure preferredHeight = component.getPreferredHeight();
+ if (preferredHeight != null) {
+ vertical.setFixedLength(vIndex, preferredHeight, component.getClass().getSimpleName());
+ }
}
}
}
@@ -206,19 +219,21 @@
}
}
- private void addFixedConstraints(LayoutContext layoutContext, int horizontalIndexOffset, int verticalIndexOffset) {
+ private void addPixelConstraints(LayoutContext layoutContext, int horizontalIndexOffset, int verticalIndexOffset) {
// horizontal
for (int i = 0; i < columnTokens.getSize(); i++) {
LayoutToken layoutToken = columnTokens.get(i);
if (layoutToken instanceof PixelLayoutToken) {
Measure pixel = new PixelMeasure(((PixelLayoutToken) layoutToken).getPixel());
- layoutContext.getHorizontal().setFixedLength(i + horizontalIndexOffset, pixel);
+ layoutContext.getHorizontal().setFixedLength(i + horizontalIndexOffset, pixel, ClassUtils.getShortClassName(getParent(), "null"));
}
- if (layoutToken instanceof FixedLayoutToken) {
+/*
+ if (layoutToken instanceof AutoLayoutToken) {
Measure pixel = new PixelMeasure(100); // TODO
LOG.warn("auto/fixed is not implemented yet and was set to 100px");
layoutContext.getHorizontal().setFixedLength(i + horizontalIndexOffset, pixel);
}
+*/
}
// vertical
for (int i = 0; i < rowTokens.getSize(); i++) {
@@ -226,13 +241,15 @@
if (layoutToken instanceof PixelLayoutToken) {
// XXX PixelLayoutToken might be removed/changed
Measure pixel = new PixelMeasure(((PixelLayoutToken) layoutToken).getPixel());
- layoutContext.getVertical().setFixedLength(i + verticalIndexOffset, pixel);
+ layoutContext.getVertical().setFixedLength(i + verticalIndexOffset, pixel, ClassUtils.getShortClassName(getParent(), "null"));
}
- if (layoutToken instanceof FixedLayoutToken) {
+/*
+ if (layoutToken instanceof AutoLayoutToken) {
Measure pixel = new PixelMeasure(25); // TODO
LOG.warn("auto/fixed is not implemented yet and was set to 25px");
layoutContext.getVertical().setFixedLength(i + verticalIndexOffset, pixel);
}
+*/
}
}
@@ -248,7 +265,8 @@
first = factor;
firstIndex = i + horizontalIndexOffset;
} else {
- layoutContext.getHorizontal().proportionate(firstIndex, i + horizontalIndexOffset, first, factor);
+ layoutContext.getHorizontal().proportionate(
+ firstIndex, i + horizontalIndexOffset, first, factor, ClassUtils.getShortClassName(getParent(), "null"));
}
}
}
@@ -263,7 +281,8 @@
first = factor;
firstIndex = i + verticalIndexOffset;
} else {
- layoutContext.getVertical().proportionate(firstIndex, i + verticalIndexOffset, first, factor);
+ layoutContext.getVertical().proportionate(
+ firstIndex, i + verticalIndexOffset, first, factor, ClassUtils.getShortClassName(getParent(), "null"));
}
}
}
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIImage.java (from r799324, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIOut.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIImage.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIImage.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIOut.java&r1=799324&r2=801140&rev=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIOut.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIImage.java Wed Aug 5 11:48:51 2009
@@ -19,7 +19,7 @@
import org.apache.myfaces.tobago.layout.LayoutComponent;
-import javax.faces.component.UIOutput;
+import javax.faces.component.UIGraphic;
-public abstract class AbstractUIOut extends UIOutput implements LayoutComponent {
-}
+public abstract class AbstractUIImage extends UIGraphic implements LayoutComponent {
+}
\ No newline at end of file
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/ThemeConfig.java Wed Aug 5 11:48:51 2009
@@ -63,7 +63,12 @@
}
public static Measure getMeasure(FacesContext facesContext, UIComponent component, String name) {
- return new PixelMeasure(getValue(facesContext, component, name));
+ try {
+ return new PixelMeasure(getValue0(facesContext, component, name));
+ } catch (Exception e) {
+ // XXX: not a good style to use exception for this normal behaviour, use Integer als result type of getValue0()
+ return null;
+ }
}
private static int getValue0(FacesContext facesContext, UIComponent component, String name) {
@@ -161,6 +166,7 @@
this.name = name;
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -187,6 +193,7 @@
return true;
}
+ @Override
public int hashCode() {
int result;
result = clientProperties.hashCode();
@@ -195,6 +202,14 @@
result = 29 * result + name.hashCode();
return result;
}
+
+ @Override
+ public String toString() {
+ return "CacheKey(" + clientProperties +
+ "," + locale +
+ "," + rendererType +
+ "," + name + ')';
+ }
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java Wed Aug 5 11:48:51 2009
@@ -553,6 +553,11 @@
public int hashCode() {
return hashCode;
}
+
+ @Override
+ public String toString() {
+ return "PropertyCacheKey(" + cacheKey + "," + name + "," + key + "," + hashCode + '}';
+ }
}
private static final class MiscCacheKey {
@@ -592,6 +597,11 @@
public int hashCode() {
return hashCode;
}
+
+ @Override
+ public String toString() {
+ return "MiscCacheKey(" + cacheKey + "," + name + "," + hashCode + ')';
+ }
}
private static final class RendererCacheKey {
@@ -631,6 +641,11 @@
public int hashCode() {
return hashCode;
}
+
+ @Override
+ public String toString() {
+ return "RendererCacheKey(" + cacheKey + "," + name + "," + hashCode + ')';
+ }
}
public static final class CacheKey implements Serializable {
@@ -686,5 +701,10 @@
public int hashCode() {
return hashCode;
}
+
+ @Override
+ public String toString() {
+ return "CacheKey(" + clientProperties + "," + locale + "," + hashCode + ')';
+ }
}
}
Copied: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java (from r799324, myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FixedLayoutToken.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java?p2=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java&p1=myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FixedLayoutToken.java&r1=799324&r2=801140&rev=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/FixedLayoutToken.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java Wed Aug 5 11:48:51 2009
@@ -17,12 +17,9 @@
* limitations under the License.
*/
-/*
- * Date: May 2, 2007
- * Time: 7:16:18 PM
- */
-public final class FixedLayoutToken extends LayoutToken {
- public static final FixedLayoutToken INSTANCE = new FixedLayoutToken();
+public final class AutoLayoutToken extends LayoutToken {
+
+ public static final AutoLayoutToken INSTANCE = new AutoLayoutToken();
public String toString() {
return "fixed";
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/AutoLayoutToken.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
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=801140&r1=801139&r2=801140&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 Aug 5 11:48:51 2009
@@ -45,10 +45,10 @@
vertical.addComponentRoot();
if (container.getWidth() != null) {
- horizontal.setFixedLength(0, container.getWidth());
+ horizontal.setFixedLength(0, container.getWidth(), container.getClass().getSimpleName());
}
if (container.getHeight() != null) {
- vertical.setFixedLength(0, container.getHeight());
+ vertical.setFixedLength(0, container.getHeight(), container.getClass().getSimpleName());
}
container.getLayoutManager().collect(this, container, 0, 0);
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutObject.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutObject.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutObject.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutObject.java Wed Aug 5 11:48:51 2009
@@ -33,8 +33,10 @@
void setMinimumHeight(Measure minimumHeight);
void setPreferredWidth(Measure preferredWidth);
+ Measure getPreferredWidth();
void setPreferredHeight(Measure preferredHeight);
+ Measure getPreferredHeight();
void setMaximumWidth(Measure maximumWidth);
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutTokens.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutTokens.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutTokens.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/LayoutTokens.java Wed Aug 5 11:48:51 2009
@@ -109,8 +109,8 @@
try {
if ("*".equals(token)) {
return RelativeLayoutToken.DEFAULT_INSTANCE;
- } else if (token.equals("fixed")) {
- return FixedLayoutToken.INSTANCE;
+ } else if (token.equals("fixed") || token.equals("auto")) {
+ return AutoLayoutToken.INSTANCE;
} else if (token.equals("minimum")) {
return new MinimumLayoutToken();
} else if (isPixelToken(token)) {
@@ -120,12 +120,13 @@
} else if (isRelativeToken(token)) {
return new RelativeLayoutToken(Integer.parseInt(removeSuffix(token, RelativeLayoutToken.SUFFIX)));
} else {
- LOG.error("Ignoring unknown layout token '" + token + "'");
+ LOG.error("Unknown layout token '" + token + "'! Using 'auto' instead.");
+ return AutoLayoutToken.INSTANCE;
}
} catch (NumberFormatException e) {
- LOG.error("Error parsing layout token '" + token + "'", e);
+ LOG.error("Error parsing layout token '" + token + "'! Using 'auto' instead.");
+ return AutoLayoutToken.INSTANCE;
}
- return null;
}
static boolean isPixelToken(String token) {
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=801140&r1=801139&r2=801140&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 Wed Aug 5 11:48:51 2009
@@ -31,6 +31,7 @@
private int parent;
private int span;
private Measure spacing;
+ private String component;
/**
* @param newIndex new index
@@ -38,11 +39,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) {
+ public CombinationEquation(int newIndex, int parent, int span, Measure spacing, String component) {
this.newIndex = newIndex;
this.parent = parent;
this.span = span;
this.spacing = spacing;
+ this.component = component;
}
public void fillRow(double[] row) {
@@ -67,6 +69,10 @@
}
}
+ public int priority() {
+ return 10;
+ }
+
public int getNewIndex() {
return newIndex;
}
@@ -112,6 +118,10 @@
builder.append("x_");
builder.append(newIndex);
+ builder.append(" (");
+ builder.append(component);
+ builder.append(")");
+
return builder.toString();
}
}
Modified: 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/Equation.java?rev=801140&r1=801139&r2=801140&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/Equation.java Wed Aug 5 11:48:51 2009
@@ -21,6 +21,14 @@
/**
* The row has the format: index 0 to n-2 are the factors and index n-1 is the result.
+ * @param row array to fill in the factors of the equation.
*/
void fillRow(double[] row);
+
+ /**
+ * Priority for sorting.
+ * @return Large values represent a high priority
+ */
+ int priority();
+
}
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationComparator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationComparator.java?rev=801140&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationComparator.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/EquationComparator.java Wed Aug 5 11:48:51 2009
@@ -0,0 +1,11 @@
+package org.apache.myfaces.tobago.layout.math;
+
+import java.util.Comparator;
+
+public class EquationComparator implements Comparator<Equation> {
+
+ public int compare(Equation x, Equation y) {
+
+ return y.priority() - x.priority();
+ }
+}
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=801140&r1=801139&r2=801140&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 Wed Aug 5 11:48:51 2009
@@ -37,44 +37,44 @@
return 0;
}
- public void setFixedLength(int index, Measure length) {
- equations.addEqualsEquation(new FixedEquation(index, length));
+ public void setFixedLength(int index, Measure length, String component) {
+ equations.addEqualsEquation(new FixedEquation(index, length, component));
LOG.info(equations);
}
- public int[] partition(int index, int number, Measure spacing) {
+ public int[] partition(int index, int number, Measure spacing, String component) {
// TODO
- return partition(index, number, spacing, PixelMeasure.ZERO, PixelMeasure.ZERO);
+ return partition(index, number, spacing, PixelMeasure.ZERO, PixelMeasure.ZERO, component);
}
- public int[] partition(int index, int number, Measure spacing, Measure beginOffset, Measure endOffset) {
+ public int[] partition(int index, int number, Measure spacing, Measure beginOffset, Measure endOffset, String component) {
assert number > 0;
int[] newIndices = equations.addVariables(number);
- equations.addEqualsEquation(new PartitionEquation(newIndices[0], number, index, spacing, beginOffset, endOffset));
+ equations.addEqualsEquation(new PartitionEquation(newIndices[0], number, index, spacing, beginOffset, endOffset, component));
LOG.info(equations);
return newIndices;
}
- public int combine(int index, int span, Measure spacing) {
+ public int combine(int index, int span, Measure spacing, String component) {
assert span > 0;
int[] newIndices = equations.addVariables(1);
- equations.addEqualsEquation(new CombinationEquation(newIndices[0], index, span, spacing));
+ equations.addEqualsEquation(new CombinationEquation(newIndices[0], index, span, spacing, component));
LOG.info(equations);
return newIndices[0];
}
- public void proportionate(int index1, int index2, int factor1, int factor2) {
+ public void proportionate(int index1, int index2, int factor1, int factor2, String component) {
assert index1 >= 0;
assert index2 >= 0;
assert factor1 > 0;
assert factor2 > 0;
- equations.addEqualsEquation(new ProportionEquation(index1, index2, factor1, factor2));
+ equations.addEqualsEquation(new ProportionEquation(index1, index2, factor1, factor2, component));
LOG.info(equations);
}
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=801140&r1=801139&r2=801140&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 Wed Aug 5 11:48:51 2009
@@ -25,10 +25,12 @@
private int index;
private Measure result;
+ private String component;
- public FixedEquation(int index, Measure result) {
+ public FixedEquation(int index, Measure result, String component) {
this.index = index;
this.result = result;
+ this.component = component;
}
public void fillRow(double[] row) {
@@ -37,8 +39,12 @@
row[row.length - 1] = result.getPixel();
}
+ public int priority() {
+ return 40;
+ }
+
@Override
public String toString() {
- return "FixedEquation: x_" + index + " = " + result;
+ return "FixedEquation: x_" + index + " = " + result + " (" + component + ")";
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/MathUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/MathUtils.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/MathUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/MathUtils.java Wed Aug 5 11:48:51 2009
@@ -30,11 +30,10 @@
*
* @param list
*/
- static void adjustRemainders(double[] list) {
- double bias = 0.0;
+ static void adjustRemainders(double[] list, double bias) {
for (double v : list) {
double lastBias;
- if (bias >= 0.0) {
+ if (bias < 0.0) {
lastBias = findAndAdjustMaxRemainder(list);
} else {
lastBias = findAndAdjustMinRemainder(list);
@@ -60,7 +59,7 @@
}
if (indexOfMax != null) {
list[indexOfMax] += 1.0 - max;
- return max - 1.0;
+ return 1.0 - max;
}
return 0.0;
}
@@ -80,7 +79,7 @@
}
if (indexOfMin != null) {
list[indexOfMin] -= min;
- return min;
+ return -min;
}
return 0.0;
}
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=801140&r1=801139&r2=801140&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 Wed Aug 5 11:48:51 2009
@@ -34,10 +34,11 @@
private Measure spacing;
private Measure beginOffset;
private Measure endOffset;
+ private String component;
@Deprecated
- public PartitionEquation(int begin, int count, int parent, Measure spacing) {
- this(begin, count, parent, spacing, PixelMeasure.ZERO, PixelMeasure.ZERO);
+ public PartitionEquation(int begin, int count, int parent, Measure spacing, String component) {
+ this(begin, count, parent, spacing, PixelMeasure.ZERO, PixelMeasure.ZERO, component);
}
/**
@@ -47,14 +48,21 @@
* @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
*/
- public PartitionEquation(int begin, int count, int parent, Measure spacing, Measure beginOffset, Measure endOffset) {
+ public PartitionEquation(int begin, int count, int parent, Measure spacing, Measure beginOffset, Measure endOffset, String component) {
+
+ assert spacing != null;
+ assert beginOffset != null;
+ assert endOffset != null;
+
this.begin = begin;
this.count = count;
this.parent = parent;
this.spacing = spacing;
this.beginOffset = beginOffset;
this.endOffset = endOffset;
+ this.component = component;
assert begin >= 0 && count > 0 && parent >= 0;
assert parent <= begin;
@@ -79,6 +87,10 @@
}
}
+ public int priority() {
+ return 30;
+ }
+
public int getBegin() {
return begin;
}
@@ -87,6 +99,10 @@
return count;
}
+ public int getParent() {
+ return parent;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder("PartitionEquation: ");
@@ -126,6 +142,10 @@
builder.append(endOffset);
}
+ builder.append(" (");
+ builder.append(component);
+ builder.append(")");
+
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=801140&r1=801139&r2=801140&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 Wed Aug 5 11:48:51 2009
@@ -23,12 +23,14 @@
private int index2;
private double factor1;
private double factor2;
+ private String component;
- public ProportionEquation(int index1, int index2, double factor1, double factor2) {
+ public ProportionEquation(int index1, int index2, double factor1, double factor2, String component) {
this.index1 = index1;
this.index2 = index2;
this.factor1 = factor1;
this.factor2 = factor2;
+ this.component = component;
}
public void fillRow(double[] row) {
@@ -42,6 +44,10 @@
}
}
+ public int priority() {
+ return 20;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -59,6 +65,11 @@
}
builder.append(" x_");
builder.append(index2);
+
+ builder.append(" (");
+ builder.append(component);
+ builder.append(")");
+
return builder.toString();
}
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=801140&r1=801139&r2=801140&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 Wed Aug 5 11:48:51 2009
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -149,6 +150,10 @@
equations.add(new ZeroEquation());
}
+ LOG.info("Before sorting: " + this);
+
+ Collections.sort(equations, new EquationComparator());
+
if (numberOfVariables != equations.size()) {
LOG.warn("SOE have not correct dimensions: " + this);
}
@@ -230,20 +235,35 @@
LOG.info(this);
- round();
+ double[] original = copyResult();
+
+ round(original);
+
+ Measure[] rounded = copyResultMeasure();
+
+ LOG.info("after adjust remainders: " + Arrays.toString(rounded));
+ return rounded;
+ }
+
+ private double[] copyResult() {
+ double[] result = new double[numberOfVariables];
+ for (int i = 0; i < numberOfVariables; i++) {
+ result[i] = data[i][numberOfVariables];
+ }
+ return result;
+ }
+
+ private Measure[] copyResultMeasure() {
Measure[] result = new Measure[numberOfVariables];
for (int i = 0; i < numberOfVariables; i++) {
assert MathUtils.isInteger(data[i][numberOfVariables]);
result[i] = new PixelMeasure((int) Math.round(data[i][numberOfVariables]));
}
-
- LOG.info("after adjust remainders: " + Arrays.toString(result));
-
return result;
}
- private void round() {
+ private void round(double[] original) {
for (Equation equation : equations) {
if (equation instanceof PartitionEquation) {
@@ -257,29 +277,33 @@
temp[i] = data[i + begin][numberOfVariables];
}
// processing
- MathUtils.adjustRemainders(temp);
+ int parent = partition.getParent();
+ MathUtils.adjustRemainders(temp, original[parent] - data[parent][numberOfVariables]);
// write back to data
for (int i = 0; i < count; i++) {
data[i + begin][numberOfVariables] = temp[i];
}
- }
- if (equation instanceof CombinationEquation) {
+ } else if (equation instanceof CombinationEquation) {
CombinationEquation combination = (CombinationEquation) equation;
combination.getParent();
int parent = combination.getParent();
int span = combination.getSpan();
- double sum = (span - 1) * combination.getSpacing().getPixel();
+ double sum = (span - 1) * combination.getSpacing().getPixel(); // the spacings
for (int i = 0; i < span; i++) {
double value = data[i + parent][numberOfVariables];
assert MathUtils.isInteger(value);
sum += value;
}
int index = combination.getNewIndex();
- LOG.info("Change value for index=" + index + " from "
- + (data[index][numberOfVariables]) + " -> " + Math.round(sum));
- assert Math.abs(data[index][numberOfVariables] - Math.round(sum)) < 1;
- data[index][numberOfVariables] = Math.round(sum);
- }
+ double old = data[index][numberOfVariables];
+ if (Math.abs(old - Math.round(sum)) < 1) {
+ data[index][numberOfVariables] = Math.round(sum);
+ } else {
+ data[index][numberOfVariables] = Math.round(old);
+ }
+ LOG.info("Change value for index=" + index + " from " + old + " -> " + Math.round(sum));
+
+ } //else if (equation instanceof )
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ZeroEquation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ZeroEquation.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ZeroEquation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/layout/math/ZeroEquation.java Wed Aug 5 11:48:51 2009
@@ -25,6 +25,10 @@
Arrays.fill(row, 0.0);
}
+ public int priority() {
+ return 0;
+ }
+
@Override
public String toString() {
return "ZeroEquation (no meaning)";
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ImageTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ImageTagDeclaration.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ImageTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/ImageTagDeclaration.java Wed Aug 5 11:48:51 2009
@@ -33,8 +33,8 @@
*/
@Tag(name = "image", bodyContent = BodyContent.JSP)
@UIComponentTag(
- uiComponent = "org.apache.myfaces.tobago.component.UIGraphic",
- uiComponentBaseClass = "javax.faces.component.UIGraphic",
+ uiComponent = "org.apache.myfaces.tobago.component.UIImage",
+ uiComponentBaseClass = "org.apache.myfaces.tobago.component.AbstractUIImage",
rendererType = RendererTypes.IMAGE,
allowedChildComponenents = "NONE")
public interface ImageTagDeclaration
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponent.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponent.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponent.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponent.java Wed Aug 5 11:48:51 2009
@@ -64,13 +64,17 @@
/**
* @param preferredWidth The preferred width for this component.
*/
- @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure")
+ @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure",
+ defaultCode = "org.apache.myfaces.tobago.config.ThemeConfig.getMeasure("
+ + "getFacesContext(), this, \"preferredWidth\")")
void setPreferredWidth(String preferredWidth);
/**
* @param preferredHeight The preferred height for this component.
*/
- @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure")
+ @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure",
+ defaultCode = "org.apache.myfaces.tobago.config.ThemeConfig.getMeasure("
+ + "getFacesContext(), this, \"preferredHeight\")")
void setPreferredHeight(String preferredHeight);
/**
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponentWithDeprecatedDimension.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponentWithDeprecatedDimension.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponentWithDeprecatedDimension.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/IsGridLayoutComponentWithDeprecatedDimension.java Wed Aug 5 11:48:51 2009
@@ -74,13 +74,17 @@
/**
* @param preferredWidth The preferred width for this component.
*/
- @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure")
+ @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure",
+ defaultCode = "org.apache.myfaces.tobago.config.ThemeConfig.getMeasure("
+ + "getFacesContext(), this, \"preferredWidth\")")
void setPreferredWidth(String preferredWidth);
/**
* @param preferredHeight The preferred height for this component.
*/
- @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure")
+ @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.Measure",
+ defaultCode = "org.apache.myfaces.tobago.config.ThemeConfig.getMeasure("
+ + "getFacesContext(), this, \"preferredHeight\")")
void setPreferredHeight(String preferredHeight);
/**
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/Deprecation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/Deprecation.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/Deprecation.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/Deprecation.java Wed Aug 5 11:48:51 2009
@@ -21,7 +21,11 @@
import org.apache.commons.logging.LogFactory;
-public class Deprecation {
+public final class Deprecation {
+
+ // to prevent instantiation
+ private Deprecation() {
+ }
/**
* This Log object should help to detect the usage of deprecated code.
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterWrapper.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterWrapper.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterWrapper.java Wed Aug 5 11:48:51 2009
@@ -25,11 +25,8 @@
import java.io.IOException;
import java.io.Writer;
-/*
- * Date: May 12, 2007
- * Time: 8:20:51 PM
- */
public class TobagoResponseWriterWrapper extends TobagoResponseWriter {
+
private ResponseWriter responseWriter;
public TobagoResponseWriterWrapper(ResponseWriter responseWriter) {
Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/component/GridLayoutManagerUnitTest.java Wed Aug 5 11:48:51 2009
@@ -54,11 +54,17 @@
UIGridLayout manager = new UIGridLayout();
manager.setColumns("*;2*");
manager.setRows("*");
+ manager.setColumnSpacing(PixelMeasure.ZERO);
+ manager.setRowSpacing(PixelMeasure.ZERO);
manager.onComponentCreated(null, manager);
container.setLayoutManager(manager);
container.setWidth(new PixelMeasure(300));
container.setHeight(new PixelMeasure(20));
+ container.setLeftOffset(PixelMeasure.ZERO);
+ container.setTopOffset(PixelMeasure.ZERO);
+ container.setRightOffset(PixelMeasure.ZERO);
+ container.setBottomOffset(PixelMeasure.ZERO);
LayoutContext layoutContext = new LayoutContext(container);
layoutContext.layout();
@@ -95,11 +101,17 @@
container.getComponents().add(c);
MockComponent span = new MockComponent();
container.getComponents().add(span);
+ container.setLeftOffset(PixelMeasure.ZERO);
+ container.setTopOffset(PixelMeasure.ZERO);
+ container.setRightOffset(PixelMeasure.ZERO);
+ container.setBottomOffset(PixelMeasure.ZERO);
span.setColumnSpan(2);
UIGridLayout manager = new UIGridLayout();
manager.setColumns("*;*;*");
manager.setRows("*");
+ manager.setColumnSpacing(PixelMeasure.ZERO);
+ manager.setRowSpacing(PixelMeasure.ZERO);
manager.onComponentCreated(null, manager);
container.setLayoutManager(manager);
@@ -158,21 +170,33 @@
UIGridLayout manager = new UIGridLayout();
manager.setColumns("*;2*;500px");
manager.setRows("*;600px");
+ manager.setColumnSpacing(PixelMeasure.ZERO);
+ manager.setRowSpacing(PixelMeasure.ZERO);
manager.onComponentCreated(null, manager);
container.setLayoutManager(manager);
UIGridLayout subManager = new UIGridLayout();
subManager.setColumns("7*;3*");
subManager.setRows("*;*");
+ subManager.setColumnSpacing(PixelMeasure.ZERO);
+ subManager.setRowSpacing(PixelMeasure.ZERO);
subManager.onComponentCreated(null, manager);
subContainer.setLayoutManager(subManager);
subContainer.getComponents().add(new MockComponent());
subContainer.getComponents().add(new MockComponent());
subContainer.getComponents().add(new MockComponent());
subContainer.getComponents().add(new MockComponent());
+ subContainer.setLeftOffset(PixelMeasure.ZERO);
+ subContainer.setTopOffset(PixelMeasure.ZERO);
+ subContainer.setRightOffset(PixelMeasure.ZERO);
+ subContainer.setBottomOffset(PixelMeasure.ZERO);
container.setWidth(new PixelMeasure(800));
container.setHeight(new PixelMeasure(800));
+ container.setLeftOffset(PixelMeasure.ZERO);
+ container.setTopOffset(PixelMeasure.ZERO);
+ container.setRightOffset(PixelMeasure.ZERO);
+ container.setBottomOffset(PixelMeasure.ZERO);
LayoutContext layoutContext = new LayoutContext(container);
layoutContext.layout();
@@ -225,23 +249,33 @@
UIGridLayout manager1 = new UIGridLayout();
manager1.setColumns("*;*;*");
manager1.setRows("*;*");
+ manager1.setColumnSpacing(PixelMeasure.ZERO);
+ manager1.setRowSpacing(PixelMeasure.ZERO);
manager1.onComponentCreated(null, manager1);
container.setLayoutManager(manager1);
UIGridLayout manager2 = new UIGridLayout();
manager2.setColumns("*;*;*");
manager2.setRows("*");
+ manager2.setColumnSpacing(PixelMeasure.ZERO);
+ manager2.setRowSpacing(PixelMeasure.ZERO);
manager2.onComponentCreated(null, manager2);
span1.setLayoutManager(manager2);
UIGridLayout manager3 = new UIGridLayout();
manager3.setColumns("*;*;*");
manager3.setRows("*");
+ manager3.setColumnSpacing(PixelMeasure.ZERO);
+ manager3.setRowSpacing(PixelMeasure.ZERO);
manager3.onComponentCreated(null, manager3);
span2.setLayoutManager(manager3);
container.setWidth(new PixelMeasure(900));
container.setHeight(new PixelMeasure(200));
+ container.setLeftOffset(PixelMeasure.ZERO);
+ container.setTopOffset(PixelMeasure.ZERO);
+ container.setRightOffset(PixelMeasure.ZERO);
+ container.setBottomOffset(PixelMeasure.ZERO);
LayoutContext layoutContext = new LayoutContext(container);
layoutContext.layout();
@@ -298,11 +332,17 @@
UIGridLayout manager = new UIGridLayout();
manager.setColumns("*;*");
manager.setRows("*;*");
+ manager.setColumnSpacing(PixelMeasure.ZERO);
+ manager.setRowSpacing(PixelMeasure.ZERO);
manager.onComponentCreated(null, manager);
container.setLayoutManager(manager);
container.setWidth(new PixelMeasure(800));
container.setHeight(new PixelMeasure(800));
+ container.setLeftOffset(PixelMeasure.ZERO);
+ container.setTopOffset(PixelMeasure.ZERO);
+ container.setRightOffset(PixelMeasure.ZERO);
+ container.setBottomOffset(PixelMeasure.ZERO);
LayoutContext layoutContext = new LayoutContext(container);
layoutContext.layout();
Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/CombinationEquationUnitTest.java Wed Aug 5 11:48:51 2009
@@ -25,37 +25,38 @@
@Test
public void testToString() {
- Assert.assertEquals("CombinationEquation: x_0 = x_4",
- new CombinationEquation(4, 0, 1, PixelMeasure.ZERO).toString());
- Assert.assertEquals("CombinationEquation: x_0 + x_1 = x_4",
- new CombinationEquation(4, 0, 2, PixelMeasure.ZERO).toString());
- Assert.assertEquals("CombinationEquation: x_0 + ... + x_2 = x_4",
- new CombinationEquation(4, 0, 3, PixelMeasure.ZERO).toString());
-
- Assert.assertEquals("CombinationEquation: x_0 = x_4",
- new CombinationEquation(4, 0, 1, new PixelMeasure(5)).toString());
- Assert.assertEquals("CombinationEquation: x_0 + x_1 + 5px = x_4",
- new CombinationEquation(4, 0, 2, new PixelMeasure(5)).toString());
- Assert.assertEquals("CombinationEquation: x_0 + ... + x_2 + 2 * 5px = x_4",
- new CombinationEquation(4, 0, 3, new PixelMeasure(5)).toString());
+
+ Assert.assertEquals("CombinationEquation: x_0 = x_4 (test)",
+ new CombinationEquation(4, 0, 1, PixelMeasure.ZERO, "test").toString());
+ Assert.assertEquals("CombinationEquation: x_0 + x_1 = x_4 (test)",
+ new CombinationEquation(4, 0, 2, PixelMeasure.ZERO, "test").toString());
+ Assert.assertEquals("CombinationEquation: x_0 + ... + x_2 = x_4 (test)",
+ new CombinationEquation(4, 0, 3, PixelMeasure.ZERO, "test").toString());
+
+ Assert.assertEquals("CombinationEquation: x_0 = x_4 (test)",
+ new CombinationEquation(4, 0, 1, new PixelMeasure(5), "test").toString());
+ Assert.assertEquals("CombinationEquation: x_0 + x_1 + 5px = x_4 (test)",
+ new CombinationEquation(4, 0, 2, new PixelMeasure(5), "test").toString());
+ Assert.assertEquals("CombinationEquation: x_0 + ... + x_2 + 2 * 5px = x_4 (test)",
+ new CombinationEquation(4, 0, 3, new PixelMeasure(5), "test").toString());
}
@Test
public void testFillRow() {
double[] row = new double[8];
- new CombinationEquation(4, 0, 1, PixelMeasure.ZERO).fillRow(row);
+ new CombinationEquation(4, 0, 1, PixelMeasure.ZERO, "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
- new CombinationEquation(4, 0, 2, PixelMeasure.ZERO).fillRow(row);
+ new CombinationEquation(4, 0, 2, PixelMeasure.ZERO, "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, -1, 0, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
- new CombinationEquation(4, 0, 3, PixelMeasure.ZERO).fillRow(row);
+ new CombinationEquation(4, 0, 3, PixelMeasure.ZERO, "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, -1, -1, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
- new CombinationEquation(4, 0, 1, new PixelMeasure(5)).fillRow(row);
+ new CombinationEquation(4, 0, 1, new PixelMeasure(5), "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
- new CombinationEquation(4, 0, 2, new PixelMeasure(5)).fillRow(row);
+ new CombinationEquation(4, 0, 2, new PixelMeasure(5), "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, -1, 0, 0, 1, 0, 0, 5}, row, MathUtils.EPSILON);
- new CombinationEquation(4, 0, 3, new PixelMeasure(5)).fillRow(row);
+ new CombinationEquation(4, 0, 3, new PixelMeasure(5), "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, -1, -1, 0, 1, 0, 0, 10}, row, MathUtils.EPSILON);
}
Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/EquationManagerUnitTest.java Wed Aug 5 11:48:51 2009
@@ -255,65 +255,65 @@
index = equationManager.addComponentRoot();
Assert.assertEquals(0, index);
- equationManager.setFixedLength(index, new PixelMeasure(630)); // the first (current) index has a fix size of 600
- indices = equationManager.partition(index, 4, PixelMeasure.ZERO); // this index is divided into 4 parts
+ equationManager.setFixedLength(index, new PixelMeasure(630), "test"); // the first (current) index has a fix size of 600
+ indices = equationManager.partition(index, 4, PixelMeasure.ZERO, "test"); // this index is divided into 4 parts
Assert.assertArrayEquals(new int[]{1, 2, 3, 4}, indices);
- equationManager.proportionate(indices[2], indices[3], 1, 2); // the value on index 2 has factor 1,
+ equationManager.proportionate(indices[2], indices[3], 1, 2, "test"); // the value on index 2 has factor 1,
// the value on position 3 has factor 2
{
- equationManager.setFixedLength(indices[0], new PixelMeasure(100)); // the first one has a fix size of 100
- index = equationManager.combine(indices[0], 1, PixelMeasure.ZERO);
+ equationManager.setFixedLength(indices[0], new PixelMeasure(100), "test"); // the first one has a fix size of 100
+ index = equationManager.combine(indices[0], 1, PixelMeasure.ZERO, "test");
Assert.assertEquals(5, index);
}
{
- equationManager.setFixedLength(indices[1], new PixelMeasure(200)); // the second one has a fix size of 200
- index = equationManager.combine(indices[1], 1, PixelMeasure.ZERO);
+ equationManager.setFixedLength(indices[1], new PixelMeasure(200), "test"); // the second one has a fix size of 200
+ index = equationManager.combine(indices[1], 1, PixelMeasure.ZERO, "test");
Assert.assertEquals(6, index);
- index = equationManager.combine(indices[1], 1, PixelMeasure.ZERO);
+ index = equationManager.combine(indices[1], 1, PixelMeasure.ZERO, "test");
Assert.assertEquals(7, index);
- int[] i7 = equationManager.partition(7, 2, PixelMeasure.ZERO);
+ int[] i7 = equationManager.partition(7, 2, PixelMeasure.ZERO, "test");
Assert.assertArrayEquals(new int[]{8, 9}, i7);
- equationManager.proportionate(i7[0], i7[1], 1, 2);
+ equationManager.proportionate(i7[0], i7[1], 1, 2, "test");
- index = equationManager.combine(indices[1], 1, PixelMeasure.ZERO);
+ index = equationManager.combine(indices[1], 1, PixelMeasure.ZERO, "test");
Assert.assertEquals(10, index);
- int[] i10 = equationManager.partition(10, 2, PixelMeasure.ZERO);
+ int[] i10 = equationManager.partition(10, 2, PixelMeasure.ZERO, "test");
Assert.assertArrayEquals(new int[]{11, 12}, i10);
- equationManager.proportionate(i10[0], i10[1], 4, 1);
+ equationManager.proportionate(i10[0], i10[1], 4, 1, "test");
}
{
- index = equationManager.combine(indices[2], 1, PixelMeasure.ZERO);
+ index = equationManager.combine(indices[2], 1, PixelMeasure.ZERO, "test");
Assert.assertEquals(13, index);
}
{
- index = equationManager.combine(indices[3], 1, PixelMeasure.ZERO);
+ index = equationManager.combine(indices[3], 1, PixelMeasure.ZERO, "test");
Assert.assertEquals(14, index);
- int[] i14 = equationManager.partition(14, 2, PixelMeasure.ZERO);
+ int[] i14 = equationManager.partition(14, 2, PixelMeasure.ZERO, "test");
Assert.assertArrayEquals(new int[]{15, 16}, i14);
- equationManager.setFixedLength(i14[0], new PixelMeasure(130)); // the second one has a fix size of 200
+ equationManager.setFixedLength(i14[0], new PixelMeasure(130), "test"); // the second one has a fix size of 200
}
{
- int iSpan2 = equationManager.combine(indices[2], 2, PixelMeasure.ZERO);
+ int iSpan2 = equationManager.combine(indices[2], 2, PixelMeasure.ZERO, "test");
Assert.assertEquals(17, iSpan2);
}
{
- int iSpan4 = equationManager.combine(indices[0], 4, PixelMeasure.ZERO);
+ int iSpan4 = equationManager.combine(indices[0], 4, PixelMeasure.ZERO, "test");
Assert.assertEquals(18, iSpan4);
- int[] i18 = equationManager.partition(18, 6, PixelMeasure.ZERO);
+ int[] i18 = equationManager.partition(18, 6, PixelMeasure.ZERO, "test");
Assert.assertArrayEquals(new int[]{19, 20, 21, 22, 23, 24}, i18);
- equationManager.proportionate(i18[0], i18[1], 1, 2);
- equationManager.proportionate(i18[0], i18[2], 1, 3);
- equationManager.proportionate(i18[0], i18[3], 1, 4);
- equationManager.proportionate(i18[0], i18[4], 1, 5);
- equationManager.proportionate(i18[0], i18[5], 1, 6);
+ equationManager.proportionate(i18[0], i18[1], 1, 2, "test");
+ equationManager.proportionate(i18[0], i18[2], 1, 3, "test");
+ equationManager.proportionate(i18[0], i18[3], 1, 4, "test");
+ equationManager.proportionate(i18[0], i18[4], 1, 5, "test");
+ equationManager.proportionate(i18[0], i18[5], 1, 6, "test");
}
{
- int i19_1 = equationManager.combine(19, 6, PixelMeasure.ZERO);
+ int i19_1 = equationManager.combine(19, 6, PixelMeasure.ZERO, "test");
Assert.assertEquals(25, i19_1);
- int i19_2 = equationManager.combine(19, 3, PixelMeasure.ZERO);
+ int i19_2 = equationManager.combine(19, 3, PixelMeasure.ZERO, "test");
Assert.assertEquals(26, i19_2);
- int i22 = equationManager.combine(22, 3, PixelMeasure.ZERO);
+ int i22 = equationManager.combine(22, 3, PixelMeasure.ZERO, "test");
Assert.assertEquals(27, i22);
}
Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/MathUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/MathUtilsUnitTest.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/MathUtilsUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/MathUtilsUnitTest.java Wed Aug 5 11:48:51 2009
@@ -25,35 +25,43 @@
@Test
public void testAdjust() {
double[] d = {6.3, 7.9, 8.7, 9.2, 10.3, 11.6};
- MathUtils.adjustRemainders(d);
+ MathUtils.adjustRemainders(d, 0.0);
Assert.assertArrayEquals("mixed", new double[]{6, 8, 9, 9, 10, 12}, d, MathUtils.EPSILON);
}
@Test
public void testAdjust999() {
double[] d = {9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9, 9.9};
- MathUtils.adjustRemainders(d);
+ MathUtils.adjustRemainders(d, 0.0);
Assert.assertArrayEquals(
- "9.9, ...", new double[]{10, 9, 10, 10, 10, 10, 10, 10, 10, 10}, d, MathUtils.EPSILON);
+ "9.9, ...", new double[]{9, 10, 10, 10, 10, 10, 10, 10, 10, 10}, d, MathUtils.EPSILON);
}
@Test
public void testAdjust111() {
double[] d = {1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1};
- MathUtils.adjustRemainders(d);
+ MathUtils.adjustRemainders(d, 0.0);
Assert.assertArrayEquals(
- "1.1, ...", new double[]{2, 1, 1, 1, 1, 1, 1, 1, 1, 1}, d, MathUtils.EPSILON);
+ "1.1, ...", new double[]{1, 2, 1, 1, 1, 1, 1, 1, 1, 1}, d, MathUtils.EPSILON);
}
@Test
public void testAdjust133() {
double[] d = {1, 1, 1, 1.333333333, 1.333333333, 1.333333333, 1, 1, 1};
- MathUtils.adjustRemainders(d);
+ MathUtils.adjustRemainders(d, 0.0);
Assert.assertArrayEquals(
- "1, ..., 1.333...", new double[]{1, 1, 1, 2, 1, 1, 1, 1, 1}, d, MathUtils.EPSILON);
+ "1, ..., 1.333...", new double[]{1, 1, 1, 1, 2, 1, 1, 1, 1}, d, MathUtils.EPSILON);
}
@Test
+ public void testInitialBias() {
+ double[] d = {5.5};
+ MathUtils.adjustRemainders(d, 0.5);
+ Assert.assertArrayEquals("initial bias", new double[]{5}, d, MathUtils.EPSILON);
+ }
+
+
+ @Test
public void testIsZero() {
Assert.assertTrue(MathUtils.isZero(0));
Assert.assertFalse(MathUtils.isZero(1.0/1000.0));
Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/PartitionEquationUnitTest.java Wed Aug 5 11:48:51 2009
@@ -25,37 +25,37 @@
@Test
public void testToString() {
- Assert.assertEquals("PartitionEquation: x_0 = x_4",
- new PartitionEquation(4, 1, 0, PixelMeasure.ZERO).toString());
- Assert.assertEquals("PartitionEquation: x_0 = x_4 + x_5",
- new PartitionEquation(4, 2, 0, PixelMeasure.ZERO).toString());
- Assert.assertEquals("PartitionEquation: x_0 = x_4 + ... + x_6",
- new PartitionEquation(4, 3, 0, PixelMeasure.ZERO).toString());
+ Assert.assertEquals("PartitionEquation: x_0 = x_4 (test)",
+ new PartitionEquation(4, 1, 0, PixelMeasure.ZERO, "test").toString());
+ Assert.assertEquals("PartitionEquation: x_0 = x_4 + x_5 (test)",
+ new PartitionEquation(4, 2, 0, PixelMeasure.ZERO, "test").toString());
+ Assert.assertEquals("PartitionEquation: x_0 = x_4 + ... + x_6 (test)",
+ new PartitionEquation(4, 3, 0, PixelMeasure.ZERO, "test").toString());
- Assert.assertEquals("PartitionEquation: x_0 = x_4",
- new PartitionEquation(4, 1, 0, new PixelMeasure(5)).toString());
- Assert.assertEquals("PartitionEquation: x_0 = x_4 + x_5 + 5px",
- new PartitionEquation(4, 2, 0, new PixelMeasure(5)).toString());
- Assert.assertEquals("PartitionEquation: x_0 = x_4 + ... + x_6 + 2 * 5px",
- new PartitionEquation(4, 3, 0, new PixelMeasure(5)).toString());
+ Assert.assertEquals("PartitionEquation: x_0 = x_4 (test)",
+ new PartitionEquation(4, 1, 0, new PixelMeasure(5), "test").toString());
+ Assert.assertEquals("PartitionEquation: x_0 = x_4 + x_5 + 5px (test)",
+ new PartitionEquation(4, 2, 0, new PixelMeasure(5), "test").toString());
+ Assert.assertEquals("PartitionEquation: x_0 = x_4 + ... + x_6 + 2 * 5px (test)",
+ new PartitionEquation(4, 3, 0, new PixelMeasure(5), "test").toString());
}
@Test
public void testFillRow() {
double[] row = new double[8];
- new PartitionEquation(4, 1, 0, PixelMeasure.ZERO).fillRow(row);
+ new PartitionEquation(4, 1, 0, PixelMeasure.ZERO, "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
- new PartitionEquation(4, 2, 0, PixelMeasure.ZERO).fillRow(row);
+ new PartitionEquation(4, 2, 0, PixelMeasure.ZERO, "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 1, 0, 0}, row, MathUtils.EPSILON);
- new PartitionEquation(4, 3, 0, PixelMeasure.ZERO).fillRow(row);
+ new PartitionEquation(4, 3, 0, PixelMeasure.ZERO, "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 1, 1, 0}, row, MathUtils.EPSILON);
- new PartitionEquation(4, 1, 0, new PixelMeasure(5)).fillRow(row);
+ new PartitionEquation(4, 1, 0, new PixelMeasure(5), "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 0, 0, 0}, row, MathUtils.EPSILON);
- new PartitionEquation(4, 2, 0, new PixelMeasure(5)).fillRow(row);
+ new PartitionEquation(4, 2, 0, new PixelMeasure(5), "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 1, 0, -5}, row, MathUtils.EPSILON);
- new PartitionEquation(4, 3, 0, new PixelMeasure(5)).fillRow(row);
+ new PartitionEquation(4, 3, 0, new PixelMeasure(5), "test").fillRow(row);
Assert.assertArrayEquals(new double[] {-1, 0, 0, 0, 1, 1, 1, -10}, row, MathUtils.EPSILON);
}
}
\ No newline at end of file
Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/layout/math/SystemOfEquationsUnitTest.java Wed Aug 5 11:48:51 2009
@@ -37,9 +37,9 @@
long begin = System.nanoTime();
SystemOfEquations system = new SystemOfEquations(3);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1005)));
- system.addEqualsEquation(new PartitionEquation(1, 2, 0, new PixelMeasure(5)));
- system.addEqualsEquation(new ProportionEquation(1, 2, 2, 3));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1005), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 2, 0, new PixelMeasure(5), "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 2, 3, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -57,11 +57,11 @@
long begin = System.nanoTime();
SystemOfEquations system = new SystemOfEquations(5);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1015)));
- system.addEqualsEquation(new PartitionEquation(1, 4, 0, new PixelMeasure(5)));
- system.addEqualsEquation(new ProportionEquation(1, 2, 1, 2));
- system.addEqualsEquation(new ProportionEquation(2, 3, 2, 3));
- system.addEqualsEquation(new ProportionEquation(3, 4, 3, 4));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1015), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 4, 0, new PixelMeasure(5), "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 2, "test"));
+ system.addEqualsEquation(new ProportionEquation(2, 3, 2, 3, "test"));
+ system.addEqualsEquation(new ProportionEquation(3, 4, 3, 4, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -80,17 +80,17 @@
long begin = System.nanoTime();
SystemOfEquations system = new SystemOfEquations(11);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1100)));
- system.addEqualsEquation(new PartitionEquation(1, 10, 0, PixelMeasure.ZERO));
- system.addEqualsEquation(new ProportionEquation(1, 2, 1, 2));
- system.addEqualsEquation(new ProportionEquation(2, 3, 2, 3));
- system.addEqualsEquation(new ProportionEquation(3, 4, 3, 4));
- system.addEqualsEquation(new ProportionEquation(4, 5, 4, 5));
- system.addEqualsEquation(new ProportionEquation(5, 6, 5, 6));
- system.addEqualsEquation(new ProportionEquation(6, 7, 6, 7));
- system.addEqualsEquation(new ProportionEquation(7, 8, 7, 8));
- system.addEqualsEquation(new ProportionEquation(8, 9, 8, 9));
- system.addEqualsEquation(new ProportionEquation(9, 10, 9, 10));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1100), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 10, 0, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 2, "test"));
+ system.addEqualsEquation(new ProportionEquation(2, 3, 2, 3, "test"));
+ system.addEqualsEquation(new ProportionEquation(3, 4, 3, 4, "test"));
+ system.addEqualsEquation(new ProportionEquation(4, 5, 4, 5, "test"));
+ system.addEqualsEquation(new ProportionEquation(5, 6, 5, 6, "test"));
+ system.addEqualsEquation(new ProportionEquation(6, 7, 6, 7, "test"));
+ system.addEqualsEquation(new ProportionEquation(7, 8, 7, 8, "test"));
+ system.addEqualsEquation(new ProportionEquation(8, 9, 8, 9, "test"));
+ system.addEqualsEquation(new ProportionEquation(9, 10, 9, 10, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -113,10 +113,10 @@
int sum = n * (n + 1) / 2;
SystemOfEquations system = new SystemOfEquations(n + 1);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(sum)));
- system.addEqualsEquation(new PartitionEquation(1, n, 0, PixelMeasure.ZERO));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(sum), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, n, 0, PixelMeasure.ZERO, "test"));
for (int i = 1; i < n; i++) {
- system.addEqualsEquation(new ProportionEquation(i, i + 1, (double) i, (double) i + 1));
+ system.addEqualsEquation(new ProportionEquation(i, i + 1, (double) i, (double) i + 1, "test"));
}
Measure[] result = system.solve();
@@ -145,14 +145,14 @@
long begin = System.nanoTime();
SystemOfEquations system = new SystemOfEquations(8);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(900)));
- system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO));
- system.addEqualsEquation(new CombinationEquation(4, 2, 2, PixelMeasure.ZERO));
- system.addEqualsEquation(new PartitionEquation(5, 3, 4, PixelMeasure.ZERO));
- system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1));
- system.addEqualsEquation(new ProportionEquation(1, 3, 1, 1));
- system.addEqualsEquation(new ProportionEquation(5, 6, 1, 1));
- system.addEqualsEquation(new ProportionEquation(5, 7, 1, 1));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(900), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new CombinationEquation(4, 2, 2, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new PartitionEquation(5, 3, 4, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 3, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(5, 6, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(5, 7, 1, 1, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -190,13 +190,13 @@
SystemOfEquations system = new SystemOfEquations(8);
// system.addEqualsEquation(new FixedEquation(0, 900));
- system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO));
- system.addEqualsEquation(new CombinationEquation(4, 2, 2, PixelMeasure.ZERO));
- system.addEqualsEquation(new PartitionEquation(5, 3, 4, PixelMeasure.ZERO));
- system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1));
- system.addEqualsEquation(new ProportionEquation(1, 3, 1, 1));
- system.addEqualsEquation(new ProportionEquation(5, 6, 1, 1));
- system.addEqualsEquation(new ProportionEquation(5, 7, 1, 1));
+ system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new CombinationEquation(4, 2, 2, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new PartitionEquation(5, 3, 4, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 3, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(5, 6, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(5, 7, 1, 1, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -221,12 +221,12 @@
long begin = System.nanoTime();
SystemOfEquations system = new SystemOfEquations(4);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(100)));
- system.addEqualsEquation(new PartitionEquation(1, 2, 0, PixelMeasure.ZERO));
- system.addEqualsEquation(new FixedEquation(1, new PixelMeasure(50)));
- system.addEqualsEquation(new FixedEquation(2, new PixelMeasure(50)));
- system.addEqualsEquation(new PartitionEquation(3, 1, 2, PixelMeasure.ZERO));
- system.addEqualsEquation(new FixedEquation(3, new PixelMeasure(50)));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(100), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 2, 0, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new FixedEquation(1, new PixelMeasure(50), "test"));
+ system.addEqualsEquation(new FixedEquation(2, new PixelMeasure(50), "test"));
+ system.addEqualsEquation(new PartitionEquation(3, 1, 2, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new FixedEquation(3, new PixelMeasure(50), "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -252,13 +252,13 @@
SystemOfEquations system = new SystemOfEquations(8);
// system.addEqualsEquation(new FixedEquation(0, 900));
- system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO));
- system.addEqualsEquation(new CombinationEquation(4, 2, 2, PixelMeasure.ZERO));
- system.addEqualsEquation(new PartitionEquation(5, 3, 4, PixelMeasure.ZERO));
- system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1));
- system.addEqualsEquation(new ProportionEquation(1, 3, 1, 1));
- system.addEqualsEquation(new ProportionEquation(5, 6, 1, 1));
- system.addEqualsEquation(new ProportionEquation(5, 7, 1, 1));
+ system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new CombinationEquation(4, 2, 2, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new PartitionEquation(5, 3, 4, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 3, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(5, 6, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(5, 7, 1, 1, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -277,10 +277,10 @@
long begin = System.nanoTime();
SystemOfEquations system = new SystemOfEquations(4);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1001)));
- system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO));
- system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1));
- system.addEqualsEquation(new ProportionEquation(2, 3, 1, 1));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(1001), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 3, 0, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1, "test"));
+ system.addEqualsEquation(new ProportionEquation(2, 3, 1, 1, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -289,7 +289,7 @@
LOG.info("Duration: " + new DecimalFormat().format(end - begin) + " ns");
Assert.assertArrayEquals(new Measure[]{
- new PixelMeasure(1001), new PixelMeasure(334), new PixelMeasure(333), new PixelMeasure(334)}, result);
+ new PixelMeasure(1001), new PixelMeasure(333), new PixelMeasure(334), new PixelMeasure(334)}, result);
}
@Test
@@ -298,13 +298,13 @@
long begin = System.nanoTime();
SystemOfEquations system = new SystemOfEquations(7);
- system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(310)));
- system.addEqualsEquation(new PartitionEquation(1, 2, 0, new PixelMeasure(5)));
- system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1));
- system.addEqualsEquation(new CombinationEquation(3, 1, 1, PixelMeasure.ZERO));
- system.addEqualsEquation(new CombinationEquation(4, 1, 1, PixelMeasure.ZERO));
- system.addEqualsEquation(new CombinationEquation(5, 2, 1, PixelMeasure.ZERO));
- system.addEqualsEquation(new CombinationEquation(6, 2, 1, PixelMeasure.ZERO));
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(310), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 2, 0, new PixelMeasure(5), "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1, "test"));
+ system.addEqualsEquation(new CombinationEquation(3, 1, 1, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new CombinationEquation(4, 1, 1, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new CombinationEquation(5, 2, 1, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new CombinationEquation(6, 2, 1, PixelMeasure.ZERO, "test"));
Measure[] result = system.solve();
long end = System.nanoTime();
@@ -313,8 +313,29 @@
LOG.info("Duration: " + new DecimalFormat().format(end - begin) + " ns");
Assert.assertArrayEquals(new Measure[]{
- new PixelMeasure(310), new PixelMeasure(153), new PixelMeasure(152),
- new PixelMeasure(153), new PixelMeasure(153), new PixelMeasure(152), new PixelMeasure(152)}, result);
+ new PixelMeasure(310), new PixelMeasure(152), new PixelMeasure(153),
+ new PixelMeasure(152), new PixelMeasure(152), new PixelMeasure(153), new PixelMeasure(153)}, result);
+ }
+
+ @Test
+ public void testRoundWithPartitionToPartition() {
+
+ long begin = System.nanoTime();
+
+ SystemOfEquations system = new SystemOfEquations(4);
+ system.addEqualsEquation(new FixedEquation(0, new PixelMeasure(11), "test"));
+ system.addEqualsEquation(new PartitionEquation(1, 2, 0, PixelMeasure.ZERO, "test"));
+ system.addEqualsEquation(new ProportionEquation(1, 2, 1, 1, "test"));
+ system.addEqualsEquation(new PartitionEquation(3, 1, 1, PixelMeasure.ZERO, "test"));
+ Measure[] result = system.solve();
+
+ long end = System.nanoTime();
+
+ LOG.info("result: " + Arrays.toString(result));
+ LOG.info("Duration: " + new DecimalFormat().format(end - begin) + " ns");
+
+ Assert.assertArrayEquals(new Measure[]{
+ new PixelMeasure(11), new PixelMeasure(5), new PixelMeasure(6), new PixelMeasure(5)}, result);
}
/**
Modified: myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java (original)
+++ myfaces/tobago/trunk/core/src/test/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriterUnitTest.java Wed Aug 5 11:48:51 2009
@@ -30,7 +30,7 @@
protected void setUp() throws Exception {
super.setUp();
stringWriter = new StringWriter();
- writer = new TobagoResponseWriterImpl(stringWriter, "", "UTF-8");
+ writer = new TobagoResponseWriterImpl(stringWriter, "", "UTF-8", false);
}
public void testDocument() throws IOException {
@@ -96,7 +96,7 @@
}
public void testNonUtf8() throws IOException {
- TobagoResponseWriterImpl writer1 = new TobagoResponseWriterImpl(stringWriter, "", "ISO-8859-1");
+ TobagoResponseWriterImpl writer1 = new TobagoResponseWriterImpl(stringWriter, "", "ISO-8859-1", false);
writer1.startElement("input", null);
writer1.writeAttribute("value", "Gutschein über 100 â¬.", null);
writer1.writeAttribute("readonly", true);
@@ -106,7 +106,7 @@
}
public void testCharArray() throws IOException {
- TobagoResponseWriterImpl writer = new TobagoResponseWriterImpl(stringWriter, "text/xml", "ISO-8859-1");
+ TobagoResponseWriterImpl writer = new TobagoResponseWriterImpl(stringWriter, "text/xml", "ISO-8859-1", true);
writer.writeText("123".toCharArray(), 0, 3);
assertEquals("123", stringWriter.toString());
}
Modified: myfaces/tobago/trunk/example/test/src/main/resources/log4j.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/resources/log4j.xml?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/resources/log4j.xml (original)
+++ myfaces/tobago/trunk/example/test/src/main/resources/log4j.xml Wed Aug 5 11:48:51 2009
@@ -34,6 +34,12 @@
<priority value="debug" />
</category>
+<!--
+ <category name="org.apache.myfaces.tobago.context.ResourceLocator">
+ <priority value="debug" />
+ </category>
+-->
+
<root>
<priority value="info" />
<appender-ref ref="logfile" />
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/navigation.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/navigation.xhtml?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/navigation.xhtml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/navigation.xhtml Wed Aug 5 11:48:51 2009
@@ -22,5 +22,7 @@
<!-- src will be set via tc:treeNode -->
<tc:object id="content" />
+ <!--<tc:script file="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"/>-->
+
</tc:page>
</f:view>
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/tc/cell/3x3-center.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/cell/3x3-center.xhtml?rev=801140&r1=801139&r2=801140&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/cell/3x3-center.xhtml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/cell/3x3-center.xhtml Wed Aug 5 11:48:51 2009
@@ -18,7 +18,7 @@
<tc:cell spanX="3"/>
<tc:cell/>
- <tc:in value="test" id="in"/>
+ <tc:image value="pidgeon-point.jpg" id="in"/>
<tc:cell/>
<tc:cell spanX="3"/>