Class CropDialog

    • Constructor Detail

      • CropDialog

        public CropDialog​(Frame owner,
                          Strings strings,
                          int width,
                          int height)
        Parameters:
        owner - the Frame this dialog will belong to
        strings - Strings resource to be used for text messages
        width - width of the original image, before cropping; this is used to determine the valid values for left and right column, from 0 to width - 1
        height - height of the original image, before cropping; this is used to determine the valid values for top and bottom row, from 0 to height - 1
    • Method Detail

      • actionPerformed

        public void actionPerformed​(ActionEvent e)
        Hides (closes) this dialog if the OK button was source of the action event (e.g. if the button was pressed).
        Specified by:
        actionPerformed in interface ActionListener
      • getValue

        private int getValue​(TextComponent textField)
        Attempts to convert the content of the argument text component to an int; if successful, returns that int, otherwise -1 is returned.
        Parameters:
        textField - the text component that is supposed to hold an int value
        Returns:
        int representation of the text component's data
      • getWidth

        public int getWidth()
        Returns the width of the to-be-cropped image as given by the current values in the text fields for left column and right column. Computes the width from those values and returns it or returns -1 if the data in the text fields is not valid for some reason.
        Overrides:
        getWidth in class Component
        Returns:
        width of cropped image or -1 if information is invalid
      • getX1

        public int getX1()
      • getX2

        public int getX2()
      • getY1

        public int getY1()
      • getY2

        public int getY2()
      • hasPressedOk

        public boolean hasPressedOk()
      • updateLabels

        private void updateLabels()
        Computes width and height of new image and updates the corresponding labels. The labels will either display width and height or a single dash if the data in the text fields is invalid.