Packages

 

com.aspose.imaging

Interfaces

Classes

com.aspose.imaging

Class GraphicsPath



  • public final class GraphicsPath
    extends ObjectWithBounds

    Represents a series of connected lines and curves. This class cannot be inherited.

    Code example:

    This examples make use of GraphicsPath and Graphics class to create and manipulate Figures on an Image surface. Example creates a new Image (of type Tiff) and draw paths with the help of GraphicsPath class. At the end DrawPath method exposed by Graphics class is called to render the paths on surface.


    // Create an instance of FileStream
    com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.tif", com.aspose.imaging.system.io.FileMode.Create);
    try {
        // Create an instance of TiffOptions and set its various properties
        com.aspose.imaging.imageoptions.TiffOptions tiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default);
    
        // Set the source for the instance of ImageOptions
        tiffOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream));
    
        // Create an instance of Image
        com.aspose.imaging.Image image = com.aspose.imaging.Image.create(tiffOptions, 500, 500);
        try {
            // Create and initialize an instance of Graphics class
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image);
    
            // Clear Graphics surface
            graphics.clear(com.aspose.imaging.Color.getWheat());
    
            // Create an instance of GraphicsPath class
            com.aspose.imaging.GraphicsPath graphicspath = new com.aspose.imaging.GraphicsPath();
    
            // Create an instance of Figure class
            com.aspose.imaging.Figure figure = new com.aspose.imaging.Figure();
    
            // Add Shapes to Figure object
            figure.addShape(new com.aspose.imaging.shapes.RectangleShape(new com.aspose.imaging.RectangleF(10, 10, 300, 300)));
            figure.addShape(new com.aspose.imaging.shapes.EllipseShape(new com.aspose.imaging.RectangleF(50, 50, 300, 300)));
            figure.addShape(
                    new com.aspose.imaging.shapes.PieShape(new com.aspose.imaging.RectangleF(
                            new com.aspose.imaging.PointF(250, 250),
                            new com.aspose.imaging.SizeF(200, 200)),
                            0, 45));
    
            // Add Figure object to GraphicsPath
            graphicspath.addFigure(figure);
    
            // Draw path with Pen object of color Black
            graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), graphicspath);
    
            // Save all changes.
            image.save();
        } finally {
            image.dispose();
        }
    } finally {
        stream.dispose();
    }
    

    • Constructor Summary

      Constructors 
      Constructor and Description
      GraphicsPath()
      Initializes a new instance of the GraphicsPath class.
      GraphicsPath(Figure[] figures)
      Initializes a new instance of the GraphicsPath class.
      GraphicsPath(Figure[] figures, int fillMode)
      Initializes a new instance of the GraphicsPath class.
      GraphicsPath(int fillMode)
      Initializes a new instance of the GraphicsPath class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addFigure(Figure figure)
      Adds a new figure.
      void addFigures(Figure[] figures)
      Adds new figures.
      void addPath(GraphicsPath addingPath)
      Appends the specified com.aspose.imaging.GraphicsPath to this path.
      void addPath(GraphicsPath addingPath, boolean connect)
      Appends the specified com.aspose.imaging.GraphicsPath to this path.
      GraphicsPath deepClone()
      Performs a deep clone of this graphics path.
      void flatten()
      Converts each curve in this path into a sequence of connected line segments.
      void flatten(Matrix matrix)
      Applies the specified transform and then converts each curve in this com.aspose.imaging.GraphicsPath into a sequence of connected line segments.
      void flatten(Matrix matrix, float flatness)
      Converts each curve in this com.aspose.imaging.GraphicsPath into a sequence of connected line segments.
      RectangleF getBounds()
      Gets or sets the object's bounds.
      RectangleF getBounds(Matrix matrix)
      Gets the object's bounds.
      RectangleF getBounds(Matrix matrix, Pen pen)
      Gets the object's bounds.
      Figure[] getFigures()
      Gets the path figures.
      int getFillMode()
      Gets a com.aspose.imaging.FillMode enumeration that determines how the interiors of shapes in this com.aspose.imaging.GraphicsPath are filled.
      boolean isOutlineVisible(float x, float y, Pen pen)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.
      boolean isOutlineVisible(float x, float y, Pen pen, Graphics graphics)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.
      boolean isOutlineVisible(int x, int y, Pen pen)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.
      boolean isOutlineVisible(int x, int y, Pen pen, Graphics graphics)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.
      boolean isOutlineVisible(PointF point, Pen pen)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.
      boolean isOutlineVisible(PointF pt, Pen pen, Graphics graphics)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.
      boolean isOutlineVisible(Point point, Pen pen)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.
      boolean isOutlineVisible(Point pt, Pen pen, Graphics graphics)
      Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.
      boolean isVisible(float x, float y)
      Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.
      boolean isVisible(float x, float y, Graphics graphics)
      Indicates whether the specified point is contained within this com.aspose.imaging.GraphicsPath in the visible clip region of the specified com.aspose.imaging.graphics.
      boolean isVisible(int x, int y)
      Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.
      boolean isVisible(int x, int y, Graphics graphics)
      Indicates whether the specified point is contained within this com.aspose.imaging.GraphicsPath, using the specified com.aspose.imaging.graphics.
      boolean isVisible(Point point)
      Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.
      boolean isVisible(PointF point)
      Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.
      boolean isVisible(PointF pt, Graphics graphics)
      Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.
      boolean isVisible(Point pt, Graphics graphics)
      Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.
      void removeFigure(Figure figure)
      Removes a figure.
      void removeFigures(Figure[] figures)
      Removes figures.
      void reset()
      Empties the graphics path and sets the com.aspose.imaging.FillMode to F:com.aspose.imaging.fillMode.alternate.
      void reverse()
      Reverses the order of figures, shapes, and points in each shape of this com.aspose.imaging.graphicsPath.
      void setFillMode(int value)
      Sets a com.aspose.imaging.FillMode enumeration that determines how the interiors of shapes in this com.aspose.imaging.GraphicsPath are filled.
      void transform(Matrix transform)
      Applies the specified transformation to the shape.
      void warp(PointF[] destPoints, RectangleF srcRect)
      Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.
      void warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix)
      Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.
      void warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, int warpMode)
      Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.
      void warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, int warpMode, float flatness)
      Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.
      void widen(Pen pen)
      Adds an additional outline to the path.
      void widen(Pen pen, Matrix matrix)
      Adds an additional outline to the com.aspose.imaging.graphicsPath.
      void widen(Pen pen, Matrix matrix, float flatness)
      Replaces this com.aspose.imaging.GraphicsPath with curves that enclose the area that is filled when this path is drawn by the specified pen.
    • Constructor Detail

      • GraphicsPath

        public GraphicsPath()

        Initializes a new instance of the GraphicsPath class.

        Code example:

        This examples make use of GraphicsPath and Graphics class to create and manipulate Figures on an Image surface. Example creates a new Image (of type Tiff) and draw paths with the help of GraphicsPath class. At the end DrawPath method exposed by Graphics class is called to render the paths on surface.


        // Create an instance of FileStream
        com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.tif", com.aspose.imaging.system.io.FileMode.Create);
        try {
            // Create an instance of TiffOptions and set its various properties
            com.aspose.imaging.imageoptions.TiffOptions tiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default);
        
            // Set the source for the instance of ImageOptions
            tiffOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream));
        
            // Create an instance of Image
            com.aspose.imaging.Image image = com.aspose.imaging.Image.create(tiffOptions, 500, 500);
            try {
                // Create and initialize an instance of Graphics class
                com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image);
        
                // Clear Graphics surface
                graphics.clear(com.aspose.imaging.Color.getWheat());
        
                // Create an instance of GraphicsPath class
                com.aspose.imaging.GraphicsPath graphicspath = new com.aspose.imaging.GraphicsPath();
        
                // Create an instance of Figure class
                com.aspose.imaging.Figure figure = new com.aspose.imaging.Figure();
        
                // Add Shapes to Figure object
                figure.addShape(new com.aspose.imaging.shapes.RectangleShape(new com.aspose.imaging.RectangleF(10, 10, 300, 300)));
                figure.addShape(new com.aspose.imaging.shapes.EllipseShape(new com.aspose.imaging.RectangleF(50, 50, 300, 300)));
                figure.addShape(
                        new com.aspose.imaging.shapes.PieShape(new com.aspose.imaging.RectangleF(
                                new com.aspose.imaging.PointF(250, 250),
                                new com.aspose.imaging.SizeF(200, 200)),
                                0, 45));
        
                // Add Figure object to GraphicsPath
                graphicspath.addFigure(figure);
        
                // Draw path with Pen object of color Black
                graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), graphicspath);
        
                // Save all changes.
                image.save();
            } finally {
                image.dispose();
            }
        } finally {
            stream.dispose();
        }
        

      • GraphicsPath

        public GraphicsPath(Figure[] figures)

        Initializes a new instance of the GraphicsPath class.

        Parameters:
        figures - The figures to initialize from.
      • GraphicsPath

        public GraphicsPath(Figure[] figures,
                            int fillMode)

        Initializes a new instance of the GraphicsPath class.

        Parameters:
        figures - The figures to initialize from.
        fillMode - The fill mode.
      • GraphicsPath

        public GraphicsPath(int fillMode)

        Initializes a new instance of the GraphicsPath class.

        Parameters:
        fillMode - The fill mode.
    • Method Detail

      • getFillMode

        public int getFillMode()

        Gets a com.aspose.imaging.FillMode enumeration that determines how the interiors of shapes in this com.aspose.imaging.GraphicsPath are filled.

        Returns:
        The fill mode. A com.aspose.imaging.FillMode enumeration that specifies how the interiors of shapes in this com.aspose.imaging.GraphicsPath are filled.
      • setFillMode

        public void setFillMode(int value)

        Sets a com.aspose.imaging.FillMode enumeration that determines how the interiors of shapes in this com.aspose.imaging.GraphicsPath are filled.

        Parameters:
        value - The fill mode.
      • getFigures

        public Figure[] getFigures()

        Gets the path figures.

        Returns:
        The path figures.
      • reset

        public void reset()

        Empties the graphics path and sets the com.aspose.imaging.FillMode to F:com.aspose.imaging.fillMode.alternate.

      • reverse

        public void reverse()

        Reverses the order of figures, shapes, and points in each shape of this com.aspose.imaging.graphicsPath.

      • isVisible

        public boolean isVisible(float x,
                                 float y)

        Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        Returns:
        This method returns true if the specified point is contained within this com.aspose.imaging.GraphicsPath; otherwise, false.
      • isVisible

        public boolean isVisible(PointF point)

        Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.

        Parameters:
        point - A com.aspose.imaging.PointF that represents the point to test.
        Returns:
        This method returns true if the specified point is contained within this com.aspose.imaging.GraphicsPath; otherwise, false.
      • isVisible

        public boolean isVisible(int x,
                                 int y)

        Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        Returns:
        This method returns true if the specified point is contained within this com.aspose.imaging.GraphicsPath; otherwise, false.
      • isVisible

        public boolean isVisible(Point point)

        Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.

        Parameters:
        point - A com.aspose.imaging.Point that represents the point to test.
        Returns:
        This method returns true if the specified point is contained within this com.aspose.imaging.GraphicsPath; otherwise, false.
      • isVisible

        public boolean isVisible(float x,
                                 float y,
                                 Graphics graphics)

        Indicates whether the specified point is contained within this com.aspose.imaging.GraphicsPath in the visible clip region of the specified com.aspose.imaging.graphics.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within this com.aspose.imaging.GraphicsPath; otherwise, false.
      • isVisible

        public boolean isVisible(PointF pt,
                                 Graphics graphics)

        Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.

        Parameters:
        pt - A com.aspose.imaging.PointF that represents the point to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within this; otherwise, false.
      • isVisible

        public boolean isVisible(int x,
                                 int y,
                                 Graphics graphics)

        Indicates whether the specified point is contained within this com.aspose.imaging.GraphicsPath, using the specified com.aspose.imaging.graphics.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within this com.aspose.imaging.GraphicsPath; otherwise, false.
      • isVisible

        public boolean isVisible(Point pt,
                                 Graphics graphics)

        Indicates whether the specified point is contained within this com.aspose.imaging.graphicsPath.

        Parameters:
        pt - A com.aspose.imaging.Point that represents the point to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within this com.aspose.imaging.GraphicsPath; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(float x,
                                        float y,
                                        Pen pen)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        pen - The com.aspose.imaging.Pen to test.
        Returns:
        This method returns true if the specified point is contained within the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(PointF point,
                                        Pen pen)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.

        Parameters:
        point - A com.aspose.imaging.PointF that specifies the location to test.
        pen - The com.aspose.imaging.Pen to test.
        Returns:
        This method returns true if the specified point is contained within the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(float x,
                                        float y,
                                        Pen pen,
                                        Graphics graphics)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        pen - The com.aspose.imaging.Pen to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath as drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(PointF pt,
                                        Pen pen,
                                        Graphics graphics)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.

        Parameters:
        pt - A com.aspose.imaging.PointF that specifies the location to test.
        pen - The com.aspose.imaging.Pen to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath as drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(int x,
                                        int y,
                                        Pen pen)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        pen - The com.aspose.imaging.Pen to test.
        Returns:
        This method returns true if the specified point is contained within the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(Point point,
                                        Pen pen)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.pen.

        Parameters:
        point - A com.aspose.imaging.Point that specifies the location to test.
        pen - The com.aspose.imaging.Pen to test.
        Returns:
        This method returns true if the specified point is contained within the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(int x,
                                        int y,
                                        Pen pen,
                                        Graphics graphics)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.

        Parameters:
        x - The x-coordinate of the point to test.
        y - The y-coordinate of the point to test.
        pen - The com.aspose.imaging.Pen to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within the outline of this com.aspose.imaging.GraphicsPath as drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • isOutlineVisible

        public boolean isOutlineVisible(Point pt,
                                        Pen pen,
                                        Graphics graphics)

        Indicates whether the specified point is contained within (under) the outline of this com.aspose.imaging.GraphicsPath when drawn with the specified com.aspose.imaging.Pen and using the specified com.aspose.imaging.graphics.

        Parameters:
        pt - A com.aspose.imaging.Point that specifies the location to test.
        pen - The com.aspose.imaging.Pen to test.
        graphics - The com.aspose.imaging.Graphics for which to test visibility.
        Returns:
        This method returns true if the specified point is contained within the outline of this com.aspose.imaging.GraphicsPath as drawn with the specified com.aspose.imaging.Pen; otherwise, false.
      • flatten

        public void flatten()

        Converts each curve in this path into a sequence of connected line segments.

      • flatten

        public void flatten(Matrix matrix)

        Applies the specified transform and then converts each curve in this com.aspose.imaging.GraphicsPath into a sequence of connected line segments.

        Parameters:
        matrix - A com.aspose.imaging.Matrix by which to transform this com.aspose.imaging.GraphicsPath before flattening.
      • flatten

        public void flatten(Matrix matrix,
                            float flatness)

        Converts each curve in this com.aspose.imaging.GraphicsPath into a sequence of connected line segments.

        Parameters:
        matrix - A com.aspose.imaging.Matrix by which to transform this com.aspose.imaging.GraphicsPath before flattening.
        flatness - Specifies the maximum permitted error between the curve and its flattened approximation. A value of 0.25 is the default. Reducing the flatness value will increase the number of line segments in the approximation.
      • widen

        public void widen(Pen pen)

        Adds an additional outline to the path.

        Parameters:
        pen - A com.aspose.imaging.Pen that specifies the width between the original outline of the path and the new outline this method creates.
      • widen

        public void widen(Pen pen,
                          Matrix matrix)

        Adds an additional outline to the com.aspose.imaging.graphicsPath.

        Parameters:
        pen - A com.aspose.imaging.Pen that specifies the width between the original outline of the path and the new outline this method creates.
        matrix - A com.aspose.imaging.Matrix that specifies a transform to apply to the path before widening.
      • widen

        public void widen(Pen pen,
                          Matrix matrix,
                          float flatness)

        Replaces this com.aspose.imaging.GraphicsPath with curves that enclose the area that is filled when this path is drawn by the specified pen.

        Parameters:
        pen - A com.aspose.imaging.Pen that specifies the width between the original outline of the path and the new outline this method creates.
        matrix - A com.aspose.imaging.Matrix that specifies a transform to apply to the path before widening.
        flatness - A value that specifies the flatness for curves.
      • warp

        public void warp(PointF[] destPoints,
                         RectangleF srcRect)

        Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.

        Parameters:
        destPoints - An array of com.aspose.imaging.PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.
        srcRect - A com.aspose.imaging.RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.
      • warp

        public void warp(PointF[] destPoints,
                         RectangleF srcRect,
                         Matrix matrix)

        Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.

        Parameters:
        destPoints - An array of com.aspose.imaging.PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.
        srcRect - A com.aspose.imaging.RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.
        matrix - A com.aspose.imaging.Matrix that specifies a geometric transform to apply to the path.
      • warp

        public void warp(PointF[] destPoints,
                         RectangleF srcRect,
                         Matrix matrix,
                         int warpMode)

        Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.

        Parameters:
        destPoints - An array of com.aspose.imaging.PointF structures that defines a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.
        srcRect - A com.aspose.imaging.RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.
        matrix - A com.aspose.imaging.Matrix that specifies a geometric transform to apply to the path.
        warpMode - A com.aspose.imaging.WarpMode enumeration that specifies whether this warp operation uses perspective or bilinear mode.
      • warp

        public void warp(PointF[] destPoints,
                         RectangleF srcRect,
                         Matrix matrix,
                         int warpMode,
                         float flatness)

        Applies a warp transform, defined by a rectangle and a parallelogram, to this com.aspose.imaging.graphicsPath.

        Parameters:
        destPoints - An array of com.aspose.imaging.PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. The array can contain either three or four elements. If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.
        srcRect - A com.aspose.imaging.RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.
        matrix - A com.aspose.imaging.Matrix that specifies a geometric transform to apply to the path.
        warpMode - A com.aspose.imaging.WarpMode enumeration that specifies whether this warp operation uses perspective or bilinear mode.
        flatness - A value from 0 through 1 that specifies how flat the resulting path is. For more information, see the com.aspose.imaging.GraphicsPath.flatten methods.
      • addFigure

        public void addFigure(Figure figure)

        Adds a new figure.

        Parameters:
        figure - The figure to add.
        Code example:

        This examples make use of GraphicsPath and Graphics class to create and manipulate Figures on an Image surface. Example creates a new Image (of type Tiff) and draw paths with the help of GraphicsPath class. At the end DrawPath method exposed by Graphics class is called to render the paths on surface.


        // Create an instance of FileStream
        com.aspose.imaging.system.io.FileStream stream = new com.aspose.imaging.system.io.FileStream("C:\\temp\\output.tif", com.aspose.imaging.system.io.FileMode.Create);
        try {
            // Create an instance of TiffOptions and set its various properties
            com.aspose.imaging.imageoptions.TiffOptions tiffOptions = new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default);
        
            // Set the source for the instance of ImageOptions
            tiffOptions.setSource(new com.aspose.imaging.sources.StreamSource(stream));
        
            // Create an instance of Image
            com.aspose.imaging.Image image = com.aspose.imaging.Image.create(tiffOptions, 500, 500);
            try {
                // Create and initialize an instance of Graphics class
                com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image);
        
                // Clear Graphics surface
                graphics.clear(com.aspose.imaging.Color.getWheat());
        
                // Create an instance of GraphicsPath class
                com.aspose.imaging.GraphicsPath graphicspath = new com.aspose.imaging.GraphicsPath();
        
                // Create an instance of Figure class
                com.aspose.imaging.Figure figure = new com.aspose.imaging.Figure();
        
                // Add Shapes to Figure object
                figure.addShape(new com.aspose.imaging.shapes.RectangleShape(new com.aspose.imaging.RectangleF(10, 10, 300, 300)));
                figure.addShape(new com.aspose.imaging.shapes.EllipseShape(new com.aspose.imaging.RectangleF(50, 50, 300, 300)));
                figure.addShape(
                        new com.aspose.imaging.shapes.PieShape(new com.aspose.imaging.RectangleF(
                                new com.aspose.imaging.PointF(250, 250),
                                new com.aspose.imaging.SizeF(200, 200)),
                                0, 45));
        
                // Add Figure object to GraphicsPath
                graphicspath.addFigure(figure);
        
                // Draw path with Pen object of color Black
                graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), graphicspath);
        
                // Save all changes.
                image.save();
            } finally {
                image.dispose();
            }
        } finally {
            stream.dispose();
        }
        

      • addFigures

        public void addFigures(Figure[] figures)

        Adds new figures.

        Parameters:
        figures - The figures to add.
        Code example:

        This example creates a new Image and draws a variety of shapes using Figures and GraphicsPath on the Image surface


        //Creates an instance of BmpOptions and set its various properties
        com.aspose.imaging.imageoptions.BmpOptions bmpOptions = new com.aspose.imaging.imageoptions.BmpOptions();
        bmpOptions.setBitsPerPixel(24);
        
        //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions
        //Second Boolean parameter determines if the file to be created IsTemporal or not
        bmpOptions.setSource(new com.aspose.imaging.sources.FileCreateSource("c:\\temp\\output.bmp", false));
        
        //Create an instance of Image
        com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpOptions, 500, 500);
        try {
            //Create and initialize an instance of Graphics class
            com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image);
        
            //Clear Graphics surface
            graphics.clear(com.aspose.imaging.Color.getWheat());
        
            //Create an instance of GraphicsPath class
            com.aspose.imaging.GraphicsPath graphicspath = new com.aspose.imaging.GraphicsPath();
        
            //Create an instance of Figure class
            com.aspose.imaging.Figure figure1 = new com.aspose.imaging.Figure();
        
            //Add Shape to Figure object
            figure1.addShape(new com.aspose.imaging.shapes.EllipseShape(new com.aspose.imaging.RectangleF(50, 50, 300, 300)));
            figure1.addShape(new com.aspose.imaging.shapes.PieShape(
                    new com.aspose.imaging.RectangleF(
                            new com.aspose.imaging.PointF(110, 110),
                            new com.aspose.imaging.SizeF(200, 200)), 0, 90));
        
            //Create an instance of Figure class
            com.aspose.imaging.Figure figure2 = new com.aspose.imaging.Figure();
        
            //Add Shape to Figure object
            figure2.addShape(new com.aspose.imaging.shapes.ArcShape(new com.aspose.imaging.RectangleF(10, 10, 300, 300), 0, 45));
            figure2.addShape(new com.aspose.imaging.shapes.PolygonShape(
                    new com.aspose.imaging.PointF[]
                            {
                                    new com.aspose.imaging.PointF(150, 10),
                                    new com.aspose.imaging.PointF(150, 200),
                                    new com.aspose.imaging.PointF(250, 300),
                                    new com.aspose.imaging.PointF(350, 400)}, true));
            figure2.addShape(new com.aspose.imaging.shapes.RectangleShape(
                    new com.aspose.imaging.RectangleF(
                            new com.aspose.imaging.PointF(250, 250),
                            new com.aspose.imaging.SizeF(200, 200))));
        
            //Add Figure object to GraphicsPath
            graphicspath.addFigures(new com.aspose.imaging.Figure[]{figure1, figure2});
        
            //Draw path with Pen object of color Black
            graphics.drawPath(new com.aspose.imaging.Pen(com.aspose.imaging.Color.getBlack(), 2), graphicspath);
        
            // save all changes.
            image.save();
        } finally {
            image.dispose();
        }
        

      • removeFigure

        public void removeFigure(Figure figure)

        Removes a figure.

        Parameters:
        figure - The figure to remove.
      • removeFigures

        public void removeFigures(Figure[] figures)

        Removes figures.

        Parameters:
        figures - The figures to remove.
      • addPath

        public void addPath(GraphicsPath addingPath)

        Appends the specified com.aspose.imaging.GraphicsPath to this path.

        Parameters:
        addingPath - The com.aspose.imaging.GraphicsPath to add.
      • addPath

        public void addPath(GraphicsPath addingPath,
                            boolean connect)

        Appends the specified com.aspose.imaging.GraphicsPath to this path.

        Parameters:
        addingPath - The com.aspose.imaging.GraphicsPath to add.
        connect - A Boolean value that specifies whether the first figure in the added path is part of the last figure in this path. A value of true specifies that the first figure in the added path is part of the last figure in this path. A value of false specifies that the first figure in the added path is separate from the last figure in this path.
      • getBounds

        public RectangleF getBounds(Matrix matrix)

        Gets the object's bounds.

        Specified by:
        getBounds in class ObjectWithBounds
        Parameters:
        matrix - The matrix to apply before bounds will be calculated.
        Returns:
        The estimated object's bounds.
      • getBounds

        public RectangleF getBounds(Matrix matrix,
                                    Pen pen)

        Gets the object's bounds.

        Specified by:
        getBounds in class ObjectWithBounds
        Parameters:
        matrix - The matrix to apply before bounds will be calculated.
        pen - The pen to use for object. This can influence the object's bounds size.
        Returns:
        The estimated object's bounds.
      • deepClone

        public GraphicsPath deepClone()

        Performs a deep clone of this graphics path.

        Returns:
        A deep clone of the graphics path.
      • transform

        public void transform(Matrix transform)

        Applies the specified transformation to the shape.

        Specified by:
        transform in class ObjectWithBounds
        Parameters:
        transform - The transformation to apply.