summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2006-03-22 20:45:15 +0000
committerTom Tromey <tromey@redhat.com>2006-03-22 20:45:15 +0000
commitbdd0650b931a3d46cf89d43849fcec2c7a386604 (patch)
treebfe767ba7cd68ecc285f7087d175b32faf923db1
parentd0ff75c28cb7f8bce70d0dcfa4c3cde12a9aa14d (diff)
downloadclasspath-bdd0650b931a3d46cf89d43849fcec2c7a386604.tar.gz
* javax/swing/plaf/synth/SynthStyle.java (getInt): Implemented.
(getBoolean): Likewise. (getString): Likewise. (getIcon): Likewise.
-rw-r--r--ChangeLog7
-rw-r--r--javax/swing/plaf/synth/SynthStyle.java67
2 files changed, 62 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index b7bcb99af..ba8aa55fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-03-22 Tom Tromey <tromey@redhat.com>
+
+ * javax/swing/plaf/synth/SynthStyle.java (getInt): Implemented.
+ (getBoolean): Likewise.
+ (getString): Likewise.
+ (getIcon): Likewise.
+
2006-03-22 Mark Wielaard <mark@klomp.org>
Fixes bug #26301
diff --git a/javax/swing/plaf/synth/SynthStyle.java b/javax/swing/plaf/synth/SynthStyle.java
index c02e708a8..f5ab3df3b 100644
--- a/javax/swing/plaf/synth/SynthStyle.java
+++ b/javax/swing/plaf/synth/SynthStyle.java
@@ -130,31 +130,74 @@ public abstract class SynthStyle
// FIXME: Implement this correctly.
}
+ /**
+ * A convenience method to fetch an integer property.
+ * If the property's value is a {@link Number}, then the
+ * integer value is returned. Otherwise, the default value
+ * is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @param defaultValue the default value
+ * @return the integer value of the property, or the default value
+ */
public int getInt(SynthContext ctx, Object key, int defaultValue)
- throws NotImplementedException
{
- // FIXME: Implement this correctly.
- return -1;
+ Object obj = get(ctx, key);
+ if (obj instanceof Number)
+ return ((Number) obj).intValue();
+ return defaultValue;
}
- public boolean getBoolean(SynthContext ctx, Object key, boolean defaultValue)
- throws NotImplementedException
+ /**
+ * A convenience method to fetch an integer property.
+ * If the property's value is a {@link Boolean}, then the
+ * value is returned. Otherwise, the default value
+ * is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @param defaultValue the default value
+ * @return the boolean value of the property, or the default value
+ */
+ public boolean getBoolean(SynthContext ctx, Object key,
+ boolean defaultValue)
{
- // FIXME: Implement this correctly.
- return false;
+ Object obj = get(ctx, key);
+ if (obj instanceof Boolean)
+ return ((Boolean) obj).booleanValue();
+ return defaultValue;
}
+ /**
+ * A convenience method to fetch an Icon-valued property.
+ * If the property's value is an {@link Icon}, then the
+ * value is returned. Otherwise, null is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @return the icon, or null
+ */
public Icon getIcon(SynthContext ctx, Object key)
- throws NotImplementedException
{
- // FIXME: Implement this correctly.
+ Object obj = get(ctx, key);
+ if (key instanceof Icon)
+ return (Icon) obj;
return null;
}
+ /**
+ * A convenience method to fetch a String property.
+ * If the property's value is a {@link String}, then the
+ * value is returned. Otherwise, the default value
+ * is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @param defaultValue the default value
+ * @return the String value of the property, or the default value
+ */
public String getString(SynthContext ctx, Object key, String defaultValue)
- throws NotImplementedException
{
- // FIXME: Implement this correctly.
- return null;
+ Object obj = get(ctx, key);
+ if (obj instanceof String)
+ return (String) obj;
+ return defaultValue;
}
}