Packages

 

com.aspose.imaging.shapes

Class ArcShape

  • All Implemented Interfaces:
    IOrderedShape


    public final class ArcShape
    extends PieShape
    implements IOrderedShape

    Represents an arc shape.

    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();
    }
    

    • Constructor Detail

      • ArcShape

        public ArcShape()

        Initializes a new instance of the ArcShape class.

      • ArcShape

        public ArcShape(RectangleF rectangle,
                        float startAngle,
                        float sweepAngle)

        Initializes a new instance of the ArcShape class.

        Parameters:
        rectangle - The rectangle.
        startAngle - The start angle.
        sweepAngle - The sweep angle.
        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();
        }
        

      • ArcShape

        public ArcShape(RectangleF rectangle,
                        float startAngle,
                        float sweepAngle,
                        boolean isClosed)

        Initializes a new instance of the ArcShape class.

        Parameters:
        rectangle - The rectangle.
        startAngle - The start angle.
        sweepAngle - The sweep angle.
        isClosed - If set to true the arc is closed. The closed arc is actually degenereates to an ellipse.
    • Method Detail

      • getSegments

        public ShapeSegment[] getSegments()

        Gets the shape segments.

        Value: The shape segments.
        Overrides:
        getSegments in class PieShape
        Returns:
        The shape segments.
      • getStartPoint

        public PointF getStartPoint()

        Gets the starting shape point.

        Value: The starting shape point.
        Specified by:
        getStartPoint in interface IOrderedShape
        Returns:
        The starting shape point.
      • getEndPoint

        public PointF getEndPoint()

        Gets the ending shape point.

        Value: The ending shape point.
        Specified by:
        getEndPoint in interface IOrderedShape
        Returns:
        The ending shape point.
      • isClosed

        public boolean isClosed()

        Gets or sets a value indicating whether ordered shape is closed. When processing closed ordered shape the starting and ending points have no meaning.

        Value: True if this ordered shape is closed; otherwise, false.
        Specified by:
        isClosed in interface IOrderedShape
        Returns:
        true if this ordered shape is closed; otherwise, false.
      • setClosed

        public void setClosed(boolean value)

        Gets or sets a value indicating whether ordered shape is closed. When processing closed ordered shape the starting and ending points have no meaning.

        Value: True if this ordered shape is closed; otherwise, false.
        Specified by:
        setClosed in interface IOrderedShape
        Parameters:
        value - true if this ordered shape is closed; otherwise, false.
      • reverse

        public void reverse()

        Reverses the order of points for this shape.

        Specified by:
        reverse in interface IOrderedShape
      • getBounds

        public RectangleF getBounds(Matrix matrix)

        Gets the object's bounds.

        Overrides:
        getBounds in class RectangleProjectedShape
        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.

        Overrides:
        getBounds in class RectangleProjectedShape
        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.