From 693bcd896af2f12a1d7bebfdf7747c475cef1837 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Fri, 8 Oct 2004 21:41:40 +0000 Subject: 2004-10-08 Graydon Hoare * gnu/java/awt/ClasspathToolkit.java (getClasspathTextLayoutPeer) Add. * gnu/java/awt/peer/ClasspathFontPeer.java (copyStyleToAttrs) (copySizeToAttrs): Make public. * gnu/java/awt/peer/ClasspathTextLayoutPeer.java: New file. * gnu/java/awt/peer/gtk/GdkClasspathFontPeer.java: Remove. * gnu/java/awt/peer/gtk/GdkClasspathFontPeerMetrics.java: Remove. * gnu/java/awt/peer/gtk/GdkFontMetrics.java: Rewrite. * gnu/java/awt/peer/gtk/GdkFontPeer.java: New file. * gnu/java/awt/peer/gtk/GdkGlyphVector.java: Adjust type names. * gnu/java/awt/peer/gtk/GdkGraphics.java (getFontPeer): New function. (drawString): Pass font peer to native side. * gnu/java/awt/peer/gtk/GdkGraphics2D.java (cairoSetFont) (cairoShowGlyphs) (PainterThread): Remove. (GdkGraphics2D): Set hints during construction. (shifted) (walkPath) (draw) (setRenderingHint) (setRenderingHints): Reimplement normalization logic. (getDefaultHints) (updateBufferedImage) (isBufferedImageGraphics) (updateImagePixels) (drawImage): Make final. (drawImage): Always paint synchronously. (drawString) (drawGlyphVector): Rewrite. (releasePeerGraphicResource) (getPeerTextMetrics) (getPeerFontMetrics) (drawGdkGlyphVector) (drawGdkTextLayout) (cairoDrawGdkGlyphVector) (cairoDrawGdkTextLayout) (cairoDrawString) (getFontPeer): New functions. * gnu/java/awt/peer/gtk/GdkTextLayout.java: New file. * gnu/java/awt/peer/gtk/GtkComponentPeer.java (getFontMetrics): Get metrics via toolkit, to hit cache. * gnu/java/awt/peer/gtk/GtkTextAreaPeer.java: Use getFontMetrics. * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Likewise. * gnu/java/awt/peer/gtk/GtkToolkit.java (LRUCache): New class. (fontCache) (metricsCache) (imageCache): New members. (getFontMetrics) (getImage) (getClasspathFontPeer): Use caches. (getFontPeer): Route through getClasspathFontPeer. * java/awt/Font.java (attrsToMap): Remove, adjust ctors. * java/awt/font/TextLayout.java: Implement in terms of peer. * javax/swing/plaf/basic/BasicSliderUI.java (paintThumb): Use polyline rather than polygon. * javax/swing/plaf/basic/BasicGraphicsUtils.java: Update comment but, alas, still do not switch to using TextLayouts. * javax/swing/text/Utilities.java (drawTabbedText): Draw text run-at-a-time, not char-at-a-time. * jni/gtk-peer/gdkfont.h: Publicize some of the font interface, add layout table. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeer.c: * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c: Remove files. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c: Rewrite to incorporate brains of old GdkClasspathFontPeerMetrics. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c: Rewrite to incorporate brains of old GdkClasspathFontPeer. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c: New file. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (drawString): Rewrite to use persistent layout in peer font. Comment out extraneous gdk_flush calls. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c (metrics_cairo) (metrics_surface): New static variables. (paint_glyph_run) (install_font_peer): New helper functions. (releasePeerGraphicResource) (getPeerTextMetrics) (getPeerFontMetrics) (cairoDrawGdkTextLayout) (cairoDrawGdkGlyphVector): New native methods. (cairoDrawString): Rewrite, leaving layout-based version commented out for the time being. * jni/gtk-peer/gtkpeer.h (graphics): Add fields for pango stuff. 2004-10-08 Michael Koch * include/gnu_java_awt_peer_gtk_GdkFontMetrics.h include/gnu_java_awt_peer_gtk_GdkGraphics.h include/gnu_java_awt_peer_gtk_GdkGraphics2D.h: Regenerated. * include/gnu_java_awt_peer_gtk_GdkFontPeer.h include/gnu_java_awt_peer_gtk_GdkTextLayout.h: New files * include/Makefile.am: Added new files. * native/jni/gtk-peer/Makefile.am: Added new files. --- gnu/java/awt/peer/ClasspathTextLayoutPeer.java | 111 +++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 gnu/java/awt/peer/ClasspathTextLayoutPeer.java (limited to 'gnu/java/awt/peer/ClasspathTextLayoutPeer.java') diff --git a/gnu/java/awt/peer/ClasspathTextLayoutPeer.java b/gnu/java/awt/peer/ClasspathTextLayoutPeer.java new file mode 100644 index 000000000..143412caf --- /dev/null +++ b/gnu/java/awt/peer/ClasspathTextLayoutPeer.java @@ -0,0 +1,111 @@ +/* ClasspathTextLayoutPeer.java + Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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. */ + + +package gnu.java.awt.peer; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.font.TextHitInfo; +import java.awt.font.TextLayout; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.text.CharacterIterator; +import java.text.AttributedCharacterIterator; +import java.text.AttributedString; +import java.util.Map; +import java.awt.font.TextAttribute; + + +/** + * @author Graydon Hoare + */ + +public interface ClasspathTextLayoutPeer +{ + TextHitInfo getStrongCaret (TextHitInfo hit1, + TextHitInfo hit2); + + void draw (Graphics2D g2, float x, float y); + + byte getBaseline (); + + boolean isLeftToRight (); + boolean isVertical (); + + float getAdvance (); + float getAscent (); + float getDescent (); + float getLeading (); + + int getCharacterCount (); + byte getCharacterLevel (int index); + + float[] getBaselineOffsets (); + Shape getBlackBoxBounds (int firstEndpoint, int secondEndpoint); + Rectangle2D getBounds (); + + float[] getCaretInfo (TextHitInfo hit, Rectangle2D bounds); + Shape getCaretShape (TextHitInfo hit, Rectangle2D bounds); + Shape[] getCaretShapes (int offset, Rectangle2D bounds, + TextLayout.CaretPolicy policy); + + Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint, + Rectangle2D bounds); + int[] getLogicalRangesForVisualSelection (TextHitInfo firstEndpoint, + TextHitInfo secondEndpoint); + + TextHitInfo getNextLeftHit (int offset, TextLayout.CaretPolicy policy); + TextHitInfo getNextRightHit (int offset, TextLayout.CaretPolicy policy); + TextHitInfo hitTestChar (float x, float y, Rectangle2D bounds); + TextHitInfo getVisualOtherHit (TextHitInfo hit); + + float getVisibleAdvance (); + Shape getOutline (AffineTransform tx); + Shape getVisualHighlightShape (TextHitInfo firstEndpoint, + TextHitInfo secondEndpoint, + Rectangle2D bounds); + + TextLayout getJustifiedLayout (float justificationWidth); + void handleJustify (float justificationWidth); + + Object clone (); + int hashCode (); + boolean equals (ClasspathTextLayoutPeer tl); + String toString (); +} -- cgit v1.2.1