Font.java (deriveFont): Implement missing variants.
authorJerry Quinn <jlquinn@optonline.net>
Thu, 22 Apr 2004 05:34:30 +0000 (05:34 +0000)
committerJerry Quinn <jlquinn@gcc.gnu.org>
Thu, 22 Apr 2004 05:34:30 +0000 (05:34 +0000)
2004-04-22  Jerry Quinn  <jlquinn@optonline.net>

* java/awt/Font.java (deriveFont): Implement missing variants.
* gnu/java/awt/peer/ClasspathFontPeer.java (deriveFont): Implement
missing variants.

From-SVN: r81002

libjava/ChangeLog
libjava/gnu/java/awt/peer/ClasspathFontPeer.java
libjava/java/awt/Font.java

index b5a60bd1216717d7e9a228fb338e0c784df4c849..ae285939f4208c1004bd54be5a0dcb6a3f70cd49 100644 (file)
@@ -1,3 +1,9 @@
+2004-04-22  Jerry Quinn  <jlquinn@optonline.net>
+
+       * java/awt/Font.java (deriveFont): Implement missing variants.
+       * gnu/java/awt/peer/ClasspathFontPeer.java (deriveFont): Implement
+       missing variants.
+
 2004-04-21  Bryce McKinlay  <mckinlay@redhat.com>
 
        * java/lang/natClass.cc (_Jv_LayoutInterfaceMethods): New method.
index 287c271ba2f4963e0b8af818ddeafa059e441173..6b753aa15ec523a93031ffd7e016c753f40b267b 100644 (file)
@@ -1,5 +1,5 @@
 /* ClasspathFontPeer.java -- Font peer used by GNU Classpath.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -394,6 +394,23 @@ public abstract class ClasspathFontPeer
     return ((style & Font.ITALIC) == Font.ITALIC); 
   }
 
+  /** 
+   * Implementation of {@link Font#deriveFont(int, float)}
+   *
+   * @param font the font this peer is being called from. This may be
+   * useful if you are sharing peers between Font objects. Otherwise it may
+   * be ignored.
+   */
+
+  public Font deriveFont (Font font, int style, float size)
+  {
+    Map attrs = new HashMap ();
+    getStandardAttributes (attrs);
+    copyStyleToAttrs (style, attrs);
+    copySizeToAttrs (size, attrs);
+    return tk().getFont (logicalName, attrs);
+  }
+
   /** 
    * Implementation of {@link Font#deriveFont(float)}
    *
@@ -443,6 +460,22 @@ public abstract class ClasspathFontPeer
     return tk().getFont (logicalName, attrs);
   }
 
+  /** 
+   * Implementation of {@link Font#deriveFont(AffineTransform)}
+   *
+   * @param font the font this peer is being called from. This may be
+   * useful if you are sharing peers between Font objects. Otherwise it may
+   * be ignored.
+   */
+
+  public Font deriveFont (Font font, AffineTransform t)
+  {
+    Map attrs = new HashMap ();
+    getStandardAttributes (attrs);
+    copyTransformToAttrs (t, attrs);
+    return tk().getFont (logicalName, attrs);
+  }
+
   /** 
    * Implementation of {@link Font#deriveFont(Map)}
    *
index 42f9f7b85ebe794be304657dd72fcd576a8d3959..4c70c735797d08e793715265f72dfaf77e539db1 100644 (file)
@@ -1,5 +1,5 @@
 /* Font.java -- Font object
-   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -648,6 +648,22 @@ private static final long serialVersionUID = -4206021311591459213L;
     return peer.createGlyphVector (this, ctx, glyphCodes);
 }
 
+/**
+  * Produces a new {@link Font} based on the current font, adjusted to a
+  * new size and style.
+  *
+  * @param style The style of the newly created font.
+  * @param size The size of the newly created font.
+  *
+  * @return A clone of the current font, with the specified size and style.
+  *
+  * @since 1.2
+  */
+  public Font deriveFont (int style, float size)
+{
+    return peer.deriveFont (this, style, size);
+}
+
 /**
   * Produces a new {@link Font} based on the current font, adjusted to a
   * new size.
@@ -701,6 +717,27 @@ private static final long serialVersionUID = -4206021311591459213L;
     return peer.deriveFont (this, style, a);
 }
 
+/**
+  * Produces a new {@link Font} based on the current font, subjected
+  * to a new affine transformation.
+  *
+  * @param a The transformation to apply.
+  *
+  * @return A clone of the current font, with the specified transform.
+  *
+  * @throws IllegalArgumentException If transformation is
+  * <code>null</code>.
+  *
+  * @since 1.2
+  */
+  public Font deriveFont (AffineTransform a)
+{
+    if (a == null)
+      throw new IllegalArgumentException ("Affine transformation is null");
+
+    return peer.deriveFont (this, a);
+}
+
 /**
   * Produces a new {@link Font} based on the current font, adjusted to a
   * new set of attributes.