home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / font / GlyphSetComponent.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  6.2 KB  |  237 lines

  1. /*
  2.  * @(#)GlyphSetComponent.java    1.4 98/03/18
  3.  *
  4.  * Copyright 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. /*
  16.  * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
  17.  * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
  18.  *
  19.  * The original version of this source code and documentation is
  20.  * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
  21.  * of IBM. These materials are provided under terms of a License
  22.  * Agreement between Taligent and Sun. This technology is protected
  23.  * by multiple US and International patents.
  24.  *
  25.  * This notice and attribution to Taligent may not be removed.
  26.  * Taligent is a registered trademark of Taligent, Inc.
  27.  *
  28.  */
  29.  
  30. package java.awt.font;
  31.  
  32. import java.text.AttributedCharacterIterator;
  33. import java.awt.geom.Rectangle2D;
  34. import java.awt.Graphics2D;
  35. import java.awt.Font;
  36.  
  37. class GlyphSetComponent implements TextLayoutComponent {
  38.  
  39.     private final GlyphSet fGlyphSet;
  40.  
  41.     public GlyphSetComponent(GlyphSet glyphSet) {
  42.  
  43.         fGlyphSet = glyphSet;
  44.     }
  45.  
  46.     public float getAdvance() {
  47.  
  48.         return fGlyphSet.getAdvance();
  49.     }
  50.  
  51.     public float getAscent() {
  52.  
  53.         return fGlyphSet.getAscent();
  54.     }
  55.  
  56.     public float getDescent(float ascent) {
  57.  
  58.         return fGlyphSet.getDescent();
  59.     }
  60.  
  61.     public float getLeading() {
  62.  
  63.         return fGlyphSet.getFont().getLeading();
  64.     }
  65.  
  66.     public int getNumGlyphs() {
  67.  
  68.         return fGlyphSet.getNumGlyphs();
  69.     }
  70.  
  71.     public int getNumCharacters() {
  72.  
  73.         return fGlyphSet.getNumCharacters();
  74.     }
  75.  
  76.     public byte getBaseline() {
  77.  
  78.         return fGlyphSet.getBaseline();
  79.     }
  80.  
  81.     public float getXAdjust() {
  82.  
  83.         return fGlyphSet.getXAdjust();
  84.     }
  85.  
  86.     public float getGlyphXAdvance(int index) {
  87.  
  88.         return fGlyphSet.getGlyphXAdvance(index);
  89.     }
  90.  
  91.     public float getYAdjust() {
  92.  
  93.         return fGlyphSet.getYAdjust();
  94.     }
  95.  
  96.     public float getGlyphYAdvance(int index) {
  97.  
  98.         return fGlyphSet.getGlyphYAdvance(index);
  99.     }
  100.  
  101.     public float getGlyphAdvance(int index) {
  102.  
  103.         return fGlyphSet.getGlyphAdvance(index);
  104.     }
  105.  
  106.     public int visualToLogicalIndex(int index) {
  107.  
  108.         return fGlyphSet.visualToLogicalIndex(index);
  109.     }
  110.  
  111.     public byte getLevel(int index) {
  112.  
  113.         return fGlyphSet.getLevel(index);
  114.     }
  115.  
  116.     public boolean isCompletelyLTR() {
  117.  
  118.         return fGlyphSet.isCompletelyLTR();
  119.     }
  120.  
  121.     public TextLayoutComponent applyJustification(
  122.                         float[] deltas, int index, boolean[] flags) {
  123.  
  124.         GlyphSet gs = fGlyphSet.applyJustification(deltas, index, flags);
  125.         return new GlyphSetComponent(gs);
  126.     }
  127.  
  128.     public float getAdvanceBetween(int start, int limit) {
  129.  
  130.         return fGlyphSet.getAdvanceBetween(start, limit);
  131.     }
  132.  
  133.     public int getLineBreakIndex(int start, float hitAdvance) {
  134.  
  135.         return fGlyphSet.getLineBreakIndex(start, hitAdvance);
  136.     }
  137.  
  138.     public TextLayoutComponent subset(int start, int limit) {
  139.  
  140.         GlyphSet gs = fGlyphSet.subset(start, limit);
  141.         return new GlyphSetComponent(gs);
  142.     }
  143.  
  144.     public TextLayoutComponent insertChar(
  145.                                     AttributedCharacterIterator newText,
  146.                                     int start, int limit,
  147.                                     int insertPos,
  148.                                     int[] order,
  149.                                     byte[] levels) {
  150.  
  151.         GlyphSet gs = fGlyphSet.insertChar(
  152.                             newText, start, limit, insertPos, order, levels);
  153.         return new GlyphSetComponent(gs);
  154.     }
  155.  
  156.     public TextLayoutComponent deleteChar(
  157.                                     AttributedCharacterIterator newText,
  158.                                     int start, int limit,
  159.                                     int deletePos,
  160.                                     int[] order,
  161.                                     byte[] levels) {
  162.  
  163.         GlyphSet gs = fGlyphSet.deleteChar(
  164.                             newText, start, limit, deletePos, order, levels);
  165.         return new GlyphSetComponent(gs);
  166.     }
  167.  
  168.     public TextLayoutComponent reshape(
  169.                                     AttributedCharacterIterator newText,
  170.                                     int start, int limit,
  171.                                     int changePos,
  172.                                     int[] order,
  173.                                     byte[] levels) {
  174.  
  175.         GlyphSet gs = fGlyphSet.reshape(
  176.                             newText, start, limit, changePos, order, levels);
  177.         return new GlyphSetComponent(gs);
  178.     }
  179.  
  180.     public void draw(Graphics2D graphics, float x, float y, TextLayout hostLayout) {
  181.  
  182.         fGlyphSet.draw(graphics, x, y);
  183.     }
  184.  
  185.     public Rectangle2D getBounds(TextLayout hostLayout) {
  186.  
  187.         return fGlyphSet.getBounds();
  188.     }
  189.  
  190.     public TextLayoutComponent setDirection(boolean leftToRight) {
  191.  
  192.         GlyphSet gs = fGlyphSet.setDirection(leftToRight);
  193.         return new GlyphSetComponent(gs);
  194.     }
  195.  
  196.     public GlyphMetrics getGlyphMetrics(int index, TextLayout hostLayout) {
  197.  
  198.         Font font = fGlyphSet.getFont();
  199.         return font.getGlyphMetrics(fGlyphSet.getGlyphCode(index));
  200.     }
  201.  
  202.     public boolean isComponent(int index) {
  203.  
  204.         Font font = fGlyphSet.getFont();
  205.         return font.getGlyphMetrics(fGlyphSet.getGlyphCode(index)).isComponent();
  206.     }
  207.  
  208.     public int hashCode() {
  209.  
  210.         return fGlyphSet.hashCode();
  211.     }
  212.  
  213.     public boolean equals(TextLayoutComponent rhs) {
  214.  
  215.         try {
  216.             return fGlyphSet.equals(((GlyphSetComponent)rhs).fGlyphSet);
  217.         }
  218.         catch (ClassCastException e) {
  219.             return false;
  220.         }
  221.     }
  222.  
  223.     public float getItalicAngle() {
  224.  
  225.         return fGlyphSet.getFont().getItalicAngle();
  226.     }
  227.  
  228.     public GlyphJustificationInfo getGlyphJustificationInfo(int index) {
  229.  
  230.         Font font = fGlyphSet.getFont();
  231.         int glyphCode = fGlyphSet.getGlyphCode(index);
  232.  
  233.         return font.getGlyphJustificationInfo(glyphCode);
  234.     }
  235. }
  236.  
  237.