org.deft.extension.tools.astlayouter
Class ASTLayout

java.lang.Object
  extended by org.deft.extension.tools.astlayouter.ASTLayout

public class ASTLayout
extends java.lang.Object

Representation of the complete layout behind a AST.

Author:
Martin Heinzerling

Constructor Summary
ASTLayout(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)
           
 
Method Summary
 TokenLine getLine(int line)
           
 TokenLine getLine(org.deft.repository.ast.Token t)
           
 java.lang.Integer getNextValidLine(int current)
           
 int getPreviousRealLine(int current)
           
 java.lang.Integer getPreviousValidLine(int current)
           
 int lastLine()
           
 void moveCol(int selectedLine, int offset)
          Moves a line in horizontal direction.
 void moveLinesAfterLine(int targetLine, int offset)
          Moves tokens after a line by a given line offset.
 void moveLinesBeginningByToken(org.deft.repository.ast.Token token, int offset)
          Moves tokens by a given line offset.
 void reload(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)
          Reloads a AST (i.e. after modification) without recalculating the line break width.
 void repairOffset()
          Recalculates the offset of each token in the layout.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ASTLayout

public ASTLayout(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)
Method Detail

reload

public void reload(java.util.List<org.deft.repository.ast.TokenNode> tokenNodes)
Reloads a AST (i.e. after modification) without recalculating the line break width.

Parameters:
tokenNodes - serialized AST

repairOffset

public void repairOffset()
Recalculates the offset of each token in the layout. Recommended after last operation.


getLine

public TokenLine getLine(int line)
Parameters:
line - line index
Returns:
TokenLine

getLine

public TokenLine getLine(org.deft.repository.ast.Token t)
Parameters:
t - in line
Returns:
TokenLine

getNextValidLine

public java.lang.Integer getNextValidLine(int current)
Parameters:
current - current line index
Returns:
index of next filled line.

getPreviousValidLine

public java.lang.Integer getPreviousValidLine(int current)
Parameters:
current - current line index
Returns:
index of the previous filled line (also multilines)

getPreviousRealLine

public int getPreviousRealLine(int current)
Parameters:
current - current line index
Returns:
index of the previous filled line (no multilines)

moveLinesBeginningByToken

public void moveLinesBeginningByToken(org.deft.repository.ast.Token token,
                                      int offset)
Moves tokens by a given line offset.

Parameters:
token - Token
offset - lines

moveLinesAfterLine

public void moveLinesAfterLine(int targetLine,
                               int offset)
Moves tokens after a line by a given line offset.

Parameters:
targetLine - line index
offset - lines

moveCol

public void moveCol(int selectedLine,
                    int offset)
Moves a line in horizontal direction. (Negative values allowed).

Parameters:
selectedLine - index
offset - cols

lastLine

public int lastLine()
Returns:
last line in layout

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object