~jozilla/uiml.net/uiml.net-tp

« back to all changes in this revision

Viewing changes to Cassowary/ClStrength.cs

  • Committer: Jo Vermeulen
  • Date: 2007-09-05 14:26:30 UTC
  • mfrom: (249.1.16 Uiml.net)
  • Revision ID: jo.vermeulen@uhasselt.be-20070905142630-w5eafpsfntbgz0ko
Merged with Jo's main branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  Cassowary.net: an incremental constraint solver for .NET
3
 
  (http://lumumba.uhasselt.be/jo/projects/cassowary.net/)
4
 
  
5
 
  Copyright (C) 2005  Jo Vermeulen (jo.vermeulen@uhasselt.be)
6
 
  
7
 
  This program is free software; you can redistribute it and/or
8
 
  modify it under the terms of the GNU Lesser General Public License
9
 
  as published by the Free Software Foundation; either version 2.1
10
 
  of  the License, or (at your option) any later version.
11
 
 
12
 
  This program is distributed in the hope that it will be useful,
13
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
  GNU Lesser General Public License for more details.
16
 
 
17
 
  You should have received a copy of the GNU Lesser General Public License
18
 
  along with this program; if not, write to the Free Software
19
 
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
 
*/
21
 
 
22
 
using System;
23
 
 
24
 
namespace Cassowary
25
 
{
26
 
  public class ClStrength
27
 
  {
28
 
    public ClStrength(string name, ClSymbolicWeight symbolicWeight)
29
 
    {
30
 
      _name = name;
31
 
      _symbolicWeight = symbolicWeight;
32
 
    }
33
 
 
34
 
    public ClStrength(string name, double w1, double w2, double w3)
35
 
    {
36
 
      _name = name;
37
 
      _symbolicWeight = new ClSymbolicWeight(w1, w2, w3);
38
 
    }
39
 
 
40
 
    public bool IsRequired
41
 
    {
42
 
      get { return (this == Required); }
43
 
    }
44
 
 
45
 
    public ClSymbolicWeight SymbolicWeight
46
 
    {
47
 
      get { return _symbolicWeight; } 
48
 
      set { _symbolicWeight = value; }
49
 
    }
50
 
 
51
 
    public string Name
52
 
    {
53
 
      get { return _name; }
54
 
      set { _name = value; }
55
 
    }
56
 
    
57
 
    public override string ToString()
58
 
    {
59
 
      if (!IsRequired)
60
 
        return string.Format("{0}:{1}", Name, SymbolicWeight);
61
 
      else
62
 
        return Name;
63
 
    }
64
 
    
65
 
    public static ClStrength Required
66
 
    {
67
 
      get { return _required; }
68
 
    }
69
 
 
70
 
    public static ClStrength Strong
71
 
    {
72
 
      get { return _strong; }
73
 
    }
74
 
 
75
 
    public static ClStrength Medium
76
 
    {
77
 
      get { return _medium; }
78
 
    }
79
 
 
80
 
    public static ClStrength Weak
81
 
    {
82
 
      get { return _weak; }
83
 
    }
84
 
    
85
 
    private string _name;
86
 
    private ClSymbolicWeight _symbolicWeight;
87
 
 
88
 
    private static readonly ClStrength _required = new ClStrength("<Required>", 1000, 1000, 1000);
89
 
    private static readonly ClStrength _strong = new ClStrength("strong", 1.0, 0.0, 0.0);
90
 
    private static readonly ClStrength _medium = new ClStrength("medium", 0.0, 1.0, 0.0);
91
 
    private static readonly ClStrength _weak = new ClStrength("weak", 0.0, 0.0, 1.0);
92
 
  }
93
 
}