2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
* CGHViewerDataModel.java |
2 |
26 Feb 07 |
jari |
3 |
* |
2 |
26 Feb 07 |
jari |
* Created on June 15, 2003, 1:42 AM |
2 |
26 Feb 07 |
jari |
5 |
*/ |
2 |
26 Feb 07 |
jari |
6 |
|
2 |
26 Feb 07 |
jari |
7 |
package org.tigr.microarray.mev.cgh.CGHDataModel; |
2 |
26 Feb 07 |
jari |
8 |
|
2 |
26 Feb 07 |
jari |
9 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
10 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
11 |
|
2 |
26 Feb 07 |
jari |
12 |
import org.tigr.microarray.mev.cluster.gui.ICGHCloneValueMenu; |
2 |
26 Feb 07 |
jari |
13 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
14 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
15 |
|
2 |
26 Feb 07 |
jari |
16 |
/** |
2 |
26 Feb 07 |
jari |
17 |
* |
2 |
26 Feb 07 |
jari |
* @author Adam Margolin |
2 |
26 Feb 07 |
jari |
* @author Raktim Sinha |
2 |
26 Feb 07 |
jari |
20 |
*/ |
2 |
26 Feb 07 |
jari |
21 |
|
2 |
26 Feb 07 |
jari |
22 |
public class CGHViewerDataModel { |
2 |
26 Feb 07 |
jari |
23 |
|
2 |
26 Feb 07 |
jari |
24 |
public static final int CLONE_VALUES_DISCRETE_DETERMINATION = 0; |
2 |
26 Feb 07 |
jari |
25 |
public static final int CLONE_VALUES_CONTINUOUS = 1; |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
public static final int BAD_CLONE = -10; |
2 |
26 Feb 07 |
jari |
28 |
public static final int NO_COPY_CHANGE = -11; |
2 |
26 Feb 07 |
jari |
29 |
|
2 |
26 Feb 07 |
jari |
30 |
/** |
2 |
26 Feb 07 |
jari |
protected Color COLOR_NULL = Color.darkGray; |
2 |
26 Feb 07 |
jari |
protected Color COLOR_AMP = Color.green; |
2 |
26 Feb 07 |
jari |
protected Color COLOR_AMP_2_COPY = Color.yellow; |
2 |
26 Feb 07 |
jari |
protected Color COLOR_DEL = Color.red; |
2 |
26 Feb 07 |
jari |
protected Color COLOR_DEL_2_COPY = Color.pink; |
2 |
26 Feb 07 |
jari |
protected Color COLOR_DEFAULT = Color.blue; |
2 |
26 Feb 07 |
jari |
protected Color COLOR_ERROR = Color.white; |
2 |
26 Feb 07 |
jari |
38 |
*/ |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
/** |
2 |
26 Feb 07 |
jari |
* New Color Defs for CGH |
2 |
26 Feb 07 |
jari |
* Raktim CGH Colors |
2 |
26 Feb 07 |
jari |
* Nov 22, 2005 |
2 |
26 Feb 07 |
jari |
44 |
*/ |
2 |
26 Feb 07 |
jari |
45 |
protected Color COLOR_NULL = Color.darkGray; |
2 |
26 Feb 07 |
jari |
46 |
protected Color COLOR_AMP = Color.red; |
2 |
26 Feb 07 |
jari |
47 |
protected Color COLOR_AMP_2_COPY = Color.pink; |
2 |
26 Feb 07 |
jari |
48 |
protected Color COLOR_DEL = Color.green; |
2 |
26 Feb 07 |
jari |
49 |
protected Color COLOR_DEL_2_COPY = Color.yellow; |
2 |
26 Feb 07 |
jari |
50 |
protected Color COLOR_DEFAULT = Color.blue; |
2 |
26 Feb 07 |
jari |
51 |
protected Color COLOR_ERROR = Color.white; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
protected BufferedImage negColorImage; |
2 |
26 Feb 07 |
jari |
54 |
protected BufferedImage posColorImage; |
2 |
26 Feb 07 |
jari |
55 |
protected float maxRatioScale; |
2 |
26 Feb 07 |
jari |
56 |
protected float minRatioScale; |
2 |
26 Feb 07 |
jari |
57 |
|
2 |
26 Feb 07 |
jari |
58 |
protected int cloneValueType; |
2 |
26 Feb 07 |
jari |
59 |
|
2 |
26 Feb 07 |
jari |
60 |
IData data; |
2 |
26 Feb 07 |
jari |
//CGHMultipleArrayDataFcd fcd; |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of CGHViewerDataModel */ |
2 |
26 Feb 07 |
jari |
//public CGHViewerDataModel(CGHMultipleArrayDataFcd fcd) { |
2 |
26 Feb 07 |
jari |
65 |
public CGHViewerDataModel(IFramework framework) { |
2 |
26 Feb 07 |
jari |
//this.fcd = fcd; |
2 |
26 Feb 07 |
jari |
//this.data = fcd.getData(); |
2 |
26 Feb 07 |
jari |
68 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
69 |
|
2 |
26 Feb 07 |
jari |
70 |
this.negColorImage = framework.getDisplayMenu().getNegativeGradientImage(); |
2 |
26 Feb 07 |
jari |
71 |
this.posColorImage = framework.getDisplayMenu().getPositiveGradientImage(); |
2 |
26 Feb 07 |
jari |
72 |
} |
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
public Color getColor(float value){ |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
77 |
if (Float.isNaN(value) || value == BAD_CLONE) { |
2 |
26 Feb 07 |
jari |
78 |
return COLOR_NULL; |
2 |
26 Feb 07 |
jari |
79 |
} |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
if(this.cloneValueType == CLONE_VALUES_DISCRETE_DETERMINATION){ |
2 |
26 Feb 07 |
jari |
82 |
return getDiscreteColor((int)value); |
2 |
26 Feb 07 |
jari |
83 |
}else{ |
2 |
26 Feb 07 |
jari |
84 |
return getContinuousColor(value); |
2 |
26 Feb 07 |
jari |
85 |
} |
2 |
26 Feb 07 |
jari |
86 |
} |
2 |
26 Feb 07 |
jari |
87 |
|
2 |
26 Feb 07 |
jari |
88 |
public Color getContinuousColor(float value){ |
2 |
26 Feb 07 |
jari |
89 |
float maximum = value < 0 ? minRatioScale : maxRatioScale; |
2 |
26 Feb 07 |
jari |
90 |
int colorIndex = (int)(255*value/maximum); |
2 |
26 Feb 07 |
jari |
91 |
colorIndex = colorIndex > 255 ? 255 : colorIndex; |
2 |
26 Feb 07 |
jari |
92 |
colorIndex = colorIndex < 0 ? 0 : colorIndex; |
2 |
26 Feb 07 |
jari |
93 |
int rgb = value < 0 ? negColorImage.getRGB(255-colorIndex, 0) : posColorImage.getRGB(colorIndex, 0); |
2 |
26 Feb 07 |
jari |
94 |
return new Color(rgb); |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
} |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
public Color getDiscreteColor(int copyNumber){ |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
if(copyNumber == BAD_CLONE){ |
2 |
26 Feb 07 |
jari |
101 |
return COLOR_NULL; |
2 |
26 Feb 07 |
jari |
102 |
} |
2 |
26 Feb 07 |
jari |
103 |
|
2 |
26 Feb 07 |
jari |
104 |
if(copyNumber == NO_COPY_CHANGE){ |
2 |
26 Feb 07 |
jari |
105 |
return COLOR_DEFAULT; |
2 |
26 Feb 07 |
jari |
106 |
} |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
108 |
if(copyNumber < 0){ |
2 |
26 Feb 07 |
jari |
109 |
if(copyNumber < -1){ |
2 |
26 Feb 07 |
jari |
110 |
return COLOR_DEL_2_COPY; |
2 |
26 Feb 07 |
jari |
111 |
}else{ |
2 |
26 Feb 07 |
jari |
112 |
return COLOR_DEL; |
2 |
26 Feb 07 |
jari |
113 |
} |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
if(copyNumber > 0){ |
2 |
26 Feb 07 |
jari |
117 |
if(copyNumber > 1){ |
2 |
26 Feb 07 |
jari |
118 |
return COLOR_AMP_2_COPY; |
2 |
26 Feb 07 |
jari |
119 |
}else{ |
2 |
26 Feb 07 |
jari |
120 |
return COLOR_AMP; |
2 |
26 Feb 07 |
jari |
121 |
} |
2 |
26 Feb 07 |
jari |
122 |
} |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
return COLOR_ERROR; |
2 |
26 Feb 07 |
jari |
125 |
} |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
/** Getter for property negColorImage. |
2 |
26 Feb 07 |
jari |
* @return Value of property negColorImage. |
2 |
26 Feb 07 |
jari |
129 |
*/ |
2 |
26 Feb 07 |
jari |
130 |
public java.awt.image.BufferedImage getNegColorImage() { |
2 |
26 Feb 07 |
jari |
131 |
return negColorImage; |
2 |
26 Feb 07 |
jari |
132 |
} |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
/** Setter for property negColorImage. |
2 |
26 Feb 07 |
jari |
* @param negColorImage New value of property negColorImage. |
2 |
26 Feb 07 |
jari |
136 |
*/ |
2 |
26 Feb 07 |
jari |
137 |
public void setNegColorImage(java.awt.image.BufferedImage negColorImage) { |
2 |
26 Feb 07 |
jari |
138 |
this.negColorImage = negColorImage; |
2 |
26 Feb 07 |
jari |
139 |
} |
2 |
26 Feb 07 |
jari |
140 |
|
2 |
26 Feb 07 |
jari |
/** Getter for property posColorImage. |
2 |
26 Feb 07 |
jari |
* @return Value of property posColorImage. |
2 |
26 Feb 07 |
jari |
143 |
*/ |
2 |
26 Feb 07 |
jari |
144 |
public java.awt.image.BufferedImage getPosColorImage() { |
2 |
26 Feb 07 |
jari |
145 |
return posColorImage; |
2 |
26 Feb 07 |
jari |
146 |
} |
2 |
26 Feb 07 |
jari |
147 |
|
2 |
26 Feb 07 |
jari |
/** Setter for property posColorImage. |
2 |
26 Feb 07 |
jari |
* @param posColorImage New value of property posColorImage. |
2 |
26 Feb 07 |
jari |
150 |
*/ |
2 |
26 Feb 07 |
jari |
151 |
public void setPosColorImage(java.awt.image.BufferedImage posColorImage) { |
2 |
26 Feb 07 |
jari |
152 |
this.posColorImage = posColorImage; |
2 |
26 Feb 07 |
jari |
153 |
} |
2 |
26 Feb 07 |
jari |
154 |
|
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
/** Getter for property maxRatioScale. |
2 |
26 Feb 07 |
jari |
* @return Value of property maxRatioScale. |
2 |
26 Feb 07 |
jari |
158 |
*/ |
2 |
26 Feb 07 |
jari |
159 |
public float getMaxRatioScale() { |
2 |
26 Feb 07 |
jari |
160 |
return maxRatioScale; |
2 |
26 Feb 07 |
jari |
161 |
} |
2 |
26 Feb 07 |
jari |
162 |
|
2 |
26 Feb 07 |
jari |
/** Setter for property maxRatioScale. |
2 |
26 Feb 07 |
jari |
* @param maxRatioScale New value of property maxRatioScale. |
2 |
26 Feb 07 |
jari |
165 |
*/ |
2 |
26 Feb 07 |
jari |
166 |
public void setMaxRatioScale(float maxRatioScale) { |
2 |
26 Feb 07 |
jari |
167 |
this.maxRatioScale = maxRatioScale; |
2 |
26 Feb 07 |
jari |
168 |
} |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
/** Getter for property minRatioScale. |
2 |
26 Feb 07 |
jari |
* @return Value of property minRatioScale. |
2 |
26 Feb 07 |
jari |
172 |
*/ |
2 |
26 Feb 07 |
jari |
173 |
public float getMinRatioScale() { |
2 |
26 Feb 07 |
jari |
174 |
return minRatioScale; |
2 |
26 Feb 07 |
jari |
175 |
} |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
/** Setter for property minRatioScale. |
2 |
26 Feb 07 |
jari |
* @param minRatioScale New value of property minRatioScale. |
2 |
26 Feb 07 |
jari |
179 |
*/ |
2 |
26 Feb 07 |
jari |
180 |
public void setMinRatioScale(float minRatioScale) { |
2 |
26 Feb 07 |
jari |
181 |
this.minRatioScale = minRatioScale; |
2 |
26 Feb 07 |
jari |
182 |
} |
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
/** Getter for property cloneValueType. |
2 |
26 Feb 07 |
jari |
* @return Value of property cloneValueType. |
2 |
26 Feb 07 |
jari |
186 |
*/ |
2 |
26 Feb 07 |
jari |
187 |
public int getCloneValueType() { |
2 |
26 Feb 07 |
jari |
188 |
return cloneValueType; |
2 |
26 Feb 07 |
jari |
189 |
} |
2 |
26 Feb 07 |
jari |
190 |
|
2 |
26 Feb 07 |
jari |
/** Setter for property cloneValueType. |
2 |
26 Feb 07 |
jari |
* @param cloneValueType New value of property cloneValueType. |
2 |
26 Feb 07 |
jari |
193 |
*/ |
2 |
26 Feb 07 |
jari |
194 |
public void setCloneValueType(int cloneValueType) { |
2 |
26 Feb 07 |
jari |
195 |
this.cloneValueType = cloneValueType; |
2 |
26 Feb 07 |
jari |
196 |
} |
2 |
26 Feb 07 |
jari |
197 |
|
2 |
26 Feb 07 |
jari |
198 |
public void onCloneValuesChanged(ICGHCloneValueMenu menu) { |
2 |
26 Feb 07 |
jari |
199 |
int type = menu.getCloneValueType(); |
2 |
26 Feb 07 |
jari |
200 |
if(type == ICGHCloneValueMenu.CLONE_VALUE_DISCRETE_DETERMINATION || |
2 |
26 Feb 07 |
jari |
201 |
type == ICGHCloneValueMenu.CLONE_VALUE_LOG_CLONE_DISTRIBUTION || |
2 |
26 Feb 07 |
jari |
202 |
type == ICGHCloneValueMenu.CLONE_VALUE_THRESHOLD_OR_CLONE_DISTRIBUTION){ |
2 |
26 Feb 07 |
jari |
203 |
this.cloneValueType = CLONE_VALUES_DISCRETE_DETERMINATION; |
2 |
26 Feb 07 |
jari |
204 |
}else{ |
2 |
26 Feb 07 |
jari |
205 |
this.cloneValueType = CLONE_VALUES_CONTINUOUS; |
2 |
26 Feb 07 |
jari |
206 |
} |
2 |
26 Feb 07 |
jari |
207 |
} |
2 |
26 Feb 07 |
jari |
208 |
|
2 |
26 Feb 07 |
jari |
209 |
public int getCGHSpecies(){ |
2 |
26 Feb 07 |
jari |
210 |
return data.getCGHSpecies(); |
2 |
26 Feb 07 |
jari |
211 |
} |
2 |
26 Feb 07 |
jari |
212 |
} |