Class JosmImageView
- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.html.ImageView
-
- org.openstreetmap.josm.gui.widgets.JosmImageView
-
- All Implemented Interfaces:
SwingConstants
public class JosmImageView extends 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 Field
heightField
private Field
imageField
private static int
LOADING_FLAG
private static int
RELOAD_FLAG
private static int
RELOAD_IMAGE_FLAG
private Field
stateField
private static int
WIDTH_FLAG
private 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(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.AttributeSet
getAttributes()
private static Field
getDeclaredField(String name)
Image
getImage()
float
getPreferredSpan(int axis)
void
paint(Graphics g, 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 Field imageField
-
stateField
private final Field stateField
-
widthField
private final Field widthField
-
heightField
private final Field heightField
-
-
Constructor Detail
-
JosmImageView
public JosmImageView(Element elem) throws NoSuchFieldException
Constructs a newJosmImageView
.- Parameters:
elem
- the element to create a view for- Throws:
SecurityException
- seeClass.getDeclaredField(java.lang.String)
for detailsNoSuchFieldException
- seeClass.getDeclaredField(java.lang.String)
for details
-
-
Method Detail
-
getDeclaredField
private static Field getDeclaredField(String name) throws NoSuchFieldException
- Throws:
NoSuchFieldException
-
doSync
private void doSync()
Makes sure the necessary properties and image is loaded.
-
doRefreshImage
private void doRefreshImage() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Loads the image and updates the size accordingly. This should be invoked instead of invokingloadImage
orupdateImageSize
directly.- Throws:
IllegalAccessException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsIllegalArgumentException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsInvocationTargetException
- seeMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsNoSuchMethodException
- seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
for detailsSecurityException
- seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
for details
-
doLoadImage
private void doLoadImage() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Loads the image from the URLgetImageURL
. This should only be invoked fromrefreshImage
.- Throws:
IllegalAccessException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsIllegalArgumentException
- seeField.set(java.lang.Object, java.lang.Object)
andMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsInvocationTargetException
- seeMethod.invoke(java.lang.Object, java.lang.Object...)
for detailsNoSuchMethodException
- seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
for detailsSecurityException
- seeClass.getDeclaredMethod(java.lang.String, java.lang.Class<?>...)
for details
-
getAttributes
public AttributeSet getAttributes()
- Overrides:
getAttributes
in classImageView
-
getPreferredSpan
public float getPreferredSpan(int axis)
- Overrides:
getPreferredSpan
in classImageView
-
-