public class GralPos extends java.lang.Object implements java.lang.Cloneable
org.vishia.gral.area9.GuiCallingArgs#sSize
) respectively the parameter size of GralGridProperties.GralGridProperties(char size)
.
GralCfgZbnf
.
The writing style of positions in the script regards a stinting short style to give positions,
because a hand written script should not cause a lot of calculations for positions by the writer.
It should be simple. The syntax of a position in the gral script is given in the variable syntaxZbnf
.
The method setPosition(CharSequence, GralPos)
uses that syntax.
same
or refer
added with a number in range of -1000..1000: This given position
refers to the parent position with the given distance. same and refer is equate, the difference
is in semantic only. Use same
without distance, use refer
+/- distance.
If same
or refer
is used for the line or column, and the second position is given
with 'size
- size' then the bottom or right value of the parent is referred.
size
+ number applied at lineEnd or columnEnd:
The size is given instead from..to. Because the size value is positive, the line and column value is left or top.
size
- number applied at lineEnd or columnEnd: The size is given negative.
The absolute value is the size. Because the size is negative it is measured from right to left
respectively bottom to top. It means the given line and column is the right or the bottom line.
If the position is given using same
or refer
, the related end position
is used.
next
and nextBlock
x
, and y
with its values in
GralPos.Coordinate
.
The x and y is the lesser value, left and top, and the xEnd and yEnd is the greater value, right or bottom.
This form of storing is better to calculate the pixel position while building the graphic and it is better
to calculate related position too.
Modifier and Type | Class and Description |
---|---|
static class |
GralPos.Coordinate
Class holds values for either x or y.
|
Modifier and Type | Field and Description |
---|---|
static int |
next
Use the next value for the coordinate in relation to the last one for the given direction
but the same value for the other coordinate.
|
static int |
nextBlock
Use the next value for the coordinate in relation to the last one.
|
GralPanelContent |
panel
Relation of x and y left and top to any separation line. 0 - relation to left and top border.
|
static int |
ratio
This bit at all coordinates means, that the value is given as ratio from the size.
|
static int |
refer
This adding value applied at any coordinate parameter of any setPosition- method means, that the value is
referred to the position of the previous or given position.
|
static int |
same
This value applied at any coordinate parameter of any setPosition- method means, that the value is
the same as the previous or given position.
|
static int |
samesize
Use the same size.
|
static int |
size
This adding value at xEnd or yEnd or the float presentations of the calling argument of any
setPosition- method means, that the value is the size, not the position.
|
static java.lang.String |
syntaxZbnf
Syntax of a position.
|
static int |
useNatSize
This value at xEnd or yEnd means, that the native size of a widget should be used.
|
static int |
version
Version, history and license.
|
GralPos.Coordinate |
x
The values for x and y positions.
|
GralPos.Coordinate |
y
The values for x and y positions.
|
Modifier | Constructor and Description |
---|---|
protected |
GralPos()
A GralPos should never create as instance from the application.
|
protected |
GralPos(GralPos src)
A GralPos should never create as instance from the application.
|
Modifier and Type | Method and Description |
---|---|
GralRectangle |
calcWidgetPosAndSize(GralGridProperties propertiesGui,
int widthParentPixel,
int heightParentPixel,
int widthWidgetNat,
int heightWidgetNat)
Calculates the position and size of a widget from this given Pos.
|
GralPos |
clone() |
float |
height() |
java.lang.String |
posString() |
void |
set(GralPos pos)
Sets all values of this with the values of pos (copy values)
|
void |
setFinePosition(int line,
int yPosFrac,
int ye,
int yef,
int column,
int xPosFrac,
int xe,
int xef,
int origin,
char direction,
int border,
int borderFrac,
GralPos parent)
Sets the position for the next widget to add in the container.
|
GralPos |
setNextPos(java.lang.String posString) |
void |
setNextPosition()
Sets the position to the next adequate the
#pos.dirNext . |
void |
setPosition(java.lang.CharSequence sPos,
GralPos posParent)
Sets the position with the given string representation.
|
void |
setPosition(float line,
float column) |
void |
setPosition(GralPanelContent panel,
float line,
float lineEndOrSize,
float column,
float columnEndOrSize,
int origin,
char direction,
float border)
Sets the position to the given panel as container.
|
void |
setPosition(GralPos framePos,
float line,
float lineEndOrSize,
float column,
float columnEndOrSize,
int origin,
char direction) |
void |
setPosition(GralPos framePos,
float line,
float lineEndOrSize,
float column,
float columnEndOrSize,
int origin,
char direction,
float border)
Sets the position
|
void |
setPositionSize(int line,
int column,
int height,
int width,
char direction,
GralPos posFrame) |
void |
setSize(float height,
float width,
GralPos frame) |
void |
setSize(int height,
int ySizeFrac,
int width,
int xSizeFrac) |
static void |
testScanSize() |
boolean |
toResize()
Returns true if this position is from right or bottom, so that a resize of the panel needs new positions for this widget.
|
java.lang.String |
toString()
Use especially for debug.
|
float |
width() |
public static final int next
public static final int nextBlock
public GralPanelContent panel
public static final int ratio
useNatSize
have to be 0. The ratio is stored as a value from 0 to 999
in the bits 9..0. The other bits should be 0.public static final int refer
public static final int same
refer
. This constant regards the semantic.public static final int samesize
public static final int size
public static final java.lang.String syntaxZbnf
position::= @ [<$?panel> ,] [ &+] [<#?yPos>[\\.<#?yPosFrac>]] [ [+] <#-?ySizeDown>[\\.<#?ySizeFrac>]| +* |] [ , [ &+] [<#?xPos>[\\.<#?xPosFrac>]] [ [+] <#-?xWidth>[\\.<#?xSizeFrac>]| +* |] [ ++] ].The semantic identifier match to the elements in
GralCfgPosition
.public static final int useNatSize
public static final int version
setPosition(GralPos, float, float, float, float, int, char)
etc
are moved from the GralGridMngBase to this. It are methods of this class functionally. The GralGridMngBase wrappes it
because that methods should be able to call there.
same
etc. as adding values for setPosition-methods.
It prevents the necessity of a lot of special set methods. The parameter for positions may be relative, referred etc.
to the previous position or to a frame.
toString()
to see values of instance in debug
public final GralPos.Coordinate x
public final GralPos.Coordinate y
protected GralPos()
setPosition(float, float)
etc.protected GralPos(GralPos src)
setPosition(float, float)
etc.src
- the src position to copy all values.public GralRectangle calcWidgetPosAndSize(GralGridProperties propertiesGui, int widthParentPixel, int heightParentPixel, int widthWidgetNat, int heightWidgetNat)
propertiesGui
- The properties for presentation.widthParentPixel
- width of the container. This value will be used if the position is given
from right with negative numbers.heightParentPixel
- height of the container. This value will be used if the position is given
from bottom with negative numbers.widthWidgetNat
- natural width of the component which will be positioning.
This value is used only if the pos parameter contains useNatSize
for the xe-valueheightWidgetNat
- natural height of the component which will be positioning.
This value is used only if the pos parameter contains useNatSize
for the ye-valuepublic float height()
public java.lang.String posString()
public void set(GralPos pos)
pos
- The src pospublic void setFinePosition(int line, int yPosFrac, int ye, int yef, int column, int xPosFrac, int xe, int xef, int origin, char direction, int border, int borderFrac, GralPos parent)
line
- y-Position in y-Units, count from top of the box. It is the bottom line of the widget.
If <0, then it counts from bottom of the parent.column
- x-Position in x-Units, count from left of the box.
If <0, then the previous position is valid still.
It < 0 then line = 0 is not a proper value. To show a text in the first line, use line=2.heigth:
- The height of the line. If <0, then the param line is the bottom line of the widget,
and (line-height) is the top line. If 0 then the last value of height is not changed.length:
- The number of columns. If <0, then the param column is the right column,
and column-length is the left column. If 0 then the last value of length is not changed.direction:
- direction for a next widget, use 'r', 'l', 'u', 'd' for right, left, up, downparent
- public GralPos setNextPos(java.lang.String posString) throws java.text.ParseException
java.text.ParseException
public void setNextPosition()
#pos.dirNext
.public void setPosition(java.lang.CharSequence sPos, GralPos posParent) throws java.text.ParseException
sPos
- The syntax of the string see description of this class, starting with "@panel, ..." etc.
for example "@windowA, 3..5, 16+20" for absolute line 3 and 4 (exclusive 5) and from absolute column 16, size-x=20.
The position can be given without panel designation or relative, then the posParent argument is necessary.posParent
- necessary to build the absolute position from relative given sPos, maybe null if not necessary.java.text.ParseException
- on errors of sPos or missing posParent if necessary.public void setPosition(float line, float column)
public void setPosition(GralPanelContent panel, float line, float lineEndOrSize, float column, float columnEndOrSize, int origin, char direction, float border)
panel
- The panel which is used as container. Its current GralWidget.pos()
is used for relative positionsline
- The line. If the parameter lineEndOrSize is designated with size
with a negative value,
it is the bottom line for the position.
If it is designated with same
without offset and the lineEndOrSize is designated with size
with a negative value, the framePos GralPos#y.p2
is used. If it is designated
with same
but with any offset, the y
is used as refer position, it is the top line position.
Elsewhere it is the top position.lineEndOrSize
- Maybe designated with size
or samesize
column
- columnEndOrSize
- origin
- direction
- public void setPosition(GralPos framePos, float line, float lineEndOrSize, float column, float columnEndOrSize, int origin, char direction)
public void setPosition(GralPos framePos, float line, float lineEndOrSize, float column, float columnEndOrSize, int origin, char direction, float border)
framePos
- The frame or last pos for relative positions.line
- The line. If the parameter lineEndOrSize is designated with size
with a negative value,
it is the bottom line for the position.
If it is designated with same
without offset and the lineEndOrSize is designated with size
with a negative value, the framePos GralPos#y.p2
is used. If it is designated
with same
but with any offset, the y
is used as refer position, it is the top line position.
Elsewhere it is the top position.lineEndOrSize
- Maybe designated with size
or samesize
column
- columnEndOrSize
- origin
- direction
- public void setPositionSize(int line, int column, int height, int width, char direction, GralPos posFrame)
public void setSize(int height, int ySizeFrac, int width, int xSizeFrac)
public static void testScanSize()
public boolean toResize()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public float width()