[isidorus-cvs] r545 - 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 11:01:40 UTC 2011
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;
+ }
+}
More information about the Isidorus-cvs
mailing list