|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.text.View jwo.utils.gui.html.ImprovedImageView
Customised image viewer for use by an HTML editor kit. This one handles the display of relative image URLs more flexibly than the default. Based on the JavaWorld Tip 109 by Rob Kenworthy.
Field Summary | |
static String |
ABSMIDDLE
Indicates absolute centre alignment of image. |
static String |
BOTTOM
Indicates bottom alignment of image. |
static String |
CENTER
Indicates centre alignment of image. |
static String |
MIDDLE
Indicates centre alignment of image. |
static String |
TEXTTOP
Indicates top alignment of image text. |
static String |
TOP
Indicates top alignment of image. |
Fields inherited from class javax.swing.text.View |
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Fields inherited from interface javax.swing.SwingConstants |
EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TRAILING, VERTICAL, WEST |
Constructor Summary | |
ImprovedImageView(Element elem)
Creates a new view that represents an IMG element. |
Method Summary | |
void |
changedUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
Responds to a change in the document. |
float |
getAlignment(int axis)
Determines the desired alignment for this view along an axis. |
AttributeSet |
getAttributes()
Fetches the attributes to use when rendering. |
protected Color |
getHighlightColor()
Reports the text editor's highlight colour. |
float |
getPreferredSpan(int axis)
Determines the preferred span for this view along an axis. |
protected int |
getSelectionState()
Determines whether the image is selected, and if it's the only thing selected. |
protected StyleSheet |
getStyleSheet()
Reports the style sheet used by the component for HTML viewing. |
boolean |
imageUpdate(Image img,
int flags,
int x,
int y,
int width,
int height)
Allows progressive display of images. |
protected boolean |
isEditable()
Reports whether the view is editable. |
Shape |
modelToView(int pos,
Shape a,
Position.Bias b)
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
void |
mouseClicked(MouseEvent e)
On double-click, open image properties dialogue. |
void |
mouseDragged(MouseEvent e)
Resize image if initial click was in grow-box: Mouse event logging mouse drag. |
void |
mouseEntered(MouseEvent e)
Ignores mouse entry events. |
void |
mouseExited(MouseEvent e)
Ignores mouse exit events. |
void |
mouseMoved(MouseEvent e)
Ignores mouse movement events. |
void |
mousePressed(MouseEvent e)
Select or grow image when clicked. |
void |
mouseReleased(MouseEvent e)
Stops image being resized when mouse released. |
void |
paint(Graphics g,
Shape a)
Draws the image. |
protected void |
repaint(long delay)
Request that this view be repainted. |
protected void |
resize(int width,
int height)
Change the size of this image. |
void |
setParent(View parent)
Establishes the parent view for this view. |
void |
setSize(float width,
float height)
Sets the size of the view, but ignored in this case. |
int |
viewToModel(float x,
float y,
Shape a,
Position.Bias[] bias)
Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
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, getToolTipText, 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 |
Field Detail |
public static final String TOP
public static final String TEXTTOP
public static final String MIDDLE
public static final String ABSMIDDLE
public static final String CENTER
public static final String BOTTOM
Constructor Detail |
public ImprovedImageView(Element elem)
elem
- The element to create a view forMethod Detail |
public AttributeSet getAttributes()
public void setParent(View parent)
parent
- Parent view to use.public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
e
- Document event logging change.a
- Shape holding new view.f
- View factory.public void paint(Graphics g, Shape a)
g
- the rendering surface to usea
- the allocated region to render intoView.paint(java.awt.Graphics, java.awt.Shape)
protected void repaint(long delay)
delay
- before repainting (in milliseconds).protected int getSelectionState()
protected boolean isEditable()
protected Color getHighlightColor()
public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height)
imageUpdate
in interface ImageObserver
img
- Image to update.flags
- Image loading flags.x
- x-location of image.y
- y-location of image.width
- Width of image.height
- Height of image.public float getPreferredSpan(int axis)
axis
- may be either X_AXIS or Y_AXIS
public float getAlignment(int axis)
axis
- may be either X_AXIS or Y_AXIS
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
pos
- the position to converta
- the allocated region to render into
BadLocationException
- If the given position does not represent a
valid location in the associated documentView.modelToView(int, java.awt.Shape)
public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)
x
- the X coordinatey
- the Y coordinatea
- the allocated region to render into
View.viewToModel(float, float, java.awt.Shape)
public void setSize(float width, float height)
width
- the widthheight
- the heightprotected void resize(int width, int height)
width
- New width of image.height
- New height of image.public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
e
- Mouse event logging mouse press.public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
e
- Mouse release event.public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
e
- Mouse click event.public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
e
- Mouse event (ignored).public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
e
- Mouse event (ignored).public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
e
- Mouse event (ignored).protected StyleSheet getStyleSheet()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |