public abstract class Alignment
extends java.lang.Object
getAlignment method
are aligned with each other.| Modifier and Type | Class and Description |
|---|---|
static class |
Alignment.Anchor |
| Constructor and Description |
|---|
Alignment() |
| Modifier and Type | Method and Description |
|---|---|
static Alignment |
createAlignment() |
static Alignment |
createAlignment(boolean allowBackwardShift) |
static Alignment |
createAlignment(boolean allowBackwardShift,
Alignment.Anchor anchor)
Allows to create
Alignment object with the given settings. |
static Alignment |
createChildAlignment(Alignment base)
Allows to create alignment with the following feature - aligned blocks are aligned to block with the current alignment if the one
if found; block with the given
'base' alignment is checked otherwise. |
public static Alignment createAlignment()
public static Alignment createAlignment(boolean allowBackwardShift)
public static Alignment createAlignment(boolean allowBackwardShift, Alignment.Anchor anchor)
Alignment object with the given settings.
int start = 1;
int finish = 2;
Here '=' block of 'int start = 1' statement is shifted one symbol right in order to align
to the '=' block of 'int finish = 2' statement.
int start = 1;
long finish = 2;
int start = 1;
long finish = 2;
allowBackwardShift - flag that specifies if former aligned block may be shifted to right in order to align to subsequent
aligned blockanchor - alignment anchor'allow backward shift' settingpublic static Alignment createChildAlignment(Alignment base)
'base' alignment is checked otherwise.
Example:
int i = a ? x
: y;
Here ':' is aligned to '?' and alignment of 'a' is a 'base alignment'
of '?' alignment. I.e. the thing is that ':' is not aligned to 'a'.
However, we can change example as follows:
int i = a
? x : y;
Here '?' is aligned to 'a' because the later is set as a 'base alignment' for '?'.
Note that we can't just define the same simple alignment for all blocks 'a',
'?' and ':' because it would produce formatting like the one below:
int i = a ? x
: y;
base - base alignment to use within returned alignment object'base alignment'