コード例 #1
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="parent"> the JFrame on which this dialog will be shown. </param>
        /// <param name="ds"> the Downstream node from where the ndoe should be added. </param>
        public StateMod_Network_AddNode_JDialog(StateMod_Network_JFrame parent, HydrologyNode ds) : base(parent, "Add Node", true)
        {
            __parent = parent;
            __ds     = ds;

            setupGUI();
        }
        /// <summary>
        /// Draws the network between all the nodes.
        /// </summary>
        private void drawNetworkLines()
        {
            bool dash = false;

            float[] dashes = new float[] { 5f, 4f };
            float   offset = 0;

            double[]      x          = new double[2];
            double[]      y          = new double[2];
            HydrologyNode ds         = null;
            HydrologyNode dsRealNode = null;
            HydrologyNode holdNode   = null;
            HydrologyNode holdNode2  = null;
            HydrologyNode node       = null;
            HydrologyNode nodeTop    = __network.getMostUpstreamNode();

            GRDrawingAreaUtil.setLineWidth(__drawingArea, 1);

            for (node = nodeTop; node != null; node = StateMod_NodeNetwork.getDownstreamNode(node, StateMod_NodeNetwork.POSITION_COMPUTATIONAL))
            {
                // move ahead and skip and blank or unknown nodes (which won't
                // be drawn, anyways -- check buildNodeArray()), so that
                // connections are only between visible nodes
                if (holdNode == node)
                {
                    GRDrawingAreaUtil.setLineWidth(__drawingArea, 1);
                    return;
                }
                holdNode2 = node;
                while (node.getType() == HydrologyNode.NODE_TYPE_UNKNOWN)
                {
                    node = StateMod_NodeNetwork.getDownstreamNode(node, StateMod_NodeNetwork.POSITION_COMPUTATIONAL);
                    if (node == null || node == holdNode2)
                    {
                        GRDrawingAreaUtil.setLineWidth(__drawingArea, 1);
                        return;
                    }
                }

                ds = node.getDownstreamNode();
                if (ds == null || node.getType() == HydrologyNode.NODE_TYPE_END)
                {
                    GRDrawingAreaUtil.setLineWidth(__drawingArea, 1);
                    return;
                }

                dsRealNode = StateMod_NodeNetwork.findNextRealOrXConfluenceDownstreamNode(node);

                // if the confluence of the reach (as opposed to a trib coming
                // in) then this is the last real node in disappearing stream.
                // Use the end node for the downstream node.
                dash = false;
                if (dsRealNode == StateMod_NodeNetwork.getDownstreamNode(node, StateMod_NodeNetwork.POSITION_REACH))
                {
                    dash = true;
                }

                // move ahead and skip and blank or unknown nodes (which won't
                // be drawn, anyways -- check buildNodeArray()), so that
                // connections are only between visible nodes
                holdNode2 = ds;
                while (ds.getType() == HydrologyNode.NODE_TYPE_UNKNOWN)
                {
                    ds = ds.getDownstreamNode();
                    if (ds == null || ds == holdNode2)
                    {
                        GRDrawingAreaUtil.setLineWidth(__drawingArea, 1);
                        return;
                    }
                }

                x[0] = node.getX();
                y[0] = node.getY();
                x[1] = ds.getX();
                y[1] = ds.getY();

                GRDrawingAreaUtil.setColor(__drawingArea, GRColor.black);
                GRDrawingAreaUtil.setLineWidth(__drawingArea, 1);

                if (dash)
                {
                    __drawingArea.setFloatLineDash(dashes, offset);
                    GRDrawingAreaUtil.drawLine(__drawingArea, x, y);
                    __drawingArea.setFloatLineDash(null, (float)0);
                }
                else
                {
                    GRDrawingAreaUtil.drawLine(__drawingArea, x, y);
                }
                holdNode = node;
            }
            GRDrawingAreaUtil.setLineWidth(__drawingArea, 1);
        }