Class HTMLHelper.Renderer
- java.lang.Object
-
- javax.swing.text.View
-
- com.nomagic.magicdraw.uml.symbols.shapes.html.HTMLHelper.Renderer
-
- All Implemented Interfaces:
javax.swing.SwingConstants
- Enclosing class:
- HTMLHelper
static class HTMLHelper.Renderer extends javax.swing.text.ViewRoot text view that acts as an HTML renderer.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static javax.swing.JTextPaneCONTAINERprivate javax.swing.text.ViewFactoryfactoryprivate javax.swing.text.Viewview
-
Constructor Summary
Constructors Constructor Description Renderer(javax.swing.text.ViewFactory f, javax.swing.text.View v)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetAlignment(int axis)Determines the desired alignment for this view along an axis.javax.swing.text.AttributeSetgetAttributes()Fetches the attributes to use when rendering.java.awt.ContainergetContainer()Fetches the container hosting the view.javax.swing.text.DocumentgetDocument()Returns the document model underlying the view.javax.swing.text.ElementgetElement()Gets the element that this view is mapped to.intgetEndOffset()Returns the ending offset into the model for this view.floatgetMaximumSpan(int axis)Determines the maximum span for this view along an axis.floatgetMinimumSpan(int axis)Determines the minimum span for this view along an axis.floatgetPreferredSpan(int axis)Determines the preferred span for this view along an axis.intgetStartOffset()Returns the starting offset into the model for this view.javax.swing.text.ViewgetView(int n)Gets the n-th view in this container.intgetViewCount()Returns the number of views in this view.javax.swing.text.ViewFactorygetViewFactory()Fetches the factory to be used for building the various view fragments that make up the view that represents the model.java.awt.ShapemodelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b)Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.java.awt.ShapemodelToView(int p0, javax.swing.text.Position.Bias b0, int p1, javax.swing.text.Position.Bias b1, java.awt.Shape a)Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.voidpaint(java.awt.Graphics g, java.awt.Shape allocation)Renders the view.voidpreferenceChanged(javax.swing.text.View child, boolean width, boolean height)Specifies that a preference has changed.voidsetParent(javax.swing.text.View parent)Sets the view parent.voidsetSize(float width, float height)Sets the view size.intviewToModel(float x, float y, java.awt.Shape a, javax.swing.text.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, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getBreakWeight, getChildAllocation, getGraphics, getNextVisualPositionFrom, getParent, getResizeWeight, getToolTipText, getViewIndex, getViewIndex, insert, insertUpdate, isVisible, modelToView, remove, removeAll, removeUpdate, replace, updateChildren, updateLayout, viewToModel
-
-
-
-
Method Detail
-
getAttributes
@CheckForNull public javax.swing.text.AttributeSet getAttributes()
Fetches the attributes to use when rendering. At the root level there are no attributes. If an attribute is resolved up the view hierarchy this is the end of the line.- Overrides:
getAttributesin classjavax.swing.text.View
-
getPreferredSpan
public float getPreferredSpan(int axis)
Determines the preferred span for this view along an axis.- Specified by:
getPreferredSpanin classjavax.swing.text.View- Parameters:
axis- may be either X_AXIS or Y_AXIS- Returns:
- the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
-
getMinimumSpan
public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis.- Overrides:
getMinimumSpanin classjavax.swing.text.View- Parameters:
axis- may be either X_AXIS or Y_AXIS- Returns:
- the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
-
getMaximumSpan
public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.- Overrides:
getMaximumSpanin classjavax.swing.text.View- Parameters:
axis- may be either X_AXIS or Y_AXIS- Returns:
- the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
-
preferenceChanged
public void preferenceChanged(javax.swing.text.View child, boolean width, boolean height)Specifies that a preference has changed. Child views can call this on the parent to indicate that the preference has changed. The root view routes this to invalidate on the hosting component. This can be called on a different thread from the event dispatching thread and is basically unsafe to propagate into the component. To make this safe, the operation is transferred over to the event dispatching thread for completion. It is a design goal that all view methods be safe to call without concern for concurrency, and this behavior helps make that true.- Overrides:
preferenceChangedin classjavax.swing.text.View- Parameters:
child- the child viewwidth- true if the width preference has changedheight- true if the height preference has changed
-
getAlignment
public float getAlignment(int axis)
Determines the desired alignment for this view along an axis.- Overrides:
getAlignmentin classjavax.swing.text.View- Parameters:
axis- may be either X_AXIS or Y_AXIS- Returns:
- the desired alignment, where 0.0 indicates the origin and 1.0 the full span away from the origin
-
paint
public void paint(java.awt.Graphics g, java.awt.Shape allocation)Renders the view.- Specified by:
paintin classjavax.swing.text.View- Parameters:
g- the graphics contextallocation- the region to render into
-
setParent
public void setParent(javax.swing.text.View parent)
Sets the view parent.- Overrides:
setParentin classjavax.swing.text.View- Parameters:
parent- the parent view
-
getViewCount
public int getViewCount()
Returns the number of views in this view. Since this view simply wraps the root of the view hierarchy it has exactly one child.- Overrides:
getViewCountin classjavax.swing.text.View- Returns:
- the number of views
- See Also:
getView(int)
-
getView
public javax.swing.text.View getView(int n)
Gets the n-th view in this container.- Overrides:
getViewin classjavax.swing.text.View- Parameters:
n- the number of the view to get- Returns:
- the view
-
modelToView
public java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b) throws javax.swing.text.BadLocationExceptionProvides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.- Specified by:
modelToViewin classjavax.swing.text.View- Parameters:
pos- the position to converta- the allocated region to render into- Returns:
- the bounding box of the given position
- Throws:
javax.swing.text.BadLocationException
-
modelToView
public java.awt.Shape modelToView(int p0, javax.swing.text.Position.Bias b0, int p1, javax.swing.text.Position.Bias b1, java.awt.Shape a) throws javax.swing.text.BadLocationExceptionProvides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.- Overrides:
modelToViewin classjavax.swing.text.View- Parameters:
p0- the position to convert >= 0b0- the bias toward the previous character or the next character represented by p0, in case the position is a boundary of two views.p1- the position to convert >= 0b1- the bias toward the previous character or the next character represented by p1, in case the position is a boundary of two views.a- the allocated region to render into- Returns:
- the bounding box of the given position is returned
- Throws:
javax.swing.text.BadLocationException- if the given position does not represent a valid location in the associated documentjava.lang.IllegalArgumentException- for an invalid bias argument- See Also:
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
-
viewToModel
public int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] bias)Provides a mapping from the view coordinate space to the logical coordinate space of the model.- Specified by:
viewToModelin classjavax.swing.text.View- Parameters:
x- x coordinate of the view location to converty- y coordinate of the view location to converta- the allocated region to render into- Returns:
- the location within the model that best represents the given point in the view
-
getDocument
public javax.swing.text.Document getDocument()
Returns the document model underlying the view.- Overrides:
getDocumentin classjavax.swing.text.View- Returns:
- the model
-
getStartOffset
public int getStartOffset()
Returns the starting offset into the model for this view.- Overrides:
getStartOffsetin classjavax.swing.text.View- Returns:
- the starting offset
-
getEndOffset
public int getEndOffset()
Returns the ending offset into the model for this view.- Overrides:
getEndOffsetin classjavax.swing.text.View- Returns:
- the ending offset
-
getElement
public javax.swing.text.Element getElement()
Gets the element that this view is mapped to.- Overrides:
getElementin classjavax.swing.text.View- Returns:
- the view
-
setSize
public void setSize(float width, float height)Sets the view size.- Overrides:
setSizein classjavax.swing.text.View- Parameters:
width- the widthheight- the height
-
getContainer
public java.awt.Container getContainer()
Fetches the container hosting the view. This is useful for things like scheduling a repaint, finding out the host components font, etc. The default implementation of this is to forward the query to the parent view.- Overrides:
getContainerin classjavax.swing.text.View- Returns:
- the container
-
getViewFactory
public javax.swing.text.ViewFactory getViewFactory()
Fetches the factory to be used for building the various view fragments that make up the view that represents the model. This is what determines how the model will be represented. This is implemented to fetch the factory provided by the associated EditorKit.- Overrides:
getViewFactoryin classjavax.swing.text.View- Returns:
- the factory
-
-