Package playn.core

Examples of playn.core.TextLayout


        return this;
    }

    /** Adds a static label that spans the width of the HUD. */
    public void add (String label, final boolean header) {
        final TextLayout layout = graphics().layoutText(label, _fmt);
        _rows.add(new Row() {
            public void update () {} // noop
            public float labelWidth () { return 0; }
            public float width () { return layout.width(); }
            public float height() { return layout.height(); }
            public void render (Canvas canvas, float x, float y, float valueX) {
                if (header) canvas.drawLine(0, y-1, canvas.width(), y-1);
                canvas.fillText(layout, x, y);
                float by = y + layout.height();
                if (header) canvas.drawLine(0, by, canvas.width(), by);
            }
        });
    }
View Full Code Here


        });
    }

    /** Adds a static label and changing value, which will be rendered in two columns. */
    public void add (String label, final Value<?> value) {
        final TextLayout llayout = graphics().layoutText(label, _fmt);
        _rows.add(new Row() {
            public void update () {
                _vlayout = graphics().layoutText(String.valueOf(value.get()), _fmt);
            }
            public float labelWidth () { return llayout.width(); }
            public float width () { return llayout.width() + GAP + _vlayout.width(); }
            public float height() { return Math.max(llayout.height(), _vlayout.height()); }
            public void render (Canvas canvas, float x, float y, float valueX) {
                canvas.fillText(llayout, x, y);
                canvas.fillText(_vlayout, valueX, y);
            }
            protected TextLayout _vlayout;
View Full Code Here

   */
  private static ImageLayer generateLogMessageImageLayer(String message) {
      TextFormat logFormat_ = (logCount % 2 == 0) ? logFormat : logOddFormat;
     
      ImageLayer imageLayer = graphics().createImageLayer();
        TextLayout layout = graphics().layoutText(message, logFormat_);
        CanvasImage logImage = graphics().createImage(graphics().width(), logFontSize + 4);
        logImage.canvas().drawText(layout, 0, 0);
        imageLayer.setImage(logImage);
        return imageLayer;
    }
View Full Code Here

TOP

Related Classes of playn.core.TextLayout

Copyright © 2018 www.massapicom. 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.