use of org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap in project olca-app by GreenDelta.
the class GraphEditor method createNecessaryLinks.
public void createNecessaryLinks(ProcessNode node) {
MutableProcessLinkSearchMap linkSearch = node.parent().linkSearch;
ProductSystemNode sysNode = node.parent();
long id = node.process.id;
for (ProcessLink pLink : linkSearch.getLinks(id)) {
boolean isProvider = pLink.providerId == id;
long otherID = isProvider ? pLink.processId : pLink.providerId;
ProcessNode otherNode = model.getProcessNode(otherID);
if (otherNode == null)
continue;
ProcessNode outNode = null;
ProcessNode inNode = null;
FlowType type = sysNode.flows.type(pLink.flowId);
if (type == FlowType.PRODUCT_FLOW) {
outNode = isProvider ? node : otherNode;
inNode = isProvider ? otherNode : node;
} else if (type == FlowType.WASTE_FLOW) {
outNode = isProvider ? otherNode : node;
inNode = isProvider ? node : otherNode;
}
if (outNode == null)
continue;
if (!outNode.isExpandedRight() && !inNode.isExpandedLeft())
continue;
Link link = new Link();
link.outputNode = outNode;
link.inputNode = inNode;
link.processLink = pLink;
link.link();
}
}
use of org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap in project olca-app by GreenDelta.
the class RemoveAllConnectionsAction method run.
@Override
public void run() {
if (processNodes.size() == 0)
return;
ProductSystemNode systemNode = editor.getModel();
List<Link> links = new ArrayList<>();
// create new link search to avoid problems with missing entries before
// ConnectionLink.unlink is called
List<ProcessLink> pLinks = systemNode.getProductSystem().processLinks;
MutableProcessLinkSearchMap linkSearch = new MutableProcessLinkSearchMap(pLinks);
for (ProcessNode processNode : processNodes) {
List<ProcessLink> processLinks = linkSearch.getLinks(processNode.process.id);
for (ProcessLink link : processLinks) linkSearch.remove(link);
for (Link link : processNode.links) if (!links.contains(link))
links.add(link);
}
Command command = new DeleteLinkCommand(links);
editor.getCommandStack().execute(command);
}
use of org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap in project olca-app by GreenDelta.
the class ProcessExpander method shouldBeVisible.
boolean shouldBeVisible() {
ProductSystemNode sysNode = node.parent();
MutableProcessLinkSearchMap linkSearch = sysNode.linkSearch;
long processId = node.process.id;
for (ProcessLink link : linkSearch.getLinks(processId)) {
FlowType type = sysNode.flows.type(link.flowId);
boolean isProvider = link.providerId == processId;
if (side == Side.INPUT) {
if (type == FlowType.PRODUCT_FLOW && !isProvider)
return true;
if (type == FlowType.WASTE_FLOW && isProvider)
return true;
} else if (side == Side.OUTPUT) {
if (type == FlowType.PRODUCT_FLOW && isProvider)
return true;
if (type == FlowType.WASTE_FLOW && !isProvider)
return true;
}
}
return false;
}
use of org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap in project olca-app by GreenDelta.
the class RemoveSupplyChainAction method run.
@Override
public void run() {
clear();
ProductSystem system = editor.getModel().getProductSystem();
long refId = system.referenceProcess.id;
if (refId == node.process.id) {
for (ProcessNode node : editor.getModel().getChildren()) if (refId != node.process.id) {
nodes.add(node);
connections.addAll(node.links);
}
processIds.addAll(system.processes);
processIds.remove(refId);
links.addAll(system.processLinks);
} else {
linkSearch = new MutableProcessLinkSearchMap(system.processLinks);
collectSupplyChain(node.process.id);
}
if (connections.size() > 0 || nodes.size() > 0 || links.size() > 0 || processIds.size() > 0)
editor.getCommandStack().execute(new RemoveCommand());
}
Aggregations