/// <summary>
        /// Sets new data limits for the network reference window.  Called when,
        /// for instance, the paper orientation changes. </summary>
        /// <param name="data"> the GRLimits of the data. </param>
        public virtual void setNewDataLimits(GRLimits data)
        {
            double dw = data.getRightX() - data.getLeftX();
            double dh = data.getTopY() - data.getBottomY();

            __drawingArea.setDataLimits(data);

            /*
             * System.out.println(">> W/H: " + __totalWidth + "  " + __totalHeight);
             * System.out.println(">> L/B: " + __leftX + "  " + __bottomY);
             */
            double ratio = 0;

            if (dw > dh)
            {
                ratio         = 200 / dw;
                __totalWidth  = 200;
                __leftX       = 0;
                __totalHeight = (int)(ratio * dh);
                __bottomY     = (200 - __totalHeight) / 2;
            }
            else
            {
                ratio         = 200 / dh;
                __totalHeight = 200;
                __bottomY     = 0;
                __totalWidth  = (int)(ratio * dw);
                __leftX       = (200 - __totalWidth) / 2;
            }

            /*
             * System.out.println("<< W/H: " + __totalWidth + "  " + __totalHeight);
             * System.out.println("<< L/B: " + __leftX + "  " + __bottomY);
             */
        }
        /// <summary>
        /// Responds to mouse dragged events by moving around the box representing
        /// the viewable network area, and also making the large network display change to show that area. </summary>
        /// <param name="event"> the MouseEvent that happened. </param>
        public virtual void mouseDragged(MouseEvent @event)
        {
            if (__inDrag)
            {
                if (@event.getX() < __leftX || @event.getX() > __leftX + __totalWidth)
                {
                    return;
                }
                if (@event.getY() < __bottomY || @event.getY() > __bottomY + __totalHeight)
                {
                    return;
                }

                __inDrag = true;
                GRLimits data = __networkJComponent.getTotalDataLimits();

                int    width  = __totalWidth;
                double pct    = (double)(@event.getX() - __leftX) / (double)width;
                int    nw     = (int)data.getWidth();
                int    xPoint = (int)((nw * pct) + data.getLeftX());

                int height = __totalHeight;
                pct = (double)(height - @event.getY() + __bottomY) / (double)height;
                int nh     = (int)data.getHeight();
                int yPoint = (int)((nh * pct) + data.getBottomY());

                int x = xPoint - __xAdjust;
                int y = yPoint - __yAdjust;
                __networkJComponent.setViewPosition(x, y);
            }
        }
        /// <summary>
        /// Sets the drawing area to be used with this device. </summary>
        /// <param name="drawingArea"> the drawingArea to use with this device. </param>
        public virtual void setDrawingArea(GRJComponentDrawingArea drawingArea)
        {
            __drawingArea = drawingArea;

            GRLimits data = __drawingArea.getDataLimits();
            double   dw   = data.getRightX() - data.getLeftX();
            double   dh   = data.getTopY() - data.getBottomY();

            double ratio = 0;

            if (dw > dh)
            {
                ratio         = 200 / dw;
                __totalWidth  = 200;
                __leftX       = 0;
                __totalHeight = (int)(ratio * dh);
                __bottomY     = (200 - __totalHeight) / 2;
            }
            else
            {
                ratio         = 200 / dh;
                __totalHeight = 200;
                __bottomY     = 0;
                __totalWidth  = (int)(ratio * dw);
                __leftX       = (200 - __totalWidth) / 2;
            }
        }
        /// <summary>
        /// Converts an X value from being scaled for drawing units to be scaled for data units. </summary>
        /// <param name="x"> the x value to scale. </param>
        /// <returns> the x value scaled to fit in the data units. </returns>
        public virtual double convertX(double x)
        {
            GRLimits data = __drawingArea.getDataLimits();
            GRLimits draw = __drawingArea.getDrawingLimits();
            double   newX = (data.getLeftX() + (x / draw.getWidth()) * data.getWidth());

            return(newX);
        }
        /// <summary>
        /// Draws the bounds that represent the currently-visible area of the network.
        /// </summary>
        private void drawBounds()
        {
            GRLimits vl = __networkJComponent.getVisibleDataLimits();

            if (vl == null)
            {
                return;
            }
            GRDrawingAreaUtil.setColor(__drawingArea, GRColor.green);
            double lx = vl.getLeftX();
            double by = vl.getBottomY();
            double rx = vl.getRightX();
            double ty = vl.getTopY();

            GRDrawingAreaUtil.drawLine(__drawingArea, lx, by, rx, by);
            GRDrawingAreaUtil.drawLine(__drawingArea, lx, ty, rx, ty);
            GRDrawingAreaUtil.drawLine(__drawingArea, lx, by, lx, ty);
            GRDrawingAreaUtil.drawLine(__drawingArea, rx, by, rx, ty);
        }
        /// <summary>
        /// Responds to mouse pressed events.  If the mouse was clicked within the box that
        /// represents the viewable network area, then that view can be dragged around and
        /// will be represented in the large display.  Otherwise, the view is re-centered
        /// around the mouse click point. </summary>
        /// <param name="event"> the MouseEvent that happened. </param>
        public virtual void mousePressed(MouseEvent @event)
        {
            if (@event.getX() < __leftX || @event.getX() > __leftX + __totalWidth)
            {
                return;
            }
            if (@event.getY() < __bottomY || @event.getY() > __bottomY + __totalHeight)
            {
                return;
            }
            __inDrag = true;

            GRLimits data   = __networkJComponent.getTotalDataLimits();
            int      width  = __totalWidth;
            double   pct    = (double)(@event.getX() - __leftX) / (double)width;
            int      nw     = (int)data.getWidth();
            int      xPoint = (int)((nw * pct) + data.getLeftX());

            int height = __totalHeight;

            pct = (double)(height - @event.getY() + __bottomY) / (double)height;
            int      nh     = (int)data.getHeight();
            int      yPoint = (int)((nh * pct) + data.getBottomY());
            GRLimits limits = __networkJComponent.getVisibleDataLimits();

            int lx = (int)limits.getLeftX();
            int by = (int)limits.getBottomY();
            int rx = (int)limits.getRightX();
            int ty = (int)limits.getTopY();
            int w  = rx - lx;
            int h  = ty - by;

            // If the mouse was clicked in a point outside of the display box,
            // the box is re-centered on the point and the network display is updated to show that area
            __xAdjust = (w / 2);
            __yAdjust = (h / 2);
            int x = xPoint - __xAdjust;
            int y = yPoint - __yAdjust;

            __networkJComponent.setViewPosition(x, y);
        }
        /// <summary>
        /// Draws the outline of the legend.
        /// </summary>
        public virtual void drawLegend()
        {
            GRLimits l = __networkJComponent.getLegendDataLimits();

            if (l == null)
            {
                return;
            }
            GRDrawingAreaUtil.setColor(__drawingArea, GRColor.white);
            double lx = l.getLeftX();
            double by = l.getBottomY();
            double rx = l.getRightX();
            double ty = l.getTopY();

            GRDrawingAreaUtil.fillRectangle(__drawingArea, lx, by, l.getWidth(), l.getHeight());
            GRDrawingAreaUtil.setColor(__drawingArea, GRColor.black);
            GRDrawingAreaUtil.drawLine(__drawingArea, lx, by, rx, by);
            GRDrawingAreaUtil.drawLine(__drawingArea, lx, ty, rx, ty);
            GRDrawingAreaUtil.drawLine(__drawingArea, lx, by, lx, ty);
            GRDrawingAreaUtil.drawLine(__drawingArea, rx, by, rx, ty);
        }
        /// <summary>
        /// Paints the screen. </summary>
        /// <param name="g"> the Graphics context to use for painting. </param>
        public virtual void paint(Graphics g)
        {
            // sets the graphics in the base class appropriately (double-buffered
            // if doing double-buffered drawing, single-buffered if not)
            setGraphics(g);

            // Set up drawing limits based on current window size...
            setLimits(getLimits(true));

            // first time through, do the following ...
            if (!__initialized)
            {
                // one time ONLY, do the following.
                __height      = getBounds().height;
                __width       = getBounds().width;
                __initialized = true;
                setupDoubleBuffer(0, 0, getBounds().width, getBounds().height);

                repaint();
                __forceRefresh = true;
            }

            // only do the following if explicitly instructed to ...
            if (__forceRefresh)
            {
                clear();

                GRDrawingAreaUtil.setColor(__drawingArea, GRColor.black);

                setAntiAlias(true);
                drawNetworkLines();

                setAntiAlias(true);
                drawLegend();

                setAntiAlias(true);
                if (__drawMargin)
                {
                    GRLimits margins = __networkJComponent.getMarginLimits();
                    int      lx      = (int)margins.getLeftX();
                    int      rx      = (int)margins.getRightX();
                    int      by      = (int)margins.getBottomY();
                    int      ty      = (int)margins.getTopY();

                    __drawingArea.setFloatLineDash(__bigDashes, 0);
                    GRDrawingAreaUtil.setColor(__drawingArea, GRColor.cyan);
                    GRDrawingAreaUtil.drawLine(__drawingArea, lx, by, rx, by);
                    GRDrawingAreaUtil.drawLine(__drawingArea, lx, ty, rx, ty);
                    GRDrawingAreaUtil.drawLine(__drawingArea, lx, by, lx, ty);
                    GRDrawingAreaUtil.drawLine(__drawingArea, rx, by, rx, ty);
                    __drawingArea.setFloatLineDash(null, 0);
                }

                setAntiAlias(true);
                if (__drawInchGrid)
                {
                    __drawingArea.setFloatLineDash(__smallDashes, 0);
                    double maxX       = __networkJComponent.getTotalWidth();
                    double maxY       = __networkJComponent.getTotalHeight();
                    double leftX      = __networkJComponent.getDataLeftX();
                    double bottomY    = __networkJComponent.getDataBottomY();
                    double printScale = __networkJComponent.getPrintScale();

                    GRDrawingAreaUtil.setColor(__drawingArea, GRColor.red);
                    int j        = 0;
                    int minY     = (int)(__networkJComponent.convertAbsY(0) + bottomY);
                    int tempMaxY = (int)(__networkJComponent.convertAbsY(maxY) + bottomY);
                    for (int i = 0; i < maxX; i += ((72 / printScale) / 2))
                    {
                        j = (int)(__networkJComponent.convertAbsX(i) + leftX);
                        GRDrawingAreaUtil.drawLine(__drawingArea, j, minY, j, tempMaxY);
                        GRDrawingAreaUtil.drawText(__drawingArea, "" + ((double)i / (72 / printScale)), j, minY, 0, GRText.CENTER_X | GRText.BOTTOM);
                    }

                    int minX     = (int)(__networkJComponent.convertAbsX(0) + leftX);
                    int tempMaxX = (int)(__networkJComponent.convertAbsX(maxX) + leftX);
                    for (int i = 0; i < maxY; i += ((72 / printScale) / 2))
                    {
                        j = (int)(__networkJComponent.convertAbsY(i) + bottomY);
                        GRDrawingAreaUtil.drawLine(__drawingArea, minX, j, tempMaxX, j);
                        GRDrawingAreaUtil.drawText(__drawingArea, "" + ((double)i / (72 / printScale)), minX, j, 0, GRText.CENTER_Y | GRText.LEFT);
                    }
                    __drawingArea.setFloatLineDash(null, 0);
                }

                GRDrawingAreaUtil.setColor(__drawingArea, GRColor.black);
                GRLimits drawingLimits = __networkJComponent.getTotalDataLimits();
                GRDrawingAreaUtil.drawLine(__drawingArea, drawingLimits.getLeftX(), drawingLimits.getBottomY(), drawingLimits.getRightX(), drawingLimits.getBottomY());
                GRDrawingAreaUtil.drawLine(__drawingArea, drawingLimits.getLeftX(), drawingLimits.getTopY(), drawingLimits.getRightX(), drawingLimits.getTopY());
                GRDrawingAreaUtil.drawLine(__drawingArea, drawingLimits.getLeftX(), drawingLimits.getTopY(), drawingLimits.getLeftX(), drawingLimits.getBottomY());
                GRDrawingAreaUtil.drawLine(__drawingArea, drawingLimits.getRightX(), drawingLimits.getTopY(), drawingLimits.getRightX(), drawingLimits.getBottomY());

                setAntiAlias(true);
                drawBounds();
            }

            // displays the graphics
            showDoubleBuffer(g);
        }