Java Code Examples for java.awt.font.GraphicAttribute

The following are top voted examples for showing how to use java.awt.font.GraphicAttribute. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 2
Project: jdk8u-jdk   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 3
Project: openjdk-jdk10   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 4
Project: openjdk9   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 5
Project: jdk8u_jdk   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 6
Project: lookaside_java-1.8.0-openjdk   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 7
Project: infobip-open-jdk-8   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 8
Project: jdk8u-dev-jdk   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 9
Project: jdk7-jdk   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 10
Project: openjdk-source-code-learn   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 11
Project: OLD-OpenJDK8   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 12
Project: cn1   File: BasicMetrics.java   View source code 6 votes vote down vote up
/**
 * Constructs BasicMetrics from GraphicAttribute.
 * It gets ascent and descent from the graphic attribute and
 * computes reasonable defaults for other metrics.
 * @param ga - graphic attribute
 */
BasicMetrics(GraphicAttribute ga) {
    ascent = ga.getAscent();
    descent = ga.getDescent();
    leading = 2;

    baseLineIndex = ga.getAlignment();

    italicAngle = 0;
    superScriptOffset = 0;

    underlineOffset = Math.max(descent/2, 1);

    // Just suggested, should be cap_stem_width or something like that
    underlineThickness = Math.max(ascent/13, 1);

    strikethroughOffset = -ascent/2; // Something like middle of the line
    strikethroughThickness = underlineThickness;
}
 
Example 13
Project: magarena   File: OracleText.java   View source code 6 votes vote down vote up
public static AttributedString textIconReplace(final String text) {
    final String compacted = text.replaceAll("\\{[^}]+}", "M");
    final AttributedString attrString = new AttributedString(compacted);
    for (int i = 0, j = 0; i < text.length(); i++, j++) {
        char c = text.charAt(i);
        if (c == '{') {
            final int endSymbol = text.indexOf('}', i);
            // get mana-string, substring returns at -1 value
            String iconString = text.substring(i, endSymbol + 1);
            // get related Icon as Image
            Image iconImage = MagicImages.getIcon(iconString).getImage();
            // define replacement icon
            ImageGraphicAttribute icon = new ImageGraphicAttribute(iconImage, GraphicAttribute.BOTTOM_ALIGNMENT);
            // replace M with icon
            attrString.addAttribute(
                TextAttribute.CHAR_REPLACEMENT,
                icon,
                j,
                j + 1
            );
            // advance i to the end of symbol
            i = endSymbol;
        }
    }
    return attrString;
}
 
Example 14
Project: openjdk-jdk7u-jdk   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 15
Project: freeVM   File: BasicMetrics.java   View source code 6 votes vote down vote up
/**
 * Constructs BasicMetrics from GraphicAttribute.
 * It gets ascent and descent from the graphic attribute and
 * computes reasonable defaults for other metrics.
 * @param ga - graphic attribute
 */
BasicMetrics(GraphicAttribute ga) {
    ascent = ga.getAscent();
    descent = ga.getDescent();
    leading = 2;

    baseLineIndex = ga.getAlignment();

    italicAngle = 0;
    superScriptOffset = 0;

    underlineOffset = Math.max(descent/2, 1);

    // Just suggested, should be cap_stem_width or something like that
    underlineThickness = Math.max(ascent/13, 1);

    strikethroughOffset = -ascent/2; // Something like middle of the line
    strikethroughThickness = underlineThickness;
}
 
Example 16
Project: freeVM   File: BasicMetrics.java   View source code 6 votes vote down vote up
/**
 * Constructs BasicMetrics from GraphicAttribute.
 * It gets ascent and descent from the graphic attribute and
 * computes reasonable defaults for other metrics.
 * @param ga - graphic attribute
 */
BasicMetrics(GraphicAttribute ga) {
    ascent = ga.getAscent();
    descent = ga.getDescent();
    leading = 2;

    baseLineIndex = ga.getAlignment();

    italicAngle = 0;
    superScriptOffset = 0;

    underlineOffset = Math.max(descent/2, 1);

    // Just suggested, should be cap_stem_width or something like that
    underlineThickness = Math.max(ascent/13, 1);

    strikethroughOffset = -ascent/2; // Something like middle of the line
    strikethroughThickness = underlineThickness;
}
 
Example 17
Project: openjdk-icedtea7   File: GraphicComponent.java   View source code 6 votes vote down vote up
/**
 * Create a new GraphicComponent.  start and limit are indices
 * into charLtoV and levels.  charsLtoV and levels may be adopted.
 */
public GraphicComponent(GraphicAttribute graphic,
                        Decoration decorator,
                        int[] charsLtoV,
                        byte[] levels,
                        int start,
                        int limit,
                        AffineTransform baseTx) {

    if (limit <= start) {
        throw new IllegalArgumentException("0 or negative length in GraphicComponent");
    }
    this.graphic = graphic;
    this.graphicAdvance = graphic.getAdvance();
    this.decorator = decorator;
    this.cm = createCoreMetrics(graphic);
    this.baseTx = baseTx;

    initLocalOrdering(charsLtoV, levels, start, limit);
}
 
Example 18
Project: OpenJSharp   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 19
Project: OpenJSharp   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 20
Project: jdk8u-jdk   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 21
Project: jdk8u-jdk   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 22
Project: openjdk-jdk10   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 23
Project: openjdk-jdk10   File: CoreMetrics.java   View source code 5 votes vote down vote up
public float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 24
Project: openjdk9   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 25
Project: openjdk9   File: CoreMetrics.java   View source code 5 votes vote down vote up
public float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 26
Project: jdk8u_jdk   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 27
Project: jdk8u_jdk   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 28
Project: lookaside_java-1.8.0-openjdk   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 29
Project: lookaside_java-1.8.0-openjdk   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 30
Project: infobip-open-jdk-8   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 31
Project: infobip-open-jdk-8   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 32
Project: jdk8u-dev-jdk   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 33
Project: jdk8u-dev-jdk   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 34
Project: jdk7-jdk   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 35
Project: jdk7-jdk   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 36
Project: openjdk-source-code-learn   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 37
Project: openjdk-source-code-learn   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 38
Project: OLD-OpenJDK8   File: GraphicComponent.java   View source code 5 votes vote down vote up
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
    return new CoreMetrics(graphic.getAscent(),
                           graphic.getDescent(),
                           GRAPHIC_LEADING,
                           graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
                           graphic.getAlignment(),
                           new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
                           -graphic.getAscent() / 2,
                           graphic.getAscent() / 12,
                           graphic.getDescent() / 3,
                           graphic.getAscent() / 12,
                           0, // ss offset
                           0); // italic angle -- need api for this
}
 
Example 39
Project: OLD-OpenJDK8   File: CoreMetrics.java   View source code 5 votes vote down vote up
public final float effectiveBaselineOffset(float[] fullOffsets) {
    switch (baselineIndex) {
    case GraphicAttribute.TOP_ALIGNMENT:
        return fullOffsets[4] + ascent;
    case GraphicAttribute.BOTTOM_ALIGNMENT:
        return fullOffsets[3] - descent;
    default:
        return fullOffsets[baselineIndex];
    }
}
 
Example 40
Project: cn1   File: TextMetricsCalculator.java   View source code 5 votes vote down vote up
/**
 * Returns either values cached by checkBaselines method or reasonable
 * values for the TOP and BOTTOM alignments.
 * @param baselineIndex - baseline index
 * @return baseline offset
 */
float getBaselineOffset(int baselineIndex) {
    if (baselineIndex >= 0) {
        return baselineOffsets[baselineIndex];
    } else if (baselineIndex == GraphicAttribute.BOTTOM_ALIGNMENT) {
        return descent;
    } else if (baselineIndex == GraphicAttribute.TOP_ALIGNMENT) {
        return -ascent;
    } else {
        // awt.3F=Invalid baseline index
        throw new IllegalArgumentException(Messages.getString("awt.3F")); //$NON-NLS-1$
    }
}