use of com.jme3.font.BitmapText in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method toggleTagName.
private void toggleTagName() {
for (ElecCompDef elecCompDef : compList) {
Spatial elecCompMdl = elecCompDef.getSpatial();
TagNameControl control = elecCompMdl.getControl(TagNameControl.class);
if (control == null) {
BitmapText tag = new BitmapText(tagFont);
tag.setName(elecCompDef.getProxy().getUuid());
guiNode.attachChild(tag);
control = new TagNameControl(cam, tag);
elecCompMdl.addControl(control);
}
control.setTagName(elecCompDef.getProxy().getTagName());
control.setEnabled(tagVisible);
}
for (Wire wire : wireList) {
Spatial wireMdl = wire.getSpatial();
WireNumberControl control = wireMdl.getControl(WireNumberControl.class);
if (control == null) {
BitmapText tag = new BitmapText(tagFont);
tag.setLocalScale(0.75f);
tag.setName(String.format("%s-%s", wire.getProxy().getComp1Uuid(), wire.getProxy().getComp2Uuid()));
control = new WireNumberControl(cam, guiNode, tag, wire.getProxy().getPointList());
wireMdl.addControl(control);
}
control.setNumber(wire.getProxy().getNumber());
control.setEnabled(tagVisible);
}
}
use of com.jme3.font.BitmapText in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionHandler method modifyWireNum.
private void modifyWireNum(ILinker linker, String wireNum) {
if (Util.isEmpty(wireNum)) {
return;
}
if (linker instanceof Cable && ((Cable) linker).getBindWires().size() != 0) {
List<Wire> bindWires = ((Cable) linker).getBindWires();
linker = bindWires.get(bindWires.size() - 1);
}
for (Spatial model : linker.getModels().keySet()) {
Spatial parent = ((Node) model).getChild("Label");
if (parent == null) {
continue;
}
for (Spatial bitmapText : ((Node) parent).getChildren()) {
if (bitmapText instanceof BitmapText) {
((BitmapText) bitmapText).setText(wireNum.toUpperCase());
// // 有的号码三个英文字母 塞不下 所以过大的 做一下压缩
// float lineWidth = ((BitmapText) bitmapText).getLineWidth();
// if (lineWidth > 80) {
// bitmapText.scale(80f / lineWidth, 1, 1);
// } else {
bitmapText.setLocalScale(bitmapText.getLocalScale().y);
// }
}
}
}
}
Aggregations