param.dart 756 Bytes
Newer Older
1 2 3 4 5 6
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of cassowary;

7
class Param extends _EquationMember {
8
  final Variable variable;
9
  dynamic context;
10

11
  Param([double value = 0.0]) : variable = new Variable(value) {
12 13 14
    variable._owner = this;
  }

15 16
  Param.withContext(ctx, [double value = 0.0])
      : variable = new Variable(value),
17
        context = ctx {
18 19
    variable._owner = this;
  }
20 21 22 23 24

  bool get isConstant => false;

  double get value => variable.value;

25 26 27
  String get name => variable.name;
  set name(String name) => variable.name = name;

28 29
  Expression asExpression() => new Expression([new Term(variable, 1.0)], 0.0);
}