use of com.cas.circuit.vo.ElecComp in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionHandler method connectByLinkerInfo.
/**
* 联机状态下接线
* @param linkerInfo 接线消息
* @param wireOrPipe
* @param modifiable
*/
private void connectByLinkerInfo(LinkerMsg linkerInfo, ILinker wireOrPipe, boolean modifiable) {
ElecComp elecComp = eleCompMap.get(linkerInfo.getElecCompKey());
if (elecComp == null) {
log.info("未找到指定元器件的定义信息:" + linkerInfo.getElecCompKey());
return;
}
ElecCompDef def = elecComp.getDef();
byte linkType = linkerInfo.getLinkType();
String targetKey = linkerInfo.getTargetKey();
ILinkTarget termOrPort = null;
if (LinkerMsg.WIRE == linkType || LinkerMsg.CABLE_TERM == linkType) {
termOrPort = def.getTerminalMap().get(targetKey);
} else if (LinkerMsg.PIPE == linkType) {
termOrPort = def.getGasPortMap().get(targetKey);
} else if (LinkerMsg.CABLE_JACK == linkType) {
termOrPort = def.getJackMap().get(targetKey);
}
if (wireOrPipe instanceof Cable && termOrPort instanceof Terminal) {
((Cable) wireOrPipe).setNowConnectingWire(linkerInfo.getWireMark());
((Cable) wireOrPipe).getNowConnectingWire().setWireNum(linkerInfo.getNumMark());
}
wireOrPipe.setWireNum(linkerInfo.getNumMark());
Spatial model = connect(wireOrPipe, termOrPort, true);
if (currSaveLinker != null) {
wireOrPipe = currSaveLinker;
}
// 接线头添加鼠标监听事件
addMouseEvent(model, new LinkerEventAdapter(new LinkerEventHandler(wireOrPipe, this, modifiable)));
// 记录准备存档的信息
if (modifiable) {
linkerData.addLinker(wireOrPipe, termOrPort, (String) model.getUserData("WireMark"));
}
}
use of com.cas.circuit.vo.ElecComp in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionHandler method bindSaveTransEvent.
private Cable bindSaveTransEvent(String elecCompKey, Cable cable, boolean modifiable) {
ElecComp elecComp = eleCompMap.get(elecCompKey);
if (elecComp == null) {
System.err.println("找不到elecCompKey : " + elecCompKey);
return null;
// throw new RuntimeException("找不到elecCompKey : " + elecCompKey);
}
ElecCompDef def = elecComp.getDef();
def.buildCompLogic();
Node elecCompMdl = (Node) parent.getChild(elecComp.getPO().getMdlName());
JmeUtil.setSpatialHighLight(elecCompMdl, ColorRGBA.BlackNoAlpha);
// MouseEventState.cleanEvent(elecCompMdl);
elecCompMdl.setUserData("MouseEvent", null);
Jack jack = def.getJackMap().values().iterator().next();
TransducersHandler handler = new TransducersHandler(this, elecComp, jack, modifiable);
cable.bind(jack);
cable.setElecComp(true);
cable.getModels().put(elecCompMdl, jack);
if (modifiable) {
linkerData.addLinker(cable, jack, null);
}
handler.setCable(cable);
addMouseEvent(elecCompMdl, new TransducersAdapter(handler));
return cable;
}
Aggregations