isidorus-cvs
Threads by month
- ----- 2025 -----
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
July 2011
- 1 participants
- 156 discussions

[isidorus-cvs] r546 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base values
by lgiessmann@common-lisp.net 01 Jul '11
by lgiessmann@common-lisp.net 01 Jul '11
01 Jul '11
Author: lgiessmann
Date: Fri Jul 1 04:33:23 2011
New Revision: 546
Log:
gdl-frontend: Widgets: implemented a method that gets the GDL cursor property;
Added:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/CursorValue.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/TestClass.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 04:01:40 2011 (r545)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Fri Jul 1 04:33:23 2011 (r546)
@@ -11,6 +11,7 @@
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.CursorValue;
import us.isidor.gdl.anaToMia.Widgets.values.NumUnitValue;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.Style.Display;
@@ -174,7 +175,7 @@
if(clearOcc != null){
try{
- return ClearValue.valueOf(clearOcc.getValue().toLowerCase());
+ return ClearValue.valueOf(clearOcc.getValue().toUpperCase());
}catch(IllegalArgumentException e){
throw new InvalidGdlSchemaException("The occurrence " + GdlPsis.OccurrenceType.gdlFloat + " must be set to one of \"none\", \"left\", \"right\" or \"both\", but is \"" + clearOcc.getValue() + "\"");
}
@@ -462,7 +463,12 @@
} else if(styleOcc == null) {
return BorderStyle.NONE;
} else {
- return BorderStyle.valueOf(styleOcc.getValue());
+ try{
+ return BorderStyle.valueOf(styleOcc.getValue());
+ }catch(IllegalArgumentException e){
+ String values = "none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset";
+ throw new InvalidGdlSchemaException("border-style must be set to one of " + values + ", but is " + styleOcc.getValue());
+ }
}
}
@@ -484,7 +490,12 @@
} else if(styleOcc == null) {
return BorderStyle.NONE;
} else {
- return BorderStyle.valueOf(styleOcc.getValue());
+ try{
+ return BorderStyle.valueOf(styleOcc.getValue());
+ }catch(IllegalArgumentException e){
+ String values = "none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset";
+ throw new InvalidGdlSchemaException("border-top-style must be set to one of " + values + ", but is " + styleOcc.getValue());
+ }
}
}
@@ -506,7 +517,12 @@
} else if(styleOcc == null) {
return BorderStyle.NONE;
} else {
- return BorderStyle.valueOf(styleOcc.getValue());
+ try{
+ return BorderStyle.valueOf(styleOcc.getValue());
+ }catch(IllegalArgumentException e){
+ String values = "none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset";
+ throw new InvalidGdlSchemaException("border-right-style must be set to one of " + values + ", but is " + styleOcc.getValue());
+ }
}
}
@@ -528,7 +544,12 @@
} else if(styleOcc == null) {
return BorderStyle.NONE;
} else {
- return BorderStyle.valueOf(styleOcc.getValue());
+ try{
+ return BorderStyle.valueOf(styleOcc.getValue());
+ }catch(IllegalArgumentException e){
+ String values = "none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset";
+ throw new InvalidGdlSchemaException("border-bottom-style must be set to one of " + values + ", but is " + styleOcc.getValue());
+ }
}
}
@@ -550,7 +571,12 @@
} else if(styleOcc == null) {
return BorderStyle.NONE;
} else {
- return BorderStyle.valueOf(styleOcc.getValue());
+ try{
+ return BorderStyle.valueOf(styleOcc.getValue());
+ }catch(IllegalArgumentException e){
+ String values = "none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset";
+ throw new InvalidGdlSchemaException("border-left-style must be set to one of " + values + ", but is " + styleOcc.getValue());
+ }
}
}
@@ -1017,13 +1043,37 @@
}
+ // returns a CursorValue instance that represents the cursor of this element.
+ // 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 CursorValue getCursor(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence cursorOcc = null;
+ if(styleClass != null){
+ cursorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlCursor, styleClass);
+ } else {
+ cursorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlCursor);
+ }
+
+ if(cursorOcc == null && styleClass != null){
+ return null;
+ } else if(cursorOcc == null) {
+ return CursorValue.AUTO;
+ } else {
+ try{
+ return CursorValue.valueOf(cursorOcc.getValue().toUpperCase().replace("-", "_"));
+ }catch(IllegalArgumentException e){
+ String values = "auto, default, crosshair, pointer, move, n-resize, ne-resize," +
+ "nw-resize, e-resize, se-resize, s-resize, sw-resize, w-resize," +
+ "text, wait, help, or progress";
+ throw new InvalidGdlSchemaException("cursor must be set to one of " + values + ", but is " + cursorOcc.getValue());
+ }
+ }
+ }
-
- // gdlCursor [gdl:hover | gdl:focus | gdl:active]
-
// gdlBackgroundColor [gdl:hover | gdl:focus | gdl:active]
// gdlOverflow [gdl:hover | gdl:focus | gdl:active]
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 1 04:01:40 2011 (r545)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 1 04:33:23 2011 (r546)
@@ -3,6 +3,8 @@
import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine;
import us.isidor.gdl.anaToMia.Widgets.isidorus.LoadSchemaCallback;
import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
+import us.isidor.gdl.anaToMia.Widgets.values.CursorValue;
+
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -45,5 +47,7 @@
mainPanel.add(requestButton);
+
+
}
}
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/CursorValue.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/CursorValue.java Fri Jul 1 04:33:23 2011 (r546)
@@ -0,0 +1,21 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+public enum CursorValue {
+ AUTO,
+ DEFAULT,
+ CROSSHAIR,
+ POINTER,
+ MOVE,
+ N_RESIZE,
+ NE_RESIZE,
+ NW_RESIZE,
+ E_RESIZE,
+ SE_RESIZE,
+ S_RESIZE,
+ SW_RESIZE,
+ W_RESIZE,
+ TEXT,
+ WAIT,
+ HELP,
+ PROGRESS
+}
1
0

[isidorus-cvs] r545 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base values
by lgiessmann@common-lisp.net 01 Jul '11
by lgiessmann@common-lisp.net 01 Jul '11
01 Jul '11
Author: lgiessmann
Date: Fri Jul 1 04:01:40 2011
New Revision: 545
Log:
gdl-frontend: Widgets: implemented some methods that get the GDL [max-,min-][width,height] properties; added the class AutoNumUnitValue that wraps numeric values, which also may be set to auto
Added:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AutoNumUnitValue.java
Modified:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.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:26:12 2011 (r544)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Fri Jul 1 04:01:40 2011 (r545)
@@ -5,6 +5,7 @@
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.AutoNumUnitValue;
import us.isidor.gdl.anaToMia.Widgets.values.AutoNumValue;
import us.isidor.gdl.anaToMia.Widgets.values.BorderStyle;
import us.isidor.gdl.anaToMia.Widgets.values.AbsoluteNumValue;
@@ -663,33 +664,365 @@
}
}
- // 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]
+
+ // returns a NumUnitValue instance that represents the radius 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 NumUnitValue getBorderRadius(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence radiusOcc = null;
+ if(styleClass != null){
+ radiusOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRadius, styleClass);
+ } else {
+ radiusOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRadius);
+ }
+
+ if(radiusOcc == null && styleClass != null){
+ return null;
+ } else if(radiusOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(radiusOcc.getValue());
+ }
+ }
- // 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]
+ // returns a NumUnitValue instance that represents the radius of this element's border-top-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 NumUnitValue getBorderTopLeftRadius(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence radiusOcc = null;
+ if(styleClass != null){
+ radiusOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopLeftRadius, styleClass);
+ } else {
+ radiusOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopLeftRadius);
+ }
+
+ if(radiusOcc == null && styleClass != null){
+ return null;
+ } else if(radiusOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(radiusOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the radius of this element's border-top-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 NumUnitValue getBorderTopRightRadius(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence radiusOcc = null;
+ if(styleClass != null){
+ radiusOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopRightRadius, styleClass);
+ } else {
+ radiusOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopRightRadius);
+ }
+
+ if(radiusOcc == null && styleClass != null){
+ return null;
+ } else if(radiusOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(radiusOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the radius of this element's border-bottom-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 NumUnitValue getBorderBottomLeftRadius(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence radiusOcc = null;
+ if(styleClass != null){
+ radiusOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomLeftRadius, styleClass);
+ } else {
+ radiusOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomLeftRadius);
+ }
+
+ if(radiusOcc == null && styleClass != null){
+ return null;
+ } else if(radiusOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(radiusOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the radius of this element's border-bottom-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 NumUnitValue getBorderBottomRightRadius(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence radiusOcc = null;
+ if(styleClass != null){
+ radiusOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomRightRadius, styleClass);
+ } else {
+ radiusOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomRightRadius);
+ }
+
+ if(radiusOcc == null && styleClass != null){
+ return null;
+ } else if(radiusOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(radiusOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the padding of this element.
+ // 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 NumUnitValue getPadding(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence paddingOcc = null;
+ if(styleClass != null){
+ paddingOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlPadding, styleClass);
+ } else {
+ paddingOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlPadding);
+ }
+
+ if(paddingOcc == null && styleClass != null){
+ return null;
+ } else if(paddingOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(paddingOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the padding of this element's 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 NumUnitValue getPaddingTop(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence paddingOcc = null;
+ if(styleClass != null){
+ paddingOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingTop, styleClass);
+ } else {
+ paddingOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingTop);
+ }
+
+ if(paddingOcc == null && styleClass != null){
+ return null;
+ } else if(paddingOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(paddingOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the padding of this element's 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 NumUnitValue getPaddingRight(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence paddingOcc = null;
+ if(styleClass != null){
+ paddingOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingRight, styleClass);
+ } else {
+ paddingOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingRight);
+ }
+
+ if(paddingOcc == null && styleClass != null){
+ return null;
+ } else if(paddingOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(paddingOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the padding of this element's 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 NumUnitValue getPaddingBottom(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence paddingOcc = null;
+ if(styleClass != null){
+ paddingOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingBottom, styleClass);
+ } else {
+ paddingOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingBottom);
+ }
+
+ if(paddingOcc == null && styleClass != null){
+ return null;
+ } else if(paddingOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(paddingOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the padding of this element's 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 NumUnitValue getPaddingLeft(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence paddingOcc = null;
+ if(styleClass != null){
+ paddingOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingLeft, styleClass);
+ } else {
+ paddingOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlPaddingLeft);
+ }
+
+ if(paddingOcc == null && styleClass != null){
+ return null;
+ } else if(paddingOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(paddingOcc.getValue());
+ }
+ }
+
+
+ // returns an AutoNumUnitValue instance that represents the width of this element.
+ // 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 AutoNumUnitValue getWidth(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence widthOcc = null;
+ if(styleClass != null){
+ widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlWidth, styleClass);
+ } else {
+ widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlWidth);
+ }
+
+ if(widthOcc == null && styleClass != null){
+ return null;
+ } else if(widthOcc == null) {
+ return new AutoNumUnitValue();
+ } else {
+ return new AutoNumUnitValue(widthOcc.getValue());
+ }
+ }
+
+
+ // returns an AutoNumUnitValue instance that represents the min-width of this element.
+ // 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 AutoNumUnitValue getMinWidth(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence widthOcc = null;
+ if(styleClass != null){
+ widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMinWidth, styleClass);
+ } else {
+ widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMinWidth);
+ }
+
+ if(widthOcc == null && styleClass != null){
+ return null;
+ } else if(widthOcc == null) {
+ return new AutoNumUnitValue();
+ } else {
+ return new AutoNumUnitValue(widthOcc.getValue());
+ }
+ }
+
+
+ // returns an AutoNumUnitValue instance that represents the max-width of this element.
+ // 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 AutoNumUnitValue getMaxWidth(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence widthOcc = null;
+ if(styleClass != null){
+ widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMaxWidth, styleClass);
+ } else {
+ widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMaxWidth);
+ }
+
+ if(widthOcc == null && styleClass != null){
+ return null;
+ } else if(widthOcc == null) {
+ return new AutoNumUnitValue();
+ } else {
+ return new AutoNumUnitValue(widthOcc.getValue());
+ }
+ }
+
+
+ // returns an AutoNumUnitValue instance that represents the height of this element.
+ // 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 AutoNumUnitValue getHeight(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence heightOcc = null;
+ if(styleClass != null){
+ heightOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlHeight, styleClass);
+ } else {
+ heightOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlHeight);
+ }
+
+ if(heightOcc == null && styleClass != null){
+ return null;
+ } else if(heightOcc == null) {
+ return new AutoNumUnitValue();
+ } else {
+ return new AutoNumUnitValue(heightOcc.getValue());
+ }
+ }
+
+
+ // returns an AutoNumUnitValue instance that represents the min-height of this element.
+ // 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 AutoNumUnitValue getMinHeight(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence heightOcc = null;
+ if(styleClass != null){
+ heightOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMinHeight, styleClass);
+ } else {
+ heightOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMinHeight);
+ }
+
+ if(heightOcc == null && styleClass != null){
+ return null;
+ } else if(heightOcc == null) {
+ return new AutoNumUnitValue();
+ } else {
+ return new AutoNumUnitValue(heightOcc.getValue());
+ }
+ }
+
+
+ // returns an AutoNumUnitValue instance that represents the max-height of this element.
+ // 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 AutoNumUnitValue getMaxHeight(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence heightOcc = null;
+ if(styleClass != null){
+ heightOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMaxHeight, styleClass);
+ } else {
+ heightOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMaxHeight);
+ }
+
+ if(heightOcc == null && styleClass != null){
+ return null;
+ } else if(heightOcc == null) {
+ return new AutoNumUnitValue();
+ } else {
+ return new AutoNumUnitValue(heightOcc.getValue());
+ }
+ }
+
+
+
+
+
+
+
+ // gdlCursor [gdl:hover | gdl:focus | gdl:active]
// gdlBackgroundColor [gdl:hover | gdl:focus | gdl:active]
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AutoNumUnitValue.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/AutoNumUnitValue.java Fri Jul 1 04:01:40 2011 (r545)
@@ -0,0 +1,46 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+
+public class AutoNumUnitValue extends NumUnitValue {
+ public AutoNumUnitValue(){
+ super.unit = null; // if unit is null, the default value is auto
+ super.value = 0f;
+ }
+
+
+ public AutoNumUnitValue(String value) throws InvalidGdlSchemaException{
+ String upperString = value.trim().toUpperCase();
+ if(upperString.equals("AUTO")){
+ super.unit = null; // if unit is null, the default value is auto
+ super.value = 0f;
+ }else if(value.endsWith("PX")){
+ this.value = makeFloat(value, 2);
+ this.unit = CssUnit.PIXEL;
+ }else if (value.endsWith("PT")){
+ this.value = makeFloat(value, 2);
+ this.unit = CssUnit.POINT;
+ } else if(value.endsWith("%")){
+ this.value = makeFloat(value, 1);
+ this.unit = CssUnit.PERCENTAGE;
+ } else {
+ throw new InvalidGdlSchemaException("auto numeric values supported by the GDL containing a unit definition must be of the form <numeric-value>(pt|px|%)|auto, but found: " + value);
+ }
+ }
+
+
+ @Override
+ public String getStringValue() {
+ if(super.unit == null){
+ return "auto";
+ } else {
+ return super.getStringValue();
+ }
+ }
+
+
+ // this method returns true, if the value must be treated as "auto"
+ public boolean isAuto(){
+ return super.unit == null;
+ }
+}
1
0

[isidorus-cvs] r544 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base values
by lgiessmann@common-lisp.net 01 Jul '11
by lgiessmann@common-lisp.net 01 Jul '11
01 Jul '11
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);
}
1
0

[isidorus-cvs] r543 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base values
by lgiessmann@common-lisp.net 01 Jul '11
by lgiessmann@common-lisp.net 01 Jul '11
01 Jul '11
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
}
}
1
0

[isidorus-cvs] r542 - branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base
by lgiessmann@common-lisp.net 01 Jul '11
by lgiessmann@common-lisp.net 01 Jul '11
01 Jul '11
Author: lgiessmann
Date: Fri Jul 1 02:47:43 2011
New Revision: 542
Log:
gdl-frontend: Widgets: implemented a method that gets the GDL border-color, border[-top,-right,-bottom,-left]-color properties
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/TestClass.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:37:25 2011 (r541)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Fri Jul 1 02:47:43 2011 (r542)
@@ -8,10 +8,15 @@
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
import us.isidor.gdl.anaToMia.Widgets.values.AutoNumValue;
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;
@@ -48,13 +53,17 @@
// a helper method that returns one occurrence of the type bound to the passed PSI.
// If more than one occurrence is available an InvalidGdlSchemaException is thrown.
// If nor occurrence is available the return value is null
- private Occurrence getNoneOrOneOccurrence(String occurrenceType) throws InvalidGdlSchemaException{
+ private Occurrence getNoneOrOneUnscopedOccurrence(String occurrenceType) throws InvalidGdlSchemaException{
JsArray<Occurrence> occs = getOccurrences(occurrenceType);
+ ArrayList<Occurrence> unscopedOccs = new ArrayList<Occurrence>();
+ for(int i = 0; i != occs.length(); ++i){
+ if(occs.get(i).getScope().length() == 0) unscopedOccs.add(occs.get(i));
+ }
- if(occs.length() > 1){
- throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + "must be bound to none or one occurrence of the type " + occurrenceType + "but is bound " + occs.length() + " times to it");
- } else if(occs.length() == 1){
- return occs.get(0);
+ if(unscopedOccs.size() > 1){
+ throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + "must be bound to none or one unscoped occurrence of the type " + occurrenceType + "but is bound " + unscopedOccs.size() + " times to it");
+ } else if(unscopedOccs.size() == 1){
+ return unscopedOccs.get(0);
} else {
return null;
}
@@ -104,7 +113,7 @@
// returns a Display instance of a gdl:display occurrence.
// If no gdl:display occurrence is set, the default value is returned
public Display getDisplay() throws InvalidGdlSchemaException {
- Occurrence displayOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlId);
+ Occurrence displayOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlId);
if(displayOcc != null){
String value = displayOcc.getValue().toLowerCase();
@@ -128,7 +137,7 @@
// returns an AutoNumValue instance of a gdl:z-index occurrence.
// If no gdl:z-index occurrence is set, the default value is returned
public AutoNumValue getZindex() throws InvalidGdlSchemaException {
- Occurrence zOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlZindex);
+ Occurrence zOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlZindex);
if(zOcc != null){
return new AutoNumValue(zOcc.getValue());
} else {
@@ -140,7 +149,7 @@
// returns a Float instance of a gdl:float occurrence or the default value for
// this property if no gdl:float occurrence is available
public Float getFloat() throws InvalidGdlSchemaException {
- Occurrence floatOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlFloat);
+ Occurrence floatOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFloat);
if(floatOcc != null){
String value = floatOcc.getValue().toLowerCase();
@@ -162,7 +171,7 @@
// returns a ClearValue instance of a gdl:clear occurrence or the default value for
// this property if no gdl:clear occurrence is available
public ClearValue getClear() throws InvalidGdlSchemaException {
- Occurrence clearOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlFloat);
+ Occurrence clearOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFloat);
if(clearOcc != null){
try{
@@ -185,7 +194,7 @@
if(styleClass != null){
vaOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlVerticalAlign, styleClass);
} else {
- vaOcc = getNoneOrOneOccurrence(GdlPsis.OccurrenceType.gdlVerticalAlign);
+ vaOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlVerticalAlign);
}
if(vaOcc == null && styleClass != null){
@@ -217,17 +226,226 @@
}
+ // returns a NumUnitValue instance that represents the margin of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null. If the styleClass is null and no occurrence was found, the default value for this
+ // property is returned.
+ public NumUnitValue getMargin(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence marginOcc = null;
+ if(styleClass != null){
+ marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMargin, styleClass);
+ } else {
+ marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMargin);
+ }
+
+ if(marginOcc == null && styleClass != null){
+ return null;
+ } else if(marginOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(marginOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the margin-top of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null. If the styleClass is null and no occurrence was found, the default value for this
+ // property is returned.
+ public NumUnitValue getMarginTop(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence marginOcc = null;
+ if(styleClass != null){
+ marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginTop, styleClass);
+ } else {
+ marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginTop);
+ }
+
+ if(marginOcc == null && styleClass != null){
+ return null;
+ } else if(marginOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(marginOcc.getValue());
+ }
+ }
+
- // gdlMargin [gdl:hover | gdl:focus | gdl:active]
- // gdlMarginTop [gdl:hover | gdl:focus | gdl:active]
- // gdlMarginRight [gdl:hover | gdl:focus | gdl:active]
- // gdlMarginBottom [gdl:hover | gdl:focus | gdl:active]
- // gdlMarginLeft [gdl:hover | gdl:focus | gdl:active]
- // gdlBorderColor [gdl:hover | gdl:focus | gdl:active]
- // gdlBorderColorTop [gdl:hover | gdl:focus | gdl:active]
- // gdlBorderColorRight [gdl:hover | gdl:focus | gdl:active]
- // gdlBorderColorBottom [gdl:hover | gdl:focus | gdl:active]
- // gdlBorderColorLeft [gdl:hover | gdl:focus | gdl:active]
+ // returns a NumUnitValue instance that represents the margin-right of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null. If the styleClass is null and no occurrence was found, the default value for this
+ // property is returned.
+ public NumUnitValue getMarginRight(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence marginOcc = null;
+ if(styleClass != null){
+ marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginRight, styleClass);
+ } else {
+ marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginRight);
+ }
+
+ if(marginOcc == null && styleClass != null){
+ return null;
+ } else if(marginOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(marginOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the margin-bottom of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null. If the styleClass is null and no occurrence was found, the default value for this
+ // property is returned.
+ public NumUnitValue getMarginBottom(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence marginOcc = null;
+ if(styleClass != null){
+ marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginBottom, styleClass);
+ } else {
+ marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginBottom);
+ }
+
+ if(marginOcc == null && styleClass != null){
+ return null;
+ } else if(marginOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(marginOcc.getValue());
+ }
+ }
+
+
+ // returns a NumUnitValue instance that represents the margin-left of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null. If the styleClass is null and no occurrence was found, the default value for this
+ // property is returned.
+ public NumUnitValue getMarginLeft(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence marginOcc = null;
+ if(styleClass != null){
+ marginOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlMarginLeft, styleClass);
+ } else {
+ marginOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlMarginLeft);
+ }
+
+ if(marginOcc == null && styleClass != null){
+ return null;
+ } else if(marginOcc == null) {
+ return new NumUnitValue();
+ } else {
+ return new NumUnitValue(marginOcc.getValue());
+ }
+ }
+
+
+ // returns a ColorValue instance that represents the color 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 ColorValue getBorderColor(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence colorOcc = null;
+ if(styleClass != null){
+ colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderColor, styleClass);
+ } else {
+ colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderColor);
+ }
+
+ if(colorOcc == null && styleClass != null){
+ return null;
+ } else if(colorOcc == null) {
+ return new ColorValue();
+ } else {
+ return new ColorValue(colorOcc.getValue());
+ }
+ }
+
+
+ // returns a ColorValue instance that represents the color 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 ColorValue getBorderTopColor(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence colorOcc = null;
+ if(styleClass != null){
+ colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopColor, styleClass);
+ } else {
+ colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderTopColor);
+ }
+
+ if(colorOcc == null && styleClass != null){
+ return null;
+ } else if(colorOcc == null) {
+ return new ColorValue();
+ } else {
+ return new ColorValue(colorOcc.getValue());
+ }
+ }
+
+
+ // returns a ColorValue instance that represents the color 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 ColorValue getBorderRightColor(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence colorOcc = null;
+ if(styleClass != null){
+ colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightColor, styleClass);
+ } else {
+ colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRightColor);
+ }
+
+ if(colorOcc == null && styleClass != null){
+ return null;
+ } else if(colorOcc == null) {
+ return new ColorValue();
+ } else {
+ return new ColorValue(colorOcc.getValue());
+ }
+ }
+
+
+ // returns a ColorValue instance that represents the color 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 ColorValue getBorderBottomColor(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence colorOcc = null;
+ if(styleClass != null){
+ colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomColor, styleClass);
+ } else {
+ colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderBottomColor);
+ }
+
+ if(colorOcc == null && styleClass != null){
+ return null;
+ } else if(colorOcc == null) {
+ return new ColorValue();
+ } else {
+ return new ColorValue(colorOcc.getValue());
+ }
+ }
+
+
+ // returns a ColorValue instance that represents the color 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 ColorValue getBorderLeftColor(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence colorOcc = null;
+ if(styleClass != null){
+ colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftColor, styleClass);
+ } else {
+ colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderLeftColor);
+ }
+
+ if(colorOcc == null && styleClass != null){
+ return null;
+ } else if(colorOcc == null) {
+ return new ColorValue();
+ } else {
+ return new ColorValue(colorOcc.getValue());
+ }
+ }
+
+
// gdlBorderStyle [gdl:hover | gdl:focus | gdl:active]
// gdlBorderStyleTop [gdl:hover | gdl:focus | gdl:active]
// gdlBorderStyleRight [gdl:hover | gdl:focus | gdl:active]
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 1 02:37:25 2011 (r541)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 1 02:47:43 2011 (r542)
@@ -2,6 +2,7 @@
import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine;
import us.isidor.gdl.anaToMia.Widgets.isidorus.LoadSchemaCallback;
+import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
1
0

[isidorus-cvs] r541 - branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values
by lgiessmann@common-lisp.net 01 Jul '11
by lgiessmann@common-lisp.net 01 Jul '11
01 Jul '11
Author: lgiessmann
Date: Fri Jul 1 02:37:25 2011
New Revision: 541
Log:
gdl-frontend: Widgets: implemented a class that wraps a CSS Color value - instead of the GWT color value, instances of this class throw a InvalidGdlException if a color value is invalid or unsupported
Added:
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
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/ColorValue.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/ColorValue.java Fri Jul 1 02:37:25 2011 (r541)
@@ -0,0 +1,172 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+
+public class ColorValue {
+ private String stringValue = null;
+
+
+ // some constructors
+ public ColorValue(){
+ this.stringValue = "#000000";
+ }
+
+
+ public ColorValue(String color) throws InvalidGdlSchemaException{
+ String value = color.toLowerCase();
+
+ 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}$")) {
+ this.stringValue = value;
+ }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(",");
+ this.stringValue = "#" + decToHexIntegerString(rgb[0]) + decToHexIntegerString(rgb[1]) + decToHexIntegerString(rgb[2]);
+ }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(",");
+ this.stringValue = "#" + percentToHexIntegerString(rgb[0]) + percentToHexIntegerString(rgb[1]) + percentToHexIntegerString(rgb[2]);
+ }else {
+ throw new InvalidGdlSchemaException("a ColorValue must be a value of the format #RRGGBB, #RGB, rdg(rrr,ggg,bbb), rgb(rrr%,ggg%,bbb%) or a CssColor, but is " + color);
+ }
+ }
+
+
+ // converts an integer string of a decimal to a hex representation
+ private String decToHexIntegerString(String decIntegerString){
+ int intValue = Integer.valueOf(decIntegerString.replaceFirst("\\+", "").trim());
+ intValue = intValue > 255 ? 255 : intValue;
+ String result = Integer.toHexString(intValue);
+ return result.length() == 1 ? "0" + result : result;
+ }
+
+
+ // converts an integer representing a percentage value string
+ // to a hex representation
+ private String percentToHexIntegerString(String percentageString){
+ String rawValue = percentageString.replaceFirst("%", "").replaceFirst("\\+", "").trim();
+ int percentValue = Integer.valueOf(rawValue);
+ String result = Integer.toHexString((int)(255 * ((float)percentValue / 100)));
+ return result.length() == 1 ? "0" + result : result;
+ }
+
+
+ public ColorValue(int r, int g, int b) throws InvalidGdlSchemaException {
+ this("rgb(" + r + "," + g + "," + b + ")");
+ }
+
+
+ public ColorValue(CssColor color){
+ this.stringValue = cssColorToRRGGBB(color);
+ }
+
+
+ // a helper method that parses CssColor instances
+ // 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";
+ default: return "#808080";
+ }
+ }
+
+
+ // returns a string of the format #RRGGBB
+ public String getStringValue(){
+ return this.stringValue;
+ }
+
+
+ // returns an int array of the form [r, g, b] of the stored
+ // color value
+ public int[] getRGBvalue(){
+ String r = "" + this.stringValue.charAt(1) + this.stringValue.charAt(2);
+ String g = "" + this.stringValue.charAt(3) + this.stringValue.charAt(4);
+ String b = "" + this.stringValue.charAt(5) + this.stringValue.charAt(6);
+
+ return new int[]{Integer.valueOf(r, 16), Integer.valueOf(g, 16), Integer.valueOf(b, 16)};
+ }
+
+
+ // returns a CSSColor instance of the stored value, if it is
+ // a value that corresponds to the defined keywords, otherwise
+ // the return value is null
+ public CssColor getCssColor(){
+ if(this.stringValue.equals("#800000")){
+ return CssColor.maroon;
+ }else if(this.stringValue.equals("#ff0000")){
+ return CssColor.red;
+ }else if(this.stringValue.equals("#ffa500")) {
+ return CssColor.orange;
+ }else if(this.stringValue.equals("#ffff00")){
+ return CssColor.yellow;
+ }else if(this.stringValue.equals("#808000")) {
+ return CssColor.olive;
+ }else if(this.stringValue.equals("#800080")){
+ return CssColor.purple;
+ }else if(this.stringValue.equals("#ff00ff")) {
+ return CssColor.fuchsia;
+ }else if(this.stringValue.equals("#ffffff")){
+ return CssColor.white;
+ }else if(this.stringValue.equals("#00ff00")) {
+ return CssColor.lime;
+ }else if(this.stringValue.equals("#008000")) {
+ return CssColor.green;
+ }else if(this.stringValue.equals("#000080")) {
+ return CssColor.navy;
+ }else if(this.stringValue.equals("#0000ff")) {
+ return CssColor.blue;
+ }else if(this.stringValue.equals("#00ffff")) {
+ return CssColor.aqua;
+ }else if(this.stringValue.equals("#008080")) {
+ return CssColor.teal;
+ }else if(this.stringValue.equals("#000000")) {
+ return CssColor.black;
+ }else if(this.stringValue.equals("#c0c0c0")) {
+ return CssColor.silver;
+ }else if(this.stringValue.equals("#808080")) {
+ return CssColor.gray;
+ }else {
+ return null;
+ }
+ }
+
+
+ // 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
+ }
+}
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/NumUnitValue.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/NumUnitValue.java Fri Jul 1 02:37:25 2011 (r541)
@@ -0,0 +1,79 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+
+public class NumUnitValue {
+ private CssUnit unit = CssUnit.pixel;
+ private float value = 0f;
+
+
+ // some constructors
+ public NumUnitValue(){}
+
+
+ public NumUnitValue(String numUnit) throws InvalidGdlSchemaException {
+ if(numUnit.endsWith("px")){
+ this.value = makeFloat(numUnit, 2);
+ this.unit = CssUnit.pixel;
+ }else if (numUnit.endsWith("pt")){
+ this.value = makeFloat(numUnit, 2);
+ this.unit = CssUnit.point;
+ } else if(numUnit.endsWith("%")){
+ this.value = makeFloat(numUnit, 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);
+ }
+ }
+
+
+ // 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 {
+ 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);
+ }
+
+ String str = stringToParse.substring(0, stringToParse.length() - endToIgnore);
+
+ try{
+ return Float.valueOf(str);
+ }catch(NumberFormatException e){
+ 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);
+ }
+ }
+
+
+ // 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";
+ 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;
+ }
+ }
+
+
+ // returns the CssUnit that is represented by this instance
+ public CssUnit getUnit(){
+ return this.unit;
+ }
+
+
+ // a subset of CSS units that are supported by the GDL
+ public enum CssUnit {
+ point,
+ pixel,
+ percentage
+ }
+}
1
0