本文整理汇总了Java中com.jme3.font.BitmapText.setBox方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapText.setBox方法的具体用法?Java BitmapText.setBox怎么用?Java BitmapText.setBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.font.BitmapText
的用法示例。
在下文中一共展示了BitmapText.setBox方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleInitApp
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
@Override
public void simpleInitApp() {
Quad q = new Quad(6, 3);
Geometry g = new Geometry("quad", q);
g.setLocalTranslation(0, -3, -0.0001f);
g.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
rootNode.attachChild(g);
BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
BitmapText txt = new BitmapText(fnt, false);
txt.setBox(new Rectangle(0, 0, 6, 3));
txt.setQueueBucket(Bucket.Transparent);
txt.setSize( 0.5f );
txt.setText(txtB);
rootNode.attachChild(txt);
}
示例2: simpleInitApp
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
@Override
public void simpleInitApp() {
inputManager.addMapping("WordWrap", new KeyTrigger(KeyInput.KEY_TAB));
inputManager.addListener(keyListener, "WordWrap");
inputManager.addRawInputListener(textListener);
BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
txt = new BitmapText(fnt, false);
txt.setBox(new Rectangle(0, 0, settings.getWidth(), settings.getHeight()));
txt.setSize(fnt.getPreferredSize() * 2f);
txt.setText(txtB);
txt.setLocalTranslation(0, txt.getHeight(), 0);
guiNode.attachChild(txt);
txt2 = new BitmapText(fnt, false);
txt2.setSize(fnt.getPreferredSize() * 1.2f);
txt2.setText("Text without restriction. \nText without restriction. Text without restriction. Text without restriction");
txt2.setLocalTranslation(0, txt2.getHeight(), 0);
guiNode.attachChild(txt2);
txt3 = new BitmapText(fnt, false);
txt3.setBox(new Rectangle(0, 0, settings.getWidth(), 0));
txt3.setText("Press Tab to toggle word-wrap. type text and enter to input text");
txt3.setLocalTranslation(0, settings.getHeight()/2, 0);
guiNode.attachChild(txt3);
}
示例3: getTextWidth
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
/**
* Returns the width of the provided text
* @param ref Element The element the text will be added to (reference for font settings)
* @param text String the text to be evaluated
* @return float The width
*/
public static float getTextWidth(Element ref, String text) {
BitmapText eval = new BitmapText(ref.getFont());
eval.setSize(ref.getFontSize());
eval.setLineWrapMode(LineWrapMode.NoWrap);
eval.setBox(null);
eval.setText(text);
return eval.getLineWidth();
}
示例4: getTextLineHeight
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
/**
* Returns the height value of a single line of text
* @param ref Element The element the text will be added to (reference for font settings)
* @param text String the text to be evaluated
* @return float
*/
public static float getTextLineHeight(Element ref, String text) {
BitmapText eval = new BitmapText(ref.getFont());
eval.setSize(ref.getFontSize());
eval.setLineWrapMode(LineWrapMode.NoWrap);
eval.setBox(null);
eval.setText(text);
return eval.getLineHeight();
}
示例5: getTextTotalHeight
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
/**
* Returns the total height of a wrapped text string
* @param ref Element The element the text will be added to (reference for font settings)
* @param text String the text to be evaluated
* @param maxWidth The maximum width considered a valid return value
* @return float
*/
public static float getTextTotalHeight(Element ref, String text, float maxWidth) {
BitmapText eval = new BitmapText(ref.getFont());
eval.setSize(ref.getFontSize());
eval.setText("Xg");
eval.setBox(new Rectangle(0,0,maxWidth, eval.getLineHeight()));
eval.setText(text);
return eval.getLineWidth()*eval.getLineCount();
}
示例6: createBillboard
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
public void createBillboard(AssetManager manager) {
// Set position above model
// Load font and create the Text
BitmapFont font = manager.loadFont("Interface/Fonts/Default.fnt");
BitmapText bmText = new BitmapText(font);
bmText.setSize(0.25f);
bmText.setText(actorName);
bmText.setQueueBucket(Bucket.Transparent);
bmText.setColor(ColorRGBA.Orange);
bmText.setBox(new Rectangle(-bmText.getLineWidth() / 2.0f - 0.2f, 0, bmText.getLineWidth() * 2.0f, bmText.getLineHeight() + 0.1f));
bmText.setAlignment(BitmapFont.Align.Left);
bmText.setLineWrapMode(LineWrapMode.NoWrap);
Vector3f newPos = new Vector3f(0, 2.5f, 0);
// Create node and add a BillboardControl so it rotates with the cam
BillboardControl bbControl = new BillboardControl();
bbControl.setAlignment(BillboardControl.Alignment.Screen);
Node textNode = new Node("Node for text");
textNode.setLocalTranslation(newPos);
textNode.setCullHint(CullHint.Never);
textNode.attachChild(bmText);
bmText.addControl(bbControl);
//Vector3f world = textNode.getWorldTranslation();
this.attachChild(textNode);
//System.out.println("Text node location for " + actorName + "," +world);
}
示例7: createPlayerName
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
private void createPlayerName(String name, int teamId) {
BitmapText text = new BitmapText(guiFont);
text.setSize(guiFont.getCharSet().getRenderedSize() * 0.8f);
text.setBox(new Rectangle(0, 0, 80, 10));
text.setText(name);
text.setColor(TEAM_COLORS[teamId].clone());
text.setAlignment(BitmapFont.Align.Center);
text.center();
guiNode.attachChild(text);
text.setQueueBucket(RenderQueue.Bucket.Gui);
playerNames.add(text);
}
示例8: initNarratorText
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
private void initNarratorText()
{
BitmapFont narratorTextFont = assetManager.loadFont("Interface/ArialRoundedMTBold.fnt");
narratorText = new BitmapText(narratorTextFont);
narratorText.setSize(narratorTextFont.getCharSet().getRenderedSize());
narratorText.setLineWrapMode(LineWrapMode.Word);
narratorText.setBox(new Rectangle(325,0, 1280 - 325*2, 200));
narratorText.setAlignment(BitmapFont.Align.Center);
narratorText.move(0, 200, 1);
narratorText.setColor(ColorRGBA.White);
createTextBackgound(1280 - 325*2, 150);
guiNode.attachChild(narratorText);
}
示例9: initNarratorText
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
private void initNarratorText()
{
BitmapFont narratorTextFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
narratorText = new BitmapText(narratorTextFont);
narratorText.setSize(narratorTextFont.getCharSet().getRenderedSize());
narratorText.setLineWrapMode(LineWrapMode.Word);
narratorText.setBox(new Rectangle(325,0, 1280 - 325*2, 200));
narratorText.setAlignment(BitmapFont.Align.Center);
narratorText.move(0, 200, 1);
narratorText.setColor(ColorRGBA.White);
guiNode.attachChild(narratorText);
}
示例10: getVisibleText
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
@Override
protected String getVisibleText() {
getTextFieldText();
maskedText = "";
for (int i = 0; i < finalText.length(); i++) {
maskedText += String.valueOf(mask);
}
widthTest = new BitmapText(calcFont(), false);
widthTest.setBox(null);
widthTest.setSize(getFontSize());
int index1 = 0, index2;
widthTest.setText(maskedText.substring(index1));
while (widthTest.getLineWidth() > getWidth()) {
if (index1 == caretIndex)
break;
index1++;
widthTest.setText(maskedText.substring(index1));
}
index2 = maskedText.length() - 1;
if (index2 == caretIndex && caretIndex != textModel.size()) {
index2 = caretIndex + 1;
widthTest.setText(maskedText.substring(index1, index2));
while (widthTest.getLineWidth() < getWidth()) {
if (index2 == textModel.size())
break;
index2++;
widthTest.setText(maskedText.substring(index1, index2));
}
}
if (index2 != textModel.size())
index2++;
if (head != index1 || tail != index2) {
head = index1;
tail = index2;
}
if (head != tail && head != -1 && tail != -1) {
visibleText = maskedText.substring(head, tail);
} else {
visibleText = "";
}
widthTest.setText(maskedText.substring(head, caretIndex));
caretX = widthTest.getLineWidth();
setCaretPosition(caretX);
return visibleText;
}
示例11: getVisibleText
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
@Override
protected String getVisibleText() {
getTextFieldText();
maskedText = "";
for (int i = 0; i < finalText.length(); i++) {
maskedText += String.valueOf(mask);
}
widthTest = new BitmapText(font, false);
widthTest.setBox(null);
widthTest.setSize(getFontSize());
int index1 = 0, index2;
widthTest.setText(maskedText.substring(index1));
while(widthTest.getLineWidth() > getWidth()) {
if (index1 == caretIndex)
break;
index1++;
widthTest.setText(maskedText.substring(index1));
}
index2 = maskedText.length()-1;
if (index2 == caretIndex && caretIndex != textFieldText.size()) {
index2 = caretIndex+1;
widthTest.setText(maskedText.substring(index1, index2));
while(widthTest.getLineWidth() < getWidth()) {
if (index2 == textFieldText.size())
break;
index2++;
widthTest.setText(maskedText.substring(index1, index2));
}
}
if (index2 != textFieldText.size())
index2++;
if (head != index1 || tail != index2) {
head = index1;
tail = index2;
}
if (head != tail && head != -1 && tail != -1) {
visibleText = maskedText.substring(head, tail);
} else {
visibleText = "";
}
widthTest.setText(maskedText.substring(head, caretIndex));
caretX = widthTest.getLineWidth();
setCaretPosition(getAbsoluteX()+caretX);
return visibleText;
}
示例12: getTextWidth
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
/**
* Returns the width of the provided text
*
* @param ref
* Element The element the text will be added to (reference for
* font settings)
* @param text
* String the text to be evaluated
* @return float The width
*/
public static float getTextWidth(BaseElement ref, String text) {
BitmapText eval = new BitmapText(BaseElement.calcFont(ref));
eval.setSize(BaseElement.calcFontSize(ref));
eval.setLineWrapMode(LineWrapMode.NoWrap);
eval.setBox(null);
eval.setText(text);
return eval.getLineWidth();
}
示例13: getTextLineHeight
import com.jme3.font.BitmapText; //导入方法依赖的package包/类
/**
* Returns the height value of a single line of text
*
* @param ref
* Element The element the text will be added to (reference for
* font settings)
* @param text
* String the text to be evaluated
* @return float
*/
public static float getTextLineHeight(BaseElement ref, String text) {
BitmapText eval = new BitmapText(BaseElement.calcFont(ref));
eval.setSize(BaseElement.calcFontSize(ref));
eval.setLineWrapMode(LineWrapMode.NoWrap);
eval.setBox(null);
eval.setText(text);
return eval.getLineHeight();
}