// moves the end of the line attached to passed node
		public void adjustRelatedPoint(Node node)
		{
			Node origin = m_parent.getOrigin();
			Node end = m_parent.getEnd();
			if (node.Equals(origin)) { adjustFirstPoint((int)(origin.getGraphic().getCurrentX() + GraphicContainer.NODE_SIZE / 2), (int)(origin.getGraphic().getCurrentY() + GraphicContainer.NODE_SIZE / 2)); }
			else if (node.Equals(end)) { adjustSecondPoint((int)(end.getGraphic().getCurrentX() + GraphicContainer.NODE_SIZE / 2), (int)(end.getGraphic().getCurrentY() + GraphicContainer.NODE_SIZE / 2)); }
		}
Example #2
0
		// -- FUNCTIONS --

		// finishes creating connection/adds connection to both involved nodes
		// returns true on success, false on failure
		public bool completeConnection(Node other)
		{
			m_end = other;
			if (m_outNode == null) { m_outNode = other; }
			else { m_inNode = other; }

			// make sure the nodes aren't the same and are not both inputs or outputs
			if (m_origin.Equals(m_end) || 
				m_origin.isInput() == m_end.isInput() || 
                m_origin.getParent() == m_end.getParent() || 
                !m_origin.getDatatype().fits(m_end.getDatatype()))
			{
				m_graphic.removeGraphic();
				return false;
			}

            if(!m_origin.getDatatype().equals(m_end.getDatatype()))
            {
				m_graphic.setStrokeColor(Colors.Red);
            }

			// set end point to end node center
			m_graphic.finishVisualConnection(m_end);

			m_completed = true;

			int inputRepID = m_inNode.getParent().getID();
			int inputNodeID = m_inNode.getGroupNum();
			int outputRepID = m_outNode.getParent().getID();
			int outputNodeID = m_outNode.getGroupNum();
			Master.log("Connection created - OutputID: " + outputRepID + " (out-node " + outputNodeID + ") InputID: " + inputRepID + " (in-node " + inputNodeID + ")");

			return true;
		}
Example #3
0
		// construction
		public NodeGraphic(Node parent)
		{
			m_parent = parent;
			m_offsetX = parent.getParent().getGraphic().getNodeOffsetX(parent.isInput(), parent.getGroupNum());
			m_offsetY = parent.getParent().getGraphic().getNodeOffsetY(parent.isInput());

			createDrawing();
		}
Example #4
0
		// construction
		public Connection(Node start)
		{
			Master.log("Connection initialized");
			m_origin = start;
			if (start.isInput()) 
            {
                m_inNode = start;
                if(start.getNumConnections() > 0)
                {
                    Connection x = start.getConnection(0);
                    x.removeConnection();
                }
            }
			else { m_outNode = start; }
			m_graphic = GraphicFactory.createConnectionGraphic(this);
		}
		// visually attaches connection to passed node
		public void finishVisualConnection(Node n)
		{
			adjustSecondPoint((int)(n.getGraphic().getCurrentX() + GraphicContainer.NODE_SIZE / 2), (int)(n.getGraphic().getCurrentY() + GraphicContainer.NODE_SIZE / 2));
			m_body.IsHitTestVisible = true; // make clickable
			Master.getCanvas().Children.Remove(m_lblTypeName);
		}
Example #6
0
		public static NodeGraphic createNodeGraphic(Node parent)
		{
			return new NodeGraphic(parent);
		}