use of org.openlca.app.editors.graphical.model.ProcessNode 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.model.ProcessNode in project olca-app by GreenDelta.
the class LayoutCommand method execute.
@Override
public void execute() {
for (ProcessNode node : model.getChildren()) {
if (node.figure.isVisible()) {
oldConstraints.put(node.figure, node.figure.getBounds().getCopy());
}
}
layoutManager.layout(model.figure, type);
model.editor.setDirty();
}
use of org.openlca.app.editors.graphical.model.ProcessNode in project olca-app by GreenDelta.
the class MassCreationCommand method addNode.
private void addNode(RootDescriptor process) {
if (sysNode.getProcessNode(process.id) != null)
return;
ProcessNode node = new ProcessNode(sysNode.editor, process);
sysNode.getProductSystem().processes.add(process.id);
sysNode.add(node);
createdNodes.add(node);
}
use of org.openlca.app.editors.graphical.model.ProcessNode in project olca-app by GreenDelta.
the class TreeLayout method layout.
public void layout(ProductSystemNode productSystemNode) {
this.linkSearch = productSystemNode.linkSearch;
prepare(productSystemNode);
List<Node> nodes = new ArrayList<>();
Node mainNode = build(productSystemNode.getProductSystem());
mainNode.sort();
nodes.add(mainNode);
for (ProcessNode processNode : productSystemNode.getChildren()) {
if (containing.get(processNode.process.id) != null)
continue;
Node node = new Node();
node.processId = processNode.process.id;
build(productSystemNode.getProductSystem(), new Node[] { node });
node.sort();
nodes.add(node);
}
int additionalHeight = 0;
for (Node node : nodes) {
int newAdditionalHeight = 0;
locations.clear();
applyLayout(node, 0, node.getLeftDepth());
int minimumX = Integer.MAX_VALUE;
int maximumX = Integer.MIN_VALUE;
int minimumY = Integer.MAX_VALUE;
int maximumY = Integer.MIN_VALUE;
for (Point p : locations.keySet()) {
if (p.x < minimumX)
minimumX = p.x;
if (p.x > maximumX)
maximumX = p.x;
if (p.y < minimumY)
minimumY = p.y;
if (p.y > maximumY)
maximumY = p.y;
}
Map<Long, ProcessNode> processNodes = new HashMap<>();
for (ProcessNode processNode : productSystemNode.getChildren()) processNodes.put(processNode.process.id, processNode);
for (int x = minimumX; x <= maximumX; x++) {
widths.put(x, 0);
for (int y = minimumY; y <= maximumY; y++) {
Long processId = locations.get(new Point(x, y));
if (processId == null)
continue;
ProcessNode pn = processNodes.get(processId);
if (pn == null)
continue;
Dimension size = pn.getSize();
if (size == null)
continue;
int width = Math.max(widths.get(x), size.width);
widths.put(x, width);
}
}
for (int y = minimumY; y <= maximumY; y++) {
heights.put(y, 0);
for (int x = minimumX; x <= maximumX; x++) {
Long processId = locations.get(new Point(x, y));
if (processId == null)
continue;
ProcessNode pn = processNodes.get(processId);
if (pn == null)
continue;
Dimension size = pn.getSize();
if (size == null)
continue;
int height = Math.max(heights.get(y), size.height);
heights.put(y, height);
}
}
int xPosition = LayoutManager.H_SPACE;
for (int x = minimumX; x <= maximumX; x++) {
if (x > minimumX && widths.get(x - 1) > 0)
xPosition += widths.get(x - 1) + LayoutManager.H_SPACE;
int yPosition = LayoutManager.V_SPACE;
for (int y = minimumY; y <= maximumY; y++) {
Long processId = locations.get(new Point(x, y));
if (y > minimumY && heights.get(y - 1) > 0)
yPosition += heights.get(y - 1) + LayoutManager.V_SPACE;
if (processId == null)
continue;
ProcessNode processNode = processNodes.get(processId);
if (processNode == null)
continue;
Dimension size = processNode.getSize();
if (size == null)
continue;
processNode.setBox(new Rectangle(xPosition, yPosition + additionalHeight, size.width, size.height));
newAdditionalHeight = Math.max(newAdditionalHeight, yPosition + additionalHeight + size.height);
}
}
additionalHeight = newAdditionalHeight + LayoutManager.V_SPACE;
}
containing.clear();
widths.clear();
heights.clear();
locations.clear();
}
use of org.openlca.app.editors.graphical.model.ProcessNode in project olca-app by GreenDelta.
the class CreateProcessCommand method execute.
@Override
public void execute() {
model.getProductSystem().processes.add(process.id);
model.add(new ProcessNode(model.editor, process));
if (model.editor.getOutline() != null)
model.editor.getOutline().refresh();
model.editor.setDirty();
}
Aggregations