示例#1
0
        /// <summary>
        /// Validates the given cell state.
        /// </summary>
        public void UpdateEdgeState(mxCellState state, mxGeometry geo, mxCellState source, mxCellState target)
        {
            // This will remove edges with no terminals and no terminal points
            // as such edges are invalid and produce NPEs in the edge styles.
            // Also removes connected edges that have no visible terminals.
            if ((graph.Model.GetTerminal(state.Cell, true) != null && source == null) ||
                (source == null && geo.GetTerminalPoint(true) == null) ||
                (graph.Model.GetTerminal(state.Cell, false) != null && target == null) ||
                (target == null && geo.GetTerminalPoint(false) == null))
            {
                RemoveState(state.Cell, true);
            }
            else
            {
                UpdateFixedTerminalPoints(state, source, target);
                UpdatePoints(state, geo.Points, source, target);
                UpdateFloatingTerminalPoints(state, source, target);

                if (state.AbsolutePointCount() < 2 || state.AbsolutePoints[0] == null || state
                    .AbsolutePoints[state.AbsolutePointCount() - 1] == null)
                {
                    // This will remove edges with invalid points from the list of states in the view.
                    // Happens if the one of the terminals and the corresponding terminal point is null.
                    RemoveState(state.Cell, true);
                }
                else
                {
                    UpdateEdgeBounds(state);
                    state.AbsoluteOffset = GetPoint(state, geo);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Updates the terminal points in the given state after the edge style was
        /// computed for the edge.
        /// </summary>
        /// <param name="state">State whose terminal points should be updated.</param>
        /// <param name="source">State that represents the source terminal.</param>
        /// <param name="target">State that represents the target terminal.</param>
        public void UpdateFloatingTerminalPoints(mxCellState state, mxCellState source, mxCellState target)
        {
            mxPoint p0 = state.AbsolutePoints[0];
            mxPoint pe = state.AbsolutePoints[state.AbsolutePointCount() - 1];

            if (pe == null && target != null)
            {
                UpdateFloatingTerminalPoint(state, target, source, false);
            }

            if (p0 == null && source != null)
            {
                UpdateFloatingTerminalPoint(state, source, target, true);
            }
        }