if (logger.isDebugEnabled()) { logger.debug("normalize rawRect=" + rawRect + " rect=" + rect); }
    private void normalize ()    {        if (rect == null) {            rect = new Rectangle(unscaled(rawRect.x), unscaled(rawRect.y),                                 unscaled(rawRect.width),                                 unscaled(rawRect.height));        } else {            rect.setBounds(unscaled(rawRect.x), unscaled(rawRect.y),                           unscaled(rawRect.width), unscaled(rawRect.height));        }        // The x & y are the original coordinates when mouse began        // But width & height may be negative        // Make the width and height positive, if necessary.        if (rect.width < 0) {            rect.width = -rect.width;            rect.x = rect.x - rect.width + 1;            if (rect.x < 0) {                rect.width += rect.x;                rect.x = 0;            }        }        if (rect.height < 0) {            rect.height = -rect.height;            rect.y = rect.y - rect.height + 1;            if (rect.y < 0) {                rect.height += rect.y;                rect.y = 0;            }        }        // The origin must stay within the component        final int compWidth = unscaled(component.getWidth());        final int compHeight = unscaled(component.getHeight());        if (rect.x < 0) {            rect.x = 0;        } else if (rect.x > compWidth) {            rect.x = compWidth;        }        if (rect.y < 0) {            rect.y = 0;        } else if (rect.y > compHeight) {            rect.y = compHeight;        }        // The rectangle shouldn't extend past the drawing area.        if ((rect.x + rect.width) > compWidth) {            rect.width = compWidth - rect.x;        }        if ((rect.y + rect.height) > compHeight) {            rect.height = compHeight - rect.y;        }        if (logger.isDebugEnabled()) {            logger.debug("normalize rawRect=" + rawRect + " rect=" + rect);        }    }