use of com.cas.sim.tis.view.control.IContent in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method bindElecCompEvent.
private void bindElecCompEvent(ElecCompDef def) {
// 1、连接头监听事件
def.getTerminalList().forEach(t -> addListener(t.getSpatial(), new MouseEventAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (state == null || state == State.Ending) {
connectPre(def, t);
// 设置接线状态为开始
state = State.Starting;
} else if (state == State.Mid) {
//
connectEnding(def, t);
state = State.Ending;
} else if (state == State.Ending) {
// do nothing
}
}
}));
// 2、插孔监听事件
def.getJackList().forEach(j -> addListener(j.getSpatial(), new MouseEventAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(j.getName());
}
}));
// 3、按钮监听事件
def.getMagnetismList().forEach(m -> {
for (ControlIO c : m.getControlIOList()) {
if (c.getType().indexOf(CfgConst.SWITCH_CTRL_INPUT) == -1) {
continue;
}
if (ControlIO.INTERACT_ROTATE.equals(c.getInteract())) {
addListener(c.getSpatial(), new MouseEventAdapter() {
@Override
public void mouseWheel(MouseEvent e) {
c.switchStateChanged(e.getWheel());
c.playMotion();
}
});
} else if (ControlIO.INTERACT_PRESS.equals(c.getInteract())) {
addListener(c.getSpatial(), new MouseEventAdapter() {
@Override
public void mousePressed(MouseEvent e) {
c.switchStateChanged(null);
c.playMotion();
}
@Override
public void mouseReleased(MouseEvent e) {
c.switchStateChanged(null);
c.playMotion();
}
});
} else {
addListener(c.getSpatial(), new MouseEventAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
c.switchStateChanged(null);
c.playMotion();
}
});
}
}
});
// 4、元器件本身的监听事件
addListener(def.getSpatial(), new MouseEventAdapter() {
@Override
public void mouseRightClicked(MouseEvent e) {
super.mouseRightClicked(e);
IContent content = SpringUtil.getBean(PageController.class).getIContent();
if (content instanceof TypicalCase3D) {
Platform.runLater(() -> {
((TypicalCase3D) content).showPopupMenu(def);
});
}
}
});
// 5、若当前为底座添加监听事件
if (ElecComp.COMBINE_BUTTOM == def.getElecComp().getCombine()) {
addListener(def.getSpatial(), new MouseEventAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// 判断当前底座是否已经被占用
if (StringUtils.isEmpty(combineMap.get(def.getProxy().getUuid()))) {
TypicalCaseState caseState = stateManager.getState(TypicalCaseState.class);
caseState.putDownOnBase(def);
super.mouseClicked(e);
}
}
});
}
}
use of com.cas.sim.tis.view.control.IContent 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);
}
});
}
use of com.cas.sim.tis.view.control.IContent in project TeachingInSimulation by ScOrPiOzzy.
the class TypicalCaseState method initializeLocal.
@Override
protected void initializeLocal() {
// 布置场景
arrangementScene();
// 添加操作模式State
cameraState = new SceneCameraState();
stateManager.attach(cameraState);
// 绑定事件
bindEvents();
// 默认新建案例
IContent content = SpringUtil.getBean(PageController.class).getIContent();
if (content instanceof TypicalCase3D) {
((TypicalCase3D) content).setupCase(new TypicalCase());
}
// 结束加载界面
Platform.runLater(() -> SpringUtil.getBean(PageController.class).hideLoading());
}
Aggregations