You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/10/29 21:44:26 UTC
svn commit: r589849 -
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutInfo.java
Author: bommel
Date: Mon Oct 29 13:44:22 2007
New Revision: 589849
URL: http://svn.apache.org/viewvc?rev=589849&view=rev
Log:
optimized LayoutInfo.parseColumnLayout
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutInfo.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutInfo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutInfo.java?rev=589849&r1=589848&r2=589849&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutInfo.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutInfo.java Mon Oct 29 13:44:22 2007
@@ -154,10 +154,6 @@
}
- public static String[] createLayoutTokens(String columnLayout, int count) {
- return createLayoutTokens(columnLayout, count, "1*");
- }
-
public static String[] createLayoutTokens(String columnLayout, int count, String defaultToken) {
String[] tokens;
if (columnLayout != null) {
@@ -218,6 +214,10 @@
}
public int getSpaceForColumn(int column) {
+ if (column >= spaces.length) {
+ LOG.error("spaces length " + spaces.length + " column " + column);
+ return 0;
+ }
return spaces[column];
}
@@ -299,61 +299,9 @@
}
- public void parseHides(int padding) {
- for (int i = 0; i < layoutTokens.getSize(); i++) {
- if (layoutTokens.get(i) instanceof HideLayoutToken) {
- update(0, i);
- spaces[i] = HIDE;
- if (LOG.isDebugEnabled()) {
- LOG.debug("set column " + i + " from " + layoutTokens.get(i)
- + " to hide " + " clientId='" + clientIdForLogging + "'");
- }
- }
- }
- }
-
- public void parsePixels() {
- for (int i = 0; i < layoutTokens.getSize(); i++) {
- LayoutToken token = layoutTokens.get(i);
- if (token instanceof PixelLayoutToken) {
- int w = ((PixelLayoutToken) token).getPixel();
- update(w, i, true);
- if (LOG.isDebugEnabled()) {
- LOG.debug("set column " + i + " from " + token
- + " to with " + w + " clientId='" + clientIdForLogging + "'");
- }
- }
- }
- }
-
-
- public void parsePercent(double innerWidth) {
+ private void parsePortions(int portions) {
if (columnsLeft()) {
- for (int i = 0; i < layoutTokens.getSize(); i++) {
- LayoutToken token = layoutTokens.get(i);
- if (isFree(i) && token instanceof PercentLayoutToken) {
- int percent = ((PercentLayoutToken) token).getPercent();
- int w = (int) (innerWidth / 100 * percent);
- update(w, i);
- if (LOG.isDebugEnabled()) {
- LOG.debug("set column " + i + " from " + token
- + " to with " + w + " clientId='" + clientIdForLogging + "'");
- }
- }
- }
- }
- }
- public void parsePortions() {
- if (columnsLeft()) {
- // 1. count portions
- int portions = 0;
- for (int i = 0; i < layoutTokens.getSize(); i++) {
- LayoutToken token = layoutTokens.get(i);
- if (isFree(i) && token instanceof RelativeLayoutToken) {
- portions += ((RelativeLayoutToken) token).getFactor();
- }
- }
// 2. calc and set portion
if (portions > 0) {
int widthForPortions = getSpaceLeft();
@@ -418,10 +366,36 @@
public void parseColumnLayout(double space, int padding) {
if (hasLayoutTokens()) {
- parseHides(padding);
- parsePixels();
- parsePercent(space);
- parsePortions();
+ int portions = 0;
+ for (int i = 0; i < layoutTokens.getSize(); i++) {
+ LayoutToken token = layoutTokens.get(i);
+ if (token instanceof HideLayoutToken) {
+ update(0, i);
+ spaces[i] = HIDE;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("set column " + i + " from " + layoutTokens.get(i)
+ + " to hide " + " clientId='" + clientIdForLogging + "'");
+ }
+ } else if (token instanceof PixelLayoutToken) {
+ int w = ((PixelLayoutToken) token).getPixel();
+ update(w, i, true);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("set column " + i + " from " + token
+ + " to with " + w + " clientId='" + clientIdForLogging + "'");
+ }
+ } else if (token instanceof RelativeLayoutToken) {
+ portions += ((RelativeLayoutToken) token).getFactor();
+ } else if (token instanceof PercentLayoutToken) {
+ int percent = ((PercentLayoutToken) token).getPercent();
+ int w = (int) (space / 100 * percent);
+ update(w, i);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("set column " + i + " from " + token
+ + " to with " + w + " clientId='" + clientIdForLogging + "'");
+ }
+ }
+ }
+ parsePortions(portions);
// parseAsterisks();
handleSpaceLeft();
}