|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.text.View javax.swing.text.CompositeView javax.swing.text.BoxView edu.northwestern.at.utils.swing.JustifiedTextRowView
public class JustifiedTextRowView
A variant of a BoxView
which knows how to lay out
fully justified styled text.
Field Summary |
---|
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 | |
---|---|
JustifiedTextRowView(javax.swing.text.Element elem)
Create a justified text row view. |
Method Summary | |
---|---|
protected javax.swing.SizeRequirements |
calculateMinorAxisRequirements(int axis,
javax.swing.SizeRequirements r)
Calculates the size requirements for the minor axis. |
protected static int |
containsPaddableSpace(javax.swing.text.View view)
Check if child view contains a paddable space. |
float |
getAlignment(int axis)
Determines the desired alignment for this view along an axis. |
javax.swing.text.AttributeSet |
getAttributes()
Get attributes for this view. |
protected static java.lang.String |
getDocumentTextForView(javax.swing.text.View view)
Get document text contained in a view. |
int |
getEndOffset()
Get end of portion of the model for which this view is responsible. |
short |
getLeftInset()
Override to make getLeftInset public. |
float |
getMaximumSpan(int axis)
Determine maximum span for this view along an axis. |
float |
getMinimumSpan(int axis)
Determine minimum span for this view along an axis. |
protected int[] |
getPadPixels(int space,
int viewsWithBlanks,
int direction)
Determine distribution of pad pixels for text justification. |
float |
getPreferredSpan(int axis)
Determine preferred span for this view along an axis. |
short |
getRightInset()
Override to make getRightInset public. |
int |
getRowNumber()
Get row number for this view. |
int |
getStartOffset()
Get start of portion of the model for which this view is responsible. |
short |
getTopInset()
Override to make getTopInset public. |
protected int |
getViewIndexAtPosition(int pos)
Get child view index representing the given position in the model. |
protected void |
layoutMajorAxis(int targetSpan,
int axis,
int[] offsets,
int[] spans)
Perform layout for the major axis of the box. |
protected void |
layoutMinorAxis(int targetSpan,
int axis,
int[] offsets,
int[] spans)
Perform layout for the minor axis of the box. |
protected void |
loadChildren(javax.swing.text.ViewFactory f)
Load child views. |
java.awt.Shape |
modelToView(int pos,
java.awt.Shape a,
javax.swing.text.Position.Bias b)
Map from document model coordinate space to coordinate space of the view mapped to it. |
void |
setInsets(short topInset,
short leftInset,
short bottomInset,
short rightInset)
Override to make setInsets public. |
void |
setRowNumber(int rowNumber)
Set row number of this view. |
Methods inherited from class javax.swing.text.BoxView |
---|
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAxis, getChildAllocation, getHeight, getOffset, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, paint, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModel |
Methods inherited from class javax.swing.text.CompositeView |
---|
getBottomInset, getInsideAllocation, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getView, getViewAtPosition, getViewCount, getViewIndex, modelToView, setParagraphInsets, setParent |
Methods inherited from class javax.swing.text.View |
---|
append, breakView, changedUpdate, createFragment, forwardUpdateToView, getBreakWeight, getContainer, getDocument, getElement, getGraphics, getParent, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, remove, removeAll, removeUpdate, updateChildren, updateLayout, viewToModel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
JustifiedTextRowView(javax.swing.text.Element elem)
elem
- The text line element for which to
create a view. Method Detail |
---|
protected javax.swing.SizeRequirements calculateMinorAxisRequirements(int axis, javax.swing.SizeRequirements r)
calculateMinorAxisRequirements
in class javax.swing.text.BoxView
axis
- The axis being studied.r
- The SizeRequirements
object;
if null
one will be created.
SizeRequirements
object.SizeRequirements
protected static int containsPaddableSpace(javax.swing.text.View view)
view
- The view.
public float getAlignment(int axis)
getAlignment
in class javax.swing.text.BoxView
axis
- May be either View.X_AXIS
or View.Y_AXIS
.
java.lang.IllegalArgumentException
- for an invalid axis . public javax.swing.text.AttributeSet getAttributes()
getAttributes
in class javax.swing.text.View
public int getEndOffset()
getEndOffset
in class javax.swing.text.View
public short getLeftInset()
getLeftInset
in class javax.swing.text.CompositeView
public float getMaximumSpan(int axis)
getMaximumSpan
in class javax.swing.text.BoxView
axis
- Either View.X_AXIS
or
View.Y_AXIS
.
public float getMinimumSpan(int axis)
getMinimumSpan
in class javax.swing.text.BoxView
axis
- Either View.X_AXIS
or
View.Y_AXIS
.
protected int[] getPadPixels(int space, int viewsWithBlanks, int direction)
space
- The number of pad pixels required
to justify a text line.viewsWithBlanks
- The number of views with paddable
blanks to which we can allocate
pad pixels.direction
- = 0: Pad lefthand spaces
more heavily
= 1: Pad righthand spaces
more heavily.
Successive lines of displayed text alternate between direction=0 and direction=1 . This helps to even out the appearance of the padding by having it on the left end on one line and the right end on the next.
public float getPreferredSpan(int axis)
getPreferredSpan
in class javax.swing.text.BoxView
axis
- Either View.X_AXIS
or
View.Y_AXIS
.
public short getRightInset()
getRightInset
in class javax.swing.text.CompositeView
public int getRowNumber()
public int getStartOffset()
getStartOffset
in class javax.swing.text.View
public short getTopInset()
getTopInset
in class javax.swing.text.CompositeView
protected int getViewIndexAtPosition(int pos)
getViewIndexAtPosition
in class javax.swing.text.CompositeView
pos
- The position >= 0 .
protected static java.lang.String getDocumentTextForView(javax.swing.text.View view)
view
- The view.
protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
layoutMajorAxis
in class javax.swing.text.BoxView
targetSpan
- The total span given to the view, which
should be used to layout the children.axis
- The axis being layed out.offsets
- The offsets from the origin of the view
for each of the child views.
This is a return value and is
filled in here.spans
- The span of each child view.
This is a return
value and is filled in here.
The offset and span for each child view is stored in the offsets and spans parameters.
This is where the actual text justification occurs. Left, center, and right alignment are handled by the superclass in the usual fashion. The superclass is set up to treat full alignment the same as left alignment.
Once the text has been left aligned, this method determines how many extra pixels (if any) are needed to fully justify each line. Those pixels are distributed as evenly as possible to the existing blank spaces in the text. This results in fully justified text.
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
layoutMinorAxis
in class javax.swing.text.BoxView
targetSpan
- The total span given to the view, which
should be used to layout the children.axis
- The axis being layed out.offsets
- The offsets from the origin of the view
for each of the child views.
This is a return value and is
filled in here.spans
- The span of each child view.
This is a return
value and is filled in here.
The offset and span for each child view is stored in the offsets and spans parameters.
protected void loadChildren(javax.swing.text.ViewFactory f)
loadChildren
in class javax.swing.text.CompositeView
public java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b) throws javax.swing.text.BadLocationException
modelToView
in class javax.swing.text.BoxView
pos
- The position to convert >= 0.a
- The allocated region to render into.b
- The position bias value of either
Position.Bias.Forward
or
Position.Bias.Backward
.
javax.swing.text.BadLocationException
- If the given position does
not represent a valid location in the
associated document. public void setInsets(short topInset, short leftInset, short bottomInset, short rightInset)
setInsets
in class javax.swing.text.CompositeView
public void setRowNumber(int rowNumber)
rowNumber
- The row number of this view.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |