harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r597106 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main/java: common/java/awt/ common/org/apache/harmony/awt/gl/ common/org/apache/harmony/awt/gl/font/ unix/org/apache/harmony/awt/gl/font/ windows/org/apache/harmony/awt/gl/font/
Date Wed, 21 Nov 2007 14:42:08 GMT
Author: apetrenko
Date: Wed Nov 21 06:42:05 2007
New Revision: 597106

URL: http://svn.apache.org/viewvc?rev=597106&view=rev
Log:
Patch for HARMONY-5133 "[classlib][awt] Using of FontRenderContext is 
not implemented"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java Wed
Nov 21 06:42:05 2007
@@ -318,7 +318,7 @@
         return this.createGlyphVector(frc, chars);
     }
 
-    public GlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes) throws
org.apache.harmony.luni.util.NotImplementedException {
+    public GlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes){
         int length = glyphCodes.length;        
         char[] chars = new char[length];        
         FontPeerImpl peer = (FontPeerImpl) getPeer();
@@ -748,6 +748,7 @@
         Rectangle2D bounds;
 
         AffineTransform transform = getTransform();
+        AffineTransform frcTransform = frc.getTransform();
 
         // XXX: for transforms where an angle between basis vectors is not 90
         // degrees Rectanlge2D class doesn't fit as Logical bounds.
@@ -766,7 +767,10 @@
             System.arraycopy(chars, start, subChars, 0, len);
             bounds = createGlyphVector(frc, subChars).getLogicalBounds();
         }
-
+        
+        if (!(frcTransform.isIdentity()))
+            return frcTransform.createTransformedShape(bounds).getBounds2D();
+        
         return bounds;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
Wed Nov 21 06:42:05 2007
@@ -28,6 +28,7 @@
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
 import java.awt.Image;
 import java.awt.Paint;
 import java.awt.PaintContext;
@@ -158,7 +159,7 @@
     protected Stroke stroke = new BasicStroke();
 
     //TODO: Think more about FontRenderContext
-    protected FontRenderContext frc = new FontRenderContext(null, false, false);
+    protected FontRenderContext frc = null;
 
     protected JavaShapeRasterizer jsr = new JavaShapeRasterizer();
 
@@ -782,6 +783,22 @@
 
     @Override
     public FontRenderContext getFontRenderContext() {
+        AffineTransform at;
+        if (frc == null){
+            GraphicsConfiguration gc = getDeviceConfiguration();
+            if (gc != null){
+                at = gc.getDefaultTransform();
+                at.concatenate(gc.getNormalizingTransform());
+            }
+            else 
+                at = null;
+
+            boolean isAa = (hints.get(RenderingHints.KEY_TEXT_ANTIALIASING) == 
+                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+            boolean isFm = (hints.get(RenderingHints.KEY_FRACTIONALMETRICS) == 
+                RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+            frc = new FontRenderContext(at,isAa,isFm);
+        }
         return frc;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CommonGlyphVector.java
Wed Nov 21 06:42:05 2007
@@ -118,7 +118,7 @@
         visualPositions = new float[(len+1)<<1];
         defaultPositions = new float[(len+1)<<1];
 
-        glsTransforms = new AffineTransform[len];
+//        glsTransforms = new AffineTransform[len];
 
         this.charVector = chars;
         this.vectorFRC = frc;
@@ -486,7 +486,7 @@
     @Override
     public Rectangle getGlyphPixelBounds(int glyphIndex, FontRenderContext frc,
             float x, float y) {
-        // TODO : need to be implemented with FontRenderContext
+
         if ((glyphIndex < 0) || (glyphIndex >= this.getNumGlyphs())) {
             // awt.43=glyphIndex is out of vector's limits
             throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
@@ -507,8 +507,16 @@
 
         if (frc != null){
             at.concatenate(frc.getTransform());
+        
+/*          if (frc.usesFractionalMetrics()){
+                shape.transform(at);
+                Rectangle2D bounds = shape.getBounds2D();
+                Rectangle rect = new Rectangle();
+                rect.setRect(bounds);
+                return rect;
+            }*/
         }
-
+        
         shape.transform(at);
 
         Rectangle bounds = shape.getBounds();

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/CompositeFont.java
Wed Nov 21 06:42:05 2007
@@ -161,13 +161,20 @@
      * @param frc specified FontRenderContext 
      * @param at specified AffineTransform
      */
-     @Override
+    @Override
     public LineMetrics getLineMetrics(String str, FontRenderContext frc , AffineTransform
at){
+        AffineTransform frcAt = null;
         LineMetricsImpl lm = (LineMetricsImpl)(this.nlm.clone());
         lm.setNumChars(str.length());
-
+        if (frc != null)
+            frcAt = frc.getTransform();
+        
         if ((at != null) && (!at.isIdentity())){
+            if (frcAt != null)
+                at.concatenate(frcAt);
             lm.scale((float)at.getScaleX(), (float)at.getScaleY());
+        } else if ((frcAt != null) && (!frcAt.isIdentity())){
+            lm.scale((float)frcAt.getScaleX(), (float)frcAt.getScaleY());
         }
 
         return lm;
@@ -315,7 +322,11 @@
      */
     public Rectangle2D getStringBounds(char[] chars, int start, int end, FontRenderContext
frc){
 
-        LineMetrics lm = getLineMetrics();
+        if (nlm == null){
+            setDefaultLineMetrics("", frc); //$NON-NLS-1$
+        }
+
+        LineMetrics lm = nlm;
         float minY = -lm.getAscent();
         float minX = 0;
         float height = lm.getHeight();

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
Wed Nov 21 06:42:05 2007
@@ -371,7 +371,11 @@
      * @param frc specified FontRenderContext
      */
     public Rectangle2D getMaxCharBounds(FontRenderContext frc) {
-        return maxCharBounds;
+        if (frc != null){
+            AffineTransform at = frc.getTransform();
+            return at.createTransformedShape(maxCharBounds).getBounds2D();
+        } else 
+            return maxCharBounds;
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
Wed Nov 21 06:42:05 2007
@@ -89,7 +89,7 @@
                 this.italicAngle = LinuxNativeFont.getItalicAngleNative(pFont, this.fontType);
         }
         
-        this.nlm = new LinuxLineMetrics(this, null, " "); //$NON-NLS-1$
+        this.nlm = new LinuxLineMetrics(this, " "); //$NON-NLS-1$
 
         this.ascent = nlm.getLogicalAscent();
         this.descent = nlm.getLogicalDescent();
@@ -119,16 +119,22 @@
     }
 
     public LineMetrics getLineMetrics(String str, FontRenderContext frc, AffineTransform
at) {
-        //TODO: frc isn't used now
         
+        AffineTransform frcAt = null;
         // Initialize baseline offsets
         nlm.getBaselineOffsets();
+        if (frc != null)
+            frcAt = frc.getTransform();
         
         LineMetricsImpl lm = (LineMetricsImpl)(this.nlm.clone());
         lm.setNumChars(str.length());
 
         if ((at != null) && (!at.isIdentity())){
+            if (frcAt != null) 
+                at.concatenate(frcAt);
             lm.scale((float)at.getScaleX(), (float)at.getScaleY());
+        } else if ((frcAt != null) && (!frcAt.isIdentity())) {
+            lm.scale((float)frcAt.getScaleX(), (float)frcAt.getScaleY());
         }
 
         return lm;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxLineMetrics.java
Wed Nov 21 06:42:05 2007
@@ -36,10 +36,8 @@
     /**
      * Constructor
      */
-    public LinuxLineMetrics(    LinuxFont fnt,
-                                FontRenderContext frc,
-                                String str){
-        // TODO : FontRenderContext isn't used now
+    public LinuxLineMetrics(LinuxFont fnt, String str){
+
         float[] metrics = LinuxNativeFont.getNativeLineMetrics(fnt.getFontHandle(), fnt.getSize(),
false, false, fnt.fontType);
 
         if (metrics == null){

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java?rev=597106&r1=597105&r2=597106&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
Wed Nov 21 06:42:05 2007
@@ -330,11 +330,19 @@
      */
     @Override
     public LineMetrics getLineMetrics(String str, FontRenderContext frc, AffineTransform
at) {
+        AffineTransform frcAt = null;
         LineMetricsImpl lm = getDefaultLineMetrics();
         lm.setNumChars(str.length());
+        
+        if (frc != null)
+            frcAt = frc.getTransform();
 
         if ((at != null) && (!at.isIdentity())){
+            if (frcAt != null) 
+                at.concatenate(frcAt);
             lm.scale((float)at.getScaleX(), (float)at.getScaleY());
+        } else if ((frcAt != null) && (!frcAt.isIdentity())){
+            lm.scale((float)frcAt.getScaleX(), (float)frcAt.getScaleY());
         }
 
         return lm;



Mime
View raw message