[isidorus-cvs] r543 - 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:10:47 UTC 2011


Author: lgiessmann
Date: Fri Jul  1 03:10:46 2011
New Revision: 543

Log:
gdl-frontend: Widgets: implemented a method that gets the GDL border-style and border[-top,-right,-bottom,-left]-style properties; changed all fields of enums in the package us.isidoru.gdl.anaToMia.Widgets.values to uppercase characters to avoid conflicts with java keywords, e.g. double (borderstyle), ...

Added:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/BorderStyle.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/ClearValue.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ColorValue.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 02:47:43 2011	(r542)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Jul  1 03:10:46 2011	(r543)
@@ -1,22 +1,19 @@
 package us.isidor.gdl.anaToMia.Widgets.base;
 
 import java.util.ArrayList;
-
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
 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.ClearValue;
 import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
 import us.isidor.gdl.anaToMia.Widgets.values.NumUnitValue;
-
-import com.google.gwt.canvas.dom.client.CssColor;
 import com.google.gwt.core.client.JsArray;
 import com.google.gwt.dom.client.Style.Display;
 import com.google.gwt.dom.client.Style.Float;
 import com.google.gwt.dom.client.Style.VerticalAlign;
-import com.google.gwt.resources.css.ast.CssCompilerException;
 import com.google.gwt.user.client.ui.AbsolutePanel;
 import com.google.gwt.user.client.ui.Composite;
 
@@ -180,7 +177,7 @@
 				throw new InvalidGdlSchemaException("The occurrence " + GdlPsis.OccurrenceType.gdlFloat + " must be set to one of \"none\", \"left\", \"right\" or \"both\", but is \"" + clearOcc.getValue() + "\"");
 			}
 		} else {
-			return ClearValue.none;
+			return ClearValue.NONE;
 		}
 	}
 	
@@ -446,11 +443,117 @@
 	}
 
 
-	// gdlBorderStyle [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderStyleTop [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderStyleRight [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderStyleBottom [gdl:hover | gdl:focus | gdl:active]
-	// gdlBorderStyleLeft [gdl:hover | gdl:focus | gdl:active]
+	// returns a ColorValue instance that represents the style 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 BorderStyle getBorderStyle(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence styleOcc = null;
+		if(styleClass != null){
+			styleOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderStyle, styleClass);
+		} else {
+			styleOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderStyle);
+		}
+		
+		if(styleOcc == null && styleClass != null){
+			return null;
+		} else if(styleOcc == null) {
+			return BorderStyle.NONE;
+		} else {
+			return BorderStyle.valueOf(styleOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the style 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 BorderStyle getBorderTopStyle(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence styleOcc = null;
+		if(styleClass != null){
+			styleOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopStyle, styleClass);
+		} else {
+			styleOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopStyle);
+		}
+		
+		if(styleOcc == null && styleClass != null){
+			return null;
+		} else if(styleOcc == null) {
+			return BorderStyle.NONE;
+		} else {
+			return BorderStyle.valueOf(styleOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the style 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 BorderStyle getBorderRightStyle(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence styleOcc = null;
+		if(styleClass != null){
+			styleOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightStyle, styleClass);
+		} else {
+			styleOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightStyle);
+		}
+		
+		if(styleOcc == null && styleClass != null){
+			return null;
+		} else if(styleOcc == null) {
+			return BorderStyle.NONE;
+		} else {
+			return BorderStyle.valueOf(styleOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the style 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 BorderStyle getBorderBottomStyle(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence styleOcc = null;
+		if(styleClass != null){
+			styleOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomStyle, styleClass);
+		} else {
+			styleOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomStyle);
+		}
+		
+		if(styleOcc == null && styleClass != null){
+			return null;
+		} else if(styleOcc == null) {
+			return BorderStyle.NONE;
+		} else {
+			return BorderStyle.valueOf(styleOcc.getValue());
+		}
+	}
+	
+	
+	// returns a ColorValue instance that represents the style 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 BorderStyle getBorderLeftStyle(String styleClass) throws InvalidGdlSchemaException {
+		Occurrence styleOcc = null;
+		if(styleClass != null){
+			styleOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftStyle, styleClass);
+		} else {
+			styleOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftStyle);
+		}
+		
+		if(styleOcc == null && styleClass != null){
+			return null;
+		} else if(styleOcc == null) {
+			return BorderStyle.NONE;
+		} else {
+			return BorderStyle.valueOf(styleOcc.getValue());
+		}
+	}
+	
+
+
 	// gdlBorderWidth [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderWidthTop [gdl:hover | gdl:focus | gdl:active]
 	// gdlBorderWidthRight [gdl:hover | gdl:focus | gdl:active]

Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/BorderStyle.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/BorderStyle.java	Fri Jul  1 03:10:46 2011	(r543)
@@ -0,0 +1,14 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+public enum BorderStyle {
+	NONE,
+	HIDDEN,
+	DOTTED,
+	DASHED,
+	SOLID,
+	DOUBLE,
+	GROOVE,
+	RIDGE,
+	INSET,
+	OUTSET
+}

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ClearValue.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ClearValue.java	Fri Jul  1 02:47:43 2011	(r542)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ClearValue.java	Fri Jul  1 03:10:46 2011	(r543)
@@ -1,8 +1,8 @@
 package us.isidor.gdl.anaToMia.Widgets.values;
 
 public enum ClearValue {
-	none,
-	left,
-	right,
-	both
+	NONE,
+	LEFT,
+	RIGHT,
+	BOTH
 }

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ColorValue.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ColorValue.java	Fri Jul  1 02:47:43 2011	(r542)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ColorValue.java	Fri Jul  1 03:10:46 2011	(r543)
@@ -13,13 +13,13 @@
 	
 	
 	public ColorValue(String color) throws InvalidGdlSchemaException{
-		String value = color.toLowerCase();
+		String value = color.toUpperCase();
 		
-		if(value.matches("^(maroon|red|orange|yellow|olive|purple|fuchsia|white|lime|green|navy|blue|aqua|teal|black|silver|gray)$")){
+		if(value.matches("^(MAROON|RED|ORANGE|YELLOW|OLIVE|PURPLE|FUCHSIA|WHITE|LIME|GREEN|NAVY|BLUE|AQUA|TEAL|BLACK|SILVER|GRAY)$")){
 			this.stringValue = cssColorToRRGGBB(CssColor.valueOf(value));
-		}else if(value.matches("^#[0-9a-f]{6}$")) {
+		}else if(value.matches("^#[0-9A-F]{6}$")) {
 			this.stringValue = value;
-		}else if(value.matches("^#[0-9a-f]{3}$")) {
+		}else if(value.matches("^#[0-9A-F]{3}$")) {
 			this.stringValue = "#" + value.charAt(1) + value.charAt(1) + value.charAt(2) + value.charAt(2) + value.charAt(3) + value.charAt(3);
 		}else if(value.matches("^rgb\\( *\\+?[0-9]{1,3} *, *\\+?[0-9]{1,3} *, *\\+?[0-9]{1,3} *\\)$")){
 			String[] rgb = value.substring(4, value.length() - 1).split(",");
@@ -66,22 +66,22 @@
 	// to a string of the format ##RRGGBB
 	private String cssColorToRRGGBB(CssColor color){
 		switch(color){
-		case maroon: return "#800000";
-		case red: return "#ff0000";
-		case orange: return "#ffa500";
-		case yellow: return "#ffff00";
-		case olive: return "#808000";
-		case purple: return "#800080";
-		case fuchsia: return "#ff00ff";
-		case white: return "#ffffff";
-		case lime: return "#00ff00";
-		case green: return "#008000";
-		case navy: return "#000080";
-		case blue: return "#0000ff";
-		case aqua: return "#00ffff";
-		case teal: return "#008080";
-		case black: return "#000000";
-		case silver: return "#c0c0c0";
+		case MAROON: return "#800000";
+		case RED: return "#ff0000";
+		case ORANGE: return "#ffa500";
+		case YELLOW: return "#ffff00";
+		case OLIVE: return "#808000";
+		case PURPLE: return "#800080";
+		case FUCHSIA: return "#ff00ff";
+		case WHITE: return "#ffffff";
+		case LIME: return "#00ff00";
+		case GREEN: return "#008000";
+		case NAVY: return "#000080";
+		case BLUE: return "#0000ff";
+		case AQUA: return "#00ffff";
+		case TEAL: return "#008080";
+		case BLACK: return "#000000";
+		case SILVER: return "#c0c0c0";
 		default: return "#808080";
 		}
 	}
@@ -109,39 +109,39 @@
 	// the return value is null
 	public CssColor getCssColor(){
 		if(this.stringValue.equals("#800000")){
-			return CssColor.maroon;
+			return CssColor.MAROON;
 		}else if(this.stringValue.equals("#ff0000")){
-			return CssColor.red;
+			return CssColor.RED;
 		}else if(this.stringValue.equals("#ffa500")) {
-			return CssColor.orange;
+			return CssColor.ORANGE;
 		}else if(this.stringValue.equals("#ffff00")){
-			return CssColor.yellow;
+			return CssColor.YELLOW;
 		}else if(this.stringValue.equals("#808000")) {
-			return CssColor.olive;
+			return CssColor.OLIVE;
 		}else if(this.stringValue.equals("#800080")){
-			return CssColor.purple;
+			return CssColor.PURPLE;
 		}else if(this.stringValue.equals("#ff00ff")) {
-			return CssColor.fuchsia;
+			return CssColor.FUCHSIA;
 		}else if(this.stringValue.equals("#ffffff")){
-			return CssColor.white;
+			return CssColor.WHITE;
 		}else if(this.stringValue.equals("#00ff00")) {
-			return CssColor.lime;
+			return CssColor.LIME;
 		}else if(this.stringValue.equals("#008000")) {
-			return CssColor.green;
+			return CssColor.GREEN;
 		}else if(this.stringValue.equals("#000080")) {
-			return CssColor.navy;
+			return CssColor.NAVY;
 		}else if(this.stringValue.equals("#0000ff")) {
-			return CssColor.blue;
+			return CssColor.BLUE;
 		}else if(this.stringValue.equals("#00ffff")) {
-			return CssColor.aqua;
+			return CssColor.AQUA;
 		}else if(this.stringValue.equals("#008080")) {
-			return CssColor.teal;
+			return CssColor.TEAL;
 		}else if(this.stringValue.equals("#000000")) {
-			return CssColor.black;
+			return CssColor.BLACK;
 		}else if(this.stringValue.equals("#c0c0c0")) {
-			return CssColor.silver;
+			return CssColor.SILVER;
 		}else if(this.stringValue.equals("#808080")) {
-			return CssColor.gray;
+			return CssColor.GRAY;
 		}else {
 			return null;
 		}
@@ -151,22 +151,22 @@
 	// represents the color key words that are defined in CSS chapter 4.3.6
 	// (http://www.w3.org/TR/CSS21/syndata.html#value-def-color)
 	public enum CssColor{
-		maroon,
-		red,
-		orange,
-		yellow,
-		olive,
-		purple,
-		fuchsia,
-		white,
-		lime,
-		green,
-		navy,
-		blue,
-		aqua,
-		teal,
-		black,
-		silver,
-		gray
+		MAROON,
+		RED,
+		ORANGE,
+		YELLOW,
+		OLIVE,
+		PURPLE,
+		FUCHSIA,
+		WHITE,
+		LIME,
+		GREEN,
+		NAVY,
+		BLUE,
+		AQUA,
+		TEAL,
+		BLACK,
+		SILVER,
+		GRAY
 	}
 }

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 02:47:43 2011	(r542)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/NumUnitValue.java	Fri Jul  1 03:10:46 2011	(r543)
@@ -3,7 +3,7 @@
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 
 public class NumUnitValue {
-	private CssUnit unit = CssUnit.pixel;
+	private CssUnit unit = CssUnit.PIXEL;
 	private float value = 0f;
 	
 	
@@ -12,15 +12,16 @@
 	
 	
 	public NumUnitValue(String numUnit) throws InvalidGdlSchemaException {
-		if(numUnit.endsWith("px")){
+		String value = numUnit.toUpperCase();
+		if(value.endsWith("PX")){
 			this.value = makeFloat(numUnit, 2);
-			this.unit = CssUnit.pixel;
-		}else if (numUnit.endsWith("pt")){
+			this.unit = CssUnit.PIXEL;
+		}else if (value.endsWith("PT")){
 			this.value = makeFloat(numUnit, 2);
-			this.unit = CssUnit.point;
-		} else if(numUnit.endsWith("%")){
+			this.unit = CssUnit.POINT;
+		} else if(value.endsWith("%")){
 			this.value = makeFloat(numUnit, 1);
-			this.unit = CssUnit.percentage;
+			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);
 		}
@@ -47,20 +48,16 @@
 	// returns the value represented by this instance as a css string
 	public String getStringValue(){
 		switch(this.unit){
-		case pixel: return (int)this.value + "px";
-		case point: return (int)this.value + "pt";
+		case PIXEL: return (int)this.value + "px";
+		case POINT: return (int)this.value + "pt";
 		default: return this.value + "%";
 		}
 	}
 	
 	
 	// returns the numeric value as a float
-	public float getNumValue(){
-		if(this.unit == CssUnit.percentage){
-			return this.value;
-		} else {
-			return (int)this.value;
-		}
+	public int getNumValue(){
+		return (int)this.value;
 	}
 	
 	
@@ -72,8 +69,8 @@
 	
 	// a subset of CSS units that are supported by the GDL
 	public enum CssUnit {
-		point,
-		pixel,
-		percentage
+		POINT,
+		PIXEL,
+		PERCENTAGE
 	}
 }




More information about the Isidorus-cvs mailing list