package org.simantics.plant3d.scenegraph; import java.util.HashMap; import java.util.Map; import org.simantics.g3d.scenegraph.base.ParentNode; import org.simantics.objmap.graph.annotations.DynamicGraphType; import org.simantics.objmap.graph.annotations.GetType; import org.simantics.objmap.graph.annotations.SetType; import org.simantics.plant3d.ontology.Plant3D; import org.simantics.plant3d.scenegraph.controlpoint.ControlPointFactory; import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint; @DynamicGraphType(Plant3D.URIs.InlineComponent) public class InlineComponent extends PipelineComponent { private String type; private PipeControlPoint controlPoint; @GetType(Plant3D.URIs.InlineComponent) public String getType() { return type; } @SetType(Plant3D.URIs.InlineComponent) public void setType(String type) throws Exception{ this.type = type; controlPoint = ControlPointFactory.create(this); } @Override public PipeControlPoint getControlPoint() { return controlPoint; } @Override public void setParent(ParentNode parent, String name) { super.setParent(parent, name); setPipeRun((PipeRun)parent); } public boolean isVariableLength() { return !controlPoint.isFixed(); } @Override public void updateParameters() { super.updateParameters(); if (!isVariableLength()) { Map calculated = getCalculatedParameters(); if (calculated.containsKey("length")) { controlPoint.setLength((Double)calculated.get("length")); } } } @Override public Map updateParameterMap() { Map map = new HashMap(); if (controlPoint != null) { if (!Double.isNaN(controlPoint.getLength())) map.put("length", controlPoint.getLength()); if (controlPoint.isDualInline()) { PipeControlPoint sub = controlPoint.getSubPoint().get(0); PipeRun pipeRun = sub.getPipeRun(); if (pipeRun != null) { map.put("radius2", pipeRun.getPipeDiameter() * 0.5); } } } PipeRun pipeRun = getPipeRun(); if (pipeRun != null) { map.put("radius", pipeRun.getPipeDiameter() * 0.5); } return map; } }