Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 44122 invoked from network); 11 Sep 2006 03:51:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Sep 2006 03:51:44 -0000 Received: (qmail 18662 invoked by uid 500); 11 Sep 2006 03:51:44 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 18562 invoked by uid 500); 11 Sep 2006 03:51:43 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 18551 invoked by uid 99); 11 Sep 2006 03:51:43 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Sep 2006 20:51:43 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Sep 2006 20:51:42 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id C194C1A981A; Sun, 10 Sep 2006 20:51:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r442084 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt: Font.java RenderingHints.java Date: Mon, 11 Sep 2006 03:51:22 -0000 To: harmony-commits@incubator.apache.org From: ndbeyer@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060911035122.C194C1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ndbeyer Date: Sun Sep 10 20:51:22 2006 New Revision: 442084 URL: http://svn.apache.org/viewvc?view=rev&rev=442084 Log: Uplift code to Java 5 spec. Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java?view=diff&rev=442084&r1=442083&r2=442084 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java Sun Sep 10 20:51:22 2006 @@ -13,10 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @author Ilya S. Okomin - * @version $Revision$ - */ + package java.awt; import java.awt.font.FontRenderContext; @@ -28,6 +25,7 @@ import java.awt.geom.Rectangle2D; import java.io.BufferedInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -65,6 +63,8 @@ public static final int HANGING_BASELINE = 2; public static final int TRUETYPE_FONT = 0; + + public static final int TYPE1_FONT = 1; public static final int LAYOUT_LEFT_TO_RIGHT = 0; @@ -125,7 +125,7 @@ } - public Font(Map attributes) { + public Font(Map attributes) { Object currAttr; // Default values are taken from the documentation of the Font class. @@ -232,6 +232,14 @@ FontPeerImpl peer = (FontPeerImpl)this.getPeer(); return peer.canDisplay(c); } + + public boolean canDisplay(int i) { + if (!Character.isValidCodePoint(i)) { + throw new IllegalArgumentException(); + } + //TODO implement true code point support + return canDisplay((char)i); + } public int canDisplayUpTo(char[] text, int start, int limit) { int st = start; @@ -478,8 +486,9 @@ } + @SuppressWarnings("unchecked") - public Font deriveFont(Map attributes) { + public Font deriveFont(Map attributes) { Attribute[] avalAttributes = this.getAvailableAttributes(); Hashtable derivefRequestedAttributes = (Hashtable)fRequestedAttributes.clone(); @@ -516,8 +525,8 @@ } @SuppressWarnings("unchecked") - public Map getAttributes() { - return (Map)fRequestedAttributes.clone(); + public Map getAttributes() { + return (Map)fRequestedAttributes.clone(); } public Attribute[] getAvailableAttributes() { @@ -549,7 +558,7 @@ } - public static Font getFont(Map attributes) { + public static Font getFont(Map attributes) { Font fnt = (Font)attributes.get(TextAttribute.FONT); if (fnt != null){ return fnt; @@ -882,6 +891,16 @@ return peer.getItalicAngle(); } + public static Font createFont(int fontFormat, File fontFile) throws FontFormatException, + IOException { + InputStream is = new FileInputStream(fontFile); + try { + return createFont(fontFormat, is); + } finally { + is.close(); + } + } + public static Font createFont(int fontFormat, InputStream fontStream) throws FontFormatException, IOException { Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java?view=diff&rev=442084&r1=442083&r2=442084 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java Sun Sep 10 20:51:22 2006 @@ -29,12 +29,7 @@ * RenderingHints * */ -public class RenderingHints implements Map, Cloneable { - private final HashMap map = new HashMap(); - - /* - * Keys and values - */ +public class RenderingHints implements Map, Cloneable { public static final Key KEY_ALPHA_INTERPOLATION = new KeyImpl(1); public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT = new KeyValue(KEY_ALPHA_INTERPOLATION); public static final Object VALUE_ALPHA_INTERPOLATION_SPEED = new KeyValue(KEY_ALPHA_INTERPOLATION); @@ -80,18 +75,22 @@ public static final Object VALUE_TEXT_ANTIALIAS_ON = new KeyValue(KEY_TEXT_ANTIALIASING); public static final Object VALUE_TEXT_ANTIALIAS_OFF = new KeyValue(KEY_TEXT_ANTIALIASING); - public RenderingHints(Map map) { + private HashMap map = new HashMap(); + + public RenderingHints(Map map) { + super(); if (map != null) { putAll(map); } } public RenderingHints(Key key, Object value) { + super(); put(key, value); } public void add(RenderingHints hints) { - map.putAll(hints); + map.putAll(hints.map); } public Object put(Object key, Object value) { @@ -110,32 +109,31 @@ return map.get(key); } - public Set keySet() { + public Set keySet() { return map.keySet(); } - public Set entrySet() { + public Set> entrySet() { return map.entrySet(); } - public void putAll(Map m) { + public void putAll(Map m) { if (m instanceof RenderingHints) { - map.putAll(((RenderingHints)m).map); - return; - } - - Set entries = m.entrySet(); - - Iterator it = entries.iterator(); - while (it.hasNext()) { - Map.Entry entry = (Map.Entry)it.next(); - Key key = (Key)entry.getKey(); - Object val = entry.getValue(); - put(key, val); + map.putAll(((RenderingHints) m).map); + } else { + Set entries = m.entrySet(); + + Iterator it = entries.iterator(); + while (it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + Key key = (Key) entry.getKey(); + Object val = entry.getValue(); + put(key, val); + } } } - public Collection values() { + public Collection values() { return map.values(); } @@ -169,13 +167,13 @@ return false; } - Map m = (Map)o; - Set keys = keySet(); + Map m = (Map)o; + Set keys = keySet(); if (!keys.equals(m.keySet())) { return false; } - Iterator it = keys.iterator(); + Iterator it = keys.iterator(); while (it.hasNext()) { Key key = (Key)it.next(); Object v1 = get(key); @@ -192,9 +190,12 @@ return map.hashCode(); } + @SuppressWarnings("unchecked") @Override public Object clone() { - return new RenderingHints(map); + RenderingHints clone = new RenderingHints(null); + clone.map = (HashMap)this.map.clone(); + return clone; } @Override @@ -206,7 +207,7 @@ * Key */ public abstract static class Key { - private int key; + private final int key; protected Key(int key) { this.key = key;