Search in sources :

Example 51 with BitmapText

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);
    }
}
Also used : ElecCompDef(com.cas.circuit.vo.ElecCompDef) BitmapText(com.jme3.font.BitmapText) Spatial(com.jme3.scene.Spatial) TagNameControl(com.cas.sim.tis.app.control.TagNameControl) WireNumberControl(com.cas.sim.tis.app.control.WireNumberControl) Wire(com.cas.circuit.vo.Wire)

Example 52 with BitmapText

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);
            // }
            }
        }
    }
}
Also used : Cable(com.cas.circuit.vo.Cable) BitmapText(com.jme3.font.BitmapText) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) Wire(com.cas.circuit.vo.Wire)

Aggregations

BitmapText (com.jme3.font.BitmapText)52 Vector3f (com.jme3.math.Vector3f)10 Geometry (com.jme3.scene.Geometry)9 KeyTrigger (com.jme3.input.controls.KeyTrigger)8 Material (com.jme3.material.Material)8 BitmapFont (com.jme3.font.BitmapFont)7 DirectionalLight (com.jme3.light.DirectionalLight)5 ColorRGBA (com.jme3.math.ColorRGBA)5 Spatial (com.jme3.scene.Spatial)5 Rectangle (com.jme3.font.Rectangle)4 ChaseCamera (com.jme3.input.ChaseCamera)4 Quaternion (com.jme3.math.Quaternion)4 Node (com.jme3.scene.Node)4 Box (com.jme3.scene.shape.Box)4 Quad (com.jme3.scene.shape.Quad)4 ActionListener (com.jme3.input.controls.ActionListener)3 Wire (com.cas.circuit.vo.Wire)2 MotionPath (com.jme3.cinematic.MotionPath)2 MotionPathListener (com.jme3.cinematic.MotionPathListener)2 MotionEvent (com.jme3.cinematic.events.MotionEvent)2