Class PolygonScaling

  • All Implemented Interfaces:
    IPolygonScaling

    @Service
    public class PolygonScaling
    extends java.lang.Object
    implements IPolygonScaling
    Implementation class for recalculating poligons of a scaled, bordered and cropped image and on the absolute positioning of that image on the screen.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2012 Created on Jul 1, 2012
    • Constructor Detail

      • PolygonScaling

        public PolygonScaling()
    • Method Detail

      • recalculatePolygons

        public ImageData recalculatePolygons​(ImageData imgData,
                                             ImageScaleState state)
        Description copied from interface: IPolygonScaling
        Compute the location and dimensions of the NamedPolygons that are contained in imgData based on the scaling state. If the image was cropped or bordered this may result in a translocation of the defined polygon. If the image was scaled this will result in a translocation to or from the origin (top left corner) by the factor of the scaling. A new instance of image Data with the new polygon definition will be returned.
        Specified by:
        recalculatePolygons in interface IPolygonScaling
        Parameters:
        imgData - Input data of the image containing a list of NamedPolygons that are to be recalculated
        state - of the scaled image
        Returns:
        new instance of ImageData containing the recalculated polygons
      • recalculatePolygonsOffset

        public ImageData recalculatePolygonsOffset​(ImageData imgData,
                                                   javafx.geometry.Point2D offset)
        Description copied from interface: IPolygonScaling
        Recalculate the positions of the polygons to reflect their absolute on screen locations.
        Specified by:
        recalculatePolygonsOffset in interface IPolygonScaling
        Parameters:
        imgData - Input data of the image containing a list of NamedPolygons that are to be recalculated
        offset - Point indicating the absolute position on screen of the origin (top left corner) of the image
        Returns:
        new instance of ImageData containing the recalculated polygons
      • recalculatePolygonCrop

        final ImageData recalculatePolygonCrop​(ImageData imgData,
                                               ImageScaleState state)
        Compute the polygon affected by the cropping of the image as stated in state
        Parameters:
        imgData - Input data of the image containing a list of NamedPolygons that are to be recalculated
        state - of the scaled image
        Returns:
        new instance of ImageData containing the recalculated polygons
      • createNewCopy

        private ImageData createNewCopy​(ImageData imgData)
        Create a clone of the image data and handle the CloneNotSupportedException
        Parameters:
        imgData - image data
        Returns:
        copy of the image data
      • recalculatePolygonScale

        final ImageData recalculatePolygonScale​(ImageData imgData,
                                                ImageScaleState state)
        Compute the polygon affected by the scaling of the image as stated in state
        Parameters:
        imgData - Input data of the image containing a list of NamedPolygons that are to be recalculated
        state - of the scaled image
        Returns:
        new instance of ImageData containing the recalculated polygons
      • updateCoordinates

        void updateCoordinates​(NamedPolygon poly,
                               double diffX,
                               double diffY)
        Update the coordinates of the polygon by the specified values in x and y direction
        Parameters:
        poly - polygon to be updated
        diffX - difference in x direction
        diffY - difference in y direction
      • updateXCoordinate

        void updateXCoordinate​(NamedPolygon poly,
                               int amount)
        Update the x coordinate of each point within the polygon by amount
        Parameters:
        poly - polygon to be updated
        amount - the X-coordinate is to be translated
      • updateYCoordinate

        void updateYCoordinate​(NamedPolygon poly,
                               int amount)
        Update the y coordinate of each point within the polygon by amount
        Parameters:
        poly - polygon to be updated
        amount - the Y-coordinate is to be translated
      • updateCoordinate

        void updateCoordinate​(NamedPolygon poly,
                              double factor)
        Update the x and y coordinate of each point within the polygon by factor
        Parameters:
        poly - polygon to be updated
        factor - that is to be multiplied with each coordinate