Graphics2D createConstrainableGraphics()

in src/com/jetbrains/GraphicsUtils.java [37:74]


    Graphics2D createConstrainableGraphics(Graphics2D graphics2D,
                                           ConstrainableGraphics2D constrainable);

    /**
     * Allows to permanently install a rectangular maximum clip that
     * cannot be extended with setClip.
     * This is similar to {@code sun.awt.ConstrainableGraphics},
     * but allows floating-point coordinates.
     */
    @Provides
    public interface ConstrainableGraphics2D {
        /**
         * Destination that this Graphics renders to.
         * Similar to {@code sun.java2d.SunGraphics2D#getDestination()}.
         * @return rendering destination
         */
        Object getDestination();

        /**
         * Constrain this graphics object to have a permanent device space
         * origin of (x, y) and a permanent maximum clip of (x,y,w,h).
         * This overload allows floating-point coordinates.
         * @param region constraint rectangle
         * @see #constrain(int, int, int, int)
         */
        void constrain(Rectangle2D region);

        /**
         * Constrain this graphics object to have a permanent device space
         * origin of (x, y) and a permanent maximum clip of (x,y,w,h).
         * Similar to {@code sun.awt.ConstrainableGraphics#constrain(int, int, int, int)}.
         * @param x x coordinate of the constraint rectangle
         * @param y y coordinate of the constraint rectangle
         * @param w width of the constraint rectangle
         * @param h height of the constraint rectangle
         */
        void constrain(int x, int y, int w, int h);
    }