sub_arctic.constraints
Class op1_impl

java.lang.Object
  |
  +--sub_arctic.constraints.op1_impl

public class op1_impl
extends java.lang.Object
implements std_encoding_consts

Constraint implementation class to provide encoding for standard 1 operand lightweight constraint. This object takes 1 std_objpart_encoding object representing an operand, along with a signed 16 bit value to provide a constant to the function.

1 operand constraints are encoded as:

             16          6     5     5
     KKKKKKKKKKKKKKKK AAAAAA 00001 00001   31 1 operand operations
                              ...            [K is 16 bit signed]
     KKKKKKKKKKKKKKKK AAAAAA 11111 00001   
 
where KKK represents a 16 bit signed constant, AAA represents the parameter objects, and XXX represents bits used to encode an op code.


Field Summary
static int H
           
static int W
           
static int X
           
static int Y
           
 
Method Summary
static short const_val(int enc)
          Decode constant from given encoding.
static std_constraint create(int op_code, std_objpart_encoding op1, short K)
          Create a standard constraint given an op_code, an obj/part designator, and a constant.
static boolean depends_on(int enc, interactor constr_obj, int which_obj, int which_part, int nth_child, int orient)
          Test whether the given encoded constraint (constraining the given object) depends on the indicated object and part (expressed relative to it).
static int encode(int op_code, std_objpart_encoding op1, short K)
          Do an encoding given an op_code, an obj/part designator, and a constant.
static int eval_fun(int enc, interactor constr_obj, int val1, int cnst_val, int orient)
          Evaluate an encoded constraint function given its operand and constant values.
static int eval(int enc, interactor constr_obj, int constr_part, int orient)
          Evaluate an encoded constraint applied to the given part of the given object.
static java.util.Vector mk_depend_list(int enc, interactor constr_obj, int orient)
          Extract the set of objects/parts that a constraint depends on.
static java.util.Vector mk_implicit_depend_list(int enc, interactor constr_obj, int orient)
          Extract the set of objects/parts that a particular constraint function implicitly depends on.
static int op_code(int enc)
          Decode op_code from the given encoding.
static int op1(int enc)
          Decode first operand from given encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X

public static final int X

Y

public static final int Y

W

public static final int W

H

public static final int H
Method Detail

create

public static std_constraint create(int op_code,
                                    std_objpart_encoding op1,
                                    short K)
Create a standard constraint given an op_code, an obj/part designator, and a constant.

Parameters:
int - op_code op code value for this operation.
std_objpart_encoding - op1 designator for operand 1
short - K value for 16 bit signed constant

encode

public static int encode(int op_code,
                         std_objpart_encoding op1,
                         short K)
Do an encoding given an op_code, an obj/part designator, and a constant.

Parameters:
int - op_code op code value for this operation.
std_objpart_encoding - op1 designator for operand 1
short - K value for 16 bit signed constant

op_code

public static int op_code(int enc)
Decode op_code from the given encoding. Note: we assume this is already known to be a 1-op constraint. If not, the results will be wrong.

Parameters:
int - enc the encoding for the constraint.

op1

public static int op1(int enc)
Decode first operand from given encoding. Note: we assume this is already known to be a 1-op constraint. If not, the results will be wrong.

Parameters:
int - enc the encoding for the constraint.

const_val

public static short const_val(int enc)
Decode constant from given encoding. Note: we assume this is already known to be a 1-op constraint. If not, the results will be wrong.

Parameters:
int - enc the encoding for the constraint.

eval_fun

public static int eval_fun(int enc,
                           interactor constr_obj,
                           int val1,
                           int cnst_val,
                           int orient)
Evaluate an encoded constraint function given its operand and constant values. We assume here that it is has already been determined that the constraint is a 1-op constraint.

Parameters:
int - enc the encoding from the constraint
interactor - constr_obj the object being constrained
int - val1 value of first operand
int - cnst_val value of constant parameter
int - orient orientation of the constraint (should be HORIZONTAL or VERTICAL).
Returns:
int the result of the evaluation

eval

public static int eval(int enc,
                       interactor constr_obj,
                       int constr_part,
                       int orient)
Evaluate an encoded constraint applied to the given part of the given object. We assume here that it it has already been determined that the constraint is a 1-op constraint.

Parameters:
int - enc the encoding from the constraint
interactor - constr_obj the object being constrained
int - constr_part the part being constrained
int - orient the orientation of the constraint
Returns:
int the result of the evaluation

depends_on

public static boolean depends_on(int enc,
                                 interactor constr_obj,
                                 int which_obj,
                                 int which_part,
                                 int nth_child,
                                 int orient)
Test whether the given encoded constraint (constraining the given object) depends on the indicated object and part (expressed relative to it). Here we assume that the encoding is already known to contain a 1-op constraint.

Parameters:
int - enc The encoding for the constraint.
interactor - constr_obj The object the constraint is attached to
int - test_which_obj The object we are asking about. This can be one of the values OBJCODE_SELF, OBJCODE_PARENT, OBJCODE_SOME_CHILD, OBJCODE_PREV_SIBLING, or OBJCODE_NEXT_SIBLING.
int - test_which_part The part we are asking about.
int - nth_child for SOME_CHILD, this provides the index of the child (and is ignored otherwise).
int - orient Orientation of the constraint. This should be HORIZONTAL or VERTICAL.
Returns:
boolean whether the given constraint depends upon the given value

mk_depend_list

public static java.util.Vector mk_depend_list(int enc,
                                              interactor constr_obj,
                                              int orient)
Extract the set of objects/parts that a constraint depends on. This produces a Vector with pairs of entries, the first being an interactor, and the second being an Integer which is the part number of that interactor that is depended upon.

Here we assume that this is a 1 operand constraint.

Parameters:
int - enc encoding value for the constraint in question.
interactor - constr_obj the object the constraint is attached to (hence its referents are relative to).
int - orient Orientation of the constraint. This should be HORIZONTAL or VERTICAL.
Returns:
Vector containing pairs of objects, the first being an interactor which is depended upon, and the second being an Integer giving the part number of the part depended upon.

mk_implicit_depend_list

public static java.util.Vector mk_implicit_depend_list(int enc,
                                                       interactor constr_obj,
                                                       int orient)
Extract the set of objects/parts that a particular constraint function implicitly depends on. This produces a Vector with pairs of entries, the first being an interactor, and the second being an Integer which is the part number of that interactor that is depended upon.

Parameters:
int - enc encoding value for the constraint in question.
interactor - constr_obj the object the constraint is attached to (hence its referents are relative to).
int - orient Orientation of the constraint. This should be HORIZONTAL or VERTICAL.
Returns:
Vector containing pairs of objects, the first being an interactor which is depended upon, and the second being an Integer giving the part number of the part depended upon.