source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/model/BoardSpec.as@ 1227

Last change on this file since 1227 was 1227, checked in by George Lilly, 13 years ago

initial load of EDIS 1.0

File size: 2.1 KB
Line 
1package gov.va.med.edp.model
2{
3 import gov.va.med.edp.vo.ColorMapVO;
4 import gov.va.med.edp.vo.ColorMatchVO;
5 import gov.va.med.edp.vo.ColorSelectionVO;
6 import gov.va.med.edp.vo.ColumnSpecVO;
7 import gov.va.med.edp.vo.DisplayBoardPropertiesVO;
8
9 import mx.collections.ArrayCollection;
10
11 [Bindable]
12 public class BoardSpec
13 {
14 public var colorMaps: ArrayCollection; // array of ColorMapVO
15 public var columns: ArrayCollection; // array of ColumnSpecVO
16 public var rowColorMap: ColorMapVO;
17 public var displayBoardProperties: DisplayBoardPropertiesVO;
18 public var configLastUpdated: String;
19 public var reloadConfig: Boolean = false;
20 public var specReady: Boolean = false;
21
22 public function cellColor(att: String, data: Object): ColorSelectionVO
23 {
24 var i: int;
25 var col: ColumnSpecVO;
26 var colorMap: ColorMapVO;
27 var colorMatch: ColorMatchVO;
28 var defaultColor: ColorSelectionVO = new ColorSelectionVO;
29
30 // find the colorMap for this attribute
31 for (i = 0; i < columns.length; i++) {
32 col = columns[i];
33 if (col.attribute == att) {
34 colorMap = col.colorMap;
35 break;
36 } // if
37 } // for
38 if (colorMap == null) {
39 colorMap = rowColorMap;
40 }
41 if (colorMap == null) return defaultColor;
42
43 if (colorMap.type == "rng") {
44 // find a color match within the range of the value
45 for (i = colorMap.matches.length - 1; i >= 0; i--) {
46 colorMatch = colorMap.matches[i];
47 if (data.hasOwnProperty(colorMatch.attribute) &&
48 (int(data[colorMatch.attribute]) > int(colorMatch.value))) {
49 return colorMatch.color.ignore ? defaultColor : colorMatch.color;
50 } // if
51 }
52 } else {
53 // find a match where the attribute is of equal value
54 for each (colorMatch in colorMap.matches) {
55 if (colorMatch.color.ignore) continue;
56 if (data.hasOwnProperty(colorMatch.attribute) &&
57 (data[colorMatch.attribute] == colorMatch.value)) {
58 return colorMatch.color;
59 } // if
60 } // for
61 }
62
63 return defaultColor;
64 } // CellColor
65 }
66}
Note: See TracBrowser for help on using the repository browser.