List of usage examples for com.badlogic.gdx.graphics.g2d GlyphLayout GlyphLayout
public GlyphLayout()
From source file:CB_UI.GL_UI.Views.AboutView.java
License:Open Source License
private void createControls() { this.removeChilds(); if (this.isDisposed()) return;/*from www . ja va 2s .c o m*/ this.setBackground(Sprites.AboutBack); float ref = UI_Size_Base.that.getWindowHeight() / 13; margin = UI_Size_Base.that.getMargin(); CB_RectF CB_LogoRec = new CB_RectF(this.getHalfWidth() - (ref * 2.5f), this.getHeight() - ((ref * 5) / 4.11f) - ref - margin - margin, ref * 5, (ref * 5) / 4.11f); //Log.debug(log, "CB_Logo" + CB_LogoRec.toString()); CB_Logo = new Image(CB_LogoRec, "CB_Logo", false); CB_Logo.setDrawable(new SpriteDrawable(Sprites.getSpriteDrawable("cachebox-logo"))); this.addChild(CB_Logo); String VersionString = GlobalCore.getVersionString() + GlobalCore.br + GlobalCore.br + GlobalCore.aboutMsg; GlyphLayout layout = new GlyphLayout(); layout.setText(Fonts.getSmall(), VersionString); descTextView = new Label(this.name + " descTextView", 0, CB_Logo.getY() - margin - margin - margin - layout.height, this.getWidth(), layout.height + margin); descTextView.setFont(Fonts.getSmall()).setHAlignment(HAlignment.CENTER); descTextView.setWrappedText(VersionString); this.addChild(descTextView); CachesFoundLabel = new Label("", Fonts.getNormal(), COLOR.getLinkFontColor(), WrapType.SINGLELINE) .setHAlignment(HAlignment.CENTER); CachesFoundLabel.setWidth(getWidth()); CachesFoundLabel.setOnClickListener(new OnClickListener() { GL_MsgBox ms; @Override public boolean onClick(GL_View_Base v, int x, int y, int pointer, int button) { ms = GL_MsgBox.Show(Translation.Get("LoadFounds"), Translation.Get("AdjustFinds"), MessageBoxButtons.YesNo, MessageBoxIcon.GC_Live, new OnMsgBoxClickListener() { @Override public boolean onClick(int which, Object data) { // Behandle das ergebniss switch (which) { case 1: ms.close(); pd = CancelWaitDialog.ShowWait(Translation.Get("LoadFounds"), DownloadAnimation.GetINSTANCE(), new IcancelListener() { @Override public void isCanceld() { } }, new cancelRunnable() { @Override public void run() { result = GroundspeakAPI.GetCachesFound(this); pd.close(); if (result > -1) { String Text = Translation.Get("FoundsSetTo", String.valueOf(result)); GL_MsgBox.Show(Text, Translation.Get("LoadFinds!"), MessageBoxButtons.OK, MessageBoxIcon.GC_Live, null); Config.FoundOffset.setValue(result); Config.AcceptChanges(); AboutView.this.refreshText(); } if (result == GroundspeakAPI.CONNECTION_TIMEOUT) { GL.that.Toast(ConnectionError.INSTANCE); } if (result == GroundspeakAPI.API_IS_UNAVAILABLE) { GL.that.Toast(ApiUnavailable.INSTANCE); } } @Override public boolean cancel() { // TODO handle cancel return false; } }); break; case 3: ms.close(); GL.that.RunOnGL(new IRunOnGL() { @Override public void run() { NumericInputBox.Show(Translation.Get("TelMeFounds"), Translation.Get("AdjustFinds"), Config.FoundOffset.getValue(), mDialogListener); } }); break; } return true; } }); return true; } }); this.addChild(CachesFoundLabel); createTable(); refreshText(); }
From source file:CB_UI_Base.GL_UI.Controls.html.HtmlView.java
License:Open Source License
private static float addTextBlog(CB_List<CB_View_Base> segmentViewList, Html_Segment_TextBlock seg, float innerWidth) { boolean markUp = !seg.hyperLinkList.isEmpty(); BitmapFont font = FontCache.get(markUp, seg.getFontFamily(), seg.getFontStyle(), seg.getFontSize()); GlyphLayout layout = new GlyphLayout(); // dont do this every frame! // Store it as member layout.setText(font, seg.formatedText, getColor(Color.BLACK), innerWidth - (margin * 2), Align.left, true); float segHeight = layout.height + (margin * 2); parseHyperLinks(seg, "http://"); parseHyperLinks(seg, "www."); LinkLabel lbl = new LinkLabel("HtmlView" + " lbl", 0, 0, innerWidth - (margin * 2), segHeight); if (markUp) { lbl.setMarkupEnabled(true);//w w w . j a va 2 s.c o m } lbl.setTextColor(getColor(seg.getFontColor())); lbl.setFont(font).setHAlignment(seg.hAlignment); if (markUp) { lbl.addHyperlinks(seg.hyperLinkList); } lbl.setWrappedText(seg.formatedText); lbl.setUnderline(seg.underline); lbl.setStrikeout(seg.strikeOut); segmentViewList.add(lbl); return lbl.getHeight(); }
From source file:CB_UI_Base.graphics.GL_Paint.java
License:Open Source License
@Override public int getTextHeight(String text) { if (font == null) return 0; if (layout == null) layout = new GlyphLayout(); layout.setText(font, text);/*from w w w. j a v a2 s . c om*/ return (int) layout.height; }
From source file:CB_UI_Base.graphics.GL_Paint.java
License:Open Source License
@Override public int getTextWidth(String text) { if (font == null) return 0; if (layout == null) layout = new GlyphLayout(); layout.setText(font, text);/* w w w.java 2 s.c om*/ return (int) layout.width; }
From source file:CB_UI_Base.Math.GL_UISizes.java
License:Open Source License
/** * Berechnet die Positionen der UI-Elemente *//*www . j a va 2 s . com*/ private static void calcPos() { Log.debug(log, "GL_UISizes.calcPos()"); float w = Global.isTab ? UI_Right.getWidth() : UI_Left.getWidth(); float h = Global.isTab ? UI_Right.getHeight() : UI_Left.getHeight(); Info.setPos(new Vector2(margin, (h - margin - Info.getHeight()))); Float CompassMargin = (Info.getHeight() - Compass.getWidth()) / 2; Compass.setPos(new Vector2(Info.getX() + CompassMargin, Info.getY() + infoShadowHeight + CompassMargin)); Toggle.setPos(new Vector2((w - margin - Toggle.getWidth()), h - margin - Toggle.getHeight())); ZoomBtn.setPos(new Vector2((w - margin - ZoomBtn.getWidth()), margin)); InfoLine1.x = Compass.getMaxX() + margin; GlyphLayout bounds; if (Fonts.getNormal() != null) { bounds = new GlyphLayout(); bounds.setText(Fonts.getSmall(), "52 34,806N "); } else { bounds = new GlyphLayout(); bounds.height = 20; bounds.width = 100; } InfoLine2.x = Info.getX() + Info.getWidth() - bounds.width - (margin * 2); Float T1 = Info.getHeight() / 4; InfoLine1.y = Info.getMaxY() - T1; InfoLine2.y = Info.getY() + T1 + bounds.height; // Aufrumen CompassMargin = null; }
From source file:com.bladecoder.engineeditor.ui.components.CustomList.java
License:Apache License
public void layout() { final BitmapFont font = style.font; final BitmapFont subfont = style.subtitleFont; final Drawable selectedDrawable = style.selection; cellRenderer.layout(style);//from w w w .j av a 2s. c om GlyphLayout textLayout = new GlyphLayout(); prefWidth = 0; for (int i = 0; i < items.size; i++) { textLayout.setText(font, cellRenderer.getCellTitle(items.get(i))); prefWidth = Math.max(textLayout.width, prefWidth); if (cellRenderer.hasImage()) { TextureRegion r = cellRenderer.getCellImage(items.get(i)); float ih = r.getRegionHeight(); float iw = r.getRegionWidth(); if (ih > getItemHeight() - 10) { ih = getItemHeight() - 10; iw *= ih / r.getRegionHeight(); } prefWidth = Math.max(iw + textLayout.width, prefWidth); } if (cellRenderer.hasSubtitle()) { String subtitle = cellRenderer.getCellSubTitle(items.get(i)); if (subtitle != null) { textLayout.setText(subfont, subtitle); prefWidth = Math.max(textLayout.width, prefWidth); } } } prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth(); prefHeight = items.size * cellRenderer.getItemHeight(); Drawable background = style.background; if (background != null) { prefWidth += background.getLeftWidth() + background.getRightWidth(); prefHeight += background.getTopHeight() + background.getBottomHeight(); } }
From source file:com.bladecoder.engineeditor.utils.Message.java
License:Apache License
private static void add(Stage stage, String text) { msg.clearActions();// w w w. j a v a2 s. co m msg.setText(text); GlyphLayout textLayout = new GlyphLayout(); textLayout.setText(msg.getStyle().font, text, Color.BLACK, stage.getWidth() * .8f, Align.center, true); msg.setSize(textLayout.width + textLayout.height, textLayout.height + textLayout.height * 2); if (!stage.getActors().contains(msg, true)) stage.addActor(msg); msg.setPosition(Math.round((stage.getWidth() - msg.getWidth()) / 2), Math.round((stage.getHeight() - msg.getHeight()) / 2)); msg.invalidate(); }
From source file:com.github.badoualy.badoualyve.ui.actor.Dialog.java
License:Open Source License
public Dialog() { font = gdxUtils().getDefaultFont();//from w ww. j a v a 2 s . c om bg = gdxUtils().createImageFromTexture(AssetsUtils.BG_DIALOG); setSize(bg.getWidth(), bg.getHeight()); addActor(bg); // Compute title width GlyphLayout layout = new GlyphLayout(); // Don't do this every frame! Store it as member layout.setText(font, inputValue); inputWidth = layout.width; // Compute message width layout = new GlyphLayout(); // Don't do this every frame! Store it as member layout.setText(font, message); messageWith = layout.width; }
From source file:com.github.badoualy.badoualyve.ui.actor.Dialog.java
License:Open Source License
public void setTitle(String title) { this.title = title; // Compute new title width GlyphLayout layout = new GlyphLayout(); // Don't do this every frame! Store it as member layout.setText(font, title);// w w w .ja va 2 s. co m titleWidth = layout.width; }
From source file:com.github.badoualy.badoualyve.ui.actor.Dialog.java
License:Open Source License
public void setInputValue(String inputValue) { this.inputValue = inputValue; // Compute new input width GlyphLayout layout = new GlyphLayout(); // Don't do this every frame! Store it as member layout.setText(font, inputValue);/*www .ja v a2 s .c o m*/ inputWidth = layout.width; }