diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | gnu/java/awt/peer/x/XFontPeer.java | 28 | ||||
-rw-r--r-- | gnu/java/awt/peer/x/XGraphics.java | 46 | ||||
-rw-r--r-- | gnu/java/awt/peer/x/XImage.java | 9 | ||||
-rw-r--r-- | resource/gnu/java/awt/peer/x/fonts.properties | 76 |
5 files changed, 135 insertions, 40 deletions
@@ -1,3 +1,19 @@ +2006-07-18 Roman Kennke <kennke@aicas.com> + + * gnu/java/awt/peer/x/XFontPeer.java + (encodeFont): Be more flexible with font sizes. + (validSize): New helper method. + * gnu/java/awt/peer/x/XGraphics.java + (drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver)): + Implemented. + (drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver)): + Implemented. + * gnu/java/awt/peer/x/XImage.java + (properties): New field. + (getProperty): Implemented. + * resource/gnu/java/awt/peer/x/fonts.properties: + Added copyright header. Fixed font size field. + 2006-07-18 David Gilbert <david.gilbert@object-refinery.com> * java/awt/image/BandedSampleModel.java diff --git a/gnu/java/awt/peer/x/XFontPeer.java b/gnu/java/awt/peer/x/XFontPeer.java index 8a499db1a..fd293d8dd 100644 --- a/gnu/java/awt/peer/x/XFontPeer.java +++ b/gnu/java/awt/peer/x/XFontPeer.java @@ -694,7 +694,8 @@ public class XFontPeer } String protoType = fontProperties.getProperty(key.toString()); - return protoType.replaceFirst("%d", String.valueOf(size)); + int s = validSize(size); + return protoType.replaceFirst("%d", String.valueOf(s * 10)); } /** @@ -724,6 +725,31 @@ public class XFontPeer } /** + * Translates an arbitrary point size to a size that is typically available + * on an X server. These are the sizes 8, 10, 12, 14, 18 and 24. + * + * @param size the queried size + * @return the real available size + */ + private static final int validSize(int size) + { + int val; + if (size <= 9) + val = 8; + else if (size <= 11) + val = 10; + else if (size <= 13) + val = 12; + else if (size <= 17) + val = 14; + else if (size <= 23) + val = 18; + else + val = 24; + return val; + } + + /** * Returns the X Font reference. This lazily loads the font when first * requested. * diff --git a/gnu/java/awt/peer/x/XGraphics.java b/gnu/java/awt/peer/x/XGraphics.java index 7c1ceecbc..a9021b72a 100644 --- a/gnu/java/awt/peer/x/XGraphics.java +++ b/gnu/java/awt/peer/x/XGraphics.java @@ -46,28 +46,15 @@ import gnu.x11.Point; import java.awt.AWTError; import java.awt.Color; -import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; -import java.awt.GraphicsConfiguration; import java.awt.Image; -import java.awt.Paint; import java.awt.Rectangle; -import java.awt.RenderingHints; import java.awt.Shape; -import java.awt.Stroke; import java.awt.Toolkit; -import java.awt.RenderingHints.Key; -import java.awt.font.FontRenderContext; -import java.awt.font.GlyphVector; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.image.BufferedImageOp; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; -import java.awt.image.RenderedImage; -import java.awt.image.renderable.RenderableImage; import java.text.AttributedCharacterIterator; import java.util.HashMap; @@ -577,16 +564,41 @@ public class XGraphics int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { - // FIXME: Implement this. - throw new UnsupportedOperationException("Not yet implemented"); + return drawImage(image, dx1, dy1, dx2, dy2, sx1, sx2, sy1, sy2, null, + observer); } public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { - // FIXME: Implement this. - throw new UnsupportedOperationException("Not yet implemented"); + + // FIXME: What to do with bgcolor? + + // Scale the image. + int sw = image.getWidth(observer); + int sh = image.getHeight(observer); + double scaleX = Math.abs(dx2 - dx1) / (double) Math.abs(sx2 - sx1); + double scaleY = Math.abs(dy2 - dy1) / (double) Math.abs(sy2 - sy1); + Image scaled = image.getScaledInstance((int) (scaleX * sw), + (int) (scaleY * sh), + Image.SCALE_FAST); + + // Scaled source coordinates. + int sx1s = (int) (scaleX * Math.min(sx1, sx2)); + int sx2s = (int) (scaleX * Math.max(sx1, sx2)); + + // Temporarily clip to the target rectangle. + Rectangle old = clip; + clipRect(dx1, dy1, dx2 - dx1, dy2 - dy1); + + // Draw scaled image. + boolean res = drawImage(scaled, dx1 - sx1s, dy1 - sx2s, observer); + + // Reset clip. + setClip(old); + + return res; } /** diff --git a/gnu/java/awt/peer/x/XImage.java b/gnu/java/awt/peer/x/XImage.java index ab0b74620..b9e993628 100644 --- a/gnu/java/awt/peer/x/XImage.java +++ b/gnu/java/awt/peer/x/XImage.java @@ -45,6 +45,7 @@ import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; +import java.util.Hashtable; public class XImage extends Image @@ -52,6 +53,8 @@ public class XImage Pixmap pixmap; + private Hashtable properties; + XImage(int w, int h) { GraphicsEnvironment env = @@ -89,8 +92,10 @@ public class XImage public Object getProperty(String name, ImageObserver observer) { - // TODO: Implement this. - throw new UnsupportedOperationException("Not yet implemented."); + Object val = null; + if (properties != null) + val = properties.get(val); + return val; } public void flush() diff --git a/resource/gnu/java/awt/peer/x/fonts.properties b/resource/gnu/java/awt/peer/x/fonts.properties index 2c8755ceb..71a95c193 100644 --- a/resource/gnu/java/awt/peer/x/fonts.properties +++ b/resource/gnu/java/awt/peer/x/fonts.properties @@ -1,25 +1,61 @@ +# fonts.properties +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is part of GNU Classpath. +# +# GNU Classpath is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Classpath is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Classpath; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA. +# +# Linking this library statically or dynamically with other modules is +# making a combined work based on this library. Thus, the terms and +# conditions of the GNU General Public License cover the whole +# combination. +# +# As a special exception, the copyright holders of this library give you +# permission to link this library with independent modules to produce an +# executable, regardless of the license terms of these independent +# modules, and to copy and distribute the resulting executable under +# terms of your choice, provided that you also meet, for each linked +# independent module, the terms and conditions of the license of that +# module. An independent module is a module which is not derived from +# or based on this library. If you modify this library, you may extend +# this exception to your version of the library, but you are not +# obligated to do so. If you do not wish to do so, delete this +# exception statement from your version. -serif.plain=-adobe-times-medium-r-normal--%d-*-*-*-p-*-iso8859-1 -serif.bold=-adobe-times-bold-r-normal--%d-*-*-*-p-*-iso8859-1 -serif.italic=-adobe-times-medium-o-normal--%d-*-*-*-p-*-iso8859-1 -serif.bolditalic=-adobe-times-bold-o-normal--%d-*-*-*-p-*-iso8859-1 +serif.plain=-adobe-times-medium-r-normal--*-%d-75-*-p-*-iso8859-1 +serif.bold=-adobe-times-bold-r-normal--*-%d-75-*-p-*-iso8859-1 +serif.italic=-adobe-times-medium-o-normal--*-%d-75-*-p-*-iso8859-1 +serif.bolditalic=-adobe-times-bold-o-normal--*-%d-75-*-p-*-iso8859-1 -sansserif.plain=-adobe-helvetica-medium-r-normal--%d-*-*-*-p-*-iso8859-1 -sansserif.bold=-adobe-helvetica-bold-r-normal--%d-*-*-*-p-*-iso8859-1 -sansserif.italic=-adobe-helvetica-medium-o-normal--%d-*-*-*-p-*-iso8859-1 -sansserif.bolditalic=-adobe-helvetica-bold-o-normal--%d-*-*-*-p-*-iso8859-1 +sansserif.plain=-adobe-helvetica-medium-r-normal--*-%d-75-*-p-*-iso8859-1 +sansserif.bold=-adobe-helvetica-bold-r-normal--*-%d-75-*-p-*-iso8859-1 +sansserif.italic=-adobe-helvetica-medium-o-normal--*-%d-75-*-p-*-iso8859-1 +sansserif.bolditalic=-adobe-helvetica-bold-o-normal--*-%d-75-*-p-*-iso8859-1 -monospaced.plain=-adobe-courier-medium-r-normal--%d-*-*-*-p-*-iso8859-1 -monospaced.bold=-adobe-courier-bold-r-normal--%d-*-*-*-p-*-iso8859-1 -monospaced.italic=-adobe-courier-medium-o-normal--%d-*-*-*-p-*-iso8859-1 -monospaced.bolditalic=-adobe-courier-bold-o-normal--%d-*-*-*-p-*-iso8859-1 +monospaced.plain=-adobe-courier-medium-r-normal--*-%d-75-*-p-*-iso8859-1 +monospaced.bold=-adobe-courier-bold-r-normal--*-%d-75-*-p-*-iso8859-1 +monospaced.italic=-adobe-courier-medium-o-normal--*-%d-75-*-p-*-iso8859-1 +monospaced.bolditalic=-adobe-courier-bold-o-normal--*-%d-75-*-p-*-iso8859-1 -dialog.plain=-adobe-helvetica-medium-r-normal--%d-*-*-*-p-*-iso8859-1 -dialog.bold=-adobe-helvetica-bold-r-normal--%d-*-*-*-p-*-iso8859-1 -dialog.italic=-adobe-helvetica-medium-o-normal--%d-*-*-*-p-*-iso8859-1 -dialog.bolditalic=-adobe-helvetica-bold-o-normal--%d-*-*-*-p-*-iso8859-1 +dialog.plain=-adobe-helvetica-medium-r-normal--*-%d-75-*-p-*-iso8859-1 +dialog.bold=-adobe-helvetica-bold-r-normal--*-%d-75-*-p-*-iso8859-1 +dialog.italic=-adobe-helvetica-medium-o-normal--*-%d-75-*-p-*-iso8859-1 +dialog.bolditalic=-adobe-helvetica-bold-o-normal--*-%d-75-*-p-*-iso8859-1 -dialoginput.plain=-adobe-helvetica-medium-r-normal--%d-*-*-*-p-*-iso8859-1 -dialoginput.bold=-adobe-helvetica-bold-r-normal--%d-*-*-*-p-*-iso8859-1 -dialoginput.italic=-adobe-helvetica-medium-o-normal--%d-*-*-*-p-*-iso8859-1 -dialoginput.bolditalic=-adobe-helvetica-bold-o-normal--%d-*-*-*-p-*-iso8859-1 +dialoginput.plain=-adobe-helvetica-medium-r-normal--*-%d-75-*-p-*-iso8859-1 +dialoginput.bold=-adobe-helvetica-bold-r-normal--*-%d-75-*-p-*-iso8859-1 +dialoginput.italic=-adobe-helvetica-medium-o-normal--*-%d-75-*-p-*-iso8859-1 +dialoginput.bolditalic=-adobe-helvetica-bold-o-normal--*-%d-75-*-p-*-iso8859-1 |