use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionController method bindLocal.
@Override
protected void bindLocal(Properties parameter, Attributes controlDefinitionAttributes) {
super.bindLocal(parameter, controlDefinitionAttributes);
if (Util.notEmpty(parameter.getProperty("noMult"))) {
noMult = Boolean.valueOf(parameter.getProperty("noMult"));
}
if (Util.notEmpty(parameter.getProperty("noPipe"))) {
noPipe = Boolean.valueOf(parameter.getProperty("noPipe"));
}
if (Util.notEmpty(parameter.getProperty("noWire"))) {
noWire = Boolean.valueOf(parameter.getProperty("noWire"));
}
if (Util.notEmpty(parameter.getProperty("noCable"))) {
noCable = Boolean.valueOf(parameter.getProperty("noCable"));
}
if (noMult) {
Element multimeterPanel = findById("multimeterPanel");
multimeterPanel.markForRemoval();
}
if (noPipe) {
Element pipePanel = findById("pipePanel");
pipePanel.markForRemoval();
} else {
Element pipeColorsContent = findById("pipeColorsContent");
updateImageMode("currentPipe#colorImage", pipeImageModes[0]);
for (int i = 0; i < pipeLabels.length; i++) {
creatWireAndPipeItem(i, pipeImageModes, pipeLabels, "changePipeColor", pipeColorsContent);
}
}
if (noWire) {
Element wirePanel = findById("wirePanel");
wirePanel.markForRemoval();
} else {
Element wireColorsContent = findById("wireColorsContent");
updateImageMode("currentWire#colorImage", wireImageModes[0]);
for (int j = 0; j < wireLabels.length; j++) {
creatWireAndPipeItem(j, wireImageModes, wireLabels, "changeWireColor", wireColorsContent);
}
}
if (noCable) {
Element xianlanPanel = findById("xianlanPanel");
xianlanPanel.markForRemoval();
}
addCleanningControlOnEnd(new ICleanableControl() {
@Override
public void onClean() {
if (timer != null) {
timer.cancel();
}
}
@Override
public String getName() {
if (timer != null) {
return timer.toString();
}
return "null Timer";
}
});
}
use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionController method selectCable.
/**
*/
public void selectCable() {
setContentVisible("pipeColorsContent", "false");
setContentVisible("wireColorsContent", "false");
if (cableLabels == null) {
if (!connectionHandler.checkChange()) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
return;
}
connectionHandler.setCurrLinker(ConnectionUtil.CONNECT_CABLE, null);
return;
}
if (connectionHandler.getCurrLinker() instanceof Cable) {
currentCableIndex = currentCableIndex + 1 > cableLabels.length - 1 ? 0 : currentCableIndex + 1;
List<Element> colorEles = findById("xianlanColorsContent").getElements();
Cable cable = (Cable) connectionHandler.getCurrLinker();
for (int i = 0; i < colorEles.size(); i++) {
Element colorEle = colorEles.get(i);
if (i == currentCableIndex) {
colorEle.startEffect(EffectEventId.onActive);
cable.setNowConnectingWire(cableLabels[currentCableIndex]);
} else {
colorEle.stopEffect(EffectEventId.onActive);
}
}
}
}
use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionController method setViewAreaVisible.
public void setViewAreaVisible(boolean visible) {
Element border = findById("border");
border.setVisible(visible);
}
use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionController method selectPipe.
/**
*/
private void selectPipe() {
if (!connectionHandler.checkChange()) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
return;
}
setContentVisible("pipeColorsContent", "true");
setContentVisible("wireColorsContent", "false");
if (connectionHandler.getCurrLinker() instanceof Pipe) {
// 当前是气管
currentPipeIndex = currentPipeIndex + 1 > pipeColors.length - 1 ? 0 : currentPipeIndex + 1;
}
List<Element> pipeEles = findById("pipeColorsContent").getElements();
for (int i = 0; i < pipeEles.size(); i++) {
Element pipeEle = pipeEles.get(i);
if (i == currentPipeIndex) {
pipeEle.startEffect(EffectEventId.onHover);
} else {
pipeEle.stopEffect(EffectEventId.onHover);
}
}
changePipeColor(String.valueOf(currentPipeIndex));
// 2秒后隐藏
selectHideTimer("pipeColorsContent");
}
use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionController method removeXianLanItem.
private void removeXianLanItem(int index) {
final Element parent = findById("xianlanColorsContent");
Element item = parent.getElements().get(index);
item.markForRemoval(new EndNotify() {
@Override
public void perform() {
refreshxianlanColorsContent();
currentCableIndex = currentCableIndex == parent.getElements().size() ? 0 : currentCableIndex;
}
});
}
Aggregations