Example usage for com.badlogic.gdx.graphics.g2d BitmapFontCache BitmapFontCache

List of usage examples for com.badlogic.gdx.graphics.g2d BitmapFontCache BitmapFontCache

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d BitmapFontCache BitmapFontCache.

Prototype

public BitmapFontCache(BitmapFont font) 

Source Link

Usage

From source file:CB_Locator.Map.MapScale.java

License:Open Source License

public MapScale(CB_RectF rec, String Name, MapViewBase mapInstanz, boolean useImperialUnits) {
    super(rec, Name);
    imperialunits = useImperialUnits;//  w w  w.  jav a2 s.c  o m
    sollwidth = rec.getWidth();
    this.mapInstanz = mapInstanz;
    CachedScaleDrawable = null;
    fontCache = new BitmapFontCache(Fonts.getNormal());
    fontCache.setColor(COLOR.getFontColor());
    fontCache.setText("", 0, 0);
    invalidateTextureEventList.Add(this);
}

From source file:CB_Locator.Map.MapScale.java

License:Open Source License

public void ZoomChanged() {
    pixelsPerMeter = mapInstanz.pixelsPerMeter;
    drawableWidth = (int) (scaleLength * pixelsPerMeter);
    if (fontCache == null) {
        fontCache = new BitmapFontCache(Fonts.getNormal());
        fontCache.setColor(COLOR.getFontColor());
        fontCache.setText("", 0, 0);
    }//from   ww  w. j a  v a 2 s  . c o  m

    try {
        GlyphLayout bounds = fontCache.setText(distanceString, 0,
                fontCache.getFont().isFlipped() ? 0 : fontCache.getFont().getCapHeight());
        this.setWidth((float) (drawableWidth + (bounds.width * 1.3)));
        CachedScaleDrawable = Sprites.MapScale[scaleUnits - 3];
        float margin = (this.getHeight() - bounds.height) / 1.6f;
        fontCache.setPosition(this.getWidth() - bounds.width - margin, margin);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:CB_UI.GL_UI.Views.CacheListView.java

License:Open Source License

@Override
public void render(Batch batch) {
    // if Track List empty, draw empty Msg
    try {/*from w  ww  .j  a  v a2  s  .c  o  m*/
        if (lvAdapter == null || lvAdapter.getCount() == 0) {
            if (emptyMsg == null) {
                emptyMsg = new BitmapFontCache(Fonts.getBig());
                GlyphLayout bounds = emptyMsg.setText(Translation.Get("EmptyCacheList"), 0f, 0f,
                        this.getWidth(), Align.left, true);
                emptyMsg.setPosition(this.getHalfWidth() - (bounds.width / 2),
                        this.getHalfHeight() - (bounds.height / 2));
            }
            if (emptyMsg != null)
                emptyMsg.draw(batch, 0.5f);
        } else {
            super.render(batch);
        }
    } catch (Exception e) {
        if (emptyMsg == null) {
            emptyMsg = new BitmapFontCache(Fonts.getBig());
            GlyphLayout bounds = emptyMsg.setText(Translation.Get("EmptyCacheList"), 0f, 0f, this.getWidth(),
                    Align.left, true);
            emptyMsg.setPosition(this.getHalfWidth() - (bounds.width / 2),
                    this.getHalfHeight() - (bounds.height / 2));
        }
        if (emptyMsg != null)
            emptyMsg.draw(batch, 0.5f);
    }
}

From source file:CB_UI_Base.GL_UI.Controls.List.ListViewBase.java

License:Open Source License

@Override
protected void render(Batch batch) {

    if (!isInitial) {
        isInitial = true;/*from w w  w. j  a  va 2  s.co  m*/
        Initial();
        // return; why? after initializing it should be possible to render
    }

    if (this.childs.size() == 0 && (this.mBaseAdapter == null || this.mBaseAdapter.getCount() == 0)) {
        try {
            if (emptyMsg == null && mEmptyMsg != null) {
                emptyMsg = new BitmapFontCache(Fonts.getBig());
                GlyphLayout bounds = emptyMsg.setText(mEmptyMsg, 0f, 0f, this.getWidth(), Align.left, true);
                emptyMsg.setPosition(this.getHalfWidth() - (bounds.width / 2),
                        this.getHalfHeight() - (bounds.height / 2));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (emptyMsg != null)
            emptyMsg.draw(batch, 0.5f);
    } else {
        try {
            super.render(batch);
            if (mMustSetPos) {
                RenderThreadSetPos(mMustSetPosValue, mMustSetPosKinetic);
            } else {
                // Run WorkPool
                isWorkOnRunOnGL.set(true);
                synchronized (runOnGL_List) {
                    if (runOnGL_List.size() > 0) {
                        for (int i = 0, n = runOnGL_List.size(); i < n; i++) {
                            IRunOnGL run = runOnGL_List.get(i);
                            if (run != null)
                                run.run();
                        }

                        runOnGL_List.clear();
                    }
                }
                isWorkOnRunOnGL.set(false);
                // work RunOnGlPool
                synchronized (runOnGL_ListWaitpool) {
                    if (runOnGL_ListWaitpool != null && runOnGL_ListWaitpool.size() > 0) {
                        if (runOnGL_ListWaitpool.size() > 0) {
                            for (int i = 0, n = runOnGL_ListWaitpool.size(); i < n; i++) {
                                IRunOnGL run = runOnGL_ListWaitpool.get(i);
                                if (run != null)
                                    run.run();
                            }

                            runOnGL_ListWaitpool.clear();
                        }

                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

From source file:CB_UI_Base.GL_UI.Fonts.java

License:Open Source License

public static GlyphLayout Measure(String txt) {
    if (txt == null || txt.equals(""))
        txt = "text";
    if (measureNormalCache == null)
        measureNormalCache = new BitmapFontCache(Fonts.getNormal());
    GlyphLayout bounds = measureNormalCache.setText(txt, 0, 0);
    bounds.height = bounds.height - measureNormalCache.getFont().getDescent();
    return bounds;
}

From source file:CB_UI_Base.GL_UI.Fonts.java

License:Open Source License

public static GlyphLayout MeasureSmall(String txt) {

    if (txt == null || txt.equals(""))
        txt = "text";

    if (measureSmallCache == null)
        measureSmallCache = new BitmapFontCache(Fonts.getSmall());
    GlyphLayout bounds = measureSmallCache.setText(txt, 0, 0);
    bounds.height = bounds.height - measureSmallCache.getFont().getDescent();
    return bounds;
}

From source file:CB_UI_Base.GL_UI.Fonts.java

License:Open Source License

public static GlyphLayout MeasureBig(String txt) {
    if (txt == null || txt.equals(""))
        txt = "text";
    if (measureBigCache == null)
        measureBigCache = new BitmapFontCache(Fonts.getBig());
    GlyphLayout bounds = measureBigCache.setText(txt, 0, 0);
    bounds.height = bounds.height - measureBigCache.getFont().getDescent();
    return bounds;
}

From source file:CB_UI_Base.GL_UI.Fonts.java

License:Open Source License

public static GlyphLayout MeasureWrapped(String txt, float width) {
    if (txt == null || txt.equals(""))
        txt = "text";
    if (measureNormalCache == null)
        measureNormalCache = new BitmapFontCache(Fonts.getNormal());
    GlyphLayout bounds = measureNormalCache.setText(txt, 0, 0, width, 0, true);//measureNormalCache.setWrappedText(txt, 0, 0, width);
    bounds.height = bounds.height - measureNormalCache.getFont().getDescent();
    return bounds;
}

From source file:com.aia.hichef.ui.n.MyWindow.java

License:Apache License

public void setStyle(WindowStyle style) {
    if (style == null)
        throw new IllegalArgumentException("style cannot be null.");
    this.style = style;
    setBackground(style.background);/*  w  w  w .  ja v  a  2s  .  c om*/
    titleCache = new BitmapFontCache(style.titleFont);
    titleCache.setColor(style.titleFontColor);
    if (title != null)
        setTitle(title);
    invalidateHierarchy();
}

From source file:com.digitale.connex.Actor.java

License:Open Source License

public Actor(BigInteger uid, String race, int x, int y, int z, boolean is_static, String firstname,
        String surname, Vector3 position, int hitpoints, String shipname, float velocity) {
    set_uid(uid);//from ww  w .j  av  a2 s.  c o m
    set_race(race);
    set_x(x);
    set_y(y);
    set_z(z);
    set_position(position);
    set_is_static(is_static);
    set_firstname(firstname);
    set_surname(surname);
    setHitpoints(hitpoints);
    setSysx(sysx);
    setSysy(sysy);
    setSysz(sysz);
    setShipname(shipname);
    setVelocity(velocity);
    reticulepos = new Vector3(0, 0, 0);
    distanceString = "";
    cache = new BitmapFontCache(Renderer.fontsmall);
}