[isidorus-cvs] r544 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base values

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Fri Jul 1 10:26:12 UTC 2011


Author: lgiessmann
Date: Fri Jul  1 03:26:12 2011
New Revision: 544

Log:
gdl-frontend: Widgets: implemented a method that gets the GDL border-width and border[-top,-right,-bottom,-left]-width properties; added the class AbsoluteNumValue that wraps numeric values that describes px or pt units

Added:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AbsoluteNumValue.java
Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/NumUnitValue.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Jul  1 03:10:46 2011	(r543)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Jul  1 03:26:12 2011	(r544)
@@ -7,6 +7,7 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.values.AutoNumValue;
 import us.isidor.gdl.anaToMia.Widgets.values.BorderStyle;
+import us.isidor.gdl.anaToMia.Widgets.values.AbsoluteNumValue;
 import us.isidor.gdl.anaToMia.Widgets.values.ClearValue;
 import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
 import us.isidor.gdl.anaToMia.Widgets.values.NumUnitValue;
@@ -553,29 +554,144 @@
 	}
 	
 
-
+	// returns a ColorValue instance that represents the width of this element's border.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public AbsoluteNumValue getBorderWidth(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence widthOcc = null;
+		if(styleClass != null){
+			widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderWidth, styleClass);
+		} else {
+			widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderWidth);
+		}
+		
+		if(widthOcc == null && styleClass != null){
+			return null;
+		} else if(widthOcc == null) {
+			return new AbsoluteNumValue();
+		} else {
+			return new AbsoluteNumValue(widthOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the width of this element's border-top.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public AbsoluteNumValue getBorderTopWidth(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence widthOcc = null;
+		if(styleClass != null){
+			widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopWidth, styleClass);
+		} else {
+			widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopWidth);
+		}
+		
+		if(widthOcc == null && styleClass != null){
+			return null;
+		} else if(widthOcc == null) {
+			return new AbsoluteNumValue();
+		} else {
+			return new AbsoluteNumValue(widthOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the width of this element's border-right.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public AbsoluteNumValue getBorderRightWidth(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence widthOcc = null;
+		if(styleClass != null){
+			widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightWidth, styleClass);
+		} else {
+			widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightWidth);
+		}
+		
+		if(widthOcc == null && styleClass != null){
+			return null;
+		} else if(widthOcc == null) {
+			return new AbsoluteNumValue();
+		} else {
+			return new AbsoluteNumValue(widthOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the width of this element's border-bottom.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public AbsoluteNumValue getBorderBottomWidth(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence widthOcc = null;
+		if(styleClass != null){
+			widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomWidth, styleClass);
+		} else {
+			widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomWidth);
+		}
+		
+		if(widthOcc == null && styleClass != null){
+			return null;
+		} else if(widthOcc == null) {
+			return new AbsoluteNumValue();
+		} else {
+			return new AbsoluteNumValue(widthOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the width of this element's border-left.
+	// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+	// null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this
+	// property is returned.
+	public AbsoluteNumValue getBorderLeftWidth(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence widthOcc = null;
+		if(styleClass != null){
+			widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftWidth, styleClass);
+		} else {
+			widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftWidth);
+		}
+		
+		if(widthOcc == null && styleClass != null){
+			return null;
+		} else if(widthOcc == null) {
+			return new AbsoluteNumValue();
+		} else {
+			return new AbsoluteNumValue(widthOcc.getValue());
+		}
+	}
+	
 	// gdlBorderWidth [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderWidthTop [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderWidthRight [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderWidthBottom [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderWidthLeft [gdl:hover | gdl:focus | gdl:active]
+	
 	// gdlBorderRadius [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderTopRightRadius [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderTopLeftRadius [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderBottomRightRadius [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderBottomLeftRadius [gdl:hover | gdl:focus | gdl:active]
+	
 	// gdlCursor [gdl:hover | gdl:focus | gdl:active]
+	
 	// gdlWidth [gdl:hover | gdl:focus | gdl:active]
 	// gdlMinWidth [gdl:hover | gdl:focus | gdl:active]
 	// gdlMaxWidth [gdl:hover | gdl:focus | gdl:active]
+	
 	// gdlHeight [gdl:hover | gdl:focus | gdl:active]
 	// gdlMaxHeight [gdl:hover | gdl:focus | gdl:active]
 	// gdlMinHeight [gdl:hover | gdl:focus | gdl:active]
+	
 	// gdlPadding [gdl:hover | gdl:focus | gdl:active]
 	// gdlPaddingTop [gdl:hover | gdl:focus | gdl:active]
 	// gdlPaddingRight [gdl:hover | gdl:focus | gdl:active]
 	// gdlPaddingBottom [gdl:hover | gdl:focus | gdl:active]
 	// gdlPaddingLeft [gdl:hover | gdl:focus | gdl:active]
+	
 	// gdlBackgroundColor [gdl:hover | gdl:focus | gdl:active]
+	
 	// gdlOverflow [gdl:hover | gdl:focus | gdl:active]
 }

Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AbsoluteNumValue.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AbsoluteNumValue.java	Fri Jul  1 03:26:12 2011	(r544)
@@ -0,0 +1,24 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+
+public class AbsoluteNumValue extends NumUnitValue {
+	public AbsoluteNumValue() throws InvalidGdlSchemaException{
+		super("0px");
+	}
+	
+	
+	public AbsoluteNumValue(String value) throws InvalidGdlSchemaException {
+		String upperValue = value.toUpperCase();
+		
+		if(upperValue.endsWith("PX")){
+			super.value = super.makeFloat(upperValue, 2);
+			super.unit = CssUnit.PIXEL;
+		}else if (upperValue.endsWith("PT")){
+			super.value = super.makeFloat(upperValue, 2);
+			super.unit = CssUnit.POINT;
+		}else {
+			throw new InvalidGdlSchemaException("border width values supported by the GDL containing a unit definition must be of the form <numeric-value>(pt|px), but found: " + value);
+		}
+	}
+}

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/NumUnitValue.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/NumUnitValue.java	Fri Jul  1 03:10:46 2011	(r543)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/NumUnitValue.java	Fri Jul  1 03:26:12 2011	(r544)
@@ -3,8 +3,8 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 
 public class NumUnitValue {
-	private CssUnit unit = CssUnit.PIXEL;
-	private float value = 0f;
+	protected CssUnit unit = CssUnit.PIXEL;
+	protected float value = 0f;
 	
 	
 	// some constructors
@@ -14,13 +14,13 @@
 	public NumUnitValue(String numUnit) throws InvalidGdlSchemaException {
 		String value = numUnit.toUpperCase();
 		if(value.endsWith("PX")){
-			this.value = makeFloat(numUnit, 2);
+			this.value = makeFloat(value, 2);
 			this.unit = CssUnit.PIXEL;
 		}else if (value.endsWith("PT")){
-			this.value = makeFloat(numUnit, 2);
+			this.value = makeFloat(value, 2);
 			this.unit = CssUnit.POINT;
 		} else if(value.endsWith("%")){
-			this.value = makeFloat(numUnit, 1);
+			this.value = makeFloat(value, 1);
 			this.unit = CssUnit.PERCENTAGE;
 		} else {
 			throw new InvalidGdlSchemaException("numeric values supported by the GDL containing a unit definition must be of the form <numeric-value>(pt|px|%), but found: " + numUnit);
@@ -30,7 +30,7 @@
 	
 	// a helper method that returns a float parsed of the passed stringToParse,
 	// whereas the tailing endToIgnore characters are ignored
-	private float makeFloat(String stringToParse, int endToIgnore) throws InvalidGdlSchemaException {
+	protected float makeFloat(String stringToParse, int endToIgnore) throws InvalidGdlSchemaException {
 		if(stringToParse == null || stringToParse.length() <= endToIgnore){
 			throw new InvalidGdlSchemaException("numeric values supported by the GDL containing a unit definition must be of the form <numeric-value>(pt|px|%), but found: " + stringToParse);
 		}




More information about the Isidorus-cvs mailing list