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 intHEIGHT_FLAGprivate java.lang.reflect.FieldheightFieldprivate java.lang.reflect.FieldimageFieldprivate static intLOADING_FLAGprivate static intRELOAD_FLAGprivate static intRELOAD_IMAGE_FLAGprivate java.lang.reflect.FieldstateFieldprivate static intWIDTH_FLAGprivate java.lang.reflect.FieldwidthField
-
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 voiddoLoadImage()Loads the image from the URLgetImageURL.private voiddoRefreshImage()Loads the image and updates the size accordingly.private voiddoSync()Makes sure the necessary properties and image is loaded.javax.swing.text.AttributeSetgetAttributes()private static java.lang.reflect.FieldgetDeclaredField(java.lang.String name)java.awt.ImagegetImage()floatgetPreferredSpan(int axis)voidpaint(java.awt.Graphics g, java.awt.Shape a)voidsetSize(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 invokingloadImageorupdateImageSizedirectly.- 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:
getImagein classjavax.swing.text.html.ImageView
-
getAttributes
public javax.swing.text.AttributeSet getAttributes()
- Overrides:
getAttributesin classjavax.swing.text.html.ImageView
-
paint
public void paint(java.awt.Graphics g, java.awt.Shape a)
- Overrides:
paintin classjavax.swing.text.html.ImageView
-
getPreferredSpan
public float getPreferredSpan(int axis)
- Overrides:
getPreferredSpanin classjavax.swing.text.html.ImageView
-
setSize
public void setSize(float width, float height)
- Overrides:
setSizein classjavax.swing.text.html.ImageView
-
-