Search in sources :

Example 1 with TextLayout

use of java.awt.font.TextLayout in project jdk8u_jdk by JetBrains.

the class TestLayoutVsICU method show.

private void show(String arg) throws ParserConfigurationException, SAXException, IOException {
    id = "<none>";
    File xmlFile = new File(arg);
    if (!xmlFile.exists()) {
        throw new FileNotFoundException("Can't open input XML file " + arg);
    }
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    if (OPT_VERBOSE) {
        System.out.println("# Parsing " + xmlFile.getAbsolutePath());
    }
    Document doc = db.parse(xmlFile);
    Element e = doc.getDocumentElement();
    if (!XML_LAYOUT_TESTS.equals(e.getNodeName())) {
        throw new IllegalArgumentException("Document " + xmlFile.getAbsolutePath() + " does not have <layout-tests> as its base");
    }
    NodeList testCases = e.getElementsByTagName(XML_TEST_CASE);
    for (int caseNo = 0; caseNo < testCases.getLength(); caseNo++) {
        final Node testCase = testCases.item(caseNo);
        final Map<String, String> testCaseAttrs = attrs(testCase);
        id = testCaseAttrs.get(XML_ID);
        final String script = testCaseAttrs.get(XML_SCRIPT);
        String testText = null;
        Integer[] expectGlyphs = null;
        Integer[] expectIndices = null;
        Map<String, String> fontAttrs = null;
        if (OPT_VERBOSE) {
            System.out.println("#" + caseNo + " id=" + id + ", script=" + script);
        }
        NodeList children = testCase.getChildNodes();
        for (int sub = 0; sub < children.getLength(); sub++) {
            Node n = children.item(sub);
            if (n.getNodeType() != Node.ELEMENT_NODE)
                continue;
            String nn = n.getNodeName();
            if (nn.equals(XML_TEST_FONT)) {
                fontAttrs = attrs(n);
            } else if (nn.equals(XML_TEST_TEXT)) {
                testText = n.getTextContent();
            } else if (nn.equals(XML_RESULT_GLYPHS)) {
                String hex = n.getTextContent();
                expectGlyphs = parseHexArray(hex);
            } else if (nn.equals(XML_RESULT_INDICES)) {
                String hex = n.getTextContent();
                expectIndices = parseHexArray(hex);
            } else if (OPT_VERBOSE) {
                System.out.println("Ignoring node " + nn);
            }
        }
        if (fontAttrs == null) {
            throw new IllegalArgumentException(id + " Missing node " + XML_TEST_FONT);
        }
        if (testText == null) {
            throw new IllegalArgumentException(id + " Missing node " + XML_TEST_TEXT);
        }
        String fontName = fontAttrs.get(XML_NAME);
        Font f = getFont(fontName, fontAttrs);
        if (f == null) {
            if (OPT_FAILMISSING) {
                throw new MissingResourceException("Missing font,  abort test", Font.class.getName(), fontName);
            }
            System.out.println("Skipping " + id + " because font is missing: " + fontName);
            skipped++;
            continue;
        }
        FontRenderContext frc = new FontRenderContext(null, true, true);
        TextLayout tl = new TextLayout(testText, f, frc);
        final List<GlyphVector> glyphs = new ArrayList<GlyphVector>();
        Graphics2D myg2 = new Graphics2D() {

            @Override
            public void draw(Shape s) {
            // TODO Auto-generated method stub
            }

            @Override
            public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawString(String str, int x, int y) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawString(String str, float x, float y) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawString(AttributedCharacterIterator iterator, int x, int y) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawString(AttributedCharacterIterator iterator, float x, float y) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawGlyphVector(GlyphVector g, float x, float y) {
                if (x != 0.0 || y != 0.0) {
                    throw new InternalError("x,y should be 0 but got " + x + "," + y);
                }
                //System.err.println("dGV : " + g.toString() + " @ "+x+","+y);
                glyphs.add(g);
            }

            @Override
            public void fill(Shape s) {
            // TODO Auto-generated method stub
            }

            @Override
            public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public GraphicsConfiguration getDeviceConfiguration() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void setComposite(Composite comp) {
            // TODO Auto-generated method stub
            }

            @Override
            public void setPaint(Paint paint) {
            // TODO Auto-generated method stub
            }

            @Override
            public void setStroke(Stroke s) {
            // TODO Auto-generated method stub
            }

            @Override
            public void setRenderingHint(Key hintKey, Object hintValue) {
            // TODO Auto-generated method stub
            }

            @Override
            public Object getRenderingHint(Key hintKey) {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void setRenderingHints(Map<?, ?> hints) {
            // TODO Auto-generated method stub
            }

            @Override
            public void addRenderingHints(Map<?, ?> hints) {
            // TODO Auto-generated method stub
            }

            @Override
            public RenderingHints getRenderingHints() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void translate(int x, int y) {
            // TODO Auto-generated method stub
            }

            @Override
            public void translate(double tx, double ty) {
            // TODO Auto-generated method stub
            }

            @Override
            public void rotate(double theta) {
            // TODO Auto-generated method stub
            }

            @Override
            public void rotate(double theta, double x, double y) {
            // TODO Auto-generated method stub
            }

            @Override
            public void scale(double sx, double sy) {
            // TODO Auto-generated method stub
            }

            @Override
            public void shear(double shx, double shy) {
            // TODO Auto-generated method stub
            }

            @Override
            public void transform(AffineTransform Tx) {
            // TODO Auto-generated method stub
            }

            @Override
            public void setTransform(AffineTransform Tx) {
            // TODO Auto-generated method stub
            }

            @Override
            public AffineTransform getTransform() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public Paint getPaint() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public Composite getComposite() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void setBackground(Color color) {
            // TODO Auto-generated method stub
            }

            @Override
            public Color getBackground() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public Stroke getStroke() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void clip(Shape s) {
            // TODO Auto-generated method stub
            }

            @Override
            public FontRenderContext getFontRenderContext() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public Graphics create() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public Color getColor() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void setColor(Color c) {
            // TODO Auto-generated method stub
            }

            @Override
            public void setPaintMode() {
            // TODO Auto-generated method stub
            }

            @Override
            public void setXORMode(Color c1) {
            // TODO Auto-generated method stub
            }

            @Override
            public Font getFont() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void setFont(Font font) {
            // TODO Auto-generated method stub
            }

            @Override
            public FontMetrics getFontMetrics(Font f) {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public Rectangle getClipBounds() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void clipRect(int x, int y, int width, int height) {
            // TODO Auto-generated method stub
            }

            @Override
            public void setClip(int x, int y, int width, int height) {
            // TODO Auto-generated method stub
            }

            @Override
            public Shape getClip() {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public void setClip(Shape clip) {
            // TODO Auto-generated method stub
            }

            @Override
            public void copyArea(int x, int y, int width, int height, int dx, int dy) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawLine(int x1, int y1, int x2, int y2) {
            // TODO Auto-generated method stub
            }

            @Override
            public void fillRect(int x, int y, int width, int height) {
            // TODO Auto-generated method stub
            }

            @Override
            public void clearRect(int x, int y, int width, int height) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
            // TODO Auto-generated method stub
            }

            @Override
            public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawOval(int x, int y, int width, int height) {
            // TODO Auto-generated method stub
            }

            @Override
            public void fillOval(int x, int y, int width, int height) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
            // TODO Auto-generated method stub
            }

            @Override
            public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
            // TODO Auto-generated method stub
            }

            @Override
            public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
            // TODO Auto-generated method stub
            }

            @Override
            public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
            // TODO Auto-generated method stub
            }

            @Override
            public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) {
                // TODO Auto-generated method stub
                return false;
            }

            @Override
            public void dispose() {
            // TODO Auto-generated method stub
            }
        };
        tl.draw(myg2, 0, 0);
        if (glyphs.size() != 1) {
            err("drew " + glyphs.size() + " times - expected 1");
            total++;
            bad++;
            continue;
        }
        boolean isBad = false;
        GlyphVector gv = glyphs.get(0);
        // GLYPHS
        int[] gotGlyphs = gv.getGlyphCodes(0, gv.getNumGlyphs(), new int[gv.getNumGlyphs()]);
        // go up to this count
        int count = Math.min(gotGlyphs.length, expectGlyphs.length);
        for (int i = 0; i < count; i++) {
            if (gotGlyphs[i] != expectGlyphs[i]) {
                err("@" + i + " - got \tglyph 0x" + Integer.toHexString(gotGlyphs[i]) + " wanted 0x" + Integer.toHexString(expectGlyphs[i]));
                isBad = true;
                break;
            }
        }
        // INDICES
        int[] gotIndices = gv.getGlyphCharIndices(0, gv.getNumGlyphs(), new int[gv.getNumGlyphs()]);
        for (int i = 0; i < count; i++) {
            if (gotIndices[i] != expectIndices[i]) {
                err("@" + i + " - got \tindex 0x" + Integer.toHexString(gotGlyphs[i]) + " wanted 0x" + Integer.toHexString(expectGlyphs[i]));
                isBad = true;
                break;
            }
        }
        // COUNT
        if (gotGlyphs.length != expectGlyphs.length) {
            System.out.println("Got " + gotGlyphs.length + " wanted " + expectGlyphs.length + " glyphs");
            isBad = true;
        } else {
            if (OPT_VERBOSE) {
                System.out.println(">> OK: " + gotGlyphs.length + " glyphs");
            }
        }
        if (isBad) {
            bad++;
            System.out.println("* FAIL: " + id + "  /\t" + fontName);
        } else {
            System.out.println("* OK  : " + id + "  /\t" + fontName);
        }
        total++;
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Shape(java.awt.Shape) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) MissingResourceException(java.util.MissingResourceException) FileNotFoundException(java.io.FileNotFoundException) ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) Document(org.w3c.dom.Document) RenderableImage(java.awt.image.renderable.RenderableImage) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) RenderedImage(java.awt.image.RenderedImage) Font(java.awt.Font) BufferedImage(java.awt.image.BufferedImage) RenderableImage(java.awt.image.renderable.RenderableImage) BufferedImageOp(java.awt.image.BufferedImageOp) Stroke(java.awt.Stroke) GlyphVector(java.awt.font.GlyphVector) Composite(java.awt.Composite) NodeList(org.w3c.dom.NodeList) ImageObserver(java.awt.image.ImageObserver) Color(java.awt.Color) Paint(java.awt.Paint) Paint(java.awt.Paint) TextLayout(java.awt.font.TextLayout) Graphics2D(java.awt.Graphics2D) AttributedCharacterIterator(java.text.AttributedCharacterIterator) DocumentBuilder(javax.xml.parsers.DocumentBuilder) AffineTransform(java.awt.geom.AffineTransform) FontRenderContext(java.awt.font.FontRenderContext) RenderedImage(java.awt.image.RenderedImage) File(java.io.File) Map(java.util.Map) NamedNodeMap(org.w3c.dom.NamedNodeMap) TreeMap(java.util.TreeMap) Key(java.awt.RenderingHints.Key)

Example 2 with TextLayout

use of java.awt.font.TextLayout in project jdk8u_jdk by JetBrains.

the class TestLineBreakWithFontSub method test.

public void test() {
    // construct a paragraph as follows: MIXED + [SPACING + WORD] + ...
    StringBuffer text = new StringBuffer(MIXED);
    for (int i = 0; i < NUM_WORDS; i++) {
        text.append(SPACING);
        text.append(WORD);
    }
    AttributedString attrString = new AttributedString(text.toString());
    attrString.addAttribute(TextAttribute.SIZE, new Float(24.0));
    LineBreakMeasurer measurer = new LineBreakMeasurer(attrString.getIterator(), DEFAULT_FRC);
    // get width of a space-word sequence, in context
    int sequenceLength = WORD.length() + SPACING.length();
    measurer.setPosition(text.length() - sequenceLength);
    TextLayout layout = measurer.nextLayout(10000.0f);
    if (layout.getCharacterCount() != sequenceLength) {
        throw new Error("layout length is incorrect!");
    }
    final float sequenceAdvance = layout.getVisibleAdvance();
    float wrappingWidth = sequenceAdvance * 2;
    // now run test with a variety of widths
    while (wrappingWidth < (sequenceAdvance * NUM_WORDS)) {
        measurer.setPosition(0);
        checkMeasurer(measurer, wrappingWidth, sequenceAdvance, text.length());
        wrappingWidth += sequenceAdvance / 5;
    }
}
Also used : AttributedString(java.text.AttributedString) LineBreakMeasurer(java.awt.font.LineBreakMeasurer) TextLayout(java.awt.font.TextLayout)

Example 3 with TextLayout

use of java.awt.font.TextLayout in project jdk8u_jdk by JetBrains.

the class MissingCodePointLayoutTest method main.

public static void main(String[] args) {
    Font font = new Font("Tahoma", Font.PLAIN, 12);
    String text = "�";
    FontRenderContext frc = new FontRenderContext(null, false, false);
    TextLayout layout = new TextLayout(text, font, frc);
    layout.getCaretShapes(0);
}
Also used : FontRenderContext(java.awt.font.FontRenderContext) Font(java.awt.Font) TextLayout(java.awt.font.TextLayout)

Example 4 with TextLayout

use of java.awt.font.TextLayout in project adempiere by adempiere.

the class GridElement method setData.

/**
	 * 	Create TextLayout from Data and calculate size.
	 * 	Called from ParameterElement and Location
	 *  @param row row
	 *  @param col column
	 *  @param stringData info element
	 *  @param font font
	 *  @param foreground color for foreground
	 */
public void setData(int row, int col, String stringData, Font font, Paint foreground) {
    if (stringData == null || stringData.length() == 0)
        return;
    //
    //	log.fine("setData - " + row + "/" + col + " - " + stringData);
    AttributedString aString = new AttributedString(stringData);
    aString.addAttribute(TextAttribute.FONT, font);
    aString.addAttribute(TextAttribute.FOREGROUND, foreground);
    AttributedCharacterIterator iter = aString.getIterator();
    TextLayout layout = new TextLayout(iter, m_frc);
    setData(row, col, layout, iter);
}
Also used : AttributedString(java.text.AttributedString) AttributedCharacterIterator(java.text.AttributedCharacterIterator) TextLayout(java.awt.font.TextLayout)

Example 5 with TextLayout

use of java.awt.font.TextLayout in project adempiere by adempiere.

the class StringElement method paint.

//	getDrillAcross
/**************************************************************************
	 * 	Paint/Print.
	 *  Calculate actual Size.
	 *  The text is printed in the topmost left position - i.e. the leading is below the line
	 * 	@param g2D Graphics
	 *  @param pageStart top left Location of page
	 *  @param pageNo page number for multi page support (0 = header/footer) - ignored
	 *  @param ctx print context
	 *  @param isView true if online view (IDs are links)
	 */
public void paint(Graphics2D g2D, int pageNo, Point2D pageStart, Properties ctx, boolean isView) {
    //	log.finest( "StringElement.paint", "<" + m_originalString + "> " + p_pageLocation.x + "/" + p_pageLocation.y
    //		+ ", Clip=" + g2D.getClip()
    //		+ ", Translate=" + g2D.getTransform().getTranslateX() + "/" + g2D.getTransform().getTranslateY()
    //		+ ", Scale=" + g2D.getTransform().getScaleX() + "/" + g2D.getTransform().getScaleY()
    //		+ ", Shear=" + g2D.getTransform().getShearX() + "/" + g2D.getTransform().getShearY());
    Point2D.Double location = getAbsoluteLocation(pageStart);
    //
    if (m_originalString != null)
        translate(ctx);
    AttributedString aString = null;
    AttributedCharacterIterator iter = null;
    AttributedCharacterIterator iter2 = null;
    float xPos = (float) location.x;
    float yPos = (float) location.y;
    float yPen = 0f;
    float height = 0f;
    float width = 0f;
    //	for all lines
    for (int i = 0; i < m_string_paper.length; i++) {
        //	Get Text
        if (isView) {
            if (m_string_view[i] == null)
                continue;
            aString = m_string_view[i];
        } else {
            if (m_string_paper[i] == null)
                continue;
            aString = m_string_paper[i];
        }
        iter = aString.getIterator();
        //	Zero Length
        if (iter.getBeginIndex() == iter.getEndIndex())
            continue;
        //	Check for Tab (just first) and 16 bit characters
        int tabPos = -1;
        boolean is8Bit = true;
        for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
            if (c == '\t' && tabPos == -1)
                tabPos = iter.getIndex();
            if (c > 255)
                is8Bit = false;
        }
        TextLayout layout = null;
        float xPen = xPos;
        //	No Limit
        if (p_maxWidth == 0f) {
            if (tabPos == -1) {
                layout = new TextLayout(iter, g2D.getFontRenderContext());
                yPen = yPos + layout.getAscent();
                //	layout.draw(g2D, xPen, yPen);
                g2D.setFont(m_font);
                g2D.setPaint(m_paint);
                g2D.drawString(iter, xPen, yPen);
                //
                yPos += layout.getAscent() + layout.getDescent() + layout.getLeading();
                if (width < layout.getAdvance())
                    width = layout.getAdvance();
            } else //	we have a tab
            {
                LineBreakMeasurer measurer = new LineBreakMeasurer(iter, g2D.getFontRenderContext());
                layout = measurer.nextLayout(9999, tabPos, false);
                float lineHeight_1 = layout.getAscent() + layout.getDescent() + layout.getLeading();
                yPen = yPos + layout.getAscent();
                //	first part before tab
                layout.draw(g2D, xPen, yPen);
                xPen = getTabPos(xPos, layout.getAdvance());
                float lineWidth = xPen - xPos;
                //, iter.getEndIndex(), true);
                layout = measurer.nextLayout(9999);
                float lineHeight_2 = layout.getAscent() + layout.getDescent() + layout.getLeading();
                //	second part after tab
                layout.draw(g2D, xPen, yPen);
                //
                yPos += Math.max(lineHeight_1, lineHeight_2);
                lineWidth += layout.getAdvance();
                if (width < lineWidth)
                    width = lineWidth;
            }
        //	log.finest( "StringElement.paint - No Limit - " + location.x + "/" + yPos
        //		+ " w=" + layout.getAdvance() + ",h=" + lineHeight + ", Bounds=" + layout.getBounds());
        } else //	Size Limits
        {
            boolean fastDraw = LayoutEngine.s_FASTDRAW;
            if (fastDraw && !isView && !is8Bit)
                fastDraw = false;
            LineBreakMeasurer measurer = new LineBreakMeasurer(iter, g2D.getFontRenderContext());
            while (measurer.getPosition() < iter.getEndIndex()) {
                if (tabPos == -1) {
                    layout = measurer.nextLayout(p_maxWidth);
                    if (measurer.getPosition() < iter.getEndIndex())
                        fastDraw = false;
                } else //	tab
                {
                    fastDraw = false;
                    layout = measurer.nextLayout(p_maxWidth, tabPos, false);
                }
                //	Line Height
                float lineHeight = layout.getAscent() + layout.getDescent() + layout.getLeading();
                if (//	one line only
                p_maxHeight == -1f && i == 0)
                    p_maxHeight = lineHeight;
                //	If we have hight left over
                if (p_maxHeight == 0f || (height + lineHeight) <= p_maxHeight) {
                    yPen = (float) location.y + height + layout.getAscent();
                    //	Tab in Text
                    if (tabPos != -1) {
                        //	first part before tab
                        layout.draw(g2D, xPen, yPen);
                        xPen = getTabPos(xPos, layout.getAdvance());
                        layout = measurer.nextLayout(p_width, iter.getEndIndex(), true);
                        //	reset (just one tab)
                        tabPos = -1;
                    } else if ((MPrintFormatItem.FIELDALIGNMENTTYPE_TrailingRight.equals(p_FieldAlignmentType) && layout.isLeftToRight()) || (MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft.equals(p_FieldAlignmentType) && !layout.isLeftToRight()))
                        xPen += p_maxWidth - layout.getAdvance();
                    else if (MPrintFormatItem.FIELDALIGNMENTTYPE_Center.equals(p_FieldAlignmentType))
                        xPen += (p_maxWidth - layout.getAdvance()) / 2;
                    else if (MPrintFormatItem.FIELDALIGNMENTTYPE_Block.equals(p_FieldAlignmentType) && measurer.getPosition() < iter.getEndIndex()) {
                        layout = layout.getJustifiedLayout(p_maxWidth);
                        fastDraw = false;
                    }
                    if (fastDraw) {
                        g2D.setFont(m_font);
                        g2D.setPaint(m_paint);
                        g2D.drawString(iter, xPen, yPen);
                        height += lineHeight;
                        break;
                    } else {
                        layout.draw(g2D, xPen, yPen);
                    }
                    height += lineHeight;
                //	log.finest( "StringElement.paint - Limit - " + xPen + "/" + yPen
                //		+ " w=" + layout.getAdvance() + ",h=" + lineHeight + ", Align=" + p_FieldAlignmentType + ", Max w=" + p_maxWidth + ",h=" + p_maxHeight + ", Bounds=" + layout.getBounds());
                }
            }
            width = p_maxWidth;
        }
    //	size limits
    }
    //	for all strings
    if (m_check != null) {
        int x = (int) (location.x + width + 1);
        int y = (int) (location.y);
        g2D.drawImage(m_check.booleanValue() ? LayoutEngine.IMAGE_TRUE : LayoutEngine.IMAGE_FALSE, x, y, this);
    }
}
Also used : AttributedString(java.text.AttributedString) Point2D(java.awt.geom.Point2D) LineBreakMeasurer(java.awt.font.LineBreakMeasurer) Point(java.awt.Point) Paint(java.awt.Paint) AttributedCharacterIterator(java.text.AttributedCharacterIterator) TextLayout(java.awt.font.TextLayout)

Aggregations

TextLayout (java.awt.font.TextLayout)166 FontRenderContext (java.awt.font.FontRenderContext)56 Graphics2D (java.awt.Graphics2D)50 AttributedString (java.text.AttributedString)40 Font (java.awt.Font)27 AttributedCharacterIterator (java.text.AttributedCharacterIterator)27 LineBreakMeasurer (java.awt.font.LineBreakMeasurer)25 AffineTransform (java.awt.geom.AffineTransform)22 Rectangle2D (java.awt.geom.Rectangle2D)22 Rectangle (java.awt.Rectangle)15 Color (java.awt.Color)14 Point (java.awt.Point)13 Shape (java.awt.Shape)13 BufferedImage (java.awt.image.BufferedImage)11 Paint (java.awt.Paint)10 Dimension (java.awt.Dimension)7 TextLayoutInfo (automenta.vivisect.gui.StyledString.TextLayoutInfo)6 BasicStroke (java.awt.BasicStroke)6 TextLayoutInfo (g4p_controls.StyledString.TextLayoutInfo)5 FontMetrics (java.awt.FontMetrics)5