public void setNodesZ(Float z) { nodesZ = z; for (Node node : nodes) { node.setZ(z); } }
public void readNodeData(XMLStreamReader reader, Node node) throws XMLStreamException { boolean end = false; while (reader.hasNext() && !end) { Integer eventType = reader.next(); if (eventType.equals(XMLEvent.START_ELEMENT)) { String name = reader.getLocalName(); if (ELEMENT_NODEDATA_POSITION.equalsIgnoreCase(name)) { node.setX(Float.parseFloat(reader.getAttributeValue(null, "x"))); node.setY(Float.parseFloat(reader.getAttributeValue(null, "y"))); node.setZ(Float.parseFloat(reader.getAttributeValue(null, "z"))); } else if (ELEMENT_NODEDATA_COLOR.equalsIgnoreCase(name)) { node.setR(Float.parseFloat(reader.getAttributeValue(null, "r"))); node.setG(Float.parseFloat(reader.getAttributeValue(null, "g"))); node.setB(Float.parseFloat(reader.getAttributeValue(null, "b"))); node.setAlpha(Float.parseFloat(reader.getAttributeValue(null, "a"))); } else if (ELEMENT_NODEDATA_SIZE.equalsIgnoreCase(name)) { node.setSize(Float.parseFloat(reader.getAttributeValue(0))); } } else if (eventType.equals(XMLStreamReader.END_ELEMENT)) { if (ELEMENT_NODEDATA.equalsIgnoreCase(reader.getLocalName())) { end = true; } } } }
private void clampPosition(NodeModel nodeModel) { //Clamp Hack to avoid nodes to be outside octree float quantum = size / 2; Node node = nodeModel.getNode(); float x = node.x(); float y = node.y(); float z = node.z(); if (x > root.posX + quantum) { node.setX(root.posX + quantum); } else if (x < root.posX - quantum) { node.setX(root.posX - quantum); } if (y > root.posY + quantum) { node.setY(root.posY + quantum); } else if (y < root.posY - quantum) { node.setY(root.posY - quantum); } if (z > root.posZ + quantum) { node.setZ(root.posZ + quantum); } else if (z < root.posZ - quantum) { node.setZ(root.posZ - quantum); } }
newNode.setZ(selectedNode.z());
private Node copyNode(Node node, Graph graph) { Node copy = buildNode(graph, node.getLabel()); //Copy properties (position, size and color): copy.setX(node.x()); copy.setY(node.y()); copy.setZ(node.z()); copy.setSize(node.size()); copy.setR(node.r()); copy.setG(node.g()); copy.setB(node.b()); copy.setAlpha(node.alpha()); Table nodeTable = graph.getModel().getNodeTable(); //Copy attributes: for (Column column : nodeTable) { if (!column.isReadOnly()) { copy.setAttribute(column, node.getAttribute(column)); } } graph.addNode(copy); return copy; }