use of com.cas.circuit.vo.archive.WireProxy in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method readWires.
private void readWires(@Nonnull List<WireProxy> wireProxyList) {
Map<String, ElecCompDef> compMap = compList.stream().collect(Collectors.toMap(x -> x.getProxy().getUuid(), x -> x));
wireProxyList.forEach(proxy -> {
ElecCompDef taggedComp1 = compMap.get(proxy.getComp1Uuid());
Terminal term1 = taggedComp1.getTerminal(proxy.getTernimal1Id());
ElecCompDef taggedComp2 = compMap.get(proxy.getComp2Uuid());
Terminal term2 = taggedComp2.getTerminal(proxy.getTernimal2Id());
Wire wire = new Wire();
wire.setProxy(proxy);
wire.bind(term1);
wire.bind(term2);
Future<Geometry> task = app.enqueue((Callable<Geometry>) () -> {
Geometry wireMdl = JmeUtil.createCylinderLine(assetManager, proxy.getPointList(), proxy.getWidth(), proxy.getColor());
return wireMdl;
});
Geometry wireMdl = null;
try {
wireMdl = task.get();
} catch (Exception e) {
LOG.error("无法加载导线模型:{}", e);
throw new RuntimeException(e);
}
attachToCircuit(wireMdl, wire);
});
}
use of com.cas.circuit.vo.archive.WireProxy in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method saveWires.
private void saveWires(Archive archive) {
wireList.forEach(wire -> {
WireProxy wireProxy = wire.getProxy();
wireProxy.setNumber(wire.getWireNum());
wireProxy.setComp1Uuid(wire.getTerm1().getElecComp().getProxy().getUuid());
wireProxy.setTernimal1Id(wire.getTerm1().getId());
wireProxy.setComp2Uuid(wire.getTerm2().getElecComp().getProxy().getUuid());
wireProxy.setTernimal2Id(wire.getTerm2().getId());
//
archive.getWireList().add(wireProxy);
});
}
use of com.cas.circuit.vo.archive.WireProxy in project TeachingInSimulation by ScOrPiOzzy.
the class TypicalCase3D method showPopupMenu.
public void showPopupMenu(Wire wire) {
ContextMenu menu = null;
WireProxy proxy = wire.getProxy();
String key = String.format("%s%s-%s%s", proxy.getComp1Uuid(), proxy.getTernimal1Id(), proxy.getComp2Uuid(), proxy.getTernimal2Id());
if (menus.containsKey(key)) {
menu = menus.get(key);
} else {
MenuItem tag = new MenuItem(MsgUtil.getMessage("typical.case.wire.num"));
tag.setOnAction(e -> {
TextInputDialog steamIdDialog = new TextInputDialog(proxy.getNumber());
steamIdDialog.setTitle(MsgUtil.getMessage("typical.case.wire.num"));
steamIdDialog.setHeaderText(null);
steamIdDialog.getEditor().textProperty().addListener((b, o, n) -> {
Pattern pat = Pattern.compile(REGEX_CHINESE);
Matcher mat = pat.matcher(n);
if (mat.find()) {
steamIdDialog.getEditor().setText(o);
}
});
steamIdDialog.setContentText(MsgUtil.getMessage("typical.case.prompt.input.wire.num"));
steamIdDialog.showAndWait().ifPresent(number -> {
wire.getProxy().setNumber(number);
CircuitState state = jmeApp.getStateManager().getState(CircuitState.class);
if (state == null) {
return;
}
state.setTagNameChanged(true);
});
});
MenuItem del = new MenuItem(MsgUtil.getMessage("button.delete"));
del.setOnAction(e -> {
CircuitState state = jmeApp.getStateManager().getState(CircuitState.class);
if (state == null) {
return;
}
boolean enable = state.detachFromCircuit(wire);
if (enable) {
menus.remove(key);
} else {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.wiring"));
}
});
menu = new ContextMenu(tag, del);
}
Point anchor = MouseInfo.getPointerInfo().getLocation();
menu.show(GUIState.getStage(), anchor.x, anchor.y);
}
Aggregations