Class JosmImageView
- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.html.ImageView
-
- org.openstreetmap.josm.gui.widgets.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
-
Constructor Summary
Constructors Constructor Description JosmImageView(javax.swing.text.Element elem)
Constructs a newJosmImageView
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
doLoadImage()
Loads the image from the URLgetImageURL
.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
-
-
-
-
Field Detail
-
LOADING_FLAG
private static final int LOADING_FLAG
- See Also:
- Constant Field Values
-
WIDTH_FLAG
private static final int WIDTH_FLAG
- See Also:
- Constant Field Values
-
HEIGHT_FLAG
private static final int HEIGHT_FLAG
- See Also:
- Constant Field Values
-
RELOAD_FLAG
private static final int RELOAD_FLAG
- See Also:
- Constant Field Values
-
RELOAD_IMAGE_FLAG
private static final int RELOAD_IMAGE_FLAG
- See Also:
- Constant Field Values
-
imageField
private final java.lang.reflect.Field imageField
-
stateField
private final java.lang.reflect.Field stateField
-
widthField
private final java.lang.reflect.Field widthField
-
heightField
private final java.lang.reflect.Field heightField
-
-
Constructor Detail
-
JosmImageView
public JosmImageView(javax.swing.text.Element elem) throws java.lang.NoSuchFieldException
Constructs a newJosmImageView
.- Parameters:
elem
- the element to create a view for- Throws:
java.lang.SecurityException
- seeClass.getDeclaredField(java.lang.String)
for detailsjava.lang.NoSuchFieldException
- seeClass.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 invokingloadImage
orupdateImageSize
directly.- Throws:
java.lang.IllegalAccessException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsjava.lang.IllegalArgumentException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsjava.lang.reflect.InvocationTargetException
- seeMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsjava.lang.NoSuchMethodException
- seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
for detailsjava.lang.SecurityException
- seeClass.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 URLgetImageURL
. This should only be invoked fromrefreshImage
.- Throws:
java.lang.IllegalAccessException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsjava.lang.IllegalArgumentException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsjava.lang.reflect.InvocationTargetException
- seeMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsjava.lang.NoSuchMethodException
- seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
for detailsjava.lang.SecurityException
- seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
for details
-
getImage
public java.awt.Image getImage()
- Overrides:
getImage
in classjavax.swing.text.html.ImageView
-
getAttributes
public javax.swing.text.AttributeSet getAttributes()
- Overrides:
getAttributes
in classjavax.swing.text.html.ImageView
-
paint
public void paint(java.awt.Graphics g, java.awt.Shape a)
- Overrides:
paint
in classjavax.swing.text.html.ImageView
-
getPreferredSpan
public float getPreferredSpan(int axis)
- Overrides:
getPreferredSpan
in classjavax.swing.text.html.ImageView
-
setSize
public void setSize(float width, float height)
- Overrides:
setSize
in classjavax.swing.text.html.ImageView
-
-