Examples of GlyphJustificationInfo


Examples of ae.java.awt.font.GlyphJustificationInfo

    float[] charinfo = getCharinfo();

    float size = gv.getFont().getSize2D();

    GlyphJustificationInfo nullInfo =
      new GlyphJustificationInfo(0,
                                 false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0,
                                 false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);

    GlyphJustificationInfo spaceInfo =
      new GlyphJustificationInfo(size,
                                 true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size,
                                 true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, size / 4f);

    GlyphJustificationInfo kanjiInfo =
      new GlyphJustificationInfo(size,
                                 true, GlyphJustificationInfo.PRIORITY_INTERCHAR, size, size,
                                 false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0);

    char[] chars = source.getChars();
    int offset = source.getStart();

    // assume data is 1-1 and either all rtl or all ltr, for now

    int numGlyphs = gv.getNumGlyphs();
    int minGlyph = 0;
    int maxGlyph = numGlyphs;
    boolean ltr = (source.getLayoutFlags() & 0x1) == 0;
    if (charStart != 0 || charLimit != source.getLength()) {
      if (ltr) {
        minGlyph = charStart;
        maxGlyph = charLimit;
      } else {
        minGlyph = numGlyphs - charLimit;
        maxGlyph = numGlyphs - charStart;
      }
    }

    for (int i = 0; i < numGlyphs; ++i) {
      GlyphJustificationInfo info = null;
      if (i >= minGlyph && i < maxGlyph) {
        if (charinfo[i * numvals + advx] == 0) { // combining marks don't justify
          info = nullInfo;
        } else {
          int ci = v2l(i); // 1-1 assumption again
View Full Code Here

Examples of com.google.code.appengine.awt.font.GlyphJustificationInfo

         *    System.out.println(myGA.getJustificationInfo().shrinkPriority);
         *    System.out.println(myGA.getJustificationInfo().shrinkRightLimit);
         *    System.out.println(myGA.getJustificationInfo().weight);
         */
        float advance = getAdvance();
        return new GlyphJustificationInfo(
                                    advance,
                                    false,
                                    GlyphJustificationInfo.PRIORITY_INTERCHAR,
                                    advance / 3,
                                    advance / 3,
View Full Code Here

Examples of com.jgraph.gaeawt.java.awt.font.GlyphJustificationInfo

                int charIndicies[] = gv.getGlyphCharIndices(0, nGlyphs, null);
                gjis = new GlyphJustificationInfo[nGlyphs];

                // Patch: temporary patch, getGlyphJustificationInfo is not implemented
                float fontSize = info.font.getSize2D();
                GlyphJustificationInfo defaultInfo =
                        new GlyphJustificationInfo(
                                0, // weight
                                false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0, // grow
                                false, GlyphJustificationInfo.PRIORITY_NONE, 0, 0); // shrink
                GlyphJustificationInfo spaceInfo = new GlyphJustificationInfo(
                        fontSize, // weight
                        true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, fontSize, // grow
                        true, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, fontSize); // shrink

                ////////
View Full Code Here

Examples of com.jgraph.gaeawt.java.awt.font.GlyphJustificationInfo

                        // suppose they are contiguous
                        continue;
                    }
                    prevGlyphIdx = currGlyphIdx;

                    GlyphJustificationInfo gji = getGlyphJustificationInfos()[currGlyphIdx];
                    if (gji.growPriority == jInfo.priority) {
                        jInfo.weight += gji.weight * 2;
                        jInfo.growLimit += gji.growLeftLimit;
                        jInfo.growLimit += gji.growRightLimit;
                        if (gji.growAbsorb) {
                            jInfo.absorbedWeight += gji.weight * 2;
                        }
                    }
                }
            } else {
                for (int i=0; i<lastChar; i++) {
                    currGlyphIdx = getChar2Glyph()[i];
                    if (currGlyphIdx == prevGlyphIdx) {
                        continue;
                    }
                    prevGlyphIdx = currGlyphIdx;

                    GlyphJustificationInfo gji = getGlyphJustificationInfos()[currGlyphIdx];
                    if (gji.shrinkPriority == jInfo.priority) {
                        jInfo.weight += gji.weight * 2;
                        jInfo.growLimit -= gji.shrinkLeftLimit;
                        jInfo.growLimit -= gji.shrinkRightLimit;
                        if (gji.shrinkAbsorb) {
                            jInfo.absorbedWeight += gji.weight * 2;
                        }
                    }
                }
            }

            if (haveFirst) {  // Don't add padding before first char
                GlyphJustificationInfo gji = getGlyphJustificationInfos()[getChar2Glyph()[0]];
                jInfo.weight -= gji.weight;
                if (jInfo.grow) {
                    jInfo.growLimit -= gji.growLeftLimit;
                    if (gji.growAbsorb) {
                        jInfo.absorbedWeight -= gji.weight;
                    }
                } else {
                    jInfo.growLimit += gji.shrinkLeftLimit;
                    if (gji.shrinkAbsorb) {
                        jInfo.absorbedWeight -= gji.weight;
                    }
                }
            }

            if (haveLast) {   // Don't add padding after last char
                GlyphJustificationInfo gji =
                        getGlyphJustificationInfos()[getChar2Glyph()[lastChar]];
                jInfo.weight -= gji.weight;
                if (jInfo.grow) {
                    jInfo.growLimit -= gji.growRightLimit;
                    if (gji.growAbsorb) {
View Full Code Here

Examples of com.jgraph.gaeawt.java.awt.font.GlyphJustificationInfo

            float glyphOffset = 0;
            float positionIncrement = 0;
            float sideIncrement = 0;

            if (haveFirst) {  // Don't add padding before first char
                GlyphJustificationInfo gji = getGlyphJustificationInfos()[firstGlyph];
                currInfo = jInfos[gji.growPriority];
                if (currInfo != null) {
                    if (currInfo.useLimits) {
                        if (currInfo.absorb) {
                            glyphOffset += gji.weight * currInfo.absorbedGapPerUnit;
                        } else if (
                                lastInfo != null &&
                                lastInfo.priority == currInfo.priority
                        ) {
                            glyphOffset += gji.weight * lastInfo.absorbedGapPerUnit;
                        }
                        glyphOffset +=
                                firstInfo.grow ?
                                gji.growRightLimit :
                                -gji.shrinkRightLimit;
                    } else {
                        glyphOffset += gji.weight * currInfo.gapPerUnit;
                    }
                }

                firstGlyph++;
            }

            if (firstInfo.grow) {
                for (int i=firstGlyph; i<=lastGlyph; i++) {
                    GlyphJustificationInfo gji = getGlyphJustificationInfos()[i];
                    currInfo = jInfos[gji.growPriority];
                    if (currInfo == null) {
                        // We still have to increment glyph position
                        Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                        glyphPos.setLocation(glyphPos.getX() + glyphOffset, glyphPos.getY());
                        getGlyphVector().setGlyphPosition(i, glyphPos);

                        continue;
                    }

                    if (currInfo.useLimits) {
                        glyphOffset += gji.growLeftLimit;
                        if (currInfo.absorb) {
                            sideIncrement = gji.weight * currInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else if (lastInfo != null && lastInfo.priority == currInfo.priority) {
                            sideIncrement = gji.weight * lastInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else {
                            positionIncrement = glyphOffset;
                        }
                        glyphOffset += gji.growRightLimit;
                    } else {
                        sideIncrement = gji.weight * currInfo.gapPerUnit;
                        glyphOffset += sideIncrement;
                        positionIncrement = glyphOffset;
                        glyphOffset += sideIncrement;
                    }

                    Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                    glyphPos.setLocation(glyphPos.getX() + positionIncrement, glyphPos.getY());
                    getGlyphVector().setGlyphPosition(i, glyphPos);
                }
            } else {
                for (int i=firstGlyph; i<=lastGlyph; i++) {
                    GlyphJustificationInfo gji = getGlyphJustificationInfos()[i];
                    currInfo = jInfos[gji.shrinkPriority];
                    if (currInfo == null) {
                        // We still have to increment glyph position
                        Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                        glyphPos.setLocation(glyphPos.getX() + glyphOffset, glyphPos.getY());
                        getGlyphVector().setGlyphPosition(i, glyphPos);

                        continue;
                    }

                    if (currInfo.useLimits) {
                        glyphOffset -= gji.shrinkLeftLimit;
                        if (currInfo.absorb) {
                            sideIncrement = gji.weight * currInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else if (lastInfo != null && lastInfo.priority == currInfo.priority) {
                            sideIncrement = gji.weight * lastInfo.absorbedGapPerUnit;
                            glyphOffset += sideIncrement;
                            positionIncrement = glyphOffset;
                            glyphOffset += sideIncrement;
                        } else {
                            positionIncrement = glyphOffset;
                        }
                        glyphOffset -= gji.shrinkRightLimit;
                    } else {
                        sideIncrement =  gji.weight * currInfo.gapPerUnit;
                        glyphOffset += sideIncrement;
                        positionIncrement = glyphOffset;
                        glyphOffset += sideIncrement;
                    }

                    Point2D glyphPos = getGlyphVector().getGlyphPosition(i);
                    glyphPos.setLocation(glyphPos.getX() + positionIncrement, glyphPos.getY());
                    getGlyphVector().setGlyphPosition(i, glyphPos);
                }
            }


            if (haveLast) {   // Don't add padding after last char
                lastGlyph++;

                GlyphJustificationInfo gji = getGlyphJustificationInfos()[lastGlyph];
                currInfo = jInfos[gji.growPriority];

                if (currInfo != null) {
                    if (currInfo.useLimits) {
                        glyphOffset += firstInfo.grow ? gji.growLeftLimit : -gji.shrinkLeftLimit;
View Full Code Here

Examples of java.awt.font.GlyphJustificationInfo

    /*
     * Test method for 'java.awt.font.GlyphJustificationInfo.GlyphJustificationInfo(float, boolean, int, float, float, boolean, int, float, float)'
     */
    public final void testGlyphJustificationInfo() {
        GlyphJustificationInfo gji = new GlyphJustificationInfo(weight, growAbsorb,
                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb,
                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
       
        assertEquals("weight", weight, gji.weight, 0F);
        assertEquals("growAbsorb", growAbsorb, gji.growAbsorb);
View Full Code Here

Examples of java.awt.font.GlyphJustificationInfo

     */
    public final void testGlyphJustificationInfo_parametersCheck() {
       
        // negative weight
        try{
            new GlyphJustificationInfo(-1, growAbsorb,
                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb,
                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }
       
        // growPriority illegal level value
        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                5, growLeftLimit, growRightLimit, shrinkAbsorb,
                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }

        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                    -1, growLeftLimit, growRightLimit, shrinkAbsorb,
                    shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }

        // negative growLeftLimit
        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                growPriority, -1, growRightLimit, shrinkAbsorb,
                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }
       
        // negative growRightLimit
        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                growPriority, growLeftLimit, -1, shrinkAbsorb,
                shrinkPriority, shrinkLeftLimit, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }

        // shrinkPriority illegal level value
        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb,
                5, shrinkLeftLimit, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }

        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                    growPriority, growLeftLimit, growRightLimit, shrinkAbsorb,
                    -1, shrinkLeftLimit, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }

        // negative shrinkLeftLimit
        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb,
                shrinkPriority, -1, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
        }
       
        // negative shrinkRightLimit
        try{
            new GlyphJustificationInfo(weight, growAbsorb,
                growPriority, growLeftLimit, growRightLimit, shrinkAbsorb,
                shrinkPriority, -1, shrinkRightLimit);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            // expected
View Full Code Here

Examples of java.awt.font.GlyphJustificationInfo

     * Test method for 'java.awt.font.GraphicAttribute.getJustificationInfo()'
     */
    public final void testGetJustificationInfo() {
        iga = new ImageGraphicAttribute(img, alignment);
        float advance = iga.getAdvance();
        GlyphJustificationInfo gji = new GlyphJustificationInfo(
                advance,
                false,
                GlyphJustificationInfo.PRIORITY_INTERCHAR,
                advance / 3,
                advance / 3,
View Full Code Here

Examples of java.awt.font.GlyphJustificationInfo

     * Test method for 'java.awt.font.GraphicAttribute.getJustificationInfo()'
     */
    public final void testGetJustificationInfo() {
        sga = new ShapeGraphicAttribute(shape, alignment, stroke);
        float advance = sga.getAdvance();
        GlyphJustificationInfo gji = new GlyphJustificationInfo(
                advance,
                false,
                GlyphJustificationInfo.PRIORITY_INTERCHAR,
                advance / 3,
                advance / 3,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.