Search in sources :

Example 1 with HintControl

use of com.cas.sim.tis.app.control.HintControl in project TeachingInSimulation by ScOrPiOzzy.

the class CircuitState method bindWireEvent.

private void bindWireEvent(Geometry wireMdl, final Wire wire) {
    addListener(wireMdl, new MouseEventAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            for (Wire w : wireList) {
                Spatial mdl = w.getSpatial();
                HintControl control = mdl.getControl(HintControl.class);
                boolean enable = w == wire;
                if (control != null) {
                    mdl.removeControl(control);
                } else if (enable) {
                    control = new HintControl();
                    mdl.addControl(control);
                }
            }
            super.mouseClicked(e);
        }

        @Override
        public void mouseRightClicked(MouseEvent e) {
            // 选中显示导线菜单
            IContent content = SpringUtil.getBean(PageController.class).getIContent();
            if (content instanceof TypicalCase3D) {
                Platform.runLater(() -> {
                    ((TypicalCase3D) content).showPopupMenu(wire);
                });
            }
            super.mouseRightClicked(e);
        }
    });
}
Also used : MouseEvent(com.cas.sim.tis.app.event.MouseEvent) Spatial(com.jme3.scene.Spatial) IContent(com.cas.sim.tis.view.control.IContent) MouseEventAdapter(com.cas.sim.tis.app.event.MouseEventAdapter) HintControl(com.cas.sim.tis.app.control.HintControl) Wire(com.cas.circuit.vo.Wire) TypicalCase3D(com.cas.sim.tis.view.control.imp.jme.TypicalCase3D)

Aggregations

Wire (com.cas.circuit.vo.Wire)1 HintControl (com.cas.sim.tis.app.control.HintControl)1 MouseEvent (com.cas.sim.tis.app.event.MouseEvent)1 MouseEventAdapter (com.cas.sim.tis.app.event.MouseEventAdapter)1 IContent (com.cas.sim.tis.view.control.IContent)1 TypicalCase3D (com.cas.sim.tis.view.control.imp.jme.TypicalCase3D)1 Spatial (com.jme3.scene.Spatial)1