jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 7233 e560b64571c7
child 10292 ed7db6a12c2a
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7233
diff changeset
     2
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * (C) Copyright IBM Corp. 2003, All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * This technology is protected by multiple US and International
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * patents. This notice and attribution to IBM may not be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
package j2dbench.tests.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.Font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.awt.Graphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.awt.RenderingHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.awt.font.NumericShaper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.awt.font.TextAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.awt.font.FontRenderContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.awt.geom.AffineTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.io.BufferedReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.io.InputStreamReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.io.PrintWriter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import javax.swing.JComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import j2dbench.Destinations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import j2dbench.Group;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import j2dbench.Node;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
import j2dbench.Option;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
import j2dbench.Option.ObjectList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
import j2dbench.Result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
import j2dbench.Test;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
import j2dbench.TestEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
public abstract class TextTests extends Test {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public static boolean hasGraphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            hasGraphics2D = (Graphics2D.class != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        } catch (NoClassDefFoundError e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    // core data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    static final int[] tlengths = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        1, 2, 4, 8, 16, 32, 64, 128, 256, 512
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    static final String[] tscripts = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        // german, vietnamese, surrogate, dingbats
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        "english", "arabic", "greek", "hebrew", "hindi", "japanese", "korean", "thai",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        "english-arabic", "english-greek", "english-hindi", "english-arabic-hindi"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    static final float[] fsizes = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        1f, 6f, 8f, 10f, 12f, 12.5f, 13f, 13.5f, 16f, 20f, 36f, 72f, 128f
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    static final float[] fintsizes = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        1f, 6f, 8f, 10f, 12f, 13f, 16f, 20f, 36f, 72f, 128f
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    // utilties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    static Float[] floatObjectList(float[] input) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        Float[] result = new Float[input.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        for (int i = 0; i < result.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            result[i] = new Float(input[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    static String[] floatStringList(float[] input) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        return floatStringList("", input, "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    static String[] floatStringList(float[] input, String sfx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return floatStringList("", input, sfx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    static String[] floatStringList(String pfx, float[] input, String sfx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        String[] result = new String[input.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        for (int i = 0; i < result.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            result[i] = pfx + input[i] + sfx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    static String[] intStringList(int[] input) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        return intStringList("", input, "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    static String[] intStringList(int[] input, String sfx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        return intStringList("", input, sfx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    static String[] intStringList(String pfx, int[] input, String sfx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        String[] result = new String[input.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        for (int i = 0; i < result.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            result[i] = pfx + input[i] + sfx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    static final String[] txNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    static final String[] txDescNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    static final AffineTransform[] txList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    static final Map[] maps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        AffineTransform identity = new AffineTransform();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        AffineTransform sm_scale = AffineTransform.getScaleInstance(.5, .5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        AffineTransform lg_scale = AffineTransform.getScaleInstance(2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        AffineTransform wide = AffineTransform.getScaleInstance(2, .8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        AffineTransform tall = AffineTransform.getScaleInstance(.8, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        AffineTransform x_trans = AffineTransform.getTranslateInstance(50, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        AffineTransform y_trans = AffineTransform.getTranslateInstance(0, -30);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        AffineTransform xy_trans = AffineTransform.getTranslateInstance(50, -30);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        AffineTransform sm_rot = AffineTransform.getRotateInstance(Math.PI / 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        AffineTransform lg_rot = AffineTransform.getRotateInstance(Math.PI * 4 / 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        AffineTransform pi2_rot = AffineTransform.getRotateInstance(Math.PI / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        AffineTransform x_shear = AffineTransform.getShearInstance(.4, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        AffineTransform y_shear = AffineTransform.getShearInstance(0, -.4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        AffineTransform xy_shear = AffineTransform.getShearInstance(.3, .3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        AffineTransform x_flip = AffineTransform.getScaleInstance(-1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        AffineTransform y_flip = AffineTransform.getScaleInstance(1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        AffineTransform xy_flip = AffineTransform.getScaleInstance(-1, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        AffineTransform w_rot = AffineTransform.getRotateInstance(Math.PI / 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        w_rot.scale(2, .8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        AffineTransform w_y_shear = AffineTransform.getShearInstance(0, -.4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        w_y_shear.scale(2, .8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        AffineTransform w_r_trans = AffineTransform.getTranslateInstance(3, -7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        w_r_trans.rotate(Math.PI / 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        w_r_trans.scale(2, .8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        AffineTransform w_t_rot = AffineTransform.getRotateInstance(Math.PI / 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        w_t_rot.translate(3, -7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        w_t_rot.scale(2, .8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        AffineTransform w_y_s_r_trans = AffineTransform.getTranslateInstance(3, -7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        w_y_s_r_trans.rotate(Math.PI / 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        w_y_s_r_trans.shear(0, -.4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        w_y_s_r_trans.scale(2, .8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        txNames = new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            "ident",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            "smsc", "lgsc", "wide", "tall",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            "xtrn", "ytrn", "xytrn",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            "srot", "lrot", "hrot",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            "xshr", "yshr", "xyshr",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            "flx", "fly", "flxy",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            "wr", "wys", "wrt",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            "wtr", "wysrt"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        txDescNames = new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            "Identity",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            "Sm Scale", "Lg Scale", "Wide", "Tall",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            "X Trans", "Y Trans", "XY Trans",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            "Sm Rot", "Lg Rot", "PI/2 Rot",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            "X Shear", "Y Shear", "XY Shear",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            "FlipX", "FlipY", "FlipXY",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            "WRot", "WYShear", "WRTrans",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            "WTRot", "WYSRTrans"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        txList = new AffineTransform[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            identity,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            sm_scale, lg_scale, wide, tall,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            x_trans, y_trans, xy_trans,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            sm_rot, lg_rot, pi2_rot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            x_shear, y_shear, xy_shear,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            x_flip, y_flip, xy_flip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            w_rot, w_y_shear, w_r_trans,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            w_t_rot, w_y_s_r_trans,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        // maps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        HashMap fontMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        fontMap.put(TextAttribute.FONT, new Font("Dialog", Font.ITALIC, 18));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        HashMap emptyMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        HashMap simpleMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        simpleMap.put(TextAttribute.FAMILY, "Lucida Sans");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        simpleMap.put(TextAttribute.SIZE, new Float(14));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        simpleMap.put(TextAttribute.FOREGROUND, Color.blue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        HashMap complexMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        complexMap.put(TextAttribute.FAMILY, "Serif");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        complexMap.put(TextAttribute.TRANSFORM, tall);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        complexMap.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        complexMap.put(TextAttribute.RUN_DIRECTION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                       TextAttribute.RUN_DIRECTION_RTL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            complexMap.put(TextAttribute.NUMERIC_SHAPING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                           NumericShaper.getContextualShaper(NumericShaper.ALL_RANGES));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        } catch (NoSuchFieldError e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        maps = new Map[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            fontMap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            emptyMap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            simpleMap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            complexMap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    static String getString(Object key, int len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        String keyString = key.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        String[] strings = new String[4]; // leave room for index == 3 to return null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        int span = Math.min(32, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        int n = keyString.indexOf('-');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (n == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            strings[0] = getSimpleString(keyString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            strings[0] = getSimpleString(keyString.substring(0, n));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            int m = keyString.indexOf('-', n+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            if (m == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                strings[1] = getSimpleString(keyString.substring(n+1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                // 2 to 1 ratio, short spans between 1 and 16 chars long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                span = Math.max(1, Math.min(16, len / 3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                strings[1] = getSimpleString(keyString.substring(n+1, m));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                strings[2] = getSimpleString(keyString.substring(m+1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                span = Math.max(1, Math.min(16, len / 4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        String s = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        int pos = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        int strx = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        while (s.length() < len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            String src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            if (strings[strx] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                src = strings[0]; // use strings[0] twice for each other string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                strx = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                src = strings[strx++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            if (pos + span > src.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                pos = 0; // we know all strings are longer than span
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            s += src.substring(pos, pos+span);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            pos += span;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        return s.substring(0, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    static HashMap strcache = new HashMap(tscripts.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    private static String getSimpleString(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        String s = (String)strcache.get(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        if (s == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            String fname = "textdata/" + key + ".ut8.txt";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                InputStream is = TextTests.class.getResourceAsStream(fname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                if (is == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                    throw new IOException("Can't load resource " + fname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                BufferedReader r =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    new BufferedReader(new InputStreamReader(is, "utf8"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                StringBuffer buf = new StringBuffer(r.readLine());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                while (null != (s = r.readLine())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    buf.append("  ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                    buf.append(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                s = buf.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                if (s.charAt(0) == '\ufeff') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                    s = s.substring(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                s = "This is a dummy ascii string because " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                    fname + " was not found.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            strcache.put(key, s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        return s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    static Group textroot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    static Group txoptroot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    static Group txoptdataroot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    static Group txoptfontroot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    static Group txoptgraphicsroot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    static Group advoptsroot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    static Option tlengthList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    static Option tscriptList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    static Option fnameList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    static Option fstyleList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    static Option fsizeList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    static Option ftxList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    static Option taaList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    static Option tfmTog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    static Option gaaTog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    static Option gtxList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    static Option gvstyList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    static Option tlrunList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    static Option tlmapList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    // core is textlength, text script, font name/style/size/tx, frc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    // drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    //   drawString, drawChars, drawBytes, drawGlyphVector, TextLayout.draw, drawAttributedString
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    // length of text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    //   1, 2, 4, 8, 16, 32, 64, 128, 256 chars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    // script of text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    //   simple: latin-1, japanese, arabic, hebrew, indic, thai, surrogate, dingbats
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    //   mixed:  latin-1 + x  (1, 2, 3, 4 pairs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    // font of text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    //   name (composite, not), style, size (6, 12, 18, 24, 30, 36, 42, 48, 54, 60), transform (full set)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    // text rendering hints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    //   aa, fm, gaa
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    // graphics transform (full set)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    // (gv) gtx, gpos
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    // (tl, as) num style runs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    // querying/measuring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    //   ascent/descent/leading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    //   advance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    //   (gv) lb, vb, pb, glb, gvb, glb, gp, gjust, gmet, gtx
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    //   (tl) bounds, charpos, cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    // construction/layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    //   (bidi) no controls, controls, styles
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    //   (gv) createGV, layoutGV
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    //   (tl) TL constructors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    //   (tm) line break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    public static void init() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        textroot = new Group("text", "Text Benchmarks");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        textroot.setTabbed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        txoptroot = new Group(textroot, "opts", "Text Options");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        txoptroot.setTabbed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        txoptdataroot = new Group(txoptroot, "data", "Text Data");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        tlengthList = new Option.IntList(txoptdataroot, "tlength",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                                        "Text Length",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                                        tlengths,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                                        intStringList(tlengths),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                        intStringList(tlengths, " chars"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                                        0x10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        ((Option.ObjectList) tlengthList).setNumRows(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        tscriptList = new Option.ObjectList(txoptdataroot, "tscript",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                                            "Text Script",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                                            tscripts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                                            tscripts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                                            tscripts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                                            tscripts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                                            0x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        ((Option.ObjectList) tscriptList).setNumRows(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        txoptfontroot = new Group(txoptroot, "font", "Font");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        fnameList = new FontOption(txoptfontroot, "fname", "Family Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        fstyleList = new Option.IntList(txoptfontroot, "fstyle",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                                        "Style",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                                        new int[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                                            Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD + Font.ITALIC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                                        },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                                        new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                                            "plain", "bold", "italic", "bolditalic",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                                        },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                                        new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                                            "Plain", "Bold", "Italic", "Bold Italic",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                                        },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                                        0x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        float[] fsl = hasGraphics2D ? fsizes : fintsizes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        fsizeList = new Option.ObjectList(txoptfontroot, "fsize",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                                          "Size",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                                          floatStringList(fsl),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                                          floatObjectList(fsl),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                                          floatStringList(fsl),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                                          floatStringList(fsl, "pt"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                          0x40);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        ((Option.ObjectList) fsizeList).setNumRows(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        if (hasGraphics2D) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            ftxList = new Option.ObjectList(txoptfontroot, "ftx",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                                            "Transform",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                                            txDescNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                                            txList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                                            txNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                                            txDescNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                                            0x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            ((Option.ObjectList) ftxList).setNumRows(6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            txoptgraphicsroot = new Group(txoptroot, "graphics", "Graphics");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            String[] taaNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            Object[] taaHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                taaNames = new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    "Off", "On",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                    "LCD_HRGB", "LCD_HBGR", "LCD_VRGB", "LCD_VBGR"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                taaHints = new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                    RenderingHints.VALUE_TEXT_ANTIALIAS_OFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                    RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            } catch (NoSuchFieldError e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                taaNames = new String[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                    "Off", "On"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                taaHints = new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                    RenderingHints.VALUE_TEXT_ANTIALIAS_OFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            taaList = new Option.ObjectList(txoptgraphicsroot, "textaa",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                                            "Text AntiAlias",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                            taaNames, taaHints,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                            taaNames, taaNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                                            0x1);
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   457
            ((Option.ObjectList) taaList).setNumRows(6);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            // add special TextAAOpt for backwards compatibility with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            // older options files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            new TextAAOpt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            tfmTog = new Option.Toggle(txoptgraphicsroot, "tfm",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                                       "Fractional Metrics", Option.Toggle.Off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            gaaTog = new Option.Toggle(txoptgraphicsroot, "gaa",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                                       "Graphics AntiAlias", Option.Toggle.Off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            gtxList = new Option.ObjectList(txoptgraphicsroot, "gtx",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                                            "Transform",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                                            txDescNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                                            txList,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                                            txNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                                            txDescNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                                            0x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            ((Option.ObjectList) gtxList).setNumRows(6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            advoptsroot = new Group(txoptroot, "advopts", "Advanced Options");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            gvstyList = new Option.IntList(advoptsroot, "gvstyle", "Style",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                                           new int[] { 0, 1, 2, 3 },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                                           new String[] { "std", "wave", "twist", "circle" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                                           new String[] { "Standard",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                                                          "Positions adjusted",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                                                          "Glyph angles adjusted",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                                                          "Layout to circle"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                                           },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                                           0x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            int[] runs = { 1, 2, 4, 8 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            tlrunList = new Option.IntList(advoptsroot, "tlruns", "Attribute Runs",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                                           runs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                                           intStringList(runs),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                                           intStringList(runs, " runs"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                                           0x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            String[] tlmapnames = new String[] { "FONT", "Empty", "Simple", "Complex" };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            tlmapList = new Option.ObjectList(advoptsroot, "maptype", "Map",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                                              tlmapnames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                                              maps,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                                              new String[] { "font", "empty", "simple", "complex" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                                              tlmapnames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                                              0x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * This "virtual Node" implementation is here to maintain backward
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * compatibility with older J2DBench releases, specifically those
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * options files that were created before we added LCD-optimized text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * hints in JDK 6.  This class will translate the text antialias settings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * from the old "taa" On/Off/Both choice into the new expanded version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    private static class TextAAOpt extends Node {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        public TextAAOpt() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            super(txoptgraphicsroot, "taa", "Text AntiAlias");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        public JComponent getJComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        public void restoreDefault() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            // no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        public void write(PrintWriter pw) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            // no-op (the old "taa" choice will be saved as part of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            // new "textaa" option)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        public String setOption(String key, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            String opts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            if (value.equals("On")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                opts = "On";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            } else if (value.equals("Off")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                opts = "Off";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            } else if (value.equals("Both")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                opts = "On,Off";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                return "Bad value";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            return ((Option.ObjectList)taaList).setValueFromString(opts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    public static class Context {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        void init(TestEnvironment env, Result result) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        void cleanup(TestEnvironment env) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    public static class TextContext extends Context {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        Graphics graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        String text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        char[] chars;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        Font font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        public void init(TestEnvironment env, Result result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            // graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            graphics = env.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            // text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
            String sname = (String)env.getModifier(tscriptList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            int slen = env.getIntValue(tlengthList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            text = getString(sname, slen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            // chars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            chars = text.toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            // font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            String fname = (String)env.getModifier(fnameList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            if ("Physical".equals(fname)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                fname = physicalFontNameFor(sname, slen, text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            int fstyle = env.getIntValue(fstyleList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            float fsize = ((Float)env.getModifier(fsizeList)).floatValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            AffineTransform ftx = (AffineTransform)env.getModifier(ftxList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            font = new Font(fname, fstyle, (int)fsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            if (hasGraphics2D) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                if (fsize != Math.floor(fsize)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                    font = font.deriveFont(fsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                if (!ftx.isIdentity()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                    font = font.deriveFont(ftx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            // graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            if (hasGraphics2D) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                Graphics2D g2d = (Graphics2D)graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                                     env.getModifier(taaList));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                     env.isEnabled(tfmTog)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                                     ? RenderingHints.VALUE_FRACTIONALMETRICS_ON
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                                     : RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                                     env.isEnabled(gaaTog)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                                     ? RenderingHints.VALUE_ANTIALIAS_ON
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                                     : RenderingHints.VALUE_ANTIALIAS_OFF);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                g2d.transform((AffineTransform)env.getModifier(gtxList));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            // set result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            result.setUnits(text.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            result.setUnitName("char");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        public void cleanup(TestEnvironment env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            graphics.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            graphics = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    public static class G2DContext extends TextContext {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        Graphics2D g2d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        FontRenderContext frc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        public void init(TestEnvironment env, Result results){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            super.init(env, results);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            g2d = (Graphics2D)graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            frc = g2d.getFontRenderContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    public TextTests(Group parent, String nodeName, String description) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        super(parent, nodeName, description);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        addDependency(Destinations.destroot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        addDependencies(txoptroot, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    public Context createContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        return new TextContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    public Object initTest(TestEnvironment env, Result result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        Context ctx = createContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        ctx.init(env, result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        return ctx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    public void cleanupTest(TestEnvironment env, Object ctx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        ((Context)ctx).cleanup(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    static Map physicalMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    public static String physicalFontNameFor(String textname, int textlen, String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        Map lenMap = (Map)physicalMap.get(textname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        if (lenMap == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            lenMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            physicalMap.put(textname, lenMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        Integer key = new Integer(textlen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        Font textfont = (Font)lenMap.get(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        if (textfont == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            Font[] fontsToTry = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            if (lenMap.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                fontsToTry = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                Set fontset = new HashSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                java.util.Iterator iter = lenMap.entrySet().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                    Map.Entry e = (Map.Entry)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                    fontset.add(e.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                fontsToTry = (Font[])fontset.toArray(new Font[fontset.size()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            Font bestFont = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            int bestCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            for (int i = 0; i < fontsToTry.length; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                Font font = fontsToTry[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                int count = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                for (int j = 0, limit = text.length(); j < limit; ++j) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                    if (font.canDisplay(text.charAt(j))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                        ++count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                if (count > bestCount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                    bestFont = font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                    bestCount = count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            textfont = bestFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            lenMap.put(key, textfont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        return textfont.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    static class FontOption extends ObjectList {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        static String[] optionnames = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            "default", "serif", "lucida", "physical"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        static String[] descnames = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            "Default", "Serif", "Lucida Sans", "Physical"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        public FontOption(Group parent, String nodeName, String description) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            super(parent, nodeName, description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                  optionnames, descnames, optionnames, descnames, 0xa);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        public String getValString(Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
            return value.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        public String getAbbreviatedModifierDescription(Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            return value.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
}
7233
e560b64571c7 6689925: Add transform attributes to the rendering tests in J2DBench
jgodinez
parents: 5506
diff changeset
   710