Module org.jcommon

Class JImagePanel

    • Constructor Detail

      • JImagePanel

        public JImagePanel()
        Create a new image panel.
      • JImagePanel

        public JImagePanel​(BufferedImage image)
        Create a new image panel that display the given image.
        Parameters:
        image - the image to display.
    • Method Detail

      • isRendering

        public boolean isRendering()
        Check if the panel is actually refreshing image and features.
        Returns:
        true if the panel is actually refreshing image and features and false otherwise.
      • isAutoRepaint

        public boolean isAutoRepaint()
        Get if the panel is using auto repaint. If the auto repaint mode is activated, the panel will repaint every time a modification is made to the displayed object (image, features) or to the view (scale, translation, ...). This mode is not convenient if many modification has to be made before a display refresh. In this case, it is recommended to set the auto repaint to false and to call Component.repaint() when all modifications are done.
        Returns:
        true if the panel has to auto repaint and false otherwise.
        See Also:
        setAutoRepaint(boolean)
      • setAutoRepaint

        public void setAutoRepaint​(boolean auto)
        Set if the panel has to do auto repaint. If the auto repaint mode is activated, the panel will repaint every time a modification is made to the displayed object (image, features) or to the view (scale, translation, ...). This mode is not convenient if many modification has to be made before a display refresh. In this case, it is recommended to set the auto repaint to false and to call Component.repaint() when all modifications are done.
        Parameters:
        auto - true if the panel has to auto repaint and false otherwise.
        See Also:
        isAutoRepaint()
      • isAutoFit

        public boolean isAutoFit()
        Get if the panel fits the view when its resized.
        Returns:
        true if the panel fits the view when its resized and false otherwise.
        See Also:
        setAutoFit(boolean), fit()
      • setAutoFit

        public void setAutoFit​(boolean autoFit)
        Set if the panel has to fit the view when its resized.
        Parameters:
        autoFit - true if the panel fits the view when its resized and false otherwise.
        See Also:
        isAutoFit(), fit()
      • setImage

        public void setImage​(BufferedImage image)
        Set the image to display within the panel.
        Parameters:
        image - the image to display within the panel.
        See Also:
        getImage()
      • getScale

        public double getScale()
        Get the current scale factor of the panel view.
        Returns:
        the current scale factor of the panel view.
        See Also:
        setScale(double), getTranslation()
      • setScale

        public void setScale​(double zoom)
        Set the scale factor to apply to the panel view.
        Parameters:
        zoom - the current scale factor of the panel view.
        See Also:
        getScale(), setTranslation(Point2D)
      • setTranslation

        public void setTranslation​(Point2D translation)
        Set the translation to apply to the view.
        Parameters:
        translation - the translation to apply to the view as a 2D point.
        See Also:
        getTranslation(), setScale(double)
      • fit

        public void fit()
        Fit the view in order to display the whole image. This method update the view transformation (scale, translation) in order to make the whole image visible.
      • isLayerDisplayed

        public boolean isLayerDisplayed​(String layer)
        Check if the given layer is displayed. If this method return true, then the features that are within the layer are visible on the image panel.
        Parameters:
        layer - the layer to check.
        Returns:
        true if the layer is displayed and false otherwise.
        See Also:
        setLayerDisplayed(String, boolean)
      • setLayerDisplayed

        public void setLayerDisplayed​(String layer,
                                      boolean displayed)
        Set if the given layer has to be displayed.
        Parameters:
        layer - the layer to check.
        displayed - true if the layer has to be displayed and false otherwise.
      • getImageFeatures

        public List<JImageFeature> getImageFeatures​(String layer)
        Get the image features contained within the specified layer attached to this panel.
        Parameters:
        layer - the layer of the features.
        Returns:
        the image features attached to this panel and null if the layer is empty or does not exists.
        See Also:
        setImageFeatures(String, List)
      • setImageFeatures

        public void setImageFeatures​(String layer,
                                     List<JImageFeature> features)
        Set the image features to attach to this panel within the specified layer. If the layer does not exist, it is created. In this case, the layer will not be displayed until a call to setLayerDisplayed(layer, true). If the layer exists, all previous existing features are deleted.
        Parameters:
        layer - the layer of the features.
        features - the image features attached to attach to this panel.
        See Also:
        getImageFeatures(String)
      • getImageCoordinate

        public Point2D getImageCoordinate​(int x,
                                          int y)
        Get the coordinate within the image referential of the point located at (x, y) on the panel component.
        Parameters:
        x - the x coordinate of the point on the panel component.
        y - the y coordinate of the point on the panel component.
        Returns:
        the coordinate within the image of the point located at (x, y) on the panel component.
        See Also:
        getViewCoordinate(float, float)
      • getViewCoordinate

        public Point2D getViewCoordinate​(float x,
                                         float y)
        Get the coordinate within the view referential of the point located at (x, y) on the image.
        Parameters:
        x - the x coordinate of the point on the image.
        y - the y coordinate of the point on the image.
        Returns:
        the coordinate within the view referential of the point located at (x, y) on the image.
        See Also:
        getImageCoordinate(int, int)