com.realtime.crossfire.jxclient.skin.skin
Class Expression

java.lang.Object
  extended by com.realtime.crossfire.jxclient.skin.skin.Expression

public class Expression
extends java.lang.Object

An expression yielding an integer value derived from a screen resolution.


Field Summary
private  int constant
          The constant term.
private  int heightFactor
          The screen height dependent factor.
private  int widthFactor
          The screen width dependent factor.
 
Constructor Summary
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)
          Creates a new instance.
 
Method Summary
 Expression addConstant(int value)
          Returns this expression plus a constant value.
private static int applyFactor(int value, int factor)
          Applies a factor to a value.
 int evaluate(int width, int height)
          Evaluates the expression into a constant.
 int evaluateConstant()
          Evaluates the expression into a constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constant

private final int constant
The constant term.


heightFactor

private final int heightFactor
The screen height dependent factor.


widthFactor

private final int widthFactor
The screen width dependent factor.

Constructor Detail

Expression

public Expression(@NotNull
                  Expression expression1,
                  boolean negative,
                  @NotNull
                  Expression expression2)
Creates a new instance as the sum or difference of two expressions.

Parameters:
expression1 - the left expression
negative - whether the right expression should be added (false) or subtracted (true)
expression2 - the right expression

Expression

public Expression(int constant,
                  int widthFactor,
                  int heightFactor)
Creates a new instance.

Parameters:
constant - the constant term
widthFactor - the screen width dependent factor
heightFactor - the screen height dependent factor
Method Detail

addConstant

@NotNull
public Expression addConstant(int value)
Returns this expression plus a constant value.

Parameters:
value - the constant value
Returns:
the new expression

applyFactor

private static int applyFactor(int value,
                               int factor)
Applies a factor to a value.

Parameters:
value - the value
factor - the factor
Returns:
the result

evaluate

public int evaluate(int width,
                    int height)
Evaluates the expression into a constant.

Parameters:
width - the screen width
height - the screen height
Returns:
the constant

evaluateConstant

public int evaluateConstant()
Evaluates the expression into a constant.

Returns:
the constant