|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.whatswrong.TokenLayout
public class TokenLayout
A TokenLayout object lays out a collection of tokens in sequence by placing a stack of property values of each token at a position corresponding to the index of the token. The order in which the property values are stacked depends on the level of each corresponding property. The first property (with highest level) is rendered in black while the remaining property values are rendered in gray.
Note that the TokenLayout remembers the bounds of each token property stack and the text layout of each property
value. This can be handy when other layouts (e.g., DependencyLayout
) want to
connect the tokens.
Constructor Summary | |
---|---|
TokenLayout()
|
Method Summary | |
---|---|
java.util.Map<Token,Bounds1D> |
estimateTokenBounds(NLPInstance instance,
java.util.Map<Token,java.lang.Integer> tokenWidths,
java.awt.Graphics2D g2d)
Method estimateTokenBounds calculates the horizontal bounds of each token in the layout of the tokens. |
int |
getBaseline()
Gets the y value at which the token layout should start. |
java.awt.geom.Rectangle2D |
getBounds(Token vertex)
Gets the bounds of the property value stack of the given token. |
int |
getFromSplitPoint()
Returns the index of the first split point from which the token layout starts to render or -1 if it begins from the start of the token sequence. |
int |
getHeight()
Gets the total height of this TokenLayout (covering all token stacks). |
int |
getMargin()
Returns the margin between token stacks. |
java.awt.font.TextLayout |
getPropertyTextLayout(Token vertex,
int index)
Returns the text layout for a given property and property index in the stack. |
int |
getRowHeight()
Gets the height of each property value row in the stack. |
int |
getToSplitPoint()
Returns the index of the the split point at which the token renderer should stop rendering the token sequence. |
int |
getWidth()
Gets the total width of this TokenLayout (covering all token stacks). |
java.awt.Dimension |
layout(NLPInstance instance,
java.util.Map<Token,java.lang.Integer> tokenWidths,
java.awt.Graphics2D g2d)
Lays out all tokens in the given collection as stacks of property values that are placed next to each other according the order of the tokens (as indicated by their indices). |
void |
setBaseline(int baseline)
Sets the y value at which the token layout should start. |
void |
setFromSplitPoint(int fromSplitPoint)
Sets the first split point from which the token layout starts to render or -1 if it begins from the start of the token sequence. |
void |
setMargin(int margin)
Sets the margin between token stacks. |
void |
setRowHeight(int rowHeight)
Sets the height of each property value row in the stack. |
void |
setToSplitPoint(int toSplitPoint)
Returns the index of the the split point at which the token renderer should stop rendering the token sequence. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TokenLayout()
Method Detail |
---|
public void setRowHeight(int rowHeight)
rowHeight
- the height of each property value row in the stack.public void setBaseline(int baseline)
baseline
- the y value at which the token layout should start.public int getFromSplitPoint()
public void setFromSplitPoint(int fromSplitPoint)
fromSplitPoint
- the index of the first split point or -1 if renderering should happen from the beginning of
the token sequence.public int getToSplitPoint()
public void setToSplitPoint(int toSplitPoint)
toSplitPoint
- the index of split point at which the renderer stops or -1 if renderering goes to the end of
the token sequence.public void setMargin(int margin)
margin
- the margin between token stacks.public int getRowHeight()
public int getBaseline()
public int getMargin()
public java.util.Map<Token,Bounds1D> estimateTokenBounds(NLPInstance instance, java.util.Map<Token,java.lang.Integer> tokenWidths, java.awt.Graphics2D g2d)
instance
- the NLPInstance to layout.tokenWidths
- A map that defines some minomal widths for each token. The estimated bounds will fulfill the
width requirements specified by this map. If a token has no required width its estimated width
will be based on the length of its textual properties.g2d
- The graphics object to render to.
public java.awt.Dimension layout(NLPInstance instance, java.util.Map<Token,java.lang.Integer> tokenWidths, java.awt.Graphics2D g2d)
After this method has been called the properties of the layout (height, width, bounding boxes of token stacks and text layouts of each property value) can be queried by calling the appropriate get methods.
instance
- the NLPInstance to layout.tokenWidths
- if some tokens need extra space (for example because they have self loops in a DependencyLayout
) the space they need can be provided through this
map.g2d
- the graphics object to draw to.
public java.awt.font.TextLayout getPropertyTextLayout(Token vertex, int index)
vertex
- the token for which we want the text layout of a propery of it.index
- the index of the property in the stack.
index
of the stack for the token
vertex
public java.awt.geom.Rectangle2D getBounds(Token vertex)
vertex
- the token for which to get the bounds for.
public int getWidth()
public int getHeight()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |