[isidorus-cvs] r557 - 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
Mon Jul 4 18:50:38 UTC 2011
Author: lgiessmann
Date: Mon Jul 4 11:50:37 2011
New Revision: 557
Log:
gdl-frontend: Widgets: implemented the class GdlTextObject; implemented all corresponding css styles (with css pseudo-classes) supported by the GDL
Added:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/FontWeightValue.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/PositiveNumUnitValue.java
Modified:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlTextObject.java
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/GdlPsis.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Mon Jul 4 08:29:44 2011 (r556)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Mon Jul 4 11:50:37 2011 (r557)
@@ -147,7 +147,7 @@
public final static String gdlColor = gdl + "color";
public final static String gdlFontfamily = gdl + "font-family";
public final static String gdlFontStyle = gdl + "font-style";
- public final static String gdlFontSize = gdl + "font-weight";
+ public final static String gdlFontSize = gdl + "font-size";
public final static String gdlFontWeight = gdl + "font-weight";
public final static String gdlLetterSpacing = gdl + "letter-spacing";
public final static String gdlWordSpacing = gdl + "word-spacing";
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlTextObject.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlTextObject.java Mon Jul 4 08:29:44 2011 (r556)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlTextObject.java Mon Jul 4 11:50:37 2011 (r557)
@@ -1,12 +1,18 @@
package us.isidor.gdl.anaToMia.Widgets.base;
+import com.google.gwt.dom.client.Style.FontStyle;
+import com.google.gwt.user.client.DOM;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+import us.isidor.gdl.anaToMia.Widgets.values.ColorValue;
import us.isidor.gdl.anaToMia.Widgets.values.DirectionValue;
+import us.isidor.gdl.anaToMia.Widgets.values.FontWeightValue;
import us.isidor.gdl.anaToMia.Widgets.values.NormalNumUnitValue;
+import us.isidor.gdl.anaToMia.Widgets.values.PositiveNumUnitValue;
import us.isidor.gdl.anaToMia.Widgets.values.TextAlignValue;
import us.isidor.gdl.anaToMia.Widgets.values.TextDecorationValue;
@@ -97,7 +103,7 @@
// returns a TextDecoarionValue instance that represents the text-decoration of this element.
// If a styleClass is set, only the corresponding value of the scoped occurrence is returned
// or null.
- public TextDecorationValue getGdlTextDecoration(String styleClass) throws InvalidGdlSchemaException {
+ public TextDecorationValue getTextDecoration(String styleClass) throws InvalidGdlSchemaException {
Occurrence decorationOcc = null;
if(styleClass != null){
decorationOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlTextDecoration, styleClass);
@@ -119,29 +125,244 @@
}
+ // returns a ColorValue instance that represents the text color of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null.
+ public ColorValue getColor(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence colorOcc = null;
+ if(styleClass != null){
+ colorOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlColor, styleClass);
+ } else {
+ colorOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlColor);
+ }
+
+ if(colorOcc == null && styleClass != null){
+ return null;
+ } else if(colorOcc == null) {
+ return new ColorValue();
+ } else {
+ return new ColorValue(colorOcc.getValue());
+ }
+ }
+
+
+ // returns a String instance that represents the text font-family of this element.
+ public String getFontFamily(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence fontOcc = null;
+ if(styleClass != null){
+ fontOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlFontfamily, styleClass);
+ } else {
+ fontOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFontfamily);
+ }
+
+ if(fontOcc == null){
+ return null; // use the browser's default font
+ } else {
+ return fontOcc.getValue();
+ }
+ }
+
+
+ // returns a FontStyle instance that represents the text font-style of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null.
+ public FontStyle getFontStyle(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence styleOcc = null;
+ if(styleClass != null){
+ styleOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlFontStyle, styleClass);
+ } else {
+ styleOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFontStyle);
+ }
+
+ if(styleOcc == null && styleClass != null){
+ return null;
+ } else if(styleOcc == null) {
+ return FontStyle.NORMAL;
+ } else {
+ try{
+ return FontStyle.valueOf(styleOcc.getValue().toUpperCase());
+ }catch(IllegalArgumentException e){
+ throw new InvalidGdlSchemaException("The occurrence " + GdlPsis.OccurrenceType.gdlFontStyle + " must be set to one of \"normal\", \"italic\" or \"oblique\", but is \"" + styleOcc.getValue() + "\"");
+ }
+ }
+ }
+
+
+ // returns a PositiveNumUnitValue instance that represents the text font-size of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null.
+ public PositiveNumUnitValue getFontSize(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence sizeOcc = null;
+ if(styleClass != null){
+ sizeOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlFontSize, styleClass);
+ } else {
+ sizeOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFontSize);
+ }
+
+ if(sizeOcc == null && styleClass != null){
+ return null;
+ } else if(sizeOcc == null) {
+ return new PositiveNumUnitValue("12pt");
+ } else {
+ return new PositiveNumUnitValue(sizeOcc.getValue());
+ }
+ }
+
+
+ // returns a FontWeightValue instance that represents the text font-weight of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null.
+ public FontWeightValue getFontWeight(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence weightOcc = null;
+ if(styleClass != null){
+ weightOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlFontWeight, styleClass);
+ } else {
+ weightOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFontWeight);
+ }
+
+ if(weightOcc == null && styleClass != null){
+ return null;
+ } else if(weightOcc == null) {
+ return FontWeightValue.NORMAL;
+ } else {
+ try{
+ return FontWeightValue.fromString(weightOcc.getValue());
+ }catch(IllegalArgumentException e){
+ String values = "normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800 or 900";
+ throw new InvalidGdlSchemaException("The occurrence " + GdlPsis.OccurrenceType.gdlFontWeight + " must be set to one of " + values + ", but found " + weightOcc.getValue() + "\"");
+ }
+ }
+ }
+
+
+ // returns a NormalNumUnitValue instance that represents the text letter-spacing of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null.
+ public NormalNumUnitValue getLetterSpacing(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence spacingOcc = null;
+ if(styleClass != null){
+ spacingOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlLetterSpacing, styleClass);
+ } else {
+ spacingOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlLetterSpacing);
+ }
+
+ if(spacingOcc == null && styleClass != null){
+ return null;
+ } else if(spacingOcc == null) {
+ return new NormalNumUnitValue();
+ } else {
+ return new NormalNumUnitValue(spacingOcc.getValue());
+ }
+ }
+
+
+ // returns a NormalNumUnitValue instance that represents the text word-spacing of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null.
+ public NormalNumUnitValue getWordSpacing(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence spacingOcc = null;
+ if(styleClass != null){
+ spacingOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlWordSpacing, styleClass);
+ } else {
+ spacingOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlWordSpacing);
+ }
+
+ if(spacingOcc == null && styleClass != null){
+ return null;
+ } else if(spacingOcc == null) {
+ return new NormalNumUnitValue();
+ } else {
+ return new NormalNumUnitValue(spacingOcc.getValue());
+ }
+ }
+
+
+ // sets the direction style property of this element by using the GWT DOM class
+ public void setDirection(DirectionValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "direction", value.getCssValue());
+ }
+
+
+ // sets the text-align style property of this element by using the GWT DOM class
+ public void setTextAlign(TextAlignValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "textAlign", value.getCssValue());
+ }
+
+
+ // sets the line-height style property of this element by using the GWT DOM class
+ public void setLineHeight(NormalNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "lineHeight", value.getCssValue());
+ }
+
+
+ // sets the text-decoration style property of this element by using the GWT DOM class
+ public void setTextDecoration(TextDecorationValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "textDecoration", value.getCssValue());
+ }
+
+
+ // sets the color style property of this element by using the GWT DOM class
+ public void setColor(ColorValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "color", value.getCssValue());
+ }
+
+
+ // sets the font-family style property of this element by using the GWT DOM class
+ public void setFontFamily(String value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "fontFamily", value);
+ }
+
+
+ // sets the font-style style property of this element by using the GWT DOM class
+ public void setFontStyle(FontStyle value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "fontStyle", value.getCssName());
+ }
+
+
+ // sets the font-size style property of this element by using the GWT DOM class
+ public void setFontSize(PositiveNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "fontSize", value.getCssValue());
+ }
+
+
+ // sets the font-weight style property of this element by using the GWT DOM class
+ public void setFontWeight(FontWeightValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "fontWeight", value.getCssValue());
+ }
+
+
+ // sets the letter-spacing style property of this element by using the GWT DOM class
+ public void setLetterSpacing(NormalNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "letterSpacing", value.getCssValue());
+ }
+
+
+ // sets the word-spacing style property of this element by using the GWT DOM class
+ public void setWordSpacing(NormalNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException{
+ if(value != null) super.setCssProperty(styleClass, "wordSpacing", value.getCssValue());
+ }
+
+
// calls the super class's setGdlStyle and additionally calls local statements
// to fulfill the style settings
@Override
protected void setGdlStyle() throws InvalidGdlSchemaException, ExecutionException{
super.setGdlStyle();
- // TODO: implement
-
- // direction [hover | active | focus]
- // text-align [hover | active | focus]
- // line-height [hover | active | focus]
- // text-decoration [hover | active | focus]
- // color [hover | active | focus]
- // font-family [hover | active | focus]
- // font-style [hover | active | focus]
- // font-size [hover | active | focus]
- // font-weight [hover | active | focus]
- // letter-spacing [hover | active | focus]
- // word-spacing [hover | active | focus]
-
-
- // TODO: implement
- // css pseudo class handlers => register additional handlers for this class ???
+ String[] styleClasses = new String[]{null, GdlPsis.Scope.gdlActive, GdlPsis.Scope.gdlFocus, GdlPsis.Scope.gdlHover};
+ for (String styleClass : styleClasses) {
+ this.setDirection(this.getDirection(styleClass), styleClass);
+ this.setTextAlign(this.getTextAlign(styleClass), styleClass);
+ this.setTextAlign(this.getTextAlign(styleClass), styleClass);
+ this.setTextDecoration(this.getTextDecoration(styleClass), styleClass);
+ this.setColor(this.getColor(styleClass), styleClass);
+ this.setFontFamily(this.getFontFamily(styleClass), styleClass);
+ this.setFontStyle(this.getFontStyle(styleClass), styleClass);
+ this.setFontSize(this.getFontSize(styleClass), styleClass);
+ this.setFontWeight(this.getFontWeight(styleClass), styleClass);
+ this.setLetterSpacing(this.getLetterSpacing(styleClass), styleClass);
+ this.setWordSpacing(this.getWordSpacing(styleClass), styleClass);
+ }
}
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 Mon Jul 4 08:29:44 2011 (r556)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Mon Jul 4 11:50:37 2011 (r557)
@@ -1375,7 +1375,7 @@
// sets the passed css style porperty to the passed css value.
// If a styleClass is given, the style is applied to either active, hover or focus
- private void setCssProperty(String styleClass, String cssProperty, String cssValue)throws InvalidGdlSchemaException, ExecutionException{
+ protected void setCssProperty(String styleClass, String cssProperty, String cssValue)throws InvalidGdlSchemaException, ExecutionException{
if(cssValue == null || cssProperty == null) return;
if(styleClass == null){
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 Mon Jul 4 08:29:44 2011 (r556)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Mon Jul 4 11:50:37 2011 (r557)
@@ -71,6 +71,7 @@
Topic gdlBorderBottomColor = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlBorderBottomColor));
Topic gdlBorderStyle = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlBorderStyle));
Topic gdlBorderWidth = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlBorderWidth));
+ Topic gdlFontSize = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlFontSize));
Topic gdlHover = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.Scope.gdlHover));
Topic gdlActive = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.Scope.gdlActive));
Topic gdlFocus = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.Scope.gdlFocus));
@@ -98,6 +99,10 @@
bgcActive.addTheme(gdlActive);
Occurrence bgcFocus = tmpRepresentative.createOccurrence(gdlBackgroundColor, "silver", null);
bgcFocus.addTheme(gdlFocus);
+ tmpRepresentative.createOccurrence(gdlFontSize, "15pt", null);
+ Occurrence fsHover = tmpRepresentative.createOccurrence(gdlFontSize, "25pt", null);
+ fsHover.addTheme(gdlHover);
+
GdlTextObject tmp = new GdlTextObject(tmpRepresentative){
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/FontWeightValue.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/FontWeightValue.java Mon Jul 4 11:50:37 2011 (r557)
@@ -0,0 +1,45 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+public enum FontWeightValue implements CssValue {
+ NORMAL,
+ BOLD,
+ BOLDER,
+ LIGHTER,
+ _100,
+ _200,
+ _300,
+ _400,
+ _500,
+ _600,
+ _700,
+ _800,
+ _900;
+
+ @Override
+ public String getCssValue() {
+ String str = this.toString();
+ if(str.startsWith("_")) return str.substring(1);
+ else return str;
+ }
+
+
+ public static FontWeightValue fromString(String str) throws IllegalArgumentException{
+ if(null == str) return null;
+
+ String upperStr = str.toUpperCase();
+ if(upperStr.equals("NORMAL")) return NORMAL;
+ else if(upperStr.equals("BOLD")) return BOLD;
+ else if(upperStr.equals("BOLDER")) return BOLDER;
+ else if(upperStr.equals("LIGHTER")) return LIGHTER;
+ else if(upperStr.equals("100")) return _100;
+ else if(upperStr.equals("200")) return _200;
+ else if(upperStr.equals("300")) return _300;
+ else if(upperStr.equals("400")) return _400;
+ else if(upperStr.equals("500")) return _500;
+ else if(upperStr.equals("600")) return _600;
+ else if(upperStr.equals("700")) return _700;
+ else if(upperStr.equals("800")) return _800;
+ else if(upperStr.equals("900")) return _900;
+ else throw new IllegalArgumentException("the value " + str + "is not a FontWeightValue value");
+ }
+}
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/PositiveNumUnitValue.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/PositiveNumUnitValue.java Mon Jul 4 11:50:37 2011 (r557)
@@ -0,0 +1,17 @@
+package us.isidor.gdl.anaToMia.Widgets.values;
+
+import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+
+public class PositiveNumUnitValue extends NumUnitValue {
+ public PositiveNumUnitValue(){
+ super.value = 0f;
+ }
+
+
+ public PositiveNumUnitValue(String value) throws InvalidGdlSchemaException{
+ super(value);
+ if(super.value < 0){
+ throw new InvalidGdlSchemaException("positive numeric values supported by the GDL containing a unit definition must be of the form <positive-numeric-value>(pt|px|%), but found: " + value);
+ }
+ }
+}
More information about the Isidorus-cvs
mailing list