use of com.cas.circuit.event.LinkerEventHandler 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.event.LinkerEventHandler in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionHandler method offlineConnect.
/**
* 单机练习模式下接线
* @param termOrPort 端子、气口
*/
public LinkerMsg offlineConnect(ILinkTarget termOrPort) {
// 获得当前用户选中导线
ILinker wireOrPipe = currLinker;
Spatial model = connect(wireOrPipe, termOrPort, false);
// 线缆会在连接时对当前连接对象做一些处理,所以此处要重新获得一次
if (wireOrPipe instanceof Cable && ((Cable) wireOrPipe).getPlug1() == null && ((Cable) wireOrPipe).getPlug2() == null) {
wireOrPipe = currLinker;
}
initLinkerLine(wireOrPipe, model);
// 接线头添加鼠标监听事件
addMouseEvent(model, new LinkerEventAdapter(new LinkerEventHandler(wireOrPipe, this, true)));
return linkerData.addLinker(wireOrPipe, termOrPort, (String) model.getUserData("WireMark"));
}
Aggregations