Class JosmImageView

  • All Implemented Interfaces:
    javax.swing.SwingConstants

    public class JosmImageView
    extends javax.swing.text.html.ImageView
    Specialized Image View allowing to display SVG images.
    Since:
    8933
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int HEIGHT_FLAG  
      private java.lang.reflect.Field heightField  
      private java.lang.reflect.Field imageField  
      private static int LOADING_FLAG  
      private static int RELOAD_FLAG  
      private static int RELOAD_IMAGE_FLAG  
      private java.lang.reflect.Field stateField  
      private static int WIDTH_FLAG  
      private java.lang.reflect.Field widthField  
      • Fields inherited from class javax.swing.text.View

        BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
      • Fields inherited from interface javax.swing.SwingConstants

        BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
    • Constructor Summary

      Constructors 
      Constructor Description
      JosmImageView​(javax.swing.text.Element elem)
      Constructs a new JosmImageView.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void doLoadImage()
      Loads the image from the URL getImageURL.
      private void doRefreshImage()
      Loads the image and updates the size accordingly.
      private void doSync()
      Makes sure the necessary properties and image is loaded.
      javax.swing.text.AttributeSet getAttributes()  
      private static java.lang.reflect.Field getDeclaredField​(java.lang.String name)  
      java.awt.Image getImage()  
      float getPreferredSpan​(int axis)  
      void paint​(java.awt.Graphics g, java.awt.Shape a)  
      void setSize​(float width, float height)  
      • Methods inherited from class javax.swing.text.html.ImageView

        changedUpdate, getAlignment, getAltText, getImageURL, getLoadingImageIcon, getLoadsSynchronously, getNoImageIcon, getStyleSheet, getToolTipText, modelToView, setLoadsSynchronously, setParent, setPropertiesFromAttributes, viewToModel
      • Methods inherited from class javax.swing.text.View

        append, breakView, createFragment, forwardUpdate, forwardUpdateToView, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, removeUpdate, replace, updateChildren, updateLayout, viewToModel
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JosmImageView

        public JosmImageView​(javax.swing.text.Element elem)
                      throws java.lang.NoSuchFieldException
        Constructs a new JosmImageView.
        Parameters:
        elem - the element to create a view for
        Throws:
        java.lang.SecurityException - see Class.getDeclaredField(java.lang.String) for details
        java.lang.NoSuchFieldException - see Class.getDeclaredField(java.lang.String) for details
    • Method Detail

      • getDeclaredField

        private static java.lang.reflect.Field getDeclaredField​(java.lang.String name)
                                                         throws java.lang.NoSuchFieldException
        Throws:
        java.lang.NoSuchFieldException
      • doSync

        private void doSync()
        Makes sure the necessary properties and image is loaded.
      • doRefreshImage

        private void doRefreshImage()
                             throws java.lang.IllegalAccessException,
                                    java.lang.reflect.InvocationTargetException,
                                    java.lang.NoSuchMethodException
        Loads the image and updates the size accordingly. This should be invoked instead of invoking loadImage or updateImageSize directly.
        Throws:
        java.lang.IllegalAccessException - see Field.set(java.lang.Object, java.lang.Object) and Method.invoke(java.lang.Object, java.lang.Object...) for details
        java.lang.IllegalArgumentException - see Field.set(java.lang.Object, java.lang.Object) and Method.invoke(java.lang.Object, java.lang.Object...) for details
        java.lang.reflect.InvocationTargetException - see Method.invoke(java.lang.Object, java.lang.Object...) for details
        java.lang.NoSuchMethodException - see Class.getDeclaredMethod(java.lang.String, java.lang.Class<?>...) for details
        java.lang.SecurityException - see Class.getDeclaredMethod(java.lang.String, java.lang.Class<?>...) for details
      • doLoadImage

        private void doLoadImage()
                          throws java.lang.IllegalAccessException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.NoSuchMethodException
        Loads the image from the URL getImageURL. This should only be invoked from refreshImage.
        Throws:
        java.lang.IllegalAccessException - see Field.set(java.lang.Object, java.lang.Object) and Method.invoke(java.lang.Object, java.lang.Object...) for details
        java.lang.IllegalArgumentException - see Field.set(java.lang.Object, java.lang.Object) and Method.invoke(java.lang.Object, java.lang.Object...) for details
        java.lang.reflect.InvocationTargetException - see Method.invoke(java.lang.Object, java.lang.Object...) for details
        java.lang.NoSuchMethodException - see Class.getDeclaredMethod(java.lang.String, java.lang.Class<?>...) for details
        java.lang.SecurityException - see Class.getDeclaredMethod(java.lang.String, java.lang.Class<?>...) for details
      • getImage

        public java.awt.Image getImage()
        Overrides:
        getImage in class javax.swing.text.html.ImageView
      • getAttributes

        public javax.swing.text.AttributeSet getAttributes()
        Overrides:
        getAttributes in class javax.swing.text.html.ImageView
      • paint

        public void paint​(java.awt.Graphics g,
                          java.awt.Shape a)
        Overrides:
        paint in class javax.swing.text.html.ImageView
      • getPreferredSpan

        public float getPreferredSpan​(int axis)
        Overrides:
        getPreferredSpan in class javax.swing.text.html.ImageView
      • setSize

        public void setSize​(float width,
                            float height)
        Overrides:
        setSize in class javax.swing.text.html.ImageView