public class Expression
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
constant
The constant term.
|
private int |
heightFactor
The screen height dependent factor.
|
private int |
prefHeightFactor
The preferred height dependent factor.
|
private int |
prefWidthFactor
The preferred width dependent factor.
|
private int |
widthFactor
The screen width dependent factor.
|
Constructor and Description |
---|
Expression(Expression expression1,
boolean negative,
Expression expression2)
Creates a new instance as the sum or difference of two expressions.
|
Expression(int constant,
int widthFactor,
int heightFactor,
int prefWidthFactor,
int prefHeightFactor)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private static int |
applyFactor(int value,
int factor)
Applies a factor to a value.
|
int |
evaluate(int width,
int height,
int prefWidth,
int prefHeight)
Evaluates the expression into a constant.
|
int |
evaluateConstant()
Evaluates the expression into a constant.
|
private final int constant
private final int heightFactor
private final int prefHeightFactor
private final int prefWidthFactor
private final int widthFactor
public Expression(@NotNull Expression expression1, boolean negative, @NotNull Expression expression2)
expression1
- the left expressionnegative
- whether the right expression should be added (false
) or subtracted (true
)expression2
- the right expressionpublic Expression(int constant, int widthFactor, int heightFactor, int prefWidthFactor, int prefHeightFactor)
constant
- the constant termwidthFactor
- the screen width dependent factorheightFactor
- the screen height dependent factorprefWidthFactor
- the preferred width dependent factorprefHeightFactor
- the preferred height dependent factorprivate static int applyFactor(int value, int factor)
value
- the valuefactor
- the factorpublic int evaluate(int width, int height, int prefWidth, int prefHeight)
width
- the screen widthheight
- the screen heightprefWidth
- the preferred width dependent factorprefHeight
- the preferred height dependent factorpublic int evaluateConstant()