public final class Style extends Object implements Cloneable
All int
values are in screen pixels, that is,
the display scaling is already taken into account.
Note that Style objects are generally shared by many very different gadgets. Changing the value of a style property of a Style object may lead to unexpected results.
Modifier and Type | Class and Description |
---|---|
static class |
Style.BorderStyle
Supported values for CSS2 property border-style.
|
static class |
Style.Direction
Supported values for CSS3 property direction.
|
static class |
Style.TextAlign
Supported values for CSS2 property text-align.
|
static class |
Style.TextDecoration
Supported values for CSS2 property text-decoration.
|
static class |
Style.VerticalAlign
Supported values for CSS2 property vertical-align.
|
static class |
Style.WhiteSpace
Supported values for CSS2 property white-space.
|
Modifier and Type | Field and Description |
---|---|
Color |
backgroundColor
Same as CSS2 property background-color.
|
BackgroundPaint |
backgroundPaint
Same as CSS properties background-image, background-repeat,
background-position.
|
Color |
borderBottomColor
Same as CSS2 property border-bottom-color.
|
Style.BorderStyle |
borderBottomStyle
Same as CSS2 property borders-bottom-style.
|
Color |
borderLeftColor
Same as CSS2 property border-left-color.
|
Style.BorderStyle |
borderLeftStyle
Same as CSS2 property border-left-style.
|
BorderRadius |
borderRadius
Same as CSS3 property border-radius.
|
Color |
borderRightColor
Same as CSS2 property border-right-color.
|
Style.BorderStyle |
borderRightStyle
Same as CSS2 property border-right-style.
|
Color |
borderTopColor
Same as CSS2 property border-top-color.
|
Style.BorderStyle |
borderTopStyle
Same as CSS2 property border-top-style.
|
int |
borderWidth
Same as CSS2 property border-width.
|
Color |
color
Same as CSS2 property color.
|
Style.Direction |
direction
Same as CSS3 direction.
|
FontSpec |
fontSpec
Same as CSS2 property font.
|
double |
lineHeight
Same as CSS2 property line-height.
|
ListStyle |
listStyle
Same as CSS2 property list-style.
|
int |
marginBottom
Same as CSS2 property margin-bottom.
|
int |
marginLeft
Same as CSS2 property margins-left.
|
int |
marginRight
Same as CSS2 property margin-right.
|
int |
marginTop
Same as CSS2 property margin-top.
|
static double |
NORMAL_LINE_HEIGHT
Value of "
line-height:normal ". |
int |
paddingBottom
Same as CSS2 property padding-bottom.
|
int |
paddingLeft
Same as CSS2 property padding-left.
|
int |
paddingRight
Same as CSS2 property padding-right.
|
int |
paddingTop
Same as CSS2 property padding-top.
|
Style.TextAlign |
textAlign
Same as CSS2 property text-align.
|
Style.TextDecoration |
textDecoration
Same as CSS2 property text-decoration.
|
int |
textIndent
Same as CSS2 property text-indent.
|
Style.VerticalAlign |
verticalAlign
Same as CSS2 property vertical-align.
|
Style.WhiteSpace |
whiteSpace
Same as CSS2 property white-space.
|
Constructor and Description |
---|
Style()
Constructs a Style with default values for all style properties.
|
Modifier and Type | Method and Description |
---|---|
Style |
copy()
Returns a shallow copy of this Style object.
|
void |
copyBox(Style other)
Copies all style properties related to the CSS box
(margin*, padding*, border*, background*) from specified style.
|
boolean |
equals(Object other) |
Style.TextAlign |
getTextAlign()
Returns the actual text align
Style.TextAlign.LEFT ,
Style.TextAlign.RIGHT or Style.TextAlign.CENTER to be used
depending on the specified values of textAlign
AND direction . |
boolean |
hasBox()
Returns
true if this style specifies a CSS box
(margin*, padding*, border*, background*). |
int |
hashCode() |
boolean |
hasVerticalBorderOrPadding()
Returns
true if this style specifies a border and/or
a vertical padding (border*, padding-top, padding-bottom). |
void |
horizontalFlipBox()
Modify this style in order to make all left-hand properties
related to the CSS box (margin, padding, border) become
right-hand properties and the other way round.
|
void |
mergeBox(Style other)
Copy to this style all the style properties related to the CSS box
(margin*, padding*, border*, background*) found in other
which have not already been specified in this style.
|
void |
resetBox()
Resets all style properties related to the CSS box to default
values (margin*, padding*, border*, background*).
|
void |
resetNonInherited()
Resets all non-inherited style properties to default values
(verticalAlign, textDecoration, margin*, padding*, border*, background*).
|
public int marginTop
public int marginRight
public int marginBottom
public int marginLeft
public int paddingTop
public int paddingRight
public int paddingBottom
public int paddingLeft
public BorderRadius borderRadius
public Style.BorderStyle borderTopStyle
public Style.BorderStyle borderRightStyle
public Style.BorderStyle borderBottomStyle
public Style.BorderStyle borderLeftStyle
public int borderWidth
public Color borderTopColor
color
.public Color borderRightColor
color
.public Color borderBottomColor
color
.public Color borderLeftColor
color
.public static final double NORMAL_LINE_HEIGHT
line-height:normal
".public double lineHeight
Here lineHeight is a specification: Effective distance in pixels between 2 consecutive baselines = lineHeight*Normal distance between 2 consecutive lines.
The normal lineHeight is between 1.0 to 1.2.
XXE uses NORMAL_LINE_HEIGHT
.
public Style.VerticalAlign verticalAlign
public Color color
public Color backgroundColor
null
.
backgroundColor==null
means transparent. Other colors
cannot be transparent.
public BackgroundPaint backgroundPaint
null
.public FontSpec fontSpec
public int textIndent
public Style.TextAlign textAlign
public Style.Direction direction
public Style.TextDecoration textDecoration
public Style.WhiteSpace whiteSpace
public ListStyle listStyle
null
(if needed, implies: disc outside).public Style()
public void resetNonInherited()
public void resetBox()
public Style.TextAlign getTextAlign()
Style.TextAlign.LEFT
,
Style.TextAlign.RIGHT
or Style.TextAlign.CENTER
to be used
depending on the specified values of textAlign
AND direction
.
This is needed because start
and end
are not supported values for CSS property text-align
.
public void horizontalFlipBox()
This is needed to correctly
support direction==Direction.RTL
because
CSS Logical Properties like margin-inline-start
,
padding-inline-start
, border-inline-end-style
,
etc, are not supported.
public boolean hasBox()
true
if this style specifies a CSS box
(margin*, padding*, border*, background*).
Returns false
otherwise.public void copyBox(Style other)
public void mergeBox(Style other)
public boolean hasVerticalBorderOrPadding()
true
if this style specifies a border and/or
a vertical padding (border*, padding-top, padding-bottom).
Returns false
otherwise.public Style copy()