public class IconView extends View
Icon decorator that implements the view interface. The entire element is used to represent the icon. This acts as a gateway from the display-only View implementations to interactive lightweight icons (that is, it allows icons to be embedded into the View hierarchy. The parent of the icon is the container that is handed out by the associated view factory.
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
public IconView(Element elem)
Creates a new icon view that represents an element.
elem
- the element to create a view forpublic void paint(Graphics g, Shape a)
Paints the icon. The real paint behavior occurs naturally from the association that the icon has with its parent container (the same container hosting this view), so this simply allows us to position the icon properly relative to the view. Since the coordinate system for the view is simply the parent containers, positioning the child icon is easy.
paint
in class View
g
- the rendering surface to usea
- the allocated region to render intoView.paint(java.awt.Graphics, java.awt.Shape)
public float getPreferredSpan(int axis)
Determines the preferred span for this view along an axis.
getPreferredSpan
in class View
axis
- may be either View.X_AXIS or View.Y_AXISIllegalArgumentException
- for an invalid axisView.getPreferredSpan(int)
public float getAlignment(int axis)
Determines the desired alignment for this view along an axis. This is implemented to give the alignment to the bottom of the icon along the y axis, and the default along the x axis.
getAlignment
in class View
axis
- may be either View.X_AXIS or View.Y_AXISpublic Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
modelToView
in class View
pos
- the position to convert >= 0a
- the allocated region to render intob
- the bias toward the previous character or the next character represented by the offset, in case the position is a boundary of two views; b
will have one of these values: Position.Bias.Forward
Position.Bias.Backward
BadLocationException
- if the given position does not represent a valid location in the associated documentView.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)
public 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.
viewToModel
in class View
x
- the X coordinate >= 0y
- the Y coordinate >= 0a
- the allocated region to render intoView.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.