2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SingleArrayViewer.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.10 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/05/15 20:25:23 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Cursor; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
25 |
import java.awt.Label; |
2 |
26 Feb 07 |
jari |
26 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
27 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
28 |
import java.awt.event.AdjustmentEvent; |
2 |
26 Feb 07 |
jari |
29 |
import java.awt.event.AdjustmentListener; |
2 |
26 Feb 07 |
jari |
30 |
import java.awt.event.ItemEvent; |
2 |
26 Feb 07 |
jari |
31 |
import java.awt.event.ItemListener; |
2 |
26 Feb 07 |
jari |
32 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
33 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
34 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
35 |
import java.awt.event.MouseListener; |
2 |
26 Feb 07 |
jari |
36 |
import java.awt.event.MouseMotionListener; |
2 |
26 Feb 07 |
jari |
37 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
38 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
39 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
40 |
import java.awt.print.PageFormat; |
2 |
26 Feb 07 |
jari |
41 |
import java.awt.print.Printable; |
2 |
26 Feb 07 |
jari |
42 |
import java.awt.print.PrinterException; |
2 |
26 Feb 07 |
jari |
43 |
import java.awt.print.PrinterJob; |
2 |
26 Feb 07 |
jari |
44 |
import java.io.BufferedOutputStream; |
2 |
26 Feb 07 |
jari |
45 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
46 |
import java.io.FileOutputStream; |
2 |
26 Feb 07 |
jari |
47 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
48 |
import java.io.PrintStream; |
2 |
26 Feb 07 |
jari |
49 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
50 |
import java.util.Properties; |
2 |
26 Feb 07 |
jari |
51 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
import javax.media.jai.JAI; |
2 |
26 Feb 07 |
jari |
54 |
import javax.media.jai.RenderedOp; |
2 |
26 Feb 07 |
jari |
55 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
56 |
import javax.swing.JCheckBox; |
2 |
26 Feb 07 |
jari |
57 |
import javax.swing.JCheckBoxMenuItem; |
2 |
26 Feb 07 |
jari |
58 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
59 |
import javax.swing.JFileChooser; |
2 |
26 Feb 07 |
jari |
60 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
61 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
62 |
import javax.swing.JMenu; |
2 |
26 Feb 07 |
jari |
63 |
import javax.swing.JMenuBar; |
2 |
26 Feb 07 |
jari |
64 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
65 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
66 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
67 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
68 |
import javax.swing.JRadioButtonMenuItem; |
2 |
26 Feb 07 |
jari |
69 |
import javax.swing.JScrollBar; |
2 |
26 Feb 07 |
jari |
70 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
71 |
import javax.swing.JSlider; |
2 |
26 Feb 07 |
jari |
72 |
import javax.swing.KeyStroke; |
2 |
26 Feb 07 |
jari |
73 |
import javax.swing.ScrollPaneConstants; |
2 |
26 Feb 07 |
jari |
74 |
import javax.swing.SwingConstants; |
2 |
26 Feb 07 |
jari |
75 |
import javax.swing.event.ChangeEvent; |
2 |
26 Feb 07 |
jari |
76 |
import javax.swing.event.ChangeListener; |
2 |
26 Feb 07 |
jari |
77 |
import javax.swing.filechooser.FileFilter; |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
79 |
import org.tigr.graph.GC; |
2 |
26 Feb 07 |
jari |
80 |
import org.tigr.graph.GraphBar; |
2 |
26 Feb 07 |
jari |
81 |
import org.tigr.graph.GraphLine; |
2 |
26 Feb 07 |
jari |
82 |
import org.tigr.graph.GraphPoint; |
2 |
26 Feb 07 |
jari |
83 |
import org.tigr.graph.GraphTick; |
2 |
26 Feb 07 |
jari |
84 |
import org.tigr.graph.GraphViewer; |
2 |
26 Feb 07 |
jari |
85 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.normalization.IterativeLogMCNormInitDialog; |
2 |
26 Feb 07 |
jari |
86 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.normalization.LinRegNormInitDialog; |
2 |
26 Feb 07 |
jari |
87 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.normalization.RatioStatsNormInitDialog; |
2 |
26 Feb 07 |
jari |
88 |
import org.tigr.microarray.util.SlideDataSorter; |
2 |
26 Feb 07 |
jari |
89 |
import org.tigr.microarray.util.awt.SetSlideFilenameDialog; |
2 |
26 Feb 07 |
jari |
90 |
import org.tigr.microarray.util.swing.SlideDataLoader; |
2 |
26 Feb 07 |
jari |
91 |
import org.tigr.util.Xcon; |
2 |
26 Feb 07 |
jari |
92 |
import org.tigr.util.awt.ActionInfoEvent; |
2 |
26 Feb 07 |
jari |
93 |
import org.tigr.util.awt.ActionInfoListener; |
2 |
26 Feb 07 |
jari |
94 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
95 |
import org.tigr.util.awt.MessageDisplay; |
2 |
26 Feb 07 |
jari |
96 |
|
2 |
26 Feb 07 |
jari |
97 |
import com.sun.media.jai.codec.JPEGEncodeParam; |
2 |
26 Feb 07 |
jari |
98 |
import com.sun.media.jai.codec.TIFFEncodeParam; |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
//Graph package |
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
|
2 |
26 Feb 07 |
jari |
104 |
public class SingleArrayViewer extends ArrayViewer implements Printable { |
2 |
26 Feb 07 |
jari |
105 |
private ISlideData slideData; |
2 |
26 Feb 07 |
jari |
106 |
private int[] indices; |
2 |
26 Feb 07 |
jari |
107 |
public SingleArrayViewerPanel panel; |
2 |
26 Feb 07 |
jari |
108 |
private SingleArrayViewerCanvas canvas; |
2 |
26 Feb 07 |
jari |
109 |
private SingleArrayViewerInfoBox infoBox; |
2 |
26 Feb 07 |
jari |
110 |
private EventListener eventListener = new EventListener(); |
2 |
26 Feb 07 |
jari |
111 |
private GBA gba = new GBA(); |
2 |
26 Feb 07 |
jari |
112 |
JScrollPane scrollPane; |
2 |
26 Feb 07 |
jari |
113 |
private int oldX = -1; |
2 |
26 Feb 07 |
jari |
114 |
private int oldY = -1; |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
JMenuBar menuBar = null; |
2 |
26 Feb 07 |
jari |
117 |
JMenu fileMenu = null; |
2 |
26 Feb 07 |
jari |
118 |
JMenuItem newDatabaseItem = null; |
2 |
26 Feb 07 |
jari |
119 |
JMenuItem newFileItem = null; |
2 |
26 Feb 07 |
jari |
120 |
JMenuItem newSpotfireItem = null; |
2 |
26 Feb 07 |
jari |
121 |
JMenuItem newReportItem = null; |
2 |
26 Feb 07 |
jari |
122 |
JMenuItem saveImageItem = null; |
2 |
26 Feb 07 |
jari |
123 |
JMenuItem printImageItem = null; |
2 |
26 Feb 07 |
jari |
124 |
JMenuItem closeItem = null; |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
126 |
JMenu viewsMenu = null; |
2 |
26 Feb 07 |
jari |
127 |
JMenu viewGraphMenu = null; |
2 |
26 Feb 07 |
jari |
128 |
JMenuItem newPlotItem = null; |
2 |
26 Feb 07 |
jari |
129 |
JMenuItem newPlotLogItem = null; |
2 |
26 Feb 07 |
jari |
130 |
JMenuItem newLogRatioProductItem = null; |
2 |
26 Feb 07 |
jari |
131 |
JMenuItem newLogRatioProductByBlockItem = null; |
2 |
26 Feb 07 |
jari |
132 |
JMenuItem newHistogramItem = null; |
2 |
26 Feb 07 |
jari |
133 |
JMenuItem newHistogramLogItem = null; |
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
JMenuItem subArrayItem = null; |
2 |
26 Feb 07 |
jari |
136 |
JMenuItem regionArrayItem = null; |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
JMenu normalizationMenu = null; |
2 |
26 Feb 07 |
jari |
139 |
JRadioButtonMenuItem totalIntensityItem = null; |
2 |
26 Feb 07 |
jari |
140 |
JRadioButtonMenuItem leastSquaresItem = null; |
2 |
26 Feb 07 |
jari |
141 |
JRadioButtonMenuItem linearRegressionItem = null; |
2 |
26 Feb 07 |
jari |
142 |
JRadioButtonMenuItem ratioStatisticsItem = null; |
2 |
26 Feb 07 |
jari |
143 |
JRadioButtonMenuItem iterativeLogItem = null; |
2 |
26 Feb 07 |
jari |
// JRadioButtonMenuItem lowessItem = null; |
2 |
26 Feb 07 |
jari |
145 |
JRadioButtonMenuItem totalIntensityListItem = null; |
2 |
26 Feb 07 |
jari |
146 |
JRadioButtonMenuItem leastSquaresListItem = null; |
2 |
26 Feb 07 |
jari |
147 |
JRadioButtonMenuItem linearRegressionListItem = null; |
2 |
26 Feb 07 |
jari |
148 |
JRadioButtonMenuItem ratioStatisticsListItem = null; |
2 |
26 Feb 07 |
jari |
149 |
JRadioButtonMenuItem iterativeLogListItem = null; |
2 |
26 Feb 07 |
jari |
150 |
JRadioButtonMenuItem noNormalizationItem = null; |
2 |
26 Feb 07 |
jari |
// JRadioButtonMenuItem lowessListItem = null; |
2 |
26 Feb 07 |
jari |
152 |
|
2 |
26 Feb 07 |
jari |
153 |
JMenu sortMenu = null; |
2 |
26 Feb 07 |
jari |
154 |
JRadioButtonMenuItem sortByLocationItem = null; |
2 |
26 Feb 07 |
jari |
155 |
JRadioButtonMenuItem sortByRatioItem = null; |
2 |
26 Feb 07 |
jari |
156 |
JRadioButtonMenuItem[] sortMenuItems = null; |
2 |
26 Feb 07 |
jari |
157 |
|
2 |
26 Feb 07 |
jari |
158 |
JMenu displayMenu = null; |
2 |
26 Feb 07 |
jari |
159 |
JCheckBoxMenuItem logItem = null; |
2 |
26 Feb 07 |
jari |
160 |
JMenu sizeMenu = null; |
2 |
26 Feb 07 |
jari |
161 |
JRadioButtonMenuItem defaultSize1Item = null; |
2 |
26 Feb 07 |
jari |
162 |
JRadioButtonMenuItem defaultSize2Item = null; |
2 |
26 Feb 07 |
jari |
163 |
JRadioButtonMenuItem defaultSize3Item = null; |
2 |
26 Feb 07 |
jari |
164 |
JRadioButtonMenuItem defaultSize4Item = null; |
2 |
26 Feb 07 |
jari |
165 |
JRadioButtonMenuItem setElementSizeItem = null; |
2 |
26 Feb 07 |
jari |
166 |
JCheckBoxMenuItem changeColorsItem = null; |
2 |
26 Feb 07 |
jari |
167 |
JRadioButtonMenuItem blueToRedItem = null; |
2 |
26 Feb 07 |
jari |
168 |
JRadioButtonMenuItem greenRedItem = null; |
2 |
26 Feb 07 |
jari |
169 |
JRadioButtonMenuItem overlayItem = null; |
2 |
26 Feb 07 |
jari |
170 |
|
2 |
26 Feb 07 |
jari |
171 |
JMenu controlMenu = null; |
2 |
26 Feb 07 |
jari |
172 |
JMenuItem setUpperLimitsItem = null; |
2 |
26 Feb 07 |
jari |
173 |
JMenuItem setGreenRedThresholdsItem = null; |
2 |
26 Feb 07 |
jari |
174 |
JMenuItem setConfidenceItem = null; |
2 |
26 Feb 07 |
jari |
175 |
JCheckBoxMenuItem setThresholdsItem = null; |
2 |
26 Feb 07 |
jari |
176 |
JCheckBoxMenuItem setScaleItem = null; |
2 |
26 Feb 07 |
jari |
177 |
ButtonGroup buttonGroup = null; |
2 |
26 Feb 07 |
jari |
178 |
|
2 |
26 Feb 07 |
jari |
179 |
private final static int startingXSize = 400; |
2 |
26 Feb 07 |
jari |
180 |
private final static int startingYSize = 400; |
2 |
26 Feb 07 |
jari |
181 |
|
2 |
26 Feb 07 |
jari |
182 |
private final static int LINEAR = 0; |
2 |
26 Feb 07 |
jari |
183 |
private final static int LOG = 1; |
2 |
26 Feb 07 |
jari |
184 |
|
2 |
26 Feb 07 |
jari |
185 |
public SingleArrayViewer(JFrame frame, ISlideData inputData) { |
2 |
26 Feb 07 |
jari |
186 |
super(frame); |
2 |
26 Feb 07 |
jari |
187 |
initializeViewer(); |
2 |
26 Feb 07 |
jari |
188 |
initializePanel(); |
2 |
26 Feb 07 |
jari |
189 |
initializeCanvas(); |
2 |
26 Feb 07 |
jari |
190 |
initializeFrame(); |
2 |
26 Feb 07 |
jari |
191 |
|
2 |
26 Feb 07 |
jari |
192 |
setSlideData(inputData); |
2 |
26 Feb 07 |
jari |
//this.slideData = new SlideData(inputData); |
2 |
26 Feb 07 |
jari |
//System.out.println("*****SAV 1:"); |
2 |
26 Feb 07 |
jari |
//inputData.output(); |
2 |
26 Feb 07 |
jari |
//System.out.println("*****SAV 2:"); |
2 |
26 Feb 07 |
jari |
//slideData.output(); |
2 |
26 Feb 07 |
jari |
//Draw the data |
2 |
26 Feb 07 |
jari |
199 |
|
2 |
26 Feb 07 |
jari |
200 |
panel.setXYScrollbars((long)slideData.getMaxIntensity(ISlideDataElement.CY3), (long)slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
201 |
|
2 |
26 Feb 07 |
jari |
202 |
systemEnable(TMEV.DATA_AVAILABLE); |
2 |
26 Feb 07 |
jari |
203 |
} |
2 |
26 Feb 07 |
jari |
204 |
|
2 |
26 Feb 07 |
jari |
205 |
public SingleArrayViewer(JFrame frame) { |
2 |
26 Feb 07 |
jari |
206 |
super(frame); |
2 |
26 Feb 07 |
jari |
207 |
initializeFrame(); |
2 |
26 Feb 07 |
jari |
208 |
initializeViewer(); |
2 |
26 Feb 07 |
jari |
209 |
initializePanel(); |
2 |
26 Feb 07 |
jari |
210 |
initializeCanvas(); |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
//Redundant? |
2 |
26 Feb 07 |
jari |
213 |
systemDisable(TMEV.DATA_AVAILABLE); |
2 |
26 Feb 07 |
jari |
214 |
systemDisable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
215 |
} |
2 |
26 Feb 07 |
jari |
216 |
|
2 |
26 Feb 07 |
jari |
217 |
public SingleArrayViewer(ISlideData slideData) { |
2 |
26 Feb 07 |
jari |
218 |
super(new JFrame("Single Array Viewer")); |
2 |
26 Feb 07 |
jari |
219 |
setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
220 |
initializeViewer(); |
2 |
26 Feb 07 |
jari |
221 |
initializePanel(); |
2 |
26 Feb 07 |
jari |
222 |
initializeCanvas(); |
2 |
26 Feb 07 |
jari |
//Draw the data |
2 |
26 Feb 07 |
jari |
224 |
|
2 |
26 Feb 07 |
jari |
225 |
systemEnable(TMEV.DATA_AVAILABLE); |
2 |
26 Feb 07 |
jari |
226 |
} |
2 |
26 Feb 07 |
jari |
227 |
|
2 |
26 Feb 07 |
jari |
228 |
public SingleArrayViewer() { |
2 |
26 Feb 07 |
jari |
229 |
super(new JFrame("Single Array Viewer")); |
2 |
26 Feb 07 |
jari |
230 |
initializeViewer(); |
2 |
26 Feb 07 |
jari |
231 |
initializePanel(); |
2 |
26 Feb 07 |
jari |
232 |
initializeCanvas(); |
2 |
26 Feb 07 |
jari |
233 |
} |
2 |
26 Feb 07 |
jari |
234 |
|
2 |
26 Feb 07 |
jari |
235 |
public JFrame getFrame() { |
2 |
26 Feb 07 |
jari |
236 |
return mainframe; |
2 |
26 Feb 07 |
jari |
237 |
} |
2 |
26 Feb 07 |
jari |
238 |
|
2 |
26 Feb 07 |
jari |
239 |
|
2 |
26 Feb 07 |
jari |
240 |
private int[] createIndices() { |
2 |
26 Feb 07 |
jari |
241 |
int[] indices = new int[slideData.getSize()]; |
2 |
26 Feb 07 |
jari |
242 |
for (int i=0; i<indices.length; i++) { |
2 |
26 Feb 07 |
jari |
243 |
indices[i] = i; |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
return indices; |
2 |
26 Feb 07 |
jari |
246 |
} |
2 |
26 Feb 07 |
jari |
247 |
|
2 |
26 Feb 07 |
jari |
248 |
private void initializeViewer() { |
2 |
26 Feb 07 |
jari |
249 |
setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
//setSize(startingXSize, startingYSize); |
2 |
26 Feb 07 |
jari |
251 |
} |
2 |
26 Feb 07 |
jari |
252 |
|
2 |
26 Feb 07 |
jari |
253 |
private void initializePanel() { |
2 |
26 Feb 07 |
jari |
254 |
panel = new SingleArrayViewerPanel(); |
2 |
26 Feb 07 |
jari |
255 |
gba.add(this, panel, 0, 0, 1, 2, 0, 0, GBA.NONE, GBA.W, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
256 |
|
2 |
26 Feb 07 |
jari |
257 |
infoBox = new SingleArrayViewerInfoBox(); |
2 |
26 Feb 07 |
jari |
258 |
gba.add(this, infoBox, 0, 2, 1, 1, 0, 0, GBA.NONE, GBA.SW, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
259 |
} |
2 |
26 Feb 07 |
jari |
260 |
|
2 |
26 Feb 07 |
jari |
261 |
private void initializeCanvas() { |
2 |
26 Feb 07 |
jari |
262 |
canvas = new SingleArrayViewerCanvas(20, 20, 50, 20); |
2 |
26 Feb 07 |
jari |
263 |
canvas.addMouseListener(eventListener); |
2 |
26 Feb 07 |
jari |
264 |
canvas.addMouseMotionListener(eventListener); |
2 |
26 Feb 07 |
jari |
265 |
canvas.addKeyListener(eventListener); |
2 |
26 Feb 07 |
jari |
266 |
canvas.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
267 |
scrollPane = new JScrollPane(canvas, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
268 |
scrollPane.getViewport().setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
269 |
scrollPane.getVerticalScrollBar().setToolTipText("Use up/down/pgup/pgdown to scroll image"); |
2 |
26 Feb 07 |
jari |
270 |
gba.add(this, scrollPane, 1, 0, 1, 1, 1, 1, GBA.B, GBA.NW); |
2 |
26 Feb 07 |
jari |
//Setting the lineup, linedown, pageup, pagedown keystrokes |
2 |
26 Feb 07 |
jari |
272 |
KeyStroke up = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_UP, 0); |
2 |
26 Feb 07 |
jari |
273 |
KeyStroke down = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DOWN, 0); |
2 |
26 Feb 07 |
jari |
274 |
KeyStroke pgup = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_UP, 0); |
2 |
26 Feb 07 |
jari |
275 |
KeyStroke pgdown = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_DOWN, 0); |
2 |
26 Feb 07 |
jari |
276 |
scrollPane.registerKeyboardAction(eventListener, "lineup", up, JComponent.WHEN_IN_FOCUSED_WINDOW); |
2 |
26 Feb 07 |
jari |
277 |
scrollPane.registerKeyboardAction(eventListener, "linedown", down, JComponent.WHEN_IN_FOCUSED_WINDOW); |
2 |
26 Feb 07 |
jari |
278 |
scrollPane.registerKeyboardAction(eventListener, "pageup", pgup, JComponent.WHEN_IN_FOCUSED_WINDOW); |
2 |
26 Feb 07 |
jari |
279 |
scrollPane.registerKeyboardAction(eventListener, "pagedown", pgdown, JComponent.WHEN_IN_FOCUSED_WINDOW); |
2 |
26 Feb 07 |
jari |
280 |
} |
2 |
26 Feb 07 |
jari |
281 |
|
2 |
26 Feb 07 |
jari |
282 |
private void initializeFrame() { |
2 |
26 Feb 07 |
jari |
283 |
mainframe.setTitle("Single Array Viewer"); |
2 |
26 Feb 07 |
jari |
284 |
mainframe.getContentPane().setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
285 |
mainframe.setResizable(true); |
2 |
26 Feb 07 |
jari |
286 |
mainframe.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//mainframe.setIconImage((new ImageIcon(org.tigr.microarray.SingleArrayViewer.class.getResource("/org/tigr/images/expression.gif"))).getImage()); |
2 |
26 Feb 07 |
jari |
288 |
mainframe.addWindowListener(new WindowAdapter() { |
2 |
26 Feb 07 |
jari |
289 |
public void windowClosing(WindowEvent e) {close();} |
2 |
26 Feb 07 |
jari |
290 |
}); |
2 |
26 Feb 07 |
jari |
291 |
initializeMenuBar(mainframe); |
2 |
26 Feb 07 |
jari |
292 |
gba.add(mainframe.getContentPane(), this, 0, 0, 1, 1, 1, 1, GBA.B, GBA.C); |
2 |
26 Feb 07 |
jari |
293 |
mainframe.pack(); |
2 |
26 Feb 07 |
jari |
294 |
|
2 |
26 Feb 07 |
jari |
//Any initial MenuItem enables/disables go here |
2 |
26 Feb 07 |
jari |
296 |
newDatabaseItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
297 |
sortByLocationItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
298 |
logItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
299 |
changeColorsItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
300 |
overlayItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
301 |
setThresholdsItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
302 |
setScaleItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
303 |
noNormalizationItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
304 |
setConfidenceItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
305 |
defaultSize3Item.setSelected(true); |
2 |
26 Feb 07 |
jari |
306 |
} |
2 |
26 Feb 07 |
jari |
307 |
|
2 |
26 Feb 07 |
jari |
308 |
private void initializeMenuBar(JFrame frame) { |
2 |
26 Feb 07 |
jari |
309 |
menuBar = new JMenuBar(); |
2 |
26 Feb 07 |
jari |
310 |
|
2 |
26 Feb 07 |
jari |
311 |
fileMenu = new JMenu("File"); |
2 |
26 Feb 07 |
jari |
312 |
|
2 |
26 Feb 07 |
jari |
313 |
newDatabaseItem = new JMenuItem("Open Experiment from DB"); |
2 |
26 Feb 07 |
jari |
314 |
newDatabaseItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
315 |
fileMenu.add(newDatabaseItem); |
2 |
26 Feb 07 |
jari |
316 |
fileMenu.getMenuComponent(0).setEnabled(false); //disable until supported, 4.30.03 |
2 |
26 Feb 07 |
jari |
317 |
|
2 |
26 Feb 07 |
jari |
318 |
newFileItem = new JMenuItem("Open Experiment From File"); |
2 |
26 Feb 07 |
jari |
319 |
newFileItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
320 |
fileMenu.add(newFileItem); |
2 |
26 Feb 07 |
jari |
321 |
|
2 |
26 Feb 07 |
jari |
322 |
newReportItem = new JMenuItem("Generate Report"); |
2 |
26 Feb 07 |
jari |
323 |
newReportItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
324 |
fileMenu.add(newReportItem); |
2 |
26 Feb 07 |
jari |
325 |
|
2 |
26 Feb 07 |
jari |
326 |
fileMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
327 |
|
2 |
26 Feb 07 |
jari |
328 |
saveImageItem = new JMenuItem("Save Image"); |
2 |
26 Feb 07 |
jari |
329 |
saveImageItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
330 |
fileMenu.add(saveImageItem); |
2 |
26 Feb 07 |
jari |
331 |
|
2 |
26 Feb 07 |
jari |
332 |
printImageItem = new JMenuItem("Print Image"); |
2 |
26 Feb 07 |
jari |
333 |
printImageItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
334 |
fileMenu.add(printImageItem); |
2 |
26 Feb 07 |
jari |
335 |
|
2 |
26 Feb 07 |
jari |
336 |
fileMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
337 |
|
2 |
26 Feb 07 |
jari |
338 |
newSpotfireItem = new JMenuItem("Export to Spotfire"); |
2 |
26 Feb 07 |
jari |
339 |
newSpotfireItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
//fileMenu.add(newSpotfireItem); |
2 |
26 Feb 07 |
jari |
341 |
|
2 |
26 Feb 07 |
jari |
342 |
closeItem = new JMenuItem("Close"); |
2 |
26 Feb 07 |
jari |
343 |
closeItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
344 |
fileMenu.add(closeItem); |
2 |
26 Feb 07 |
jari |
345 |
|
2 |
26 Feb 07 |
jari |
346 |
menuBar.add(fileMenu); |
2 |
26 Feb 07 |
jari |
347 |
|
2 |
26 Feb 07 |
jari |
348 |
viewsMenu = new JMenu("Views"); |
2 |
26 Feb 07 |
jari |
349 |
|
2 |
26 Feb 07 |
jari |
350 |
viewGraphMenu = new JMenu("View Graph"); |
2 |
26 Feb 07 |
jari |
351 |
viewsMenu.add(viewGraphMenu); |
2 |
26 Feb 07 |
jari |
352 |
|
2 |
26 Feb 07 |
jari |
353 |
newPlotItem = new JMenuItem("Intensity Scatterplot"); |
2 |
26 Feb 07 |
jari |
354 |
newPlotItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
355 |
viewGraphMenu.add(newPlotItem); |
2 |
26 Feb 07 |
jari |
356 |
|
2 |
26 Feb 07 |
jari |
357 |
newPlotLogItem = new JMenuItem("Intensity Scatterplot (log)"); |
2 |
26 Feb 07 |
jari |
358 |
newPlotLogItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
359 |
viewGraphMenu.add(newPlotLogItem); |
2 |
26 Feb 07 |
jari |
360 |
|
2 |
26 Feb 07 |
jari |
361 |
newLogRatioProductItem = new JMenuItem("Log Ratio x Log Product"); |
2 |
26 Feb 07 |
jari |
362 |
newLogRatioProductItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
363 |
viewGraphMenu.add(newLogRatioProductItem); |
2 |
26 Feb 07 |
jari |
364 |
|
2 |
26 Feb 07 |
jari |
365 |
newLogRatioProductByBlockItem = new JMenuItem("Log Ratio x Log Product, by Metablock"); |
2 |
26 Feb 07 |
jari |
366 |
newLogRatioProductByBlockItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
367 |
viewGraphMenu.add(newLogRatioProductByBlockItem); |
2 |
26 Feb 07 |
jari |
368 |
|
2 |
26 Feb 07 |
jari |
369 |
newHistogramItem = new JMenuItem("Ratio Histogram"); |
2 |
26 Feb 07 |
jari |
370 |
newHistogramItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
371 |
viewGraphMenu.add(newHistogramItem); |
2 |
26 Feb 07 |
jari |
372 |
|
2 |
26 Feb 07 |
jari |
373 |
newHistogramLogItem = new JMenuItem("Ratio Histogram (log)"); |
2 |
26 Feb 07 |
jari |
374 |
newHistogramLogItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
375 |
viewGraphMenu.add(newHistogramLogItem); |
2 |
26 Feb 07 |
jari |
376 |
|
2 |
26 Feb 07 |
jari |
377 |
subArrayItem = new JMenuItem("View SubArray"); |
2 |
26 Feb 07 |
jari |
378 |
subArrayItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
379 |
viewsMenu.add(subArrayItem); |
2 |
26 Feb 07 |
jari |
380 |
|
2 |
26 Feb 07 |
jari |
381 |
regionArrayItem = new JMenuItem("View Region"); |
2 |
26 Feb 07 |
jari |
382 |
regionArrayItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
383 |
viewsMenu.add(regionArrayItem); |
2 |
26 Feb 07 |
jari |
384 |
|
2 |
26 Feb 07 |
jari |
385 |
menuBar.add(viewsMenu); |
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
387 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
388 |
normalizationMenu = new JMenu("Normalization"); |
2 |
26 Feb 07 |
jari |
389 |
|
2 |
26 Feb 07 |
jari |
390 |
totalIntensityItem = new JRadioButtonMenuItem("Total Intensity"); |
2 |
26 Feb 07 |
jari |
391 |
totalIntensityItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
392 |
normalizationMenu.add(totalIntensityItem); |
2 |
26 Feb 07 |
jari |
393 |
buttonGroup.add(totalIntensityItem); |
2 |
26 Feb 07 |
jari |
394 |
|
2 |
26 Feb 07 |
jari |
395 |
linearRegressionItem = new JRadioButtonMenuItem("Linear Regression"); |
2 |
26 Feb 07 |
jari |
396 |
linearRegressionItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
397 |
normalizationMenu.add(linearRegressionItem); |
2 |
26 Feb 07 |
jari |
398 |
buttonGroup.add(linearRegressionItem); |
2 |
26 Feb 07 |
jari |
399 |
|
2 |
26 Feb 07 |
jari |
400 |
ratioStatisticsItem = new JRadioButtonMenuItem("Ratio Statistics"); |
2 |
26 Feb 07 |
jari |
401 |
ratioStatisticsItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
402 |
normalizationMenu.add(ratioStatisticsItem); |
2 |
26 Feb 07 |
jari |
403 |
buttonGroup.add(ratioStatisticsItem); |
2 |
26 Feb 07 |
jari |
404 |
|
2 |
26 Feb 07 |
jari |
405 |
iterativeLogItem = new JRadioButtonMenuItem("Iterative Log"); |
2 |
26 Feb 07 |
jari |
406 |
iterativeLogItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
407 |
normalizationMenu.add(iterativeLogItem); |
2 |
26 Feb 07 |
jari |
408 |
buttonGroup.add(iterativeLogItem); |
2 |
26 Feb 07 |
jari |
409 |
|
2 |
26 Feb 07 |
jari |
410 |
|
2 |
26 Feb 07 |
jari |
411 |
normalizationMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
noNormalizationItem = new JRadioButtonMenuItem("No Normalization"); |
2 |
26 Feb 07 |
jari |
414 |
noNormalizationItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
415 |
normalizationMenu.add(noNormalizationItem); |
2 |
26 Feb 07 |
jari |
416 |
buttonGroup.add(noNormalizationItem); |
2 |
26 Feb 07 |
jari |
417 |
|
2 |
26 Feb 07 |
jari |
418 |
menuBar.add(normalizationMenu); |
2 |
26 Feb 07 |
jari |
419 |
|
2 |
26 Feb 07 |
jari |
420 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
421 |
sortMenu = new JMenu("Sort"); |
2 |
26 Feb 07 |
jari |
422 |
|
2 |
26 Feb 07 |
jari |
423 |
sortByLocationItem = new JRadioButtonMenuItem("By Location"); |
2 |
26 Feb 07 |
jari |
424 |
sortByLocationItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
425 |
sortMenu.add(sortByLocationItem); |
2 |
26 Feb 07 |
jari |
426 |
buttonGroup.add(sortByLocationItem); |
2 |
26 Feb 07 |
jari |
427 |
|
2 |
26 Feb 07 |
jari |
428 |
sortByRatioItem = new JRadioButtonMenuItem("By Cy5/Cy3 Ratio"); |
2 |
26 Feb 07 |
jari |
429 |
sortByRatioItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
430 |
sortMenu.add(sortByRatioItem); |
2 |
26 Feb 07 |
jari |
431 |
buttonGroup.add(sortByRatioItem); |
2 |
26 Feb 07 |
jari |
432 |
|
2 |
26 Feb 07 |
jari |
433 |
try { |
2 |
26 Feb 07 |
jari |
434 |
if (getFieldNames() != null) addSortMenuItems(getFieldNames(), buttonGroup); |
2 |
26 Feb 07 |
jari |
435 |
} catch (NullPointerException npe){} |
2 |
26 Feb 07 |
jari |
436 |
|
2 |
26 Feb 07 |
jari |
437 |
menuBar.add(sortMenu); |
2 |
26 Feb 07 |
jari |
438 |
|
2 |
26 Feb 07 |
jari |
439 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
440 |
displayMenu = new JMenu("Display"); |
2 |
26 Feb 07 |
jari |
441 |
|
2 |
26 Feb 07 |
jari |
442 |
blueToRedItem = new JRadioButtonMenuItem("Blue -> Red"); |
2 |
26 Feb 07 |
jari |
443 |
blueToRedItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
444 |
displayMenu.add(blueToRedItem); |
2 |
26 Feb 07 |
jari |
445 |
buttonGroup.add(blueToRedItem); |
2 |
26 Feb 07 |
jari |
446 |
|
2 |
26 Feb 07 |
jari |
447 |
greenRedItem = new JRadioButtonMenuItem("Green / Red"); |
2 |
26 Feb 07 |
jari |
448 |
greenRedItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
449 |
displayMenu.add(greenRedItem); |
2 |
26 Feb 07 |
jari |
450 |
buttonGroup.add(greenRedItem); |
2 |
26 Feb 07 |
jari |
451 |
|
2 |
26 Feb 07 |
jari |
452 |
overlayItem = new JRadioButtonMenuItem("G/R Overlay"); |
2 |
26 Feb 07 |
jari |
453 |
overlayItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
454 |
displayMenu.add(overlayItem); |
2 |
26 Feb 07 |
jari |
455 |
buttonGroup.add(overlayItem); |
2 |
26 Feb 07 |
jari |
456 |
|
2 |
26 Feb 07 |
jari |
457 |
displayMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
458 |
|
2 |
26 Feb 07 |
jari |
459 |
logItem = new JCheckBoxMenuItem("Log Scale"); |
2 |
26 Feb 07 |
jari |
460 |
logItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
461 |
displayMenu.add(logItem); |
2 |
26 Feb 07 |
jari |
462 |
|
2 |
26 Feb 07 |
jari |
463 |
displayMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
464 |
|
2 |
26 Feb 07 |
jari |
465 |
changeColorsItem = new JCheckBoxMenuItem("Change Colors"); |
2 |
26 Feb 07 |
jari |
466 |
changeColorsItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
467 |
displayMenu.add(changeColorsItem); |
2 |
26 Feb 07 |
jari |
468 |
|
2 |
26 Feb 07 |
jari |
469 |
displayMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
470 |
|
2 |
26 Feb 07 |
jari |
471 |
sizeMenu = new JMenu("Element Size"); |
2 |
26 Feb 07 |
jari |
472 |
sizeMenu.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
473 |
displayMenu.add(sizeMenu); |
2 |
26 Feb 07 |
jari |
474 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
475 |
|
2 |
26 Feb 07 |
jari |
476 |
defaultSize1Item = new JRadioButtonMenuItem("5 x 2"); |
2 |
26 Feb 07 |
jari |
477 |
defaultSize1Item.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
478 |
sizeMenu.add(defaultSize1Item); |
2 |
26 Feb 07 |
jari |
479 |
buttonGroup.add(defaultSize1Item); |
2 |
26 Feb 07 |
jari |
480 |
|
2 |
26 Feb 07 |
jari |
481 |
defaultSize2Item = new JRadioButtonMenuItem("10 x 10"); |
2 |
26 Feb 07 |
jari |
482 |
defaultSize2Item.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
483 |
sizeMenu.add(defaultSize2Item); |
2 |
26 Feb 07 |
jari |
484 |
buttonGroup.add(defaultSize2Item); |
2 |
26 Feb 07 |
jari |
485 |
|
2 |
26 Feb 07 |
jari |
486 |
defaultSize3Item = new JRadioButtonMenuItem("20 x 5"); |
2 |
26 Feb 07 |
jari |
487 |
defaultSize3Item.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
488 |
sizeMenu.add(defaultSize3Item); |
2 |
26 Feb 07 |
jari |
489 |
buttonGroup.add(defaultSize3Item); |
2 |
26 Feb 07 |
jari |
490 |
|
2 |
26 Feb 07 |
jari |
491 |
defaultSize4Item = new JRadioButtonMenuItem("50 x 10"); |
2 |
26 Feb 07 |
jari |
492 |
defaultSize4Item.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
493 |
sizeMenu.add(defaultSize4Item); |
2 |
26 Feb 07 |
jari |
494 |
buttonGroup.add(defaultSize4Item); |
2 |
26 Feb 07 |
jari |
495 |
|
2 |
26 Feb 07 |
jari |
496 |
setElementSizeItem = new JRadioButtonMenuItem("Other"); |
2 |
26 Feb 07 |
jari |
497 |
setElementSizeItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
498 |
sizeMenu.add(setElementSizeItem); |
2 |
26 Feb 07 |
jari |
499 |
buttonGroup.add(setElementSizeItem); |
2 |
26 Feb 07 |
jari |
500 |
|
2 |
26 Feb 07 |
jari |
501 |
|
2 |
26 Feb 07 |
jari |
502 |
menuBar.add(displayMenu); |
2 |
26 Feb 07 |
jari |
503 |
|
2 |
26 Feb 07 |
jari |
504 |
controlMenu = new JMenu("Control"); |
2 |
26 Feb 07 |
jari |
505 |
|
2 |
26 Feb 07 |
jari |
506 |
setUpperLimitsItem = new JMenuItem("Set Thresholds"); |
2 |
26 Feb 07 |
jari |
507 |
setUpperLimitsItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
508 |
controlMenu.add(setUpperLimitsItem); |
2 |
26 Feb 07 |
jari |
509 |
|
2 |
26 Feb 07 |
jari |
510 |
setGreenRedThresholdsItem = new JMenuItem("Set Expression Ratio"); |
2 |
26 Feb 07 |
jari |
511 |
setGreenRedThresholdsItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
512 |
controlMenu.add(setGreenRedThresholdsItem); |
2 |
26 Feb 07 |
jari |
513 |
|
2 |
26 Feb 07 |
jari |
514 |
setConfidenceItem = new JMenuItem("Set Confidence Level"); |
2 |
26 Feb 07 |
jari |
515 |
setConfidenceItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
516 |
controlMenu.add(setConfidenceItem); |
2 |
26 Feb 07 |
jari |
517 |
|
2 |
26 Feb 07 |
jari |
518 |
controlMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
519 |
|
2 |
26 Feb 07 |
jari |
520 |
setThresholdsItem = new JCheckBoxMenuItem("Expression Ratio"); |
2 |
26 Feb 07 |
jari |
521 |
setThresholdsItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
522 |
controlMenu.add(setThresholdsItem); |
2 |
26 Feb 07 |
jari |
523 |
|
2 |
26 Feb 07 |
jari |
524 |
controlMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
525 |
|
2 |
26 Feb 07 |
jari |
526 |
setScaleItem = new JCheckBoxMenuItem("G/R Scale"); |
2 |
26 Feb 07 |
jari |
527 |
setScaleItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
528 |
controlMenu.add(setScaleItem); |
2 |
26 Feb 07 |
jari |
529 |
|
2 |
26 Feb 07 |
jari |
530 |
menuBar.add(controlMenu); |
2 |
26 Feb 07 |
jari |
531 |
|
2 |
26 Feb 07 |
jari |
532 |
frame.setJMenuBar(menuBar); |
2 |
26 Feb 07 |
jari |
533 |
} |
2 |
26 Feb 07 |
jari |
534 |
|
2 |
26 Feb 07 |
jari |
535 |
public void addSortMenuItems(String[] sortTypes, ButtonGroup group) { |
2 |
26 Feb 07 |
jari |
536 |
sortMenuItems = new JRadioButtonMenuItem[sortTypes.length]; |
2 |
26 Feb 07 |
jari |
537 |
for (int i = 0; i < sortMenuItems.length; i++) { |
2 |
26 Feb 07 |
jari |
538 |
sortMenuItems[i] = new JRadioButtonMenuItem("Sort by " + sortTypes[i]); |
2 |
26 Feb 07 |
jari |
539 |
sortMenuItems[i].addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
540 |
sortMenu.add(sortMenuItems[i]); |
2 |
26 Feb 07 |
jari |
541 |
group.add(sortMenuItems[i]); |
2 |
26 Feb 07 |
jari |
542 |
} |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
|
2 |
26 Feb 07 |
jari |
545 |
/* |
2 |
26 Feb 07 |
jari |
public void loadFirstData() |
2 |
26 Feb 07 |
jari |
547 |
{ |
2 |
26 Feb 07 |
jari |
try |
2 |
26 Feb 07 |
jari |
549 |
{ |
2 |
26 Feb 07 |
jari |
String inputPreference = TMEV.getSettingForOption("Input Preference"); |
2 |
26 Feb 07 |
jari |
551 |
|
2 |
26 Feb 07 |
jari |
if (inputPreference.equals("Database")) |
2 |
26 Feb 07 |
jari |
553 |
{ |
2 |
26 Feb 07 |
jari |
databaseLogin(); |
2 |
26 Feb 07 |
jari |
//loadDataFromDatabase(); |
2 |
26 Feb 07 |
jari |
556 |
} |
2 |
26 Feb 07 |
jari |
else if (inputPreference.equals("File")) |
2 |
26 Feb 07 |
jari |
558 |
{ |
2 |
26 Feb 07 |
jari |
databaseLogin(); |
2 |
26 Feb 07 |
jari |
//loadDataFromDatabase(); |
2 |
26 Feb 07 |
jari |
561 |
} |
2 |
26 Feb 07 |
jari |
else if (inputPreference.equals("Only File")) |
2 |
26 Feb 07 |
jari |
563 |
{ |
2 |
26 Feb 07 |
jari |
//selectFile(); |
2 |
26 Feb 07 |
jari |
565 |
} |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
567 |
{ |
2 |
26 Feb 07 |
jari |
Manager.message(frame, "Error: Invalid Preferences File"); |
2 |
26 Feb 07 |
jari |
569 |
} |
2 |
26 Feb 07 |
jari |
570 |
} |
2 |
26 Feb 07 |
jari |
catch (Exception e) {System.out.println("Exception (MultipleArrayViewer.loadData()): " + e);} |
2 |
26 Feb 07 |
jari |
572 |
} |
2 |
26 Feb 07 |
jari |
573 |
*/ |
2 |
26 Feb 07 |
jari |
574 |
/** |
2 |
26 Feb 07 |
jari |
* Returns all annotation fields |
2 |
26 Feb 07 |
jari |
576 |
*/ |
2 |
26 Feb 07 |
jari |
577 |
public String[] getFieldNames() { |
2 |
26 Feb 07 |
jari |
578 |
return slideData.getSlideMetaData().getFieldNames(); |
2 |
26 Feb 07 |
jari |
579 |
} |
2 |
26 Feb 07 |
jari |
580 |
|
2 |
26 Feb 07 |
jari |
581 |
public ISlideData loadDataFromDatabase() { |
2 |
26 Feb 07 |
jari |
582 |
ISlideData slideData = null; |
2 |
26 Feb 07 |
jari |
583 |
|
2 |
26 Feb 07 |
jari |
584 |
try { |
2 |
26 Feb 07 |
jari |
//Query query = new Query("exec get_experiment_name"); |
2 |
26 Feb 07 |
jari |
//Vector resultVector = query.executeQuery(TMEV.getConnection()); |
2 |
26 Feb 07 |
jari |
// STUB: |
2 |
26 Feb 07 |
jari |
588 |
SetSlideFilenameDialog ssfd = new SetSlideFilenameDialog(mainframe, new String[] {}); |
2 |
26 Feb 07 |
jari |
589 |
if (ssfd.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
590 |
String filename = ssfd.getFileName(); |
2 |
26 Feb 07 |
jari |
591 |
loadDataFromDatabase(filename); |
2 |
26 Feb 07 |
jari |
592 |
} |
2 |
26 Feb 07 |
jari |
593 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
594 |
System.out.println("Exception (SingleArrayViewer.loadDataFromDatabase()): " + e); |
2 |
26 Feb 07 |
jari |
595 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
596 |
} |
2 |
26 Feb 07 |
jari |
597 |
return slideData; |
2 |
26 Feb 07 |
jari |
598 |
} |
2 |
26 Feb 07 |
jari |
599 |
|
2 |
26 Feb 07 |
jari |
600 |
public void loadDataFromDatabase(String filename) { |
2 |
26 Feb 07 |
jari |
/*SlideData slideData = super.loadDataFromDatabase(filename); |
2 |
26 Feb 07 |
jari |
panel.setXYScrollbars(slideData.getMaxIntensity(ISlideDataElement.CY3), slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
refreshSlide();*/ |
2 |
26 Feb 07 |
jari |
605 |
} |
2 |
26 Feb 07 |
jari |
606 |
|
2 |
26 Feb 07 |
jari |
607 |
public void loadFile() { |
2 |
26 Feb 07 |
jari |
608 |
JFileChooser jfc = new JFileChooser(TMEV.getFile("preferences/")); |
2 |
26 Feb 07 |
jari |
609 |
FileFilter ff = new FileFilter() { |
2 |
26 Feb 07 |
jari |
610 |
public boolean accept(File file) { |
2 |
26 Feb 07 |
jari |
611 |
if (file.isDirectory()) return true; |
2 |
26 Feb 07 |
jari |
612 |
String filename = file.getName(); |
2 |
26 Feb 07 |
jari |
613 |
if (filename.endsWith("Preferences")) return true; |
2 |
26 Feb 07 |
jari |
614 |
else if (filename.endsWith("preferences")) return true; |
2 |
26 Feb 07 |
jari |
615 |
else if (filename.endsWith(".pref")) return true; |
2 |
26 Feb 07 |
jari |
616 |
else return false; |
2 |
26 Feb 07 |
jari |
617 |
} |
2 |
26 Feb 07 |
jari |
618 |
|
2 |
26 Feb 07 |
jari |
619 |
public String getDescription() { |
2 |
26 Feb 07 |
jari |
620 |
return "Preference Files"; |
2 |
26 Feb 07 |
jari |
621 |
} |
2 |
26 Feb 07 |
jari |
622 |
}; |
2 |
26 Feb 07 |
jari |
623 |
jfc.setFileFilter(ff); |
2 |
26 Feb 07 |
jari |
624 |
int activityCode = jfc.showDialog(this, "Select"); |
2 |
26 Feb 07 |
jari |
625 |
|
2 |
26 Feb 07 |
jari |
626 |
if (activityCode == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
627 |
File target = jfc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
628 |
TMEV.readPreferencesFile(target); |
2 |
26 Feb 07 |
jari |
629 |
} |
2 |
26 Feb 07 |
jari |
630 |
|
2 |
26 Feb 07 |
jari |
631 |
|
2 |
26 Feb 07 |
jari |
632 |
|
2 |
26 Feb 07 |
jari |
633 |
try { |
2 |
26 Feb 07 |
jari |
634 |
ISlideData slideData = loadSlideData(null); |
2 |
26 Feb 07 |
jari |
635 |
if (slideData != null) { |
2 |
26 Feb 07 |
jari |
636 |
setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
637 |
panel.setXYScrollbars((long)slideData.getMaxIntensity(ISlideDataElement.CY3), (long)slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
638 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
639 |
} |
2 |
26 Feb 07 |
jari |
640 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
641 |
Manager.message(getFrame(), e); |
2 |
26 Feb 07 |
jari |
642 |
} |
2 |
26 Feb 07 |
jari |
643 |
} |
2 |
26 Feb 07 |
jari |
644 |
|
2 |
26 Feb 07 |
jari |
/*public SlideData loadDataFromFile(String filename) { |
2 |
26 Feb 07 |
jari |
SlideData slideData = super.loadSlideData(filename); |
2 |
26 Feb 07 |
jari |
setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
panel.setXYScrollbars(slideData.getMaxIntensity(ISlideDataElement.CY3), slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
return slideData; |
2 |
26 Feb 07 |
jari |
651 |
}*/ |
2 |
26 Feb 07 |
jari |
652 |
|
2 |
26 Feb 07 |
jari |
653 |
public ISlideData getSlideData() { |
2 |
26 Feb 07 |
jari |
654 |
return this.slideData; |
2 |
26 Feb 07 |
jari |
655 |
} |
2 |
26 Feb 07 |
jari |
656 |
|
2 |
26 Feb 07 |
jari |
657 |
public void setSlideData(ISlideData newData) { |
2 |
26 Feb 07 |
jari |
658 |
if(newData instanceof SlideData){ |
2 |
26 Feb 07 |
jari |
659 |
SlideData dataClone = (SlideData)((SlideData)newData).clone(); |
2 |
26 Feb 07 |
jari |
660 |
this.slideData = SlideDataLoader.fillBlankSpots(dataClone); |
2 |
26 Feb 07 |
jari |
661 |
} |
2 |
26 Feb 07 |
jari |
662 |
else if(newData instanceof FloatSlideData){ |
2 |
26 Feb 07 |
jari |
663 |
this.slideData = new SlideData(newData); |
2 |
26 Feb 07 |
jari |
664 |
this.slideData = SlideDataLoader.fillBlankSpots(this.slideData); |
2 |
26 Feb 07 |
jari |
665 |
} |
2 |
26 Feb 07 |
jari |
666 |
else |
2 |
26 Feb 07 |
jari |
667 |
this.slideData = newData; |
2 |
26 Feb 07 |
jari |
668 |
indices = createIndices(); |
2 |
26 Feb 07 |
jari |
669 |
canvas.updateSizes(); |
2 |
26 Feb 07 |
jari |
670 |
} |
2 |
26 Feb 07 |
jari |
671 |
|
2 |
26 Feb 07 |
jari |
672 |
public void createSubArray() { |
2 |
26 Feb 07 |
jari |
673 |
String source; |
2 |
26 Feb 07 |
jari |
674 |
SingleArrayViewer subViewer; |
2 |
26 Feb 07 |
jari |
675 |
Vector holding; |
2 |
26 Feb 07 |
jari |
676 |
ISlideData newSlideData; |
2 |
26 Feb 07 |
jari |
677 |
ISlideDataElement sde, sdo; |
2 |
26 Feb 07 |
jari |
678 |
double low = canvas.getLowDifference(); |
2 |
26 Feb 07 |
jari |
679 |
double high = canvas.getHighDifference(); |
2 |
26 Feb 07 |
jari |
680 |
|
2 |
26 Feb 07 |
jari |
681 |
if (canvas.getThresholds()) source = "SubArray: Lower " + (Math.rint(low * 100) / 100) + ", Higher " + (Math.rint(high * 100) / 100); |
2 |
26 Feb 07 |
jari |
682 |
else source = "SubArray: No Thresholds"; |
2 |
26 Feb 07 |
jari |
683 |
|
2 |
26 Feb 07 |
jari |
684 |
JFrame subFrame = new JFrame(source); |
2 |
26 Feb 07 |
jari |
685 |
subViewer = new SingleArrayViewer(subFrame); |
2 |
26 Feb 07 |
jari |
686 |
subViewer.changePaletteStyle(canvas.getPaletteStyle()); |
2 |
26 Feb 07 |
jari |
687 |
subViewer.setThresholds(canvas.getThresholds()); |
2 |
26 Feb 07 |
jari |
//Should this be nice? |
2 |
26 Feb 07 |
jari |
689 |
subViewer.canvas.setScale(canvas.getScale()); |
2 |
26 Feb 07 |
jari |
690 |
|
2 |
26 Feb 07 |
jari |
691 |
if (canvas.getThresholds()) { |
2 |
26 Feb 07 |
jari |
692 |
holding = new Vector(); |
2 |
26 Feb 07 |
jari |
693 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
694 |
try { |
2 |
26 Feb 07 |
jari |
695 |
sdo = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
696 |
sde = new SlideDataElement(new int[]{sdo.getRow(ISlideDataElement.BASE), |
2 |
26 Feb 07 |
jari |
697 |
sdo.getRow(ISlideDataElement.META), |
2 |
26 Feb 07 |
jari |
698 |
sdo.getRow(ISlideDataElement.SUB)}, |
2 |
26 Feb 07 |
jari |
699 |
new int[]{sdo.getColumn(ISlideDataElement.BASE), |
2 |
26 Feb 07 |
jari |
700 |
sdo.getColumn(ISlideDataElement.META), |
2 |
26 Feb 07 |
jari |
701 |
sdo.getColumn(ISlideDataElement.SUB)}, |
2 |
26 Feb 07 |
jari |
702 |
new float[]{sdo.getIntensity(ISlideDataElement.CY3), |
2 |
26 Feb 07 |
jari |
703 |
sdo.getIntensity(ISlideDataElement.CY5)}, |
2 |
26 Feb 07 |
jari |
704 |
sdo.getExtraFields()); |
2 |
26 Feb 07 |
jari |
705 |
int cy3 = (int) sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
706 |
int cy5 = (int) sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
707 |
if ((cy3 + cy5 > 0) && (((double) cy3 / (cy3 + cy5) > high) |
2 |
26 Feb 07 |
jari |
708 |
|| ((double) cy3 / (cy3 + cy5) < low))) holding.addElement(sde); |
2 |
26 Feb 07 |
jari |
709 |
} catch (NullPointerException npe) { |
2 |
26 Feb 07 |
jari |
710 |
npe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
711 |
} |
2 |
26 Feb 07 |
jari |
712 |
} |
2 |
26 Feb 07 |
jari |
713 |
|
2 |
26 Feb 07 |
jari |
714 |
if (holding.size() > 0) { |
2 |
26 Feb 07 |
jari |
715 |
int columns = (int) Math.ceil(Math.sqrt(holding.size() / 6)); |
2 |
26 Feb 07 |
jari |
716 |
int rows = columns * 6; |
2 |
26 Feb 07 |
jari |
717 |
|
2 |
26 Feb 07 |
jari |
718 |
for (; (columns * rows) - holding.size() >= columns; rows--) { |
2 |
26 Feb 07 |
jari |
719 |
; |
2 |
26 Feb 07 |
jari |
720 |
} |
2 |
26 Feb 07 |
jari |
721 |
|
2 |
26 Feb 07 |
jari |
722 |
newSlideData = new SlideData(rows, columns); |
2 |
26 Feb 07 |
jari |
723 |
newSlideData.setSlideDataName(slideData.getSlideDataName()); |
2 |
26 Feb 07 |
jari |
724 |
newSlideData.setNormalizedState(slideData.getNormalizedState()); |
2 |
26 Feb 07 |
jari |
725 |
int maxColumns = newSlideData.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
726 |
|
2 |
26 Feb 07 |
jari |
727 |
for (int i = 0; i < holding.size(); i++) { |
2 |
26 Feb 07 |
jari |
728 |
try { |
2 |
26 Feb 07 |
jari |
729 |
sde = (ISlideDataElement)holding.elementAt(i); |
2 |
26 Feb 07 |
jari |
730 |
sde.setColumn(ISlideDataElement.BASE, (i % maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
731 |
sde.setRow(ISlideDataElement.BASE, (i / maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
732 |
|
2 |
26 Feb 07 |
jari |
733 |
newSlideData.addSlideDataElement(sde); |
2 |
26 Feb 07 |
jari |
734 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
735 |
System.out.println("Exception (SingleArrayViewer.createSubArray(): " + e); |
2 |
26 Feb 07 |
jari |
736 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
737 |
} |
2 |
26 Feb 07 |
jari |
738 |
} |
2 |
26 Feb 07 |
jari |
739 |
subViewer.setSlideData(newSlideData); |
2 |
26 Feb 07 |
jari |
740 |
subViewer.setUpperLimits(canvas.getTopCy3(), canvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
741 |
subViewer.panel.setXYScrollbars((long)slideData.getMaxIntensity(ISlideDataElement.CY3), (long)slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
742 |
subViewer.panel.updateXUpperLimitScrollbar((long)canvas.getTopCy3()); |
2 |
26 Feb 07 |
jari |
743 |
subViewer.panel.updateYUpperLimitScrollbar((long)canvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
744 |
subFrame.setSize(650, 650); |
2 |
26 Feb 07 |
jari |
745 |
subFrame.setLocation(150, 150); |
2 |
26 Feb 07 |
jari |
746 |
subFrame.setVisible(true); |
2 |
26 Feb 07 |
jari |
747 |
} |
2 |
26 Feb 07 |
jari |
748 |
} else { |
2 |
26 Feb 07 |
jari |
749 |
subViewer.setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
750 |
subViewer.setUpperLimits(canvas.getTopCy3(), canvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
751 |
subViewer.panel.setXYScrollbars((long)slideData.getMaxIntensity(ISlideDataElement.CY3), (long)slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
752 |
subViewer.panel.updateXUpperLimitScrollbar((long)canvas.getTopCy3()); |
2 |
26 Feb 07 |
jari |
753 |
subViewer.panel.updateYUpperLimitScrollbar((long)canvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
754 |
subFrame.setSize(650, 650); |
2 |
26 Feb 07 |
jari |
755 |
subFrame.setLocation(150, 150); |
2 |
26 Feb 07 |
jari |
756 |
subFrame.setVisible(true); |
2 |
26 Feb 07 |
jari |
757 |
} |
2 |
26 Feb 07 |
jari |
758 |
} |
2 |
26 Feb 07 |
jari |
759 |
|
2 |
26 Feb 07 |
jari |
760 |
public void createRegion(int metaRow, int metaColumn) { |
2 |
26 Feb 07 |
jari |
761 |
SingleArrayViewer subViewer; |
2 |
26 Feb 07 |
jari |
762 |
Vector holding; |
2 |
26 Feb 07 |
jari |
763 |
ISlideData newSlideData; |
2 |
26 Feb 07 |
jari |
764 |
ISlideDataElement sde, sdo; |
2 |
26 Feb 07 |
jari |
765 |
int maxSubRow = 0, maxSubColumn = 0; |
2 |
26 Feb 07 |
jari |
766 |
|
2 |
26 Feb 07 |
jari |
767 |
holding = new Vector(); |
2 |
26 Feb 07 |
jari |
768 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
769 |
try { |
2 |
26 Feb 07 |
jari |
770 |
sdo = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
771 |
sde = new SlideDataElement(new int[]{sdo.getRow(ISlideDataElement.BASE), |
2 |
26 Feb 07 |
jari |
772 |
sdo.getRow(ISlideDataElement.META), |
2 |
26 Feb 07 |
jari |
773 |
sdo.getRow(ISlideDataElement.SUB)}, |
2 |
26 Feb 07 |
jari |
774 |
new int[]{sdo.getColumn(ISlideDataElement.BASE), |
2 |
26 Feb 07 |
jari |
775 |
sdo.getColumn(ISlideDataElement.META), |
2 |
26 Feb 07 |
jari |
776 |
sdo.getColumn(ISlideDataElement.SUB)}, |
2 |
26 Feb 07 |
jari |
777 |
new float[]{sdo.getIntensity(ISlideDataElement.CY3), |
2 |
26 Feb 07 |
jari |
778 |
sdo.getIntensity(ISlideDataElement.CY5)}, |
2 |
26 Feb 07 |
jari |
779 |
sdo.getExtraFields()); |
2 |
26 Feb 07 |
jari |
780 |
if ((sde.getRow(ISlideDataElement.META) == metaRow) && (sde.getColumn(ISlideDataElement.META) == metaColumn)) { |
2 |
26 Feb 07 |
jari |
781 |
holding.addElement(sde); |
2 |
26 Feb 07 |
jari |
782 |
if (sde.getRow(ISlideDataElement.SUB) > maxSubRow) maxSubRow = sde.getRow(ISlideDataElement.SUB); |
2 |
26 Feb 07 |
jari |
783 |
if (sde.getColumn(ISlideDataElement.SUB) > maxSubColumn) maxSubColumn = sde.getColumn(ISlideDataElement.SUB); |
2 |
26 Feb 07 |
jari |
784 |
} |
2 |
26 Feb 07 |
jari |
785 |
} catch (NullPointerException npe) { |
2 |
26 Feb 07 |
jari |
786 |
npe.printStackTrace(); |
2 |
26 Feb 07 |
jari |
787 |
} |
2 |
26 Feb 07 |
jari |
788 |
} |
2 |
26 Feb 07 |
jari |
789 |
|
2 |
26 Feb 07 |
jari |
790 |
if (holding.size() > 0) { |
2 |
26 Feb 07 |
jari |
791 |
JFrame subFrame = new JFrame("Region: MetaColumn " + metaColumn + ", MetaRow " + metaRow); |
2 |
26 Feb 07 |
jari |
792 |
subViewer = new SingleArrayViewer(subFrame); |
2 |
26 Feb 07 |
jari |
793 |
subViewer.changePaletteStyle(canvas.getPaletteStyle()); |
2 |
26 Feb 07 |
jari |
794 |
subViewer.setThresholds(canvas.getThresholds()); |
2 |
26 Feb 07 |
jari |
//Should this be nice? |
2 |
26 Feb 07 |
jari |
796 |
subViewer.canvas.setScale(canvas.getScale()); |
2 |
26 Feb 07 |
jari |
797 |
|
2 |
26 Feb 07 |
jari |
798 |
newSlideData = new SlideData(maxSubColumn, maxSubRow); |
2 |
26 Feb 07 |
jari |
799 |
newSlideData.setSlideDataName(slideData.getSlideDataName()); |
2 |
26 Feb 07 |
jari |
800 |
newSlideData.setNormalizedState(slideData.getNormalizedState()); |
2 |
26 Feb 07 |
jari |
801 |
int maxColumns = newSlideData.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
802 |
|
2 |
26 Feb 07 |
jari |
803 |
for (int i = 0; i < holding.size(); i++) { |
2 |
26 Feb 07 |
jari |
804 |
try { |
2 |
26 Feb 07 |
jari |
805 |
sde = (ISlideDataElement) holding.elementAt(i); |
2 |
26 Feb 07 |
jari |
806 |
sde.setColumn(ISlideDataElement.BASE, (i % maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
807 |
sde.setRow(ISlideDataElement.BASE, (i / maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
808 |
|
2 |
26 Feb 07 |
jari |
809 |
newSlideData.addSlideDataElement(sde); |
2 |
26 Feb 07 |
jari |
810 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
811 |
System.out.println("Exception (SingleArrayViewer.createRegion(): " + e); |
2 |
26 Feb 07 |
jari |
812 |
} |
2 |
26 Feb 07 |
jari |
813 |
} |
2 |
26 Feb 07 |
jari |
814 |
|
2 |
26 Feb 07 |
jari |
815 |
subViewer.setSlideData(newSlideData); |
2 |
26 Feb 07 |
jari |
816 |
subViewer.setUpperLimits(canvas.getTopCy3(), canvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
817 |
subViewer.panel.setXYScrollbars((long)slideData.getMaxIntensity(ISlideDataElement.CY3), (long)slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
818 |
subViewer.panel.updateXUpperLimitScrollbar((long)canvas.getTopCy3()); |
2 |
26 Feb 07 |
jari |
819 |
subViewer.panel.updateYUpperLimitScrollbar((long)canvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
820 |
subFrame.setSize(650, 650); |
2 |
26 Feb 07 |
jari |
821 |
subFrame.setLocation(150, 150); |
2 |
26 Feb 07 |
jari |
822 |
subFrame.setVisible(true); |
2 |
26 Feb 07 |
jari |
823 |
} |
2 |
26 Feb 07 |
jari |
824 |
|
2 |
26 Feb 07 |
jari |
825 |
else { |
2 |
26 Feb 07 |
jari |
826 |
MessageDisplay messageDisplay = new MessageDisplay(((JFrame) getParent()), "No region: Row " + metaRow + ", Column " + metaColumn, ""); |
2 |
26 Feb 07 |
jari |
827 |
} |
2 |
26 Feb 07 |
jari |
828 |
} |
2 |
26 Feb 07 |
jari |
829 |
|
2 |
26 Feb 07 |
jari |
830 |
public void setReportFilename() { |
2 |
26 Feb 07 |
jari |
831 |
JFileChooser chooser = new JFileChooser(TMEV.getFile("data/")); |
2 |
26 Feb 07 |
jari |
832 |
chooser.setDialogTitle("Choose a Report Name"); |
2 |
26 Feb 07 |
jari |
833 |
chooser.setMultiSelectionEnabled(false); |
2 |
26 Feb 07 |
jari |
834 |
if (chooser.showSaveDialog(getParent()) == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
835 |
generateReport(chooser.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
836 |
} |
2 |
26 Feb 07 |
jari |
837 |
} |
2 |
26 Feb 07 |
jari |
838 |
|
2 |
26 Feb 07 |
jari |
839 |
public void generateReport(final File reportFile) { |
2 |
26 Feb 07 |
jari |
840 |
Thread thread = new Thread() { |
2 |
26 Feb 07 |
jari |
841 |
public void run() { |
2 |
26 Feb 07 |
jari |
842 |
String filename = reportFile.getName(); |
2 |
26 Feb 07 |
jari |
843 |
FileOutputStream out = null; |
2 |
26 Feb 07 |
jari |
844 |
PrintStream ps = null; |
2 |
26 Feb 07 |
jari |
845 |
|
2 |
26 Feb 07 |
jari |
846 |
String outputString = ""; |
2 |
26 Feb 07 |
jari |
847 |
float cy3, cy5; |
2 |
26 Feb 07 |
jari |
848 |
|
2 |
26 Feb 07 |
jari |
849 |
try { |
2 |
26 Feb 07 |
jari |
850 |
ps = new PrintStream(new BufferedOutputStream(new FileOutputStream(reportFile))); |
2 |
26 Feb 07 |
jari |
851 |
} catch (IOException e) { |
2 |
26 Feb 07 |
jari |
852 |
MessageDisplay messageDisplay = new MessageDisplay(getFrame(), "Can't write output file: " + filename, ""); |
2 |
26 Feb 07 |
jari |
853 |
} |
2 |
26 Feb 07 |
jari |
854 |
try { |
2 |
26 Feb 07 |
jari |
855 |
int size = slideData.getSize(); |
2 |
26 Feb 07 |
jari |
856 |
|
2 |
26 Feb 07 |
jari |
857 |
org.tigr.util.awt.ProgressBar pb = new org.tigr.util.awt.ProgressBar(getFrame(), "Writing report: " + filename, Color.green, Color.green, Color.black, size); |
2 |
26 Feb 07 |
jari |
858 |
pb.drawProgressBar(); |
2 |
26 Feb 07 |
jari |
859 |
|
2 |
26 Feb 07 |
jari |
860 |
ps.println("Report for SlideFile: " + slideData.getSlideDataName()); |
2 |
26 Feb 07 |
jari |
861 |
ps.println("Normalization: " + SlideData.normalizationString(slideData.getNormalizedState()) + "\tThresholds: " + canvas.getLowDifference() + "/" + canvas.getHighDifference()); |
2 |
26 Feb 07 |
jari |
862 |
outputString = "Row\tColumn\tMetaRow\tMetaColumn\tSubRow\tSubColumn\tCy3\tCy5\tCy5/Cy3"; |
2 |
26 Feb 07 |
jari |
863 |
for (int i = 0; i < getFieldNames().length; i++) { |
2 |
26 Feb 07 |
jari |
864 |
outputString += "\t" + getFieldNames()[i]; |
2 |
26 Feb 07 |
jari |
865 |
} |
2 |
26 Feb 07 |
jari |
866 |
ps.println(outputString); |
2 |
26 Feb 07 |
jari |
867 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
868 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
869 |
outputString = ""; |
2 |
26 Feb 07 |
jari |
870 |
|
2 |
26 Feb 07 |
jari |
871 |
sde = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
872 |
//! |
2 |
26 Feb 07 |
jari |
873 |
if (sde != null) { |
2 |
26 Feb 07 |
jari |
874 |
for (int j = 0; j < getFieldNames().length; j++) { |
2 |
26 Feb 07 |
jari |
875 |
outputString += "\t" + sde.getFieldAt(j); |
2 |
26 Feb 07 |
jari |
876 |
} |
2 |
26 Feb 07 |
jari |
877 |
cy3 = sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
878 |
cy5 = sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
879 |
|
2 |
26 Feb 07 |
jari |
880 |
if (canvas.getThresholds() == true) { |
2 |
26 Feb 07 |
jari |
881 |
if ((cy3+cy5 > 0) && |
2 |
26 Feb 07 |
jari |
882 |
(cy3/(cy3+cy5) > canvas.getHighDifference() || |
2 |
26 Feb 07 |
jari |
883 |
(cy3/(cy3+cy5) < canvas.getLowDifference()))) { |
2 |
26 Feb 07 |
jari |
884 |
ps.println(sde.getRow(ISlideDataElement.BASE) + "\t" + |
2 |
26 Feb 07 |
jari |
885 |
sde.getColumn(ISlideDataElement.BASE) + "\t" + |
2 |
26 Feb 07 |
jari |
886 |
sde.getRow(ISlideDataElement.META) + "\t" + |
2 |
26 Feb 07 |
jari |
887 |
sde.getColumn(ISlideDataElement.META) + "\t" + |
2 |
26 Feb 07 |
jari |
888 |
sde.getRow(ISlideDataElement.SUB) + "\t" + |
2 |
26 Feb 07 |
jari |
889 |
sde.getColumn(ISlideDataElement.SUB) + "\t" + |
2 |
26 Feb 07 |
jari |
890 |
cy3 + "\t" + |
2 |
26 Feb 07 |
jari |
891 |
cy5 + "\t" + |
2 |
26 Feb 07 |
jari |
892 |
sde.getRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, ISlideDataElement.BASE) + |
2 |
26 Feb 07 |
jari |
893 |
outputString); |
2 |
26 Feb 07 |
jari |
894 |
} |
2 |
26 Feb 07 |
jari |
895 |
} else { |
2 |
26 Feb 07 |
jari |
896 |
ps.println(sde.getRow(ISlideDataElement.BASE) + "\t" + |
2 |
26 Feb 07 |
jari |
897 |
sde.getColumn(ISlideDataElement.BASE) + "\t" + |
2 |
26 Feb 07 |
jari |
898 |
sde.getRow(ISlideDataElement.META) + "\t" + |
2 |
26 Feb 07 |
jari |
899 |
sde.getColumn(ISlideDataElement.META) + "\t" + |
2 |
26 Feb 07 |
jari |
900 |
sde.getRow(ISlideDataElement.SUB) + "\t" + |
2 |
26 Feb 07 |
jari |
901 |
sde.getColumn(ISlideDataElement.SUB) + "\t" + |
2 |
26 Feb 07 |
jari |
902 |
cy3 + "\t" + |
2 |
26 Feb 07 |
jari |
903 |
cy5 + "\t" + |
2 |
26 Feb 07 |
jari |
904 |
sde.getRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, ISlideDataElement.BASE) + |
2 |
26 Feb 07 |
jari |
905 |
outputString); |
2 |
26 Feb 07 |
jari |
906 |
} |
2 |
26 Feb 07 |
jari |
907 |
} |
2 |
26 Feb 07 |
jari |
908 |
|
2 |
26 Feb 07 |
jari |
909 |
pb.increment(1); |
2 |
26 Feb 07 |
jari |
910 |
} |
2 |
26 Feb 07 |
jari |
911 |
ps.close(); |
2 |
26 Feb 07 |
jari |
912 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
913 |
MessageDisplay messageDisplay = new MessageDisplay(getFrame(), "Can't write: " + filename, ""); |
2 |
26 Feb 07 |
jari |
914 |
} |
2 |
26 Feb 07 |
jari |
915 |
} |
2 |
26 Feb 07 |
jari |
916 |
}; |
2 |
26 Feb 07 |
jari |
917 |
thread.setPriority(Thread.MIN_PRIORITY); |
2 |
26 Feb 07 |
jari |
918 |
thread.run(); |
2 |
26 Feb 07 |
jari |
919 |
} |
2 |
26 Feb 07 |
jari |
920 |
|
2 |
26 Feb 07 |
jari |
921 |
public void normalizeData(int mode) { |
2 |
26 Feb 07 |
jari |
//SlideData slideData = getData(); IS THIS IMPORTANT? |
2 |
26 Feb 07 |
jari |
//DisplayPanel displayPanel = ((DisplayFrame) parent).getDisplayPanel(); |
2 |
26 Feb 07 |
jari |
924 |
|
2 |
26 Feb 07 |
jari |
925 |
Properties properties = new Properties(); |
2 |
26 Feb 07 |
jari |
926 |
if(mode == ISlideData.LINEAR_REGRESSION){ |
2 |
26 Feb 07 |
jari |
927 |
LinRegNormInitDialog dialog = new LinRegNormInitDialog(); |
2 |
26 Feb 07 |
jari |
928 |
if(dialog.showModal() == JOptionPane.OK_OPTION){ |
2 |
26 Feb 07 |
jari |
929 |
properties.setProperty("standard-deviation", Float.toString(dialog.getSD())); |
2 |
26 Feb 07 |
jari |
930 |
properties.setProperty("mode", dialog.getMode()); |
2 |
26 Feb 07 |
jari |
931 |
dialog.dispose(); |
2 |
26 Feb 07 |
jari |
932 |
} |
2 |
26 Feb 07 |
jari |
933 |
else{ |
2 |
26 Feb 07 |
jari |
934 |
return; |
2 |
26 Feb 07 |
jari |
935 |
} |
2 |
26 Feb 07 |
jari |
936 |
} |
2 |
26 Feb 07 |
jari |
937 |
|
2 |
26 Feb 07 |
jari |
938 |
else if(mode == ISlideData.RATIO_STATISTICS_95 || mode == ISlideData.RATIO_STATISTICS_99){ |
2 |
26 Feb 07 |
jari |
939 |
RatioStatsNormInitDialog dialog = new RatioStatsNormInitDialog(); |
2 |
26 Feb 07 |
jari |
940 |
if(dialog.showModal() == JOptionPane.OK_OPTION){ |
2 |
26 Feb 07 |
jari |
941 |
properties.setProperty("confidence-interval", Integer.toString(dialog.getCI())); |
2 |
26 Feb 07 |
jari |
942 |
dialog.dispose(); |
2 |
26 Feb 07 |
jari |
943 |
} |
2 |
26 Feb 07 |
jari |
944 |
else{ |
2 |
26 Feb 07 |
jari |
945 |
return; |
2 |
26 Feb 07 |
jari |
946 |
} |
2 |
26 Feb 07 |
jari |
947 |
} |
2 |
26 Feb 07 |
jari |
948 |
|
2 |
26 Feb 07 |
jari |
949 |
else if(mode == ISlideData.ITERATIVE_LOG){ |
2 |
26 Feb 07 |
jari |
950 |
IterativeLogMCNormInitDialog dialog = new IterativeLogMCNormInitDialog(); |
2 |
26 Feb 07 |
jari |
951 |
if(dialog.showModal() == JOptionPane.OK_OPTION){ |
2 |
26 Feb 07 |
jari |
952 |
properties.setProperty("standard-deviation", Float.toString(dialog.getSD())); |
2 |
26 Feb 07 |
jari |
953 |
dialog.dispose(); |
2 |
26 Feb 07 |
jari |
954 |
} |
2 |
26 Feb 07 |
jari |
955 |
else{ |
2 |
26 Feb 07 |
jari |
956 |
return; |
2 |
26 Feb 07 |
jari |
957 |
} |
2 |
26 Feb 07 |
jari |
958 |
} |
2 |
26 Feb 07 |
jari |
959 |
|
2 |
26 Feb 07 |
jari |
960 |
|
2 |
26 Feb 07 |
jari |
961 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
962 |
|
2 |
26 Feb 07 |
jari |
963 |
slideData.applyNormalization(mode, properties); |
2 |
26 Feb 07 |
jari |
964 |
|
2 |
26 Feb 07 |
jari |
//Handle all drawing as necessary |
2 |
26 Feb 07 |
jari |
//long xVal, yVal; |
2 |
26 Feb 07 |
jari |
//xVal = displayPanel.xLastValue; |
2 |
26 Feb 07 |
jari |
//yVal = displayPanel.yLastValue; |
2 |
26 Feb 07 |
jari |
969 |
|
2 |
26 Feb 07 |
jari |
//canvas.setSlideData(slideData); IS THIS NECESSARY? |
2 |
26 Feb 07 |
jari |
//canvas.setUpperLimits(xVal, yVal); //Should be done, but think about the panel |
2 |
26 Feb 07 |
jari |
972 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
//canvas.setXYScrollbars(slideData.getMaxIntensity(ISlideDataElement.CY3), slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
//if (xVal <= displayPanel.xUpperLimitScrollbar.getMaximum()) displayPanel.updateXUpperLimitScrollbar(xVal); |
2 |
26 Feb 07 |
jari |
//else displayPanel.updateXUpperLimitScrollbar(displayPanel.xUpperLimitScrollbar.getMaximum()); |
2 |
26 Feb 07 |
jari |
//if (yVal <= displayPanel.yUpperLimitScrollbar.getMaximum()) displayPanel.updateYUpperLimitScrollbar(yVal); |
2 |
26 Feb 07 |
jari |
//else displayPanel.updateYUpperLimitScrollbar(displayPanel.yUpperLimitScrollbar.getMaximum()); |
2 |
26 Feb 07 |
jari |
//Should this second one be necessary? |
2 |
26 Feb 07 |
jari |
//canvas.drawSlide(); |
2 |
26 Feb 07 |
jari |
980 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
981 |
} |
2 |
26 Feb 07 |
jari |
982 |
|
2 |
26 Feb 07 |
jari |
983 |
public void normalizeDataList(int mode) { |
2 |
26 Feb 07 |
jari |
//SlideData slideData = getData(); IS THIS IMPORTANT? |
2 |
26 Feb 07 |
jari |
985 |
|
2 |
26 Feb 07 |
jari |
986 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
987 |
Properties properties = new Properties(); |
2 |
26 Feb 07 |
jari |
988 |
if(mode == ISlideData.LINEAR_REGRESSION){ |
2 |
26 Feb 07 |
jari |
989 |
LinRegNormInitDialog dialog = new LinRegNormInitDialog(); |
2 |
26 Feb 07 |
jari |
990 |
if(dialog.showModal() == JOptionPane.OK_OPTION){ |
2 |
26 Feb 07 |
jari |
991 |
properties.setProperty("standard-deviation", Double.toString(dialog.getSD())); |
2 |
26 Feb 07 |
jari |
992 |
properties.setProperty("mode", dialog.getMode()); |
2 |
26 Feb 07 |
jari |
993 |
dialog.dispose(); |
2 |
26 Feb 07 |
jari |
994 |
} |
2 |
26 Feb 07 |
jari |
995 |
else{ |
2 |
26 Feb 07 |
jari |
996 |
return; |
2 |
26 Feb 07 |
jari |
997 |
} |
2 |
26 Feb 07 |
jari |
998 |
} |
2 |
26 Feb 07 |
jari |
999 |
|
2 |
26 Feb 07 |
jari |
1000 |
else if(mode == ISlideData.RATIO_STATISTICS_95 || mode == ISlideData.RATIO_STATISTICS_99){ |
2 |
26 Feb 07 |
jari |
1001 |
RatioStatsNormInitDialog dialog = new RatioStatsNormInitDialog(); |
2 |
26 Feb 07 |
jari |
1002 |
if(dialog.showModal() == JOptionPane.OK_OPTION){ |
2 |
26 Feb 07 |
jari |
1003 |
properties.setProperty("confidence-interval", Integer.toString(dialog.getCI())); |
2 |
26 Feb 07 |
jari |
1004 |
dialog.dispose(); |
2 |
26 Feb 07 |
jari |
1005 |
} |
2 |
26 Feb 07 |
jari |
1006 |
else{ |
2 |
26 Feb 07 |
jari |
1007 |
return; |
2 |
26 Feb 07 |
jari |
1008 |
} |
2 |
26 Feb 07 |
jari |
1009 |
} |
2 |
26 Feb 07 |
jari |
1010 |
|
2 |
26 Feb 07 |
jari |
1011 |
else if(mode == ISlideData.ITERATIVE_LOG){ |
2 |
26 Feb 07 |
jari |
1012 |
IterativeLogMCNormInitDialog dialog = new IterativeLogMCNormInitDialog(); |
2 |
26 Feb 07 |
jari |
1013 |
if(dialog.showModal() == JOptionPane.OK_OPTION){ |
2 |
26 Feb 07 |
jari |
1014 |
properties.setProperty("standard-deviation", Double.toString(dialog.getSD())); |
2 |
26 Feb 07 |
jari |
1015 |
dialog.dispose(); |
2 |
26 Feb 07 |
jari |
1016 |
} |
2 |
26 Feb 07 |
jari |
1017 |
else{ |
2 |
26 Feb 07 |
jari |
1018 |
return; |
2 |
26 Feb 07 |
jari |
1019 |
} |
2 |
26 Feb 07 |
jari |
1020 |
} |
2 |
26 Feb 07 |
jari |
//Should change to -> slideData.applyNormalizationList(normalizationMode); |
2 |
26 Feb 07 |
jari |
1022 |
slideData.applyNormalization(mode, properties); |
2 |
26 Feb 07 |
jari |
1023 |
|
2 |
26 Feb 07 |
jari |
//Handle all drawing as necessary |
2 |
26 Feb 07 |
jari |
//canvas.setSlideData(slideData); IS THIS NECESSARY? |
2 |
26 Feb 07 |
jari |
//canvas.setUpperLimits(((DisplayFrame) parent).getDisplayPanel().xLastValue, ((DisplayFrame) parent).getDisplayPanel().yLastValue); |
2 |
26 Feb 07 |
jari |
1027 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
1028 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
1029 |
} |
2 |
26 Feb 07 |
jari |
1030 |
|
2 |
26 Feb 07 |
jari |
1031 |
public void refreshSlide() { |
2 |
26 Feb 07 |
jari |
1032 |
systemEnable(TMEV.DATA_AVAILABLE); |
2 |
26 Feb 07 |
jari |
1033 |
repaint(); |
2 |
26 Feb 07 |
jari |
1034 |
} |
2 |
26 Feb 07 |
jari |
1035 |
|
2 |
26 Feb 07 |
jari |
1036 |
public void createScatterPlot(int scale) { |
2 |
26 Feb 07 |
jari |
1037 |
JFrame graphFrame; |
2 |
26 Feb 07 |
jari |
1038 |
GraphViewer graph; |
2 |
26 Feb 07 |
jari |
1039 |
GraphPoint gp; |
2 |
26 Feb 07 |
jari |
1040 |
GraphLine gl; |
2 |
26 Feb 07 |
jari |
1041 |
GraphTick gt; |
2 |
26 Feb 07 |
jari |
1042 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
1043 |
|
2 |
26 Feb 07 |
jari |
1044 |
try { |
2 |
26 Feb 07 |
jari |
1045 |
if (scale == AC.LOG) { |
2 |
26 Feb 07 |
jari |
1046 |
int maxCy3 = (int) Xcon.log10(slideData.getMaxIntensity(ISlideDataElement.CY3)) + 1; |
2 |
26 Feb 07 |
jari |
1047 |
int maxCy5 = (int) Xcon.log10(slideData.getMaxIntensity(ISlideDataElement.CY5)) + 1; |
2 |
26 Feb 07 |
jari |
1048 |
int minCy3 = (int) Xcon.log10(slideData.getMinIntensity(ISlideDataElement.CY3, false)); |
2 |
26 Feb 07 |
jari |
1049 |
int minCy5 = (int) Xcon.log10(slideData.getMinIntensity(ISlideDataElement.CY5, false)); |
2 |
26 Feb 07 |
jari |
1050 |
|
2 |
26 Feb 07 |
jari |
1051 |
int xGap = ((int) (maxCy3 - minCy3)); |
2 |
26 Feb 07 |
jari |
1052 |
int yGap = ((int) (maxCy5 - minCy5)); |
2 |
26 Feb 07 |
jari |
1053 |
|
2 |
26 Feb 07 |
jari |
//System.out.println(slideData.getMinIntensity(ISlideDataElement.CY3, false) + "\t" + slideData.getMaxIntensity(ISlideDataElement.CY3)); |
2 |
26 Feb 07 |
jari |
//System.out.println(slideData.getMinIntensity(ISlideDataElement.CY5, false) + "\t" + slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
1056 |
|
2 |
26 Feb 07 |
jari |
//System.out.println(minCy3 + "\t" + maxCy3); |
2 |
26 Feb 07 |
jari |
//System.out.println(minCy5 + "\t" + maxCy5); |
2 |
26 Feb 07 |
jari |
//System.out.println(xGap + "\t" + yGap); |
2 |
26 Feb 07 |
jari |
1060 |
|
2 |
26 Feb 07 |
jari |
1061 |
graphFrame = new JFrame("Log Cy3 vs. Log Cy5"); |
2 |
26 Feb 07 |
jari |
1062 |
graph = new GraphViewer(graphFrame, 0, 500, 0, 500, minCy3, maxCy3, minCy5, maxCy5, 100, 100, 100, 100, "Log Cy3 vs. Log Cy5 - " + SlideData.normalizationString(slideData.getNormalizedState()), "Log Cy3", "Log Cy5"); |
2 |
26 Feb 07 |
jari |
1063 |
|
2 |
26 Feb 07 |
jari |
1064 |
graph.setXAxisValue(minCy5); |
2 |
26 Feb 07 |
jari |
1065 |
graph.setYAxisValue(minCy3); |
2 |
26 Feb 07 |
jari |
1066 |
|
2 |
26 Feb 07 |
jari |
1067 |
for (int i = minCy3 + 1; i <= maxCy3; i++) { |
2 |
26 Feb 07 |
jari |
1068 |
gl = new GraphLine(i, minCy5, i, maxCy5, Color.yellow); |
2 |
26 Feb 07 |
jari |
1069 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1070 |
} |
2 |
26 Feb 07 |
jari |
1071 |
|
2 |
26 Feb 07 |
jari |
1072 |
for (int i = minCy5 + 1; i <= maxCy5; i++) { |
2 |
26 Feb 07 |
jari |
1073 |
gl = new GraphLine(minCy3, i, maxCy3, i, Color.yellow); |
2 |
26 Feb 07 |
jari |
1074 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1075 |
} |
2 |
26 Feb 07 |
jari |
1076 |
|
2 |
26 Feb 07 |
jari |
1077 |
float cy3, cy5; |
2 |
26 Feb 07 |
jari |
1078 |
double logCy3, logCy5; |
2 |
26 Feb 07 |
jari |
1079 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
1080 |
sde = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
1081 |
|
2 |
26 Feb 07 |
jari |
1082 |
cy3 = sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
1083 |
cy5 = sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1084 |
logCy3 = Xcon.log10(cy3); |
2 |
26 Feb 07 |
jari |
1085 |
logCy5 = Xcon.log10(cy5); |
2 |
26 Feb 07 |
jari |
1086 |
|
2 |
26 Feb 07 |
jari |
1087 |
if (canvas.thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
1088 |
if ((cy3 + cy5 > 0) && ((cy3/(cy3+cy5) > canvas.highDifference) || ((double) cy3 / (cy3 + cy5) < canvas.lowDifference))) { |
2 |
26 Feb 07 |
jari |
1089 |
gp = new GraphPoint(logCy3, logCy5, Color.red, 3); |
2 |
26 Feb 07 |
jari |
1090 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1091 |
} else { |
2 |
26 Feb 07 |
jari |
1092 |
gp = new GraphPoint(logCy3, logCy5, Color.blue, 3); |
2 |
26 Feb 07 |
jari |
1093 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1094 |
} |
2 |
26 Feb 07 |
jari |
1095 |
} else { |
2 |
26 Feb 07 |
jari |
1096 |
gp = new GraphPoint(logCy3, logCy5, Color.blue, 3); |
2 |
26 Feb 07 |
jari |
1097 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1098 |
} |
2 |
26 Feb 07 |
jari |
1099 |
} |
2 |
26 Feb 07 |
jari |
1100 |
for (int i = minCy5; i <= maxCy5; i++) { |
2 |
26 Feb 07 |
jari |
1101 |
gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "1.0E" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1102 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1103 |
} |
2 |
26 Feb 07 |
jari |
1104 |
for (int i = minCy3; i <= maxCy3; i++) { |
2 |
26 Feb 07 |
jari |
1105 |
gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, "1.0E" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1106 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1107 |
} |
2 |
26 Feb 07 |
jari |
1108 |
|
2 |
26 Feb 07 |
jari |
1109 |
graphFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
1110 |
graph.setVisible(true); |
2 |
26 Feb 07 |
jari |
1111 |
} else if (scale == AC.LINEAR) { |
2 |
26 Feb 07 |
jari |
1112 |
float maxCy3 = slideData.getMaxIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
1113 |
float maxCy5 = slideData.getMaxIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1114 |
|
2 |
26 Feb 07 |
jari |
1115 |
float cy3Partition = maxCy3; |
2 |
26 Feb 07 |
jari |
1116 |
float cy5Partition = maxCy5; |
2 |
26 Feb 07 |
jari |
1117 |
long cy3Block = 0, cy5Block = 0; |
2 |
26 Feb 07 |
jari |
1118 |
int power; |
2 |
26 Feb 07 |
jari |
1119 |
|
2 |
26 Feb 07 |
jari |
1120 |
for (power = 0; (! ((cy3Partition < 10) && (cy3Partition > 0))); power++) cy3Partition /= 10; |
2 |
26 Feb 07 |
jari |
1121 |
cy3Block = (long) ((int) (cy3Partition * 10) * Math.pow(10, (power - 2))); |
2 |
26 Feb 07 |
jari |
1122 |
for (power = 0; (! ((cy5Partition < 10) && (cy5Partition > 0))); power++) cy5Partition /= 10; |
2 |
26 Feb 07 |
jari |
1123 |
cy5Block = (long) ((int) (cy5Partition * 10) * Math.pow(10, (power - 2))); |
2 |
26 Feb 07 |
jari |
1124 |
|
2 |
26 Feb 07 |
jari |
1125 |
maxCy3 = cy3Block * 11; |
2 |
26 Feb 07 |
jari |
1126 |
maxCy5 = cy5Block * 11; |
2 |
26 Feb 07 |
jari |
1127 |
|
2 |
26 Feb 07 |
jari |
1128 |
graphFrame = new JFrame("Cy3 vs. Cy5"); |
2 |
26 Feb 07 |
jari |
1129 |
graph = new GraphViewer(graphFrame, 0, 500, 0, 500, 0, maxCy3, 0, maxCy5, 75, 75, 75, 75, "Cy3 vs. Cy5 - " + SlideData.normalizationString(slideData.getNormalizedState()), "Cy3", "Cy5"); |
2 |
26 Feb 07 |
jari |
1130 |
|
2 |
26 Feb 07 |
jari |
1131 |
for (int i = 1; i < 12; i++) { |
2 |
26 Feb 07 |
jari |
1132 |
gl = new GraphLine(0, i * cy5Block, maxCy3, i * cy5Block, Color.yellow); |
2 |
26 Feb 07 |
jari |
1133 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1134 |
gl = new GraphLine(i * cy3Block, 0, i * cy3Block, maxCy5, Color.yellow); |
2 |
26 Feb 07 |
jari |
1135 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1136 |
} |
2 |
26 Feb 07 |
jari |
1137 |
|
2 |
26 Feb 07 |
jari |
1138 |
float cy3, cy5; |
2 |
26 Feb 07 |
jari |
1139 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
1140 |
sde = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
1141 |
cy3 = sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
1142 |
cy5 = sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1143 |
if (canvas.thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
1144 |
if ((cy3 + cy5 > 0) && ((cy3 / (cy3 + cy5) > canvas.highDifference) || ((double) cy3 / (cy3 + cy5) < canvas.lowDifference))) { |
2 |
26 Feb 07 |
jari |
1145 |
gp = new GraphPoint(cy3, cy5, Color.red, 3); |
2 |
26 Feb 07 |
jari |
1146 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1147 |
} else { |
2 |
26 Feb 07 |
jari |
1148 |
gp = new GraphPoint(cy3, cy5, Color.blue, 3); |
2 |
26 Feb 07 |
jari |
1149 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1150 |
} |
2 |
26 Feb 07 |
jari |
1151 |
} else { |
2 |
26 Feb 07 |
jari |
1152 |
gp = new GraphPoint(cy3, cy5, Color.blue, 3); |
2 |
26 Feb 07 |
jari |
1153 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1154 |
} |
2 |
26 Feb 07 |
jari |
1155 |
} |
2 |
26 Feb 07 |
jari |
1156 |
for (int i = 0; i < 12; i++) { |
2 |
26 Feb 07 |
jari |
1157 |
gt = new GraphTick(i * cy3Block, 8, Color.black, GC.HORIZONTAL, GC.C, "" + i * cy3Block, Color.black); |
2 |
26 Feb 07 |
jari |
1158 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1159 |
gt = new GraphTick(i * cy5Block, 8, Color.black, GC.VERTICAL, GC.C, "" + i * cy5Block, Color.black); |
2 |
26 Feb 07 |
jari |
1160 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1161 |
} |
2 |
26 Feb 07 |
jari |
1162 |
graphFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
1163 |
graph.setVisible(true); |
2 |
26 Feb 07 |
jari |
1164 |
} |
2 |
26 Feb 07 |
jari |
1165 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1166 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
1167 |
} |
2 |
26 Feb 07 |
jari |
1168 |
/* |
2 |
26 Feb 07 |
jari |
Graph2D graph; |
2 |
26 Feb 07 |
jari |
double[] rawData = new double[slideData.size() * 2]; |
2 |
26 Feb 07 |
jari |
DataSet dataSet; |
2 |
26 Feb 07 |
jari |
Axis xAxis, yAxis; |
2 |
26 Feb 07 |
jari |
Markers markers; |
2 |
26 Feb 07 |
jari |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
1175 |
|
2 |
26 Feb 07 |
jari |
graph = new Graph2D(); |
2 |
26 Feb 07 |
jari |
graph.drawzero = false; |
2 |
26 Feb 07 |
jari |
graph.drawgrid = false; |
2 |
26 Feb 07 |
jari |
graph.borderTop = 50; |
2 |
26 Feb 07 |
jari |
graph.borderRight = 50; |
2 |
26 Feb 07 |
jari |
graph.setDataBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1182 |
|
2 |
26 Feb 07 |
jari |
markers = new Markers(); |
2 |
26 Feb 07 |
jari |
markers.AddMarker(2, new boolean[]{true, true}, new int[]{0, 0}, new int[]{0, 0}); |
2 |
26 Feb 07 |
jari |
boolean[] moveDraw = new boolean[]{false, true, true, true, true}; |
2 |
26 Feb 07 |
jari |
int[] xValues = new int[]{-1, 1, 1, -1, -1}; |
2 |
26 Feb 07 |
jari |
int[] yValues = new int[]{1, 1, -1, -1, 1}; |
2 |
26 Feb 07 |
jari |
markers.AddMarker(5, moveDraw, xValues, yValues); |
2 |
26 Feb 07 |
jari |
1189 |
|
2 |
26 Feb 07 |
jari |
graph.setMarkers(markers); |
2 |
26 Feb 07 |
jari |
plotFrame.getContentPane().setLayout(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
plotFrame.getContentPane().add("Center", graph); |
2 |
26 Feb 07 |
jari |
1193 |
|
2 |
26 Feb 07 |
jari |
for (int i = 0; i < slideData.size(); i++) |
2 |
26 Feb 07 |
jari |
1195 |
{ |
2 |
26 Feb 07 |
jari |
sde = slideData.getElementAt(i); |
2 |
26 Feb 07 |
jari |
rawData[i*2] = sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
rawData[i*2+1] = sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1199 |
} |
2 |
26 Feb 07 |
jari |
1200 |
|
2 |
26 Feb 07 |
jari |
dataSet = graph.loadDataSet(rawData, slideData.size()); |
2 |
26 Feb 07 |
jari |
dataSet.linestyle = DataSet.NOLINE; |
2 |
26 Feb 07 |
jari |
dataSet.marker = 1; |
2 |
26 Feb 07 |
jari |
dataSet.markerscale = 1; |
2 |
26 Feb 07 |
jari |
dataSet.markercolor = new Color(0, 0, 255); |
2 |
26 Feb 07 |
jari |
//dataSet.legend(200, 100, "Array Data"); |
2 |
26 Feb 07 |
jari |
dataSet.legendColor(Color.black); |
2 |
26 Feb 07 |
jari |
1208 |
|
2 |
26 Feb 07 |
jari |
xAxis = graph.createAxis(Axis.BOTTOM); |
2 |
26 Feb 07 |
jari |
xAxis.attachDataSet(dataSet); |
2 |
26 Feb 07 |
jari |
xAxis.setTitleText("Cy3"); |
2 |
26 Feb 07 |
jari |
xAxis.setTitleFont(new Font("TimesRoman",Font.PLAIN,20)); |
2 |
26 Feb 07 |
jari |
xAxis.setLabelFont(new Font("Helvetica",Font.PLAIN,15)); |
2 |
26 Feb 07 |
jari |
1214 |
|
2 |
26 Feb 07 |
jari |
yAxis = graph.createAxis(Axis.LEFT); |
2 |
26 Feb 07 |
jari |
yAxis.attachDataSet(dataSet); |
2 |
26 Feb 07 |
jari |
yAxis.setTitleText("Cy5"); |
2 |
26 Feb 07 |
jari |
yAxis.setTitleFont(new Font("TimesRoman",Font.PLAIN,20)); |
2 |
26 Feb 07 |
jari |
yAxis.setLabelFont(new Font("Helvetica",Font.PLAIN,15)); |
2 |
26 Feb 07 |
jari |
1220 |
|
2 |
26 Feb 07 |
jari |
plotFrame.move(200, 200); |
2 |
26 Feb 07 |
jari |
plotFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
plotFrame.setVisible(true); |
2 |
26 Feb 07 |
jari |
1224 |
*/ |
2 |
26 Feb 07 |
jari |
1225 |
} |
2 |
26 Feb 07 |
jari |
1226 |
|
2 |
26 Feb 07 |
jari |
1227 |
public void createRatioProductPlotByBlock() { |
2 |
26 Feb 07 |
jari |
1228 |
JFrame graphFrame; |
2 |
26 Feb 07 |
jari |
1229 |
BlockGraphViewer graph; |
2 |
26 Feb 07 |
jari |
1230 |
GraphPoint gp; |
2 |
26 Feb 07 |
jari |
1231 |
GraphLine gl; |
2 |
26 Feb 07 |
jari |
1232 |
GraphTick gt; |
2 |
26 Feb 07 |
jari |
1233 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
1234 |
|
2 |
26 Feb 07 |
jari |
1235 |
try { |
2 |
26 Feb 07 |
jari |
1236 |
int maxCy3 = (int) Xcon.log10(slideData.getMaxProduct(ISlideDataElement.CY3, ISlideDataElement.CY5)) + 1; |
2 |
26 Feb 07 |
jari |
1237 |
int maxCy5 = (int) Xcon.log10(slideData.getMaxRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, AC.LINEAR)) + 1; |
2 |
26 Feb 07 |
jari |
1238 |
int minCy3 = (int) Xcon.log10(slideData.getMinProduct(ISlideDataElement.CY3, ISlideDataElement.CY5, false, 2)); |
2 |
26 Feb 07 |
jari |
1239 |
int minCy5 = (int) Xcon.log10(slideData.getMinRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, AC.LINEAR)); |
2 |
26 Feb 07 |
jari |
1240 |
|
2 |
26 Feb 07 |
jari |
1241 |
int xGap = ((int) (maxCy3 - minCy3)); |
2 |
26 Feb 07 |
jari |
1242 |
int yGap = ((int) (maxCy5 - minCy5)); |
2 |
26 Feb 07 |
jari |
1243 |
|
2 |
26 Feb 07 |
jari |
//System.out.println(slideData.getMinIntensity(ISlideDataElement.CY3, false) + "\t" + slideData.getMaxIntensity(ISlideDataElement.CY3)); |
2 |
26 Feb 07 |
jari |
//System.out.println(slideData.getMinIntensity(ISlideDataElement.CY5, false) + "\t" + slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
1246 |
|
2 |
26 Feb 07 |
jari |
//System.out.println(minCy3 + "\t" + maxCy3); |
2 |
26 Feb 07 |
jari |
//System.out.println(minCy5 + "\t" + maxCy5); |
2 |
26 Feb 07 |
jari |
//System.out.println(xGap + "\t" + yGap); |
2 |
26 Feb 07 |
jari |
1250 |
int metaRows, metaColumns; |
2 |
26 Feb 07 |
jari |
1251 |
metaRows = ((ISlideDataElement)slideData.getSlideDataElement(slideData.getSize()-1)).getRow(ISlideDataElement.META); |
2 |
26 Feb 07 |
jari |
1252 |
metaColumns = ((ISlideDataElement)slideData.getSlideDataElement(slideData.getSize()-1)).getColumn(ISlideDataElement.META); |
2 |
26 Feb 07 |
jari |
1253 |
|
2 |
26 Feb 07 |
jari |
// System.out.println("metarows = "+metaRows+"metacols"+metaColumns); |
2 |
26 Feb 07 |
jari |
1255 |
|
2 |
26 Feb 07 |
jari |
1256 |
graphFrame = new JFrame("Log Product vs. Log Ratio, by Metablock"); |
2 |
26 Feb 07 |
jari |
1257 |
graph = new BlockGraphViewer(graphFrame, metaRows, metaColumns, 0, 500, 0, 500, minCy3, maxCy3, minCy5, maxCy5, 100, 100, 100, 100, "Log Product vs. Log Ratio - " + SlideData.normalizationString(slideData.getNormalizedState()), "Log (Cy3 x Cy5)", "Log (Cy5 / Cy3)"); |
2 |
26 Feb 07 |
jari |
1258 |
|
2 |
26 Feb 07 |
jari |
1259 |
graph.setXAxisValue(0); |
2 |
26 Feb 07 |
jari |
1260 |
graph.setYAxisValue(minCy3); |
2 |
26 Feb 07 |
jari |
1261 |
|
2 |
26 Feb 07 |
jari |
1262 |
for (int i = minCy3 + 1; i <= maxCy3; i++) { |
2 |
26 Feb 07 |
jari |
1263 |
gl = new GraphLine(i, minCy5, i, maxCy5, Color.yellow); |
2 |
26 Feb 07 |
jari |
1264 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1265 |
} |
2 |
26 Feb 07 |
jari |
1266 |
|
2 |
26 Feb 07 |
jari |
1267 |
for (int i = minCy5; i <= maxCy5; i++) { |
2 |
26 Feb 07 |
jari |
1268 |
if (i != 0) { |
2 |
26 Feb 07 |
jari |
1269 |
gl = new GraphLine(minCy3, i, maxCy3, i, Color.yellow); |
2 |
26 Feb 07 |
jari |
1270 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1271 |
} |
2 |
26 Feb 07 |
jari |
1272 |
} |
2 |
26 Feb 07 |
jari |
1273 |
|
2 |
26 Feb 07 |
jari |
1274 |
float cy3, cy5; |
2 |
26 Feb 07 |
jari |
1275 |
double logCy3, logCy5; |
2 |
26 Feb 07 |
jari |
1276 |
int metaBlock, metaRow, metaCol; |
2 |
26 Feb 07 |
jari |
1277 |
Color[] metaColors = graph.getColors(); |
2 |
26 Feb 07 |
jari |
1278 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
1279 |
sde = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
1280 |
|
2 |
26 Feb 07 |
jari |
1281 |
cy3 = sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
1282 |
cy5 = sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1283 |
metaRow = sde.getRow(ISlideDataElement.META); |
2 |
26 Feb 07 |
jari |
1284 |
metaCol = sde.getColumn(ISlideDataElement.META); |
2 |
26 Feb 07 |
jari |
1285 |
metaBlock = (metaRow * metaCol) + ((metaRow - 1) * (metaColumns - metaCol))-1; |
2 |
26 Feb 07 |
jari |
//System.out.println("metablock = " + metaBlock); |
2 |
26 Feb 07 |
jari |
//metaBlock = (2 * (sde.getRow(ISlideDataElement.META) - 1) + sde.getColumn(ISlideDataElement.META) - 1); //Hardcoded for 2x6 block configuration |
2 |
26 Feb 07 |
jari |
1288 |
logCy3 = Xcon.log10(cy3 * cy5); |
2 |
26 Feb 07 |
jari |
1289 |
logCy5 = Xcon.log10((double) cy5 / (double) cy3); |
2 |
26 Feb 07 |
jari |
1290 |
|
2 |
26 Feb 07 |
jari |
1291 |
if(metaBlock < metaColors.length) |
2 |
26 Feb 07 |
jari |
1292 |
gp = new GraphPoint(logCy3, logCy5, metaColors[metaBlock], 3); |
2 |
26 Feb 07 |
jari |
1293 |
else |
2 |
26 Feb 07 |
jari |
1294 |
gp = new GraphPoint(logCy3, logCy5, Color.black, 3); |
2 |
26 Feb 07 |
jari |
1295 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1296 |
} |
2 |
26 Feb 07 |
jari |
1297 |
|
2 |
26 Feb 07 |
jari |
1298 |
for (int i = minCy5; i <= maxCy5; i++) { |
2 |
26 Feb 07 |
jari |
1299 |
if (i == 0) gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "0" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1300 |
else gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "1.0E" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1301 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1302 |
} |
2 |
26 Feb 07 |
jari |
1303 |
|
2 |
26 Feb 07 |
jari |
1304 |
for (int i = minCy3; i <= maxCy3; i++) { |
2 |
26 Feb 07 |
jari |
1305 |
if (i == 0) gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, "0" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1306 |
else gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, "1.0E" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1307 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1308 |
} |
2 |
26 Feb 07 |
jari |
1309 |
|
2 |
26 Feb 07 |
jari |
1310 |
graphFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
1311 |
graph.setVisible(true); |
2 |
26 Feb 07 |
jari |
1312 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1313 |
System.out.println("Exception (createRatioProduct()): " + e); |
2 |
26 Feb 07 |
jari |
1314 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
1315 |
} |
2 |
26 Feb 07 |
jari |
1316 |
} |
2 |
26 Feb 07 |
jari |
1317 |
|
2 |
26 Feb 07 |
jari |
1318 |
public void createRatioProductPlot() { |
2 |
26 Feb 07 |
jari |
1319 |
JFrame graphFrame; |
2 |
26 Feb 07 |
jari |
1320 |
GraphViewer graph; |
2 |
26 Feb 07 |
jari |
1321 |
GraphPoint gp; |
2 |
26 Feb 07 |
jari |
1322 |
GraphLine gl; |
2 |
26 Feb 07 |
jari |
1323 |
GraphTick gt; |
2 |
26 Feb 07 |
jari |
1324 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
1325 |
|
2 |
26 Feb 07 |
jari |
1326 |
try { |
2 |
26 Feb 07 |
jari |
1327 |
int maxCy3 = (int) Xcon.log10(slideData.getMaxProduct(ISlideDataElement.CY3, ISlideDataElement.CY5)) + 1; |
2 |
26 Feb 07 |
jari |
1328 |
int maxCy5 = (int) Xcon.log10(slideData.getMaxRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, AC.LINEAR)) + 1; |
2 |
26 Feb 07 |
jari |
1329 |
int minCy3 = (int) Xcon.log10(slideData.getMinProduct(ISlideDataElement.CY3, ISlideDataElement.CY5, false)); |
2 |
26 Feb 07 |
jari |
1330 |
int minCy5 = (int) Xcon.log10(slideData.getMinRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, AC.LINEAR)); |
2 |
26 Feb 07 |
jari |
1331 |
|
2 |
26 Feb 07 |
jari |
1332 |
int xGap = ((int) (maxCy3 - minCy3)); |
2 |
26 Feb 07 |
jari |
1333 |
int yGap = ((int) (maxCy5 - minCy5)); |
2 |
26 Feb 07 |
jari |
1334 |
|
2 |
26 Feb 07 |
jari |
//System.out.println(slideData.getMinIntensity(ISlideDataElement.CY3, false) + "\t" + slideData.getMaxIntensity(ISlideDataElement.CY3)); |
2 |
26 Feb 07 |
jari |
//System.out.println(slideData.getMinIntensity(ISlideDataElement.CY5, false) + "\t" + slideData.getMaxIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
1337 |
|
2 |
26 Feb 07 |
jari |
//System.out.println(minCy3 + "\t" + maxCy3); |
2 |
26 Feb 07 |
jari |
//System.out.println(minCy5 + "\t" + maxCy5); |
2 |
26 Feb 07 |
jari |
//System.out.println(xGap + "\t" + yGap); |
2 |
26 Feb 07 |
jari |
1341 |
|
2 |
26 Feb 07 |
jari |
1342 |
graphFrame = new JFrame("Log Product vs. Log Ratio"); |
2 |
26 Feb 07 |
jari |
1343 |
graph = new GraphViewer(graphFrame, 0, 500, 0, 500, minCy3, maxCy3, minCy5, maxCy5, 100, 100, 100, 100, "Log Product vs. Log Ratio - " + SlideData.normalizationString(slideData.getNormalizedState()), "Log (Cy3 x Cy5)", "Log (Cy5 / Cy3)"); |
2 |
26 Feb 07 |
jari |
1344 |
|
2 |
26 Feb 07 |
jari |
1345 |
graph.setXAxisValue(0); |
2 |
26 Feb 07 |
jari |
1346 |
graph.setYAxisValue(minCy3); |
2 |
26 Feb 07 |
jari |
1347 |
|
2 |
26 Feb 07 |
jari |
1348 |
for (int i = minCy3 + 1; i <= maxCy3; i++) { |
2 |
26 Feb 07 |
jari |
1349 |
gl = new GraphLine(i, minCy5, i, maxCy5, Color.yellow); |
2 |
26 Feb 07 |
jari |
1350 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1351 |
} |
2 |
26 Feb 07 |
jari |
1352 |
|
2 |
26 Feb 07 |
jari |
1353 |
for (int i = minCy5; i <= maxCy5; i++) { |
2 |
26 Feb 07 |
jari |
1354 |
if (i != 0) { |
2 |
26 Feb 07 |
jari |
1355 |
gl = new GraphLine(minCy3, i, maxCy3, i, Color.yellow); |
2 |
26 Feb 07 |
jari |
1356 |
graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1357 |
} |
2 |
26 Feb 07 |
jari |
1358 |
} |
2 |
26 Feb 07 |
jari |
1359 |
|
2 |
26 Feb 07 |
jari |
1360 |
float cy3, cy5; |
2 |
26 Feb 07 |
jari |
1361 |
double logCy3, logCy5; |
2 |
26 Feb 07 |
jari |
1362 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
1363 |
sde = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
1364 |
|
2 |
26 Feb 07 |
jari |
1365 |
cy3 = sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
1366 |
cy5 = sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1367 |
logCy3 = Xcon.log10(cy3 * cy5); |
2 |
26 Feb 07 |
jari |
1368 |
logCy5 = Xcon.log10(cy5/cy3); |
2 |
26 Feb 07 |
jari |
1369 |
|
2 |
26 Feb 07 |
jari |
1370 |
if (canvas.thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
1371 |
if ((cy3 + cy5 > 0) && ((cy3/(cy3+cy5) > canvas.highDifference) || ((double) cy3 / (cy3 + cy5) < canvas.lowDifference))) { |
2 |
26 Feb 07 |
jari |
1372 |
gp = new GraphPoint(logCy3, logCy5, Color.red, 3); |
2 |
26 Feb 07 |
jari |
1373 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1374 |
} else { |
2 |
26 Feb 07 |
jari |
1375 |
gp = new GraphPoint(logCy3, logCy5, Color.blue, 3); |
2 |
26 Feb 07 |
jari |
1376 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1377 |
} |
2 |
26 Feb 07 |
jari |
1378 |
} else { |
2 |
26 Feb 07 |
jari |
1379 |
gp = new GraphPoint(logCy3, logCy5, Color.blue, 3); |
2 |
26 Feb 07 |
jari |
1380 |
graph.addGraphElement(gp); |
2 |
26 Feb 07 |
jari |
1381 |
} |
2 |
26 Feb 07 |
jari |
1382 |
} |
2 |
26 Feb 07 |
jari |
1383 |
|
2 |
26 Feb 07 |
jari |
1384 |
for (int i = minCy5; i <= maxCy5; i++) { |
2 |
26 Feb 07 |
jari |
1385 |
if (i == 0) gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "0" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1386 |
else gt = new GraphTick(i, 8, Color.black, GC.VERTICAL, GC.C, "1.0E" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1387 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1388 |
} |
2 |
26 Feb 07 |
jari |
1389 |
|
2 |
26 Feb 07 |
jari |
1390 |
for (int i = minCy3; i <= maxCy3; i++) { |
2 |
26 Feb 07 |
jari |
1391 |
if (i == 0) gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, "0" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1392 |
else gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, "1.0E" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1393 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1394 |
} |
2 |
26 Feb 07 |
jari |
1395 |
|
2 |
26 Feb 07 |
jari |
1396 |
graphFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
1397 |
graph.setVisible(true); |
2 |
26 Feb 07 |
jari |
1398 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1399 |
System.out.println("Exception (createRatioProduct()): " + e); |
2 |
26 Feb 07 |
jari |
1400 |
} |
2 |
26 Feb 07 |
jari |
1401 |
} |
2 |
26 Feb 07 |
jari |
1402 |
|
2 |
26 Feb 07 |
jari |
1403 |
public void createHistogram(int scale) { |
2 |
26 Feb 07 |
jari |
1404 |
JFrame graphFrame; |
2 |
26 Feb 07 |
jari |
1405 |
GraphViewer graph; |
2 |
26 Feb 07 |
jari |
1406 |
GraphLine gl; |
2 |
26 Feb 07 |
jari |
1407 |
GraphBar gb; |
2 |
26 Feb 07 |
jari |
1408 |
GraphTick gt; |
2 |
26 Feb 07 |
jari |
1409 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
1410 |
|
2 |
26 Feb 07 |
jari |
1411 |
try { |
2 |
26 Feb 07 |
jari |
1412 |
if (scale == AC.LOG) { |
2 |
26 Feb 07 |
jari |
1413 |
int partitions = 103; |
2 |
26 Feb 07 |
jari |
1414 |
double spread = 0.0; |
2 |
26 Feb 07 |
jari |
1415 |
|
2 |
26 Feb 07 |
jari |
1416 |
double bottomValue = -5.0, topValue = 5.0; |
2 |
26 Feb 07 |
jari |
1417 |
double ratio = 0.0; |
2 |
26 Feb 07 |
jari |
1418 |
int maxCount = 0; |
2 |
26 Feb 07 |
jari |
1419 |
int[] bin = new int[partitions]; |
2 |
26 Feb 07 |
jari |
1420 |
|
2 |
26 Feb 07 |
jari |
1421 |
double tempDouble = 0.0; |
2 |
26 Feb 07 |
jari |
1422 |
|
2 |
26 Feb 07 |
jari |
1423 |
if (partitions % 2 == 1) { //Odd number |
2 |
26 Feb 07 |
jari |
1424 |
spread = (double) (topValue - bottomValue) / (partitions - 3); |
2 |
26 Feb 07 |
jari |
1425 |
} |
2 |
26 Feb 07 |
jari |
1426 |
|
2 |
26 Feb 07 |
jari |
1427 |
double tx, ty; |
2 |
26 Feb 07 |
jari |
1428 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
1429 |
sde = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
1430 |
ratio = sde.getRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, AC.LOG); |
2 |
26 Feb 07 |
jari |
1431 |
|
2 |
26 Feb 07 |
jari |
1432 |
for (int j = 0; j < partitions; j++) { |
2 |
26 Feb 07 |
jari |
1433 |
if (j == 0) { |
2 |
26 Feb 07 |
jari |
1434 |
tx = Double.MIN_VALUE; |
2 |
26 Feb 07 |
jari |
1435 |
ty = bottomValue - (spread / 2); |
2 |
26 Feb 07 |
jari |
1436 |
} else if (j == partitions - 1) { |
2 |
26 Feb 07 |
jari |
1437 |
tx = topValue + (spread / 2); |
2 |
26 Feb 07 |
jari |
1438 |
ty = Double.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
1439 |
} else { |
2 |
26 Feb 07 |
jari |
1440 |
tx = bottomValue - (spread / 2) + ((j - 1) * spread); |
2 |
26 Feb 07 |
jari |
1441 |
ty = tx + spread; |
2 |
26 Feb 07 |
jari |
1442 |
} |
2 |
26 Feb 07 |
jari |
1443 |
|
2 |
26 Feb 07 |
jari |
1444 |
if (((ratio >= tx) && (ratio <= ty)) && (sde.hasNoZeros())) bin[j]++; |
2 |
26 Feb 07 |
jari |
1445 |
} |
2 |
26 Feb 07 |
jari |
1446 |
} |
2 |
26 Feb 07 |
jari |
1447 |
|
2 |
26 Feb 07 |
jari |
1448 |
for (int i = 0; i < bin.length; i++) if (maxCount < bin[i]) maxCount = bin[i]; |
2 |
26 Feb 07 |
jari |
1449 |
int power, maxBlock = 0; |
2 |
26 Feb 07 |
jari |
1450 |
float maxPartition = (float) maxCount; |
2 |
26 Feb 07 |
jari |
1451 |
for (power = 0; (! ((maxPartition < 10) && (maxPartition > 0))); power++) maxPartition /= 10; |
2 |
26 Feb 07 |
jari |
1452 |
maxBlock = (int) ((int) (maxPartition * 10) * Math.pow(10, (power - 2))); |
2 |
26 Feb 07 |
jari |
1453 |
maxCount = maxBlock * 11; |
2 |
26 Feb 07 |
jari |
1454 |
|
2 |
26 Feb 07 |
jari |
1455 |
graphFrame = new JFrame("Log (Cy5 / Cy3)"); |
2 |
26 Feb 07 |
jari |
1456 |
graph = new GraphViewer(graphFrame, 0, 500, 0, 500, bottomValue - (3 * spread / 2), topValue + (3 * spread / 2), 0, maxCount, 75, 75, 75, 75, "Log (Cy5 / Cy3) - " + SlideData.normalizationString(slideData.getNormalizedState()), "Ratio", "Count"); |
2 |
26 Feb 07 |
jari |
1457 |
|
2 |
26 Feb 07 |
jari |
1458 |
for (int i = 1; i < 12; i++) { //Guide lines |
2 |
26 Feb 07 |
jari |
//gl = new GraphLine(bottomValue, i * cy5Block, topValue, i * cy5Block, Color.yellow); |
2 |
26 Feb 07 |
jari |
//graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
//gl = new GraphLine(i * cy3Block, 0, i * cy3Block, maxCy5, Color.yellow); |
2 |
26 Feb 07 |
jari |
//graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1463 |
} |
2 |
26 Feb 07 |
jari |
1464 |
double lowLog = Math.log(1 / canvas.getFactor()); |
2 |
26 Feb 07 |
jari |
1465 |
double highLog = Math.log(canvas.getFactor()); |
2 |
26 Feb 07 |
jari |
1466 |
|
2 |
26 Feb 07 |
jari |
1467 |
for (int i = 0; i < bin.length; i++) { //Histogram Bars |
2 |
26 Feb 07 |
jari |
1468 |
if (canvas.thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
1469 |
if (((bottomValue + ((i - 1) * spread)) <= lowLog) || ((bottomValue + ((i - 1) * spread)) >= highLog)) { |
2 |
26 Feb 07 |
jari |
1470 |
gb = new GraphBar(bottomValue - (3 * spread / 2) + (i * spread), bottomValue - (spread / 2) + (i * spread), |
2 |
26 Feb 07 |
jari |
1471 |
bin[i], Color.red, GraphBar.VERTICAL, GraphBar.SOLID); |
2 |
26 Feb 07 |
jari |
1472 |
} else { |
2 |
26 Feb 07 |
jari |
1473 |
gb = new GraphBar(bottomValue - (3 * spread / 2) + (i * spread), bottomValue - (spread / 2) + (i * spread), |
2 |
26 Feb 07 |
jari |
1474 |
bin[i], Color.blue, GraphBar.VERTICAL, GraphBar.SOLID); |
2 |
26 Feb 07 |
jari |
1475 |
} |
2 |
26 Feb 07 |
jari |
1476 |
} else { |
2 |
26 Feb 07 |
jari |
1477 |
gb = new GraphBar(bottomValue - (3 * spread / 2) + (i * spread), bottomValue - (spread / 2) + (i * spread), |
2 |
26 Feb 07 |
jari |
1478 |
bin[i], Color.blue, GraphBar.VERTICAL, GraphBar.SOLID); |
2 |
26 Feb 07 |
jari |
1479 |
} |
2 |
26 Feb 07 |
jari |
1480 |
graph.addGraphElement(gb); |
2 |
26 Feb 07 |
jari |
1481 |
} |
2 |
26 Feb 07 |
jari |
1482 |
|
2 |
26 Feb 07 |
jari |
/*if (false) // For a tick on every bin |
2 |
26 Feb 07 |
jari |
1484 |
{ |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < bin.length + 1; i++) //X-Axis ticks |
2 |
26 Feb 07 |
jari |
1486 |
{ |
2 |
26 Feb 07 |
jari |
tempDouble = bottomValue - (3 * spread / 2) + (i * spread); |
2 |
26 Feb 07 |
jari |
if (i == 0) gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Minimum", Color.black); |
2 |
26 Feb 07 |
jari |
else if (i == bin.length) gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Maximum", Color.black); |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
1491 |
{ |
2 |
26 Feb 07 |
jari |
tempDouble *= 100; |
2 |
26 Feb 07 |
jari |
tempDouble /= 100; |
2 |
26 Feb 07 |
jari |
gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "" + tempDouble, Color.black); |
2 |
26 Feb 07 |
jari |
1495 |
} |
2 |
26 Feb 07 |
jari |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1497 |
} |
2 |
26 Feb 07 |
jari |
1498 |
} |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
1500 |
{*/ |
2 |
26 Feb 07 |
jari |
1501 |
tempDouble = bottomValue - (3 * spread / 2) + (0 * spread); |
2 |
26 Feb 07 |
jari |
1502 |
gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Minimum", Color.black); |
2 |
26 Feb 07 |
jari |
1503 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1504 |
|
2 |
26 Feb 07 |
jari |
1505 |
tempDouble = bottomValue - (3 * spread / 2) + (bin.length * spread); |
2 |
26 Feb 07 |
jari |
1506 |
gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Maximum", Color.black); |
2 |
26 Feb 07 |
jari |
1507 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1508 |
|
2 |
26 Feb 07 |
jari |
1509 |
for (int i = (int) bottomValue; i <= (int) topValue; i++) { |
2 |
26 Feb 07 |
jari |
1510 |
gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, "" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1511 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1512 |
} |
2 |
26 Feb 07 |
jari |
1513 |
//} |
2 |
26 Feb 07 |
jari |
1514 |
|
2 |
26 Feb 07 |
jari |
1515 |
for (int i = 1; i < 12; i++) { //Y-Axis ticks |
2 |
26 Feb 07 |
jari |
1516 |
gt = new GraphTick(i * maxBlock, 8, Color.black, GC.VERTICAL, GC.C, "" + i * maxBlock, Color.black); |
2 |
26 Feb 07 |
jari |
1517 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1518 |
} |
2 |
26 Feb 07 |
jari |
1519 |
|
2 |
26 Feb 07 |
jari |
1520 |
graphFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
1521 |
graph.setVisible(true); |
2 |
26 Feb 07 |
jari |
1522 |
} else if (scale == AC.LINEAR) { |
2 |
26 Feb 07 |
jari |
1523 |
int partitions = 53; |
2 |
26 Feb 07 |
jari |
1524 |
double spread = 0.0; |
2 |
26 Feb 07 |
jari |
1525 |
|
2 |
26 Feb 07 |
jari |
1526 |
double bottomValue = 0.0, topValue = 5.0; |
2 |
26 Feb 07 |
jari |
1527 |
double ratio = 0.0; |
2 |
26 Feb 07 |
jari |
1528 |
int maxCount = 0; |
2 |
26 Feb 07 |
jari |
1529 |
int[] bin = new int[partitions]; |
2 |
26 Feb 07 |
jari |
1530 |
|
2 |
26 Feb 07 |
jari |
1531 |
double tempDouble = 0.0; |
2 |
26 Feb 07 |
jari |
1532 |
|
2 |
26 Feb 07 |
jari |
1533 |
if (partitions % 2 == 1) { //Odd number |
2 |
26 Feb 07 |
jari |
1534 |
spread = (double) (topValue - bottomValue) / (partitions - 3); |
2 |
26 Feb 07 |
jari |
1535 |
} |
2 |
26 Feb 07 |
jari |
1536 |
|
2 |
26 Feb 07 |
jari |
1537 |
double tx, ty; |
2 |
26 Feb 07 |
jari |
1538 |
for (int i = 0; i < indices.length; i++) { |
2 |
26 Feb 07 |
jari |
1539 |
sde = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
1540 |
ratio = sde.getRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, AC.LINEAR); |
2 |
26 Feb 07 |
jari |
1541 |
|
2 |
26 Feb 07 |
jari |
1542 |
for (int j = 0; j < partitions; j++) { |
2 |
26 Feb 07 |
jari |
1543 |
if (j == 0) { |
2 |
26 Feb 07 |
jari |
1544 |
tx = Double.MIN_VALUE; |
2 |
26 Feb 07 |
jari |
1545 |
ty = bottomValue - (spread / 2); |
2 |
26 Feb 07 |
jari |
1546 |
} else if (j == partitions - 1) { |
2 |
26 Feb 07 |
jari |
1547 |
tx = topValue + (spread / 2); |
2 |
26 Feb 07 |
jari |
1548 |
ty = Double.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
1549 |
} else { |
2 |
26 Feb 07 |
jari |
1550 |
tx = bottomValue - (spread / 2) + ((j - 1) * spread); |
2 |
26 Feb 07 |
jari |
1551 |
ty = tx + spread; |
2 |
26 Feb 07 |
jari |
1552 |
} |
2 |
26 Feb 07 |
jari |
1553 |
|
2 |
26 Feb 07 |
jari |
1554 |
if (((ratio >= tx) && (ratio <= ty)) && (sde.hasNoZeros())) bin[j]++; |
2 |
26 Feb 07 |
jari |
1555 |
} |
2 |
26 Feb 07 |
jari |
1556 |
} |
2 |
26 Feb 07 |
jari |
1557 |
|
2 |
26 Feb 07 |
jari |
1558 |
for (int i = 0; i < bin.length; i++) if (maxCount < bin[i]) maxCount = bin[i]; |
2 |
26 Feb 07 |
jari |
1559 |
int power, maxBlock = 0; |
2 |
26 Feb 07 |
jari |
1560 |
float maxPartition = (float) maxCount; |
2 |
26 Feb 07 |
jari |
1561 |
for (power = 0; (! ((maxPartition < 10) && (maxPartition > 0))); power++) maxPartition /= 10; |
2 |
26 Feb 07 |
jari |
1562 |
maxBlock = (int) ((int) (maxPartition * 10) * Math.pow(10, (power - 2))); |
2 |
26 Feb 07 |
jari |
1563 |
maxCount = maxBlock * 11; |
2 |
26 Feb 07 |
jari |
1564 |
|
2 |
26 Feb 07 |
jari |
1565 |
graphFrame = new JFrame("Cy5 / Cy3"); |
2 |
26 Feb 07 |
jari |
1566 |
graph = new GraphViewer(graphFrame, 0, 500, 0, 500, bottomValue - (3 * spread / 2), topValue + (3 * spread / 2), 0, maxCount, 75, 75, 75, 75, "Cy5 / Cy3 - " + SlideData.normalizationString(slideData.getNormalizedState()), "Ratio", "Count"); |
2 |
26 Feb 07 |
jari |
1567 |
|
2 |
26 Feb 07 |
jari |
1568 |
for (int i = 1; i < 12; i++) { //Guide lines |
2 |
26 Feb 07 |
jari |
//gl = new GraphLine(bottomValue, i * cy5Block, topValue, i * cy5Block, Color.yellow); |
2 |
26 Feb 07 |
jari |
//graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
//gl = new GraphLine(i * cy3Block, 0, i * cy3Block, maxCy5, Color.yellow); |
2 |
26 Feb 07 |
jari |
//graph.addGraphElement(gl); |
2 |
26 Feb 07 |
jari |
1573 |
} |
2 |
26 Feb 07 |
jari |
1574 |
|
2 |
26 Feb 07 |
jari |
1575 |
double lowLog = 1 / canvas.getFactor(); |
2 |
26 Feb 07 |
jari |
1576 |
double highLog = canvas.getFactor(); |
2 |
26 Feb 07 |
jari |
1577 |
|
2 |
26 Feb 07 |
jari |
1578 |
for (int i = 0; i < bin.length; i++) { //Histogram Bars |
2 |
26 Feb 07 |
jari |
1579 |
if (canvas.thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
1580 |
if (((bottomValue + ((i - 1) * spread)) <= lowLog) || ((bottomValue + ((i - 1) * spread)) >= highLog)) { |
2 |
26 Feb 07 |
jari |
1581 |
gb = new GraphBar(bottomValue - (3 * spread / 2) + (i * spread), bottomValue - (spread / 2) + (i * spread), |
2 |
26 Feb 07 |
jari |
1582 |
bin[i], Color.red, GraphBar.VERTICAL, GraphBar.SOLID); |
2 |
26 Feb 07 |
jari |
1583 |
} else { |
2 |
26 Feb 07 |
jari |
1584 |
gb = new GraphBar(bottomValue - (3 * spread / 2) + (i * spread), bottomValue - (spread / 2) + (i * spread), |
2 |
26 Feb 07 |
jari |
1585 |
bin[i], Color.blue, GraphBar.VERTICAL, GraphBar.SOLID); |
2 |
26 Feb 07 |
jari |
1586 |
} |
2 |
26 Feb 07 |
jari |
1587 |
} else { |
2 |
26 Feb 07 |
jari |
1588 |
gb = new GraphBar(bottomValue - (3 * spread / 2) + (i * spread), bottomValue - (spread / 2) + (i * spread), |
2 |
26 Feb 07 |
jari |
1589 |
bin[i], Color.blue, GraphBar.VERTICAL, GraphBar.SOLID); |
2 |
26 Feb 07 |
jari |
1590 |
} |
2 |
26 Feb 07 |
jari |
1591 |
graph.addGraphElement(gb); |
2 |
26 Feb 07 |
jari |
1592 |
} |
2 |
26 Feb 07 |
jari |
1593 |
|
2 |
26 Feb 07 |
jari |
/*if (false) // For a tick on every bin |
2 |
26 Feb 07 |
jari |
1595 |
{ |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < bin.length + 1; i++) //X-Axis ticks |
2 |
26 Feb 07 |
jari |
1597 |
{ |
2 |
26 Feb 07 |
jari |
tempDouble = bottomValue - (3 * spread / 2) + (i * spread); |
2 |
26 Feb 07 |
jari |
if (i == 0) gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Minimum", Color.black); |
2 |
26 Feb 07 |
jari |
else if (i == bin.length) gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Maximum", Color.black); |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
1602 |
{ |
2 |
26 Feb 07 |
jari |
tempDouble *= 100; |
2 |
26 Feb 07 |
jari |
tempDouble /= 100; |
2 |
26 Feb 07 |
jari |
gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "" + tempDouble, Color.black); |
2 |
26 Feb 07 |
jari |
1606 |
} |
2 |
26 Feb 07 |
jari |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1608 |
} |
2 |
26 Feb 07 |
jari |
1609 |
} |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
1611 |
{*/ |
2 |
26 Feb 07 |
jari |
1612 |
tempDouble = bottomValue - (3 * spread / 2) + (0 * spread); |
2 |
26 Feb 07 |
jari |
1613 |
gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Minimum", Color.black); |
2 |
26 Feb 07 |
jari |
1614 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1615 |
|
2 |
26 Feb 07 |
jari |
1616 |
tempDouble = bottomValue - (3 * spread / 2) + (bin.length * spread); |
2 |
26 Feb 07 |
jari |
1617 |
gt = new GraphTick(tempDouble, 8, Color.black, GC.HORIZONTAL, GC.C, "Maximum", Color.black); |
2 |
26 Feb 07 |
jari |
1618 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1619 |
|
2 |
26 Feb 07 |
jari |
1620 |
for (int i = (int) bottomValue; i <= (int) topValue; i++) { |
2 |
26 Feb 07 |
jari |
1621 |
gt = new GraphTick(i, 8, Color.black, GC.HORIZONTAL, GC.C, "" + i, Color.black); |
2 |
26 Feb 07 |
jari |
1622 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1623 |
} |
2 |
26 Feb 07 |
jari |
1624 |
//} |
2 |
26 Feb 07 |
jari |
1625 |
|
2 |
26 Feb 07 |
jari |
1626 |
for (int i = 1; i < 12; i++) { //Y-Axis ticks |
2 |
26 Feb 07 |
jari |
1627 |
gt = new GraphTick(i * maxBlock, 8, Color.black, GC.VERTICAL, GC.C, "" + i * maxBlock, Color.black); |
2 |
26 Feb 07 |
jari |
1628 |
graph.addGraphElement(gt); |
2 |
26 Feb 07 |
jari |
1629 |
} |
2 |
26 Feb 07 |
jari |
1630 |
|
2 |
26 Feb 07 |
jari |
1631 |
graphFrame.setSize(500, 500); |
2 |
26 Feb 07 |
jari |
1632 |
graph.setVisible(true); |
2 |
26 Feb 07 |
jari |
1633 |
} |
2 |
26 Feb 07 |
jari |
1634 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1635 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
1636 |
} |
2 |
26 Feb 07 |
jari |
1637 |
|
2 |
26 Feb 07 |
jari |
1638 |
|
2 |
26 Feb 07 |
jari |
//HistogramViewer histogramViewer = null; |
2 |
26 Feb 07 |
jari |
//JFrame histogramFrame = null; |
2 |
26 Feb 07 |
jari |
1641 |
|
2 |
26 Feb 07 |
jari |
/* If this compiles, this is not necessary |
2 |
26 Feb 07 |
jari |
int[] bin; |
2 |
26 Feb 07 |
jari |
int highY = 0; |
2 |
26 Feb 07 |
jari |
Color barColor = Color.blue; |
2 |
26 Feb 07 |
jari |
Color highlightColor = Color.red; |
2 |
26 Feb 07 |
jari |
1647 |
*/ |
2 |
26 Feb 07 |
jari |
1648 |
|
2 |
26 Feb 07 |
jari |
1649 |
/* |
2 |
26 Feb 07 |
jari |
if (scale == SingleArrayViewer.LOG) |
2 |
26 Feb 07 |
jari |
1651 |
{ |
2 |
26 Feb 07 |
jari |
histogramFrame = new JFrame(slideData.getSlideDataName() + " - Ratio Histogram (Log)"); |
2 |
26 Feb 07 |
jari |
histogramViewer = new HistogramViewer(histogramFrame, 0, 400, 0, 400, -1, 1, 0, 200, 50, 50, 50, 50); |
2 |
26 Feb 07 |
jari |
histogramViewer.setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
histogramViewer.setScale(AC.LOG); |
2 |
26 Feb 07 |
jari |
histogramFrame.setIconImage(new ImageIcon(org.tigr.microarray.SingleArrayViewer.class.getResource("/org/tigr/images/expression.gif")).getImage()); |
2 |
26 Feb 07 |
jari |
histogramFrame.setSize(600, 600); |
2 |
26 Feb 07 |
jari |
histogramFrame.move(300, 100); |
2 |
26 Feb 07 |
jari |
histogramFrame.setVisible(true); |
2 |
26 Feb 07 |
jari |
1660 |
} |
2 |
26 Feb 07 |
jari |
else if (scale == SingleArrayViewer.LINEAR) |
2 |
26 Feb 07 |
jari |
1662 |
{ |
2 |
26 Feb 07 |
jari |
histogramFrame = new JFrame(slideData.getSlideDataName() + " - Ratio Histogram (Linear)"); |
2 |
26 Feb 07 |
jari |
histogramViewer = new HistogramViewer(histogramFrame, 0, 400, 0, 400, 0, 5, 0, 200, 50, 50, 50, 50); |
2 |
26 Feb 07 |
jari |
histogramViewer.setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
histogramViewer.setScale(AC.LINEAR); |
2 |
26 Feb 07 |
jari |
histogramFrame.setIconImage(new ImageIcon(org.tigr.microarray.SingleArrayViewer.class.getResource("/org/tigr/images/expression.gif")).getImage()); |
2 |
26 Feb 07 |
jari |
histogramFrame.setSize(600, 600); |
2 |
26 Feb 07 |
jari |
histogramFrame.move(300, 100); |
2 |
26 Feb 07 |
jari |
histogramFrame.setVisible(true); |
2 |
26 Feb 07 |
jari |
1671 |
} |
2 |
26 Feb 07 |
jari |
1672 |
*/ |
2 |
26 Feb 07 |
jari |
1673 |
} |
2 |
26 Feb 07 |
jari |
1674 |
|
2 |
26 Feb 07 |
jari |
1675 |
/* |
2 |
26 Feb 07 |
jari |
public void newSubArray() |
2 |
26 Feb 07 |
jari |
1677 |
{ |
2 |
26 Feb 07 |
jari |
String source; |
2 |
26 Feb 07 |
jari |
double low = displayCanvas.getLowDifference(); |
2 |
26 Feb 07 |
jari |
double high = displayCanvas.getHighDifference(); |
2 |
26 Feb 07 |
jari |
1681 |
|
2 |
26 Feb 07 |
jari |
if (displayCanvas.getThresholds()) source = "SubArray: Lower " + (Math.rint(low * 100) / 100) + ", Higher " + (Math.rint(high * 100) / 100); |
2 |
26 Feb 07 |
jari |
else source = "SubArray: No Thresholds"; |
2 |
26 Feb 07 |
jari |
1684 |
|
2 |
26 Feb 07 |
jari |
SubApplet subApplet = new SubApplet(source); |
2 |
26 Feb 07 |
jari |
SubFrame subFrame = new SubFrame(subApplet); |
2 |
26 Feb 07 |
jari |
SubCanvas subCanvas = subApplet.getSubCanvas(); |
2 |
26 Feb 07 |
jari |
SubPanel subPanel = subFrame.getSubPanel(); |
2 |
26 Feb 07 |
jari |
Vector holding; |
2 |
26 Feb 07 |
jari |
SlideData newSlideData; |
2 |
26 Feb 07 |
jari |
ISlideDataElement sde, sdo; |
2 |
26 Feb 07 |
jari |
1692 |
|
2 |
26 Feb 07 |
jari |
subApplet.changePaletteStyle(displayCanvas.getPaletteStyle()); |
2 |
26 Feb 07 |
jari |
subApplet.setThresholds(displayCanvas.getThresholds()); |
2 |
26 Feb 07 |
jari |
//Should this be nice? |
2 |
26 Feb 07 |
jari |
subCanvas.setScale(displayCanvas.getScale()); |
2 |
26 Feb 07 |
jari |
switch (displayCanvas.getPaletteStyle()) |
2 |
26 Feb 07 |
jari |
1698 |
{ |
2 |
26 Feb 07 |
jari |
case DisplayCanvas.BLUETORED: subFrame.handleItems(subFrame.blueToRedItem); break; |
2 |
26 Feb 07 |
jari |
case DisplayCanvas.GREENRED: subFrame.handleItems(subFrame.greenRedItem); break; |
2 |
26 Feb 07 |
jari |
case DisplayCanvas.OVERLAY: subFrame.handleItems(subFrame.overlayItem); break; |
2 |
26 Feb 07 |
jari |
1702 |
} |
2 |
26 Feb 07 |
jari |
if (displayCanvas.getThresholds()) subFrame.handleItems(subFrame.setGreenRedThresholdsOnItem); |
2 |
26 Feb 07 |
jari |
else subFrame.handleItems(subFrame.setGreenRedThresholdsOffItem); |
2 |
26 Feb 07 |
jari |
if (displayCanvas.getScale()) subFrame.handleItems(subFrame.setScaleOnItem); |
2 |
26 Feb 07 |
jari |
else subFrame.handleItems(subFrame.setScaleOffItem); |
2 |
26 Feb 07 |
jari |
1707 |
|
2 |
26 Feb 07 |
jari |
if (displayCanvas.getThresholds()) |
2 |
26 Feb 07 |
jari |
1709 |
{ |
2 |
26 Feb 07 |
jari |
holding = new Vector(); |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < slideData.getSlideDataSize(); i++) |
2 |
26 Feb 07 |
jari |
1712 |
{ |
2 |
26 Feb 07 |
jari |
try |
2 |
26 Feb 07 |
jari |
1714 |
{ |
2 |
26 Feb 07 |
jari |
sdo = (ISlideDataElement) slideData.getSlideDataElementAt(i); |
2 |
26 Feb 07 |
jari |
sde = new SlideDataElement(sdo.getRow(), sdo.getColumn(), sdo.getMetaRow(), sdo.getMetaColumn(), |
2 |
26 Feb 07 |
jari |
sdo.getSubRow(), sdo.getSubColumn(), sdo.getCy3(), sdo.getCy5(), |
2 |
26 Feb 07 |
jari |
sdo.getValues(), sdo.getIsNull()); |
2 |
26 Feb 07 |
jari |
int cy3 = (int) sde.getCy3(); |
2 |
26 Feb 07 |
jari |
int cy5 = (int) sde.getCy5(); |
2 |
26 Feb 07 |
jari |
if ((cy3 + cy5 > 0) && (((double) cy3 / (cy3 + cy5) > high) |
2 |
26 Feb 07 |
jari |
|| ((double) cy3 / (cy3 + cy5) < low))) holding.addElement(sde); |
2 |
26 Feb 07 |
jari |
1723 |
} |
2 |
26 Feb 07 |
jari |
catch (NullPointerException npe) {;} |
2 |
26 Feb 07 |
jari |
1725 |
} |
2 |
26 Feb 07 |
jari |
1726 |
|
2 |
26 Feb 07 |
jari |
if (holding.size() > 0) |
2 |
26 Feb 07 |
jari |
1728 |
{ |
2 |
26 Feb 07 |
jari |
int columns = (int) Math.ceil(Math.sqrt(holding.size() / 6)); |
2 |
26 Feb 07 |
jari |
int rows = columns * 6; |
2 |
26 Feb 07 |
jari |
1731 |
|
2 |
26 Feb 07 |
jari |
for (; (columns * rows) - holding.size() >= columns; rows--) {;} |
2 |
26 Feb 07 |
jari |
1733 |
|
2 |
26 Feb 07 |
jari |
newSlideData = new SlideData(columns, rows, slideData.getTrueColumns(), slideData.getTrueRows()); |
2 |
26 Feb 07 |
jari |
newSlideData.setSlideDataName(slideData.getSlideDataName()); |
2 |
26 Feb 07 |
jari |
newSlideData.setNormalizedState(slideData.getNormalizedState()); |
2 |
26 Feb 07 |
jari |
int maxColumns = newSlideData.getColumns(); |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < holding.size(); i++) |
2 |
26 Feb 07 |
jari |
1739 |
{ |
2 |
26 Feb 07 |
jari |
try |
2 |
26 Feb 07 |
jari |
1741 |
{ |
2 |
26 Feb 07 |
jari |
sde = (ISlideDataElement) holding.elementAt(i); |
2 |
26 Feb 07 |
jari |
sde.setColumn((i % maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
sde.setRow((i / maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
1745 |
|
2 |
26 Feb 07 |
jari |
//Should this be one step? |
2 |
26 Feb 07 |
jari |
sde.setSlideData(newSlideData); |
2 |
26 Feb 07 |
jari |
newSlideData.addSlideDataElement(sde); |
2 |
26 Feb 07 |
jari |
1749 |
} |
2 |
26 Feb 07 |
jari |
catch (Exception e) {System.out.println("Exception (DisplayApplet.createSubarray(): " + e);} |
2 |
26 Feb 07 |
jari |
1751 |
} |
2 |
26 Feb 07 |
jari |
subApplet.setData(newSlideData); |
2 |
26 Feb 07 |
jari |
subCanvas.setUpperLimits(displayCanvas.getTopCy3(), displayCanvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
subPanel.setXYScrollbars(slideData.getMaxCy3(), slideData.getMaxCy5()); |
2 |
26 Feb 07 |
jari |
subPanel.updateXUpperLimitScrollbar(displayCanvas.getTopCy3()); |
2 |
26 Feb 07 |
jari |
subPanel.updateYUpperLimitScrollbar(displayCanvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
subApplet.drawNewPicture(newSlideData); |
2 |
26 Feb 07 |
jari |
subCanvas.drawSlide(); |
2 |
26 Feb 07 |
jari |
1759 |
} |
2 |
26 Feb 07 |
jari |
1760 |
} |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
1762 |
{ |
2 |
26 Feb 07 |
jari |
subApplet.setData(slideData); |
2 |
26 Feb 07 |
jari |
subApplet.drawNewPicture(slideData); |
2 |
26 Feb 07 |
jari |
subCanvas.drawSlide(); |
2 |
26 Feb 07 |
jari |
1766 |
} |
2 |
26 Feb 07 |
jari |
1767 |
} |
2 |
26 Feb 07 |
jari |
1768 |
|
2 |
26 Feb 07 |
jari |
public void createRegion(int metaRow, int metaColumn) |
2 |
26 Feb 07 |
jari |
1770 |
{ |
2 |
26 Feb 07 |
jari |
SubApplet subApplet; |
2 |
26 Feb 07 |
jari |
SubFrame subFrame; |
2 |
26 Feb 07 |
jari |
SubCanvas subCanvas; |
2 |
26 Feb 07 |
jari |
SubPanel subPanel; |
2 |
26 Feb 07 |
jari |
Vector holding; |
2 |
26 Feb 07 |
jari |
SlideData newSlideData; |
2 |
26 Feb 07 |
jari |
ISlideDataElement sde, sdo; |
2 |
26 Feb 07 |
jari |
int maxSubRow = 0, maxSubColumn = 0; |
2 |
26 Feb 07 |
jari |
1779 |
|
2 |
26 Feb 07 |
jari |
holding = new Vector(); |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < slideData.getSlideDataSize(); i++) |
2 |
26 Feb 07 |
jari |
1782 |
{ |
2 |
26 Feb 07 |
jari |
try |
2 |
26 Feb 07 |
jari |
1784 |
{ |
2 |
26 Feb 07 |
jari |
sdo = (ISlideDataElement) slideData.getSlideDataElementAt(i); |
2 |
26 Feb 07 |
jari |
sde = new SlideDataElement(sdo.getRow(), sdo.getColumn(), sdo.getMetaRow(), sdo.getMetaColumn(), |
2 |
26 Feb 07 |
jari |
sdo.getSubRow(), sdo.getSubColumn(), sdo.getCy3(), sdo.getCy5(), |
2 |
26 Feb 07 |
jari |
sdo.getValues(), sdo.getIsNull()); |
2 |
26 Feb 07 |
jari |
if ((sde.getMetaRow() == metaRow) && (sde.getMetaColumn() == metaColumn)) |
2 |
26 Feb 07 |
jari |
1790 |
{ |
2 |
26 Feb 07 |
jari |
holding.addElement(sde); |
2 |
26 Feb 07 |
jari |
if (sde.getSubRow() > maxSubRow) maxSubRow = sde.getSubRow(); |
2 |
26 Feb 07 |
jari |
if (sde.getSubColumn() > maxSubColumn) maxSubColumn = sde.getSubColumn(); |
2 |
26 Feb 07 |
jari |
1794 |
} |
2 |
26 Feb 07 |
jari |
1795 |
} |
2 |
26 Feb 07 |
jari |
catch (NullPointerException npe) {;} |
2 |
26 Feb 07 |
jari |
1797 |
} |
2 |
26 Feb 07 |
jari |
1798 |
|
2 |
26 Feb 07 |
jari |
if (holding.size() > 0) |
2 |
26 Feb 07 |
jari |
1800 |
{ |
2 |
26 Feb 07 |
jari |
subApplet = new SubApplet("Region: MetaColumn " + metaColumn + ", MetaRow " + metaRow); |
2 |
26 Feb 07 |
jari |
subFrame = new SubFrame(subApplet); |
2 |
26 Feb 07 |
jari |
subCanvas = subApplet.getSubCanvas(); |
2 |
26 Feb 07 |
jari |
subPanel = subFrame.getSubPanel(); |
2 |
26 Feb 07 |
jari |
1805 |
|
2 |
26 Feb 07 |
jari |
subApplet.changePaletteStyle(displayCanvas.getPaletteStyle()); |
2 |
26 Feb 07 |
jari |
subApplet.setThresholds(displayCanvas.getThresholds()); |
2 |
26 Feb 07 |
jari |
//Should this be nice? |
2 |
26 Feb 07 |
jari |
subCanvas.setScale(displayCanvas.getScale()); |
2 |
26 Feb 07 |
jari |
switch (displayCanvas.getPaletteStyle()) |
2 |
26 Feb 07 |
jari |
1811 |
{ |
2 |
26 Feb 07 |
jari |
case DisplayCanvas.BLUETORED: subFrame.handleItems(subFrame.blueToRedItem); break; |
2 |
26 Feb 07 |
jari |
case DisplayCanvas.GREENRED: subFrame.handleItems(subFrame.greenRedItem); break; |
2 |
26 Feb 07 |
jari |
case DisplayCanvas.OVERLAY: subFrame.handleItems(subFrame.overlayItem); break; |
2 |
26 Feb 07 |
jari |
1815 |
} |
2 |
26 Feb 07 |
jari |
if (displayCanvas.getThresholds()) subFrame.handleItems(subFrame.setGreenRedThresholdsOnItem); |
2 |
26 Feb 07 |
jari |
else subFrame.handleItems(subFrame.setGreenRedThresholdsOffItem); |
2 |
26 Feb 07 |
jari |
if (displayCanvas.getScale()) subFrame.handleItems(subFrame.setScaleOnItem); |
2 |
26 Feb 07 |
jari |
else subFrame.handleItems(subFrame.setScaleOffItem); |
2 |
26 Feb 07 |
jari |
1820 |
|
2 |
26 Feb 07 |
jari |
newSlideData = new SlideData(maxSubColumn, maxSubRow, slideData.getTrueColumns(), slideData.getTrueRows()); |
2 |
26 Feb 07 |
jari |
newSlideData.setSlideDataName(slideData.getSlideDataName()); |
2 |
26 Feb 07 |
jari |
newSlideData.setNormalizedState(slideData.getNormalizedState()); |
2 |
26 Feb 07 |
jari |
int maxColumns = newSlideData.getColumns(); |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < holding.size(); i++) |
2 |
26 Feb 07 |
jari |
1826 |
{ |
2 |
26 Feb 07 |
jari |
try |
2 |
26 Feb 07 |
jari |
1828 |
{ |
2 |
26 Feb 07 |
jari |
sde = (ISlideDataElement) holding.elementAt(i); |
2 |
26 Feb 07 |
jari |
sde.setColumn((i % maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
sde.setRow((i / maxColumns) + 1); |
2 |
26 Feb 07 |
jari |
1832 |
|
2 |
26 Feb 07 |
jari |
//Should this be one step? |
2 |
26 Feb 07 |
jari |
sde.setSlideData(newSlideData); |
2 |
26 Feb 07 |
jari |
newSlideData.addSlideDataElement(sde); |
2 |
26 Feb 07 |
jari |
1836 |
} |
2 |
26 Feb 07 |
jari |
catch (Exception e) {System.out.println("Exception (SetMetaLocation.actionPerformed(): " + e);} |
2 |
26 Feb 07 |
jari |
1838 |
} |
2 |
26 Feb 07 |
jari |
subApplet.setData(newSlideData); |
2 |
26 Feb 07 |
jari |
subCanvas.setUpperLimits(displayCanvas.getTopCy3(), displayCanvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
subPanel.setXYScrollbars(slideData.getMaxCy3(), slideData.getMaxCy5()); |
2 |
26 Feb 07 |
jari |
subPanel.updateXUpperLimitScrollbar(displayCanvas.getTopCy3()); |
2 |
26 Feb 07 |
jari |
subPanel.updateYUpperLimitScrollbar(displayCanvas.getTopCy5()); |
2 |
26 Feb 07 |
jari |
subApplet.drawNewPicture(newSlideData); |
2 |
26 Feb 07 |
jari |
subCanvas.drawSlide(); |
2 |
26 Feb 07 |
jari |
1846 |
} |
2 |
26 Feb 07 |
jari |
1847 |
|
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
1849 |
{ |
2 |
26 Feb 07 |
jari |
MessageDisplay messageDisplay = new MessageDisplay((DisplayFrame) getParent(), "No region: Row " + metaRow + ", Column " + metaColumn, ""); |
2 |
26 Feb 07 |
jari |
1851 |
} |
2 |
26 Feb 07 |
jari |
1852 |
} |
2 |
26 Feb 07 |
jari |
1853 |
*/ |
2 |
26 Feb 07 |
jari |
1854 |
|
2 |
26 Feb 07 |
jari |
1855 |
public void setThresholds(boolean state) { |
2 |
26 Feb 07 |
jari |
1856 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
1857 |
canvas.setThresholds(state); |
2 |
26 Feb 07 |
jari |
//for (int i = 0; i < getPlotAppletVector().size(); i++) |
2 |
26 Feb 07 |
jari |
1859 |
// { |
2 |
26 Feb 07 |
jari |
// plotApplet = (PlotApplet) getPlotAppletVector().elementAt(i); |
2 |
26 Feb 07 |
jari |
// plotApplet.getPlotCanvas().setThresholds(state); |
2 |
26 Feb 07 |
jari |
1862 |
// } |
2 |
26 Feb 07 |
jari |
//for (int i = 0; i < getHistogramAppletVector().size(); i++) |
2 |
26 Feb 07 |
jari |
1864 |
// { |
2 |
26 Feb 07 |
jari |
// histogramApplet = (HistogramApplet) histogramAppletVector.elementAt(i); |
2 |
26 Feb 07 |
jari |
// histogramApplet.setThresholds(state); |
2 |
26 Feb 07 |
jari |
1867 |
// } |
2 |
26 Feb 07 |
jari |
1868 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
1869 |
} |
2 |
26 Feb 07 |
jari |
1870 |
|
2 |
26 Feb 07 |
jari |
1871 |
public void setFactor(float factor) { |
2 |
26 Feb 07 |
jari |
1872 |
double lower; |
2 |
26 Feb 07 |
jari |
1873 |
double higher; |
2 |
26 Feb 07 |
jari |
1874 |
|
2 |
26 Feb 07 |
jari |
1875 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
1876 |
canvas.setFactor(factor); |
2 |
26 Feb 07 |
jari |
1877 |
|
2 |
26 Feb 07 |
jari |
1878 |
try { |
2 |
26 Feb 07 |
jari |
1879 |
lower = 1 / (factor + 1); |
2 |
26 Feb 07 |
jari |
1880 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
1881 |
lower = 1 / (canvas.getFactor() + 1); |
2 |
26 Feb 07 |
jari |
1882 |
} |
2 |
26 Feb 07 |
jari |
1883 |
try { |
2 |
26 Feb 07 |
jari |
1884 |
higher = factor / (factor + 1); |
2 |
26 Feb 07 |
jari |
1885 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
1886 |
higher = canvas.getFactor() / (canvas.getFactor() + 1); |
2 |
26 Feb 07 |
jari |
1887 |
} |
2 |
26 Feb 07 |
jari |
1888 |
|
2 |
26 Feb 07 |
jari |
1889 |
canvas.setLowDifference(lower); |
2 |
26 Feb 07 |
jari |
1890 |
canvas.setHighDifference(higher); |
2 |
26 Feb 07 |
jari |
1891 |
|
2 |
26 Feb 07 |
jari |
1892 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < plotAppletVector.size(); i++) |
2 |
26 Feb 07 |
jari |
1894 |
{ |
2 |
26 Feb 07 |
jari |
plotApplet = (PlotApplet) plotAppletVector.elementAt(i); |
2 |
26 Feb 07 |
jari |
plotApplet.getPlotCanvas().setLowDifference(lower); |
2 |
26 Feb 07 |
jari |
plotApplet.getPlotCanvas().setHighDifference(higher); |
2 |
26 Feb 07 |
jari |
plotApplet.getPlotCanvas().setThresholds(true); |
2 |
26 Feb 07 |
jari |
1899 |
} |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < histogramAppletVector.size(); i++) |
2 |
26 Feb 07 |
jari |
1901 |
{ |
2 |
26 Feb 07 |
jari |
histogramApplet = (HistogramApplet) histogramAppletVector.elementAt(i); |
2 |
26 Feb 07 |
jari |
histogramApplet.setRegion(lower, higher); |
2 |
26 Feb 07 |
jari |
histogramApplet.setThresholds(true); |
2 |
26 Feb 07 |
jari |
1905 |
} |
2 |
26 Feb 07 |
jari |
if (displayCanvas.getThresholds() == true) displayCanvas.drawSlide(); |
2 |
26 Feb 07 |
jari |
((DisplayFrame) getParent()).setGreenRedThresholdsOnItem.disable(); |
2 |
26 Feb 07 |
jari |
((DisplayFrame) getParent()).setGreenRedThresholdsOffItem.enable(); |
2 |
26 Feb 07 |
jari |
1909 |
*/ |
2 |
26 Feb 07 |
jari |
1910 |
|
2 |
26 Feb 07 |
jari |
1911 |
panel.updateThresholdScrollbar((double) (Math.rint(factor * 100) / 100)); |
2 |
26 Feb 07 |
jari |
1912 |
|
2 |
26 Feb 07 |
jari |
1913 |
if (setThresholdsItem.isSelected()) refreshSlide(); |
2 |
26 Feb 07 |
jari |
1914 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
1915 |
} |
2 |
26 Feb 07 |
jari |
1916 |
|
2 |
26 Feb 07 |
jari |
1917 |
public void setUpperLimits(float cy3, float cy5) { |
2 |
26 Feb 07 |
jari |
1918 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
1919 |
canvas.setUpperLimits(cy3, cy5); |
2 |
26 Feb 07 |
jari |
1920 |
panel.xUpperLimitScrollbar.setValue((int) cy3); |
2 |
26 Feb 07 |
jari |
1921 |
panel.yUpperLimitScrollbar.setValue((int) cy5); |
2 |
26 Feb 07 |
jari |
1922 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
1923 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
1924 |
} |
2 |
26 Feb 07 |
jari |
1925 |
|
2 |
26 Feb 07 |
jari |
1926 |
public void changePaletteStyle(int paletteStyle) { |
2 |
26 Feb 07 |
jari |
1927 |
switch (paletteStyle) { |
2 |
26 Feb 07 |
jari |
1928 |
case SingleArrayViewerCanvas.BLUETORED: |
2 |
26 Feb 07 |
jari |
1929 |
canvas.setPaletteStyle(SingleArrayViewerCanvas.BLUETORED); |
2 |
26 Feb 07 |
jari |
1930 |
break; |
2 |
26 Feb 07 |
jari |
1931 |
case SingleArrayViewerCanvas.GREENRED: |
2 |
26 Feb 07 |
jari |
1932 |
canvas.setPaletteStyle(SingleArrayViewerCanvas.GREENRED); |
2 |
26 Feb 07 |
jari |
1933 |
break; |
2 |
26 Feb 07 |
jari |
1934 |
case SingleArrayViewerCanvas.OVERLAY: |
2 |
26 Feb 07 |
jari |
1935 |
canvas.setPaletteStyle(SingleArrayViewerCanvas.OVERLAY); |
2 |
26 Feb 07 |
jari |
1936 |
break; |
2 |
26 Feb 07 |
jari |
1937 |
} |
2 |
26 Feb 07 |
jari |
1938 |
} |
2 |
26 Feb 07 |
jari |
1939 |
|
2 |
26 Feb 07 |
jari |
1940 |
public void sort(int sortType) { |
2 |
26 Feb 07 |
jari |
1941 |
/* |
2 |
26 Feb 07 |
jari |
If the sortType > 9000, then it is a standard type. Otherwise, it represents the |
2 |
26 Feb 07 |
jari |
index of the additional field on which to sort. |
2 |
26 Feb 07 |
jari |
1944 |
*/ |
2 |
26 Feb 07 |
jari |
1945 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
1946 |
|
2 |
26 Feb 07 |
jari |
//slideData.sort(sortType); |
2 |
26 Feb 07 |
jari |
1948 |
SlideDataSorter sorter = new SlideDataSorter(slideData); |
2 |
26 Feb 07 |
jari |
1949 |
indices = sorter.sort(indices, sortType); |
2 |
26 Feb 07 |
jari |
//for (int i=0; i<indices.size(); i++) { |
2 |
26 Feb 07 |
jari |
// System.out.println("indices["+i+"]="+((Integer)indices.get(i)).intValue()); |
2 |
26 Feb 07 |
jari |
1952 |
//} |
2 |
26 Feb 07 |
jari |
1953 |
|
2 |
26 Feb 07 |
jari |
//long hTopCy3 = canvas.getTopCy3(); |
2 |
26 Feb 07 |
jari |
//long hTopCy5 = canvas.getTopCy5(); |
2 |
26 Feb 07 |
jari |
1956 |
|
2 |
26 Feb 07 |
jari |
//canvas.setSlideData(slideData); IS THIS NECESSARY? |
2 |
26 Feb 07 |
jari |
//canvas.setUpperLimits(hTopCy3, hTopCy5); |
2 |
26 Feb 07 |
jari |
1959 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
1960 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
1961 |
} |
2 |
26 Feb 07 |
jari |
1962 |
|
2 |
26 Feb 07 |
jari |
1963 |
public void saveImage() { |
2 |
26 Feb 07 |
jari |
1964 |
final JFileChooser chooser = new JFileChooser(TMEV.getFile("data/")); |
2 |
26 Feb 07 |
jari |
1965 |
chooser.addChoosableFileFilter(new FileFilter() { |
2 |
26 Feb 07 |
jari |
1966 |
public boolean accept(File f) { |
2 |
26 Feb 07 |
jari |
1967 |
String extension = ""; |
2 |
26 Feb 07 |
jari |
1968 |
if (f.isDirectory()) return true; |
2 |
26 Feb 07 |
jari |
1969 |
int i = f.getName().lastIndexOf('.'); |
2 |
26 Feb 07 |
jari |
1970 |
if (i > 0) extension = f.getName().substring(i + 1).toLowerCase(); |
2 |
26 Feb 07 |
jari |
1971 |
if (extension.equals("bmp")) return true; |
2 |
26 Feb 07 |
jari |
1972 |
else return false; |
2 |
26 Feb 07 |
jari |
1973 |
} |
2 |
26 Feb 07 |
jari |
1974 |
public String getDescription() { |
2 |
26 Feb 07 |
jari |
1975 |
return "Bitmap Files (*.bmp)"; |
2 |
26 Feb 07 |
jari |
1976 |
} |
2 |
26 Feb 07 |
jari |
1977 |
}); |
2 |
26 Feb 07 |
jari |
1978 |
chooser.addChoosableFileFilter(new FileFilter() { |
2 |
26 Feb 07 |
jari |
1979 |
public boolean accept(File f) { |
2 |
26 Feb 07 |
jari |
1980 |
String extension = ""; |
2 |
26 Feb 07 |
jari |
1981 |
if (f.isDirectory()) return true; |
2 |
26 Feb 07 |
jari |
1982 |
int i = f.getName().lastIndexOf('.'); |
2 |
26 Feb 07 |
jari |
1983 |
if (i > 0) extension = f.getName().substring(i + 1).toLowerCase(); |
2 |
26 Feb 07 |
jari |
1984 |
if (extension.equals("jpg") || extension.equals("jpeg")) return true; |
2 |
26 Feb 07 |
jari |
1985 |
else return false; |
2 |
26 Feb 07 |
jari |
1986 |
} |
2 |
26 Feb 07 |
jari |
1987 |
public String getDescription() { |
2 |
26 Feb 07 |
jari |
1988 |
return "JPEG Files (*.jpg; *.jpeg)"; |
2 |
26 Feb 07 |
jari |
1989 |
} |
2 |
26 Feb 07 |
jari |
1990 |
}); |
2 |
26 Feb 07 |
jari |
1991 |
chooser.addChoosableFileFilter(new FileFilter() { |
2 |
26 Feb 07 |
jari |
1992 |
public boolean accept(File f) { |
2 |
26 Feb 07 |
jari |
1993 |
String extension = ""; |
2 |
26 Feb 07 |
jari |
1994 |
if (f.isDirectory()) return true; |
2 |
26 Feb 07 |
jari |
1995 |
int i = f.getName().lastIndexOf('.'); |
2 |
26 Feb 07 |
jari |
1996 |
if (i > 0) extension = f.getName().substring(i + 1).toLowerCase(); |
2 |
26 Feb 07 |
jari |
1997 |
if (extension.equals("png")) return true; |
2 |
26 Feb 07 |
jari |
1998 |
else return false; |
2 |
26 Feb 07 |
jari |
1999 |
} |
2 |
26 Feb 07 |
jari |
2000 |
public String getDescription() { |
2 |
26 Feb 07 |
jari |
2001 |
return "PNG Files (*.png)"; |
2 |
26 Feb 07 |
jari |
2002 |
} |
2 |
26 Feb 07 |
jari |
2003 |
}); |
2 |
26 Feb 07 |
jari |
2004 |
chooser.addChoosableFileFilter(new FileFilter() { |
2 |
26 Feb 07 |
jari |
2005 |
public boolean accept(File f) { |
2 |
26 Feb 07 |
jari |
2006 |
String extension = ""; |
2 |
26 Feb 07 |
jari |
2007 |
if (f.isDirectory()) return true; |
2 |
26 Feb 07 |
jari |
2008 |
int i = f.getName().lastIndexOf('.'); |
2 |
26 Feb 07 |
jari |
2009 |
if (i > 0) extension = f.getName().substring(i + 1).toLowerCase(); |
2 |
26 Feb 07 |
jari |
2010 |
if (extension.equals("tif") || extension.equals("tiff")) return true; |
2 |
26 Feb 07 |
jari |
2011 |
else return false; |
2 |
26 Feb 07 |
jari |
2012 |
} |
2 |
26 Feb 07 |
jari |
2013 |
public String getDescription() { |
2 |
26 Feb 07 |
jari |
2014 |
return "TIFF Files (*.tif; *.tiff)"; |
2 |
26 Feb 07 |
jari |
2015 |
} |
2 |
26 Feb 07 |
jari |
2016 |
}); |
2 |
26 Feb 07 |
jari |
2017 |
|
2 |
26 Feb 07 |
jari |
2018 |
int chooserState = chooser.showSaveDialog(getFrame()); |
2 |
26 Feb 07 |
jari |
2019 |
if (chooserState == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
2020 |
final File imageFile = chooser.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
2021 |
final BufferedImage image = (BufferedImage)java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(canvas.getWidth(), canvas.getHeight()); |
2 |
26 Feb 07 |
jari |
2022 |
|
2 |
26 Feb 07 |
jari |
//final BufferedImage image = (BufferedImage)this.createImage(canvas.getWidth(), canvas.getHeight()); |
2 |
26 Feb 07 |
jari |
2024 |
Graphics2D g = image.createGraphics(); |
2 |
26 Feb 07 |
jari |
2025 |
g.setColor(Color.white); |
2 |
26 Feb 07 |
jari |
2026 |
g.fillRect(0, 0, image.getWidth(), image.getHeight()); |
2 |
26 Feb 07 |
jari |
2027 |
canvas.controlPaint(g); |
2 |
26 Feb 07 |
jari |
2028 |
|
2 |
26 Feb 07 |
jari |
2029 |
if (chooser.getFileFilter().getDescription() == "Bitmap Files (*.bmp)") { |
2 |
26 Feb 07 |
jari |
2030 |
try { |
2 |
26 Feb 07 |
jari |
2031 |
Thread thread = new Thread() { |
2 |
26 Feb 07 |
jari |
2032 |
public void run() { |
2 |
26 Feb 07 |
jari |
2033 |
RenderedOp op = JAI.create("filestore", image, imageFile.getPath(), "BMP"); |
2 |
26 Feb 07 |
jari |
2034 |
Manager.message(getFrame(), "BMP image saved"); |
2 |
26 Feb 07 |
jari |
2035 |
} |
2 |
26 Feb 07 |
jari |
2036 |
}; |
2 |
26 Feb 07 |
jari |
2037 |
thread.setPriority(Thread.MIN_PRIORITY); |
2 |
26 Feb 07 |
jari |
2038 |
thread.start(); |
2 |
26 Feb 07 |
jari |
2039 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
2040 |
Manager.message(getFrame(), e); |
2 |
26 Feb 07 |
jari |
2041 |
} |
2 |
26 Feb 07 |
jari |
2042 |
} else if (chooser.getFileFilter().getDescription() == "JPEG Files (*.jpg; *.jpeg)") { |
2 |
26 Feb 07 |
jari |
2043 |
try { |
2 |
26 Feb 07 |
jari |
2044 |
Thread thread = new Thread() { |
2 |
26 Feb 07 |
jari |
2045 |
public void run() { |
2 |
26 Feb 07 |
jari |
2046 |
JPEGEncodeParam encoder = new JPEGEncodeParam(); |
2 |
26 Feb 07 |
jari |
2047 |
encoder.setQuality(1.0f); |
2 |
26 Feb 07 |
jari |
2048 |
RenderedOp op = JAI.create("filestore", image, imageFile.getPath(), "JPEG", encoder); |
2 |
26 Feb 07 |
jari |
2049 |
Manager.message(getFrame(), "JPEG image saved"); |
2 |
26 Feb 07 |
jari |
2050 |
} |
2 |
26 Feb 07 |
jari |
2051 |
}; |
2 |
26 Feb 07 |
jari |
2052 |
thread.setPriority(Thread.MIN_PRIORITY); |
2 |
26 Feb 07 |
jari |
2053 |
thread.start(); |
2 |
26 Feb 07 |
jari |
2054 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
2055 |
Manager.message(getFrame(), e); |
2 |
26 Feb 07 |
jari |
2056 |
} |
2 |
26 Feb 07 |
jari |
2057 |
} else if (chooser.getFileFilter().getDescription() == "PNG Files (*.png)") { |
2 |
26 Feb 07 |
jari |
2058 |
try { |
2 |
26 Feb 07 |
jari |
2059 |
Thread thread = new Thread() { |
2 |
26 Feb 07 |
jari |
2060 |
public void run() { |
2 |
26 Feb 07 |
jari |
2061 |
RenderedOp op = JAI.create("filestore", image, imageFile.getPath(), "PNG"); |
2 |
26 Feb 07 |
jari |
2062 |
Manager.message(getFrame(), "PNG image saved"); |
2 |
26 Feb 07 |
jari |
2063 |
} |
2 |
26 Feb 07 |
jari |
2064 |
}; |
2 |
26 Feb 07 |
jari |
2065 |
thread.setPriority(Thread.MIN_PRIORITY); |
2 |
26 Feb 07 |
jari |
2066 |
thread.start(); |
2 |
26 Feb 07 |
jari |
2067 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
2068 |
Manager.message(getFrame(), e); |
2 |
26 Feb 07 |
jari |
2069 |
} |
2 |
26 Feb 07 |
jari |
2070 |
} else if (chooser.getFileFilter().getDescription() == "TIFF Files (*.tif; *.tiff)") { |
2 |
26 Feb 07 |
jari |
2071 |
try { |
2 |
26 Feb 07 |
jari |
2072 |
Thread thread = new Thread() { |
2 |
26 Feb 07 |
jari |
2073 |
public void run() { |
2 |
26 Feb 07 |
jari |
2074 |
TIFFEncodeParam encoder = new TIFFEncodeParam(); |
2 |
26 Feb 07 |
jari |
2075 |
encoder.setCompression(TIFFEncodeParam.COMPRESSION_NONE); |
2 |
26 Feb 07 |
jari |
2076 |
RenderedOp op = JAI.create("filestore", image, imageFile.getPath(), "TIFF", encoder); |
2 |
26 Feb 07 |
jari |
2077 |
Manager.message(getFrame(), "TIFF image saved"); |
2 |
26 Feb 07 |
jari |
2078 |
} |
2 |
26 Feb 07 |
jari |
2079 |
}; |
2 |
26 Feb 07 |
jari |
2080 |
thread.setPriority(Thread.MIN_PRIORITY); |
2 |
26 Feb 07 |
jari |
2081 |
thread.start(); |
2 |
26 Feb 07 |
jari |
2082 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
2083 |
Manager.message(getFrame(), e); |
2 |
26 Feb 07 |
jari |
2084 |
} |
2 |
26 Feb 07 |
jari |
2085 |
} |
2 |
26 Feb 07 |
jari |
2086 |
} |
2 |
26 Feb 07 |
jari |
2087 |
} |
2 |
26 Feb 07 |
jari |
2088 |
|
2 |
26 Feb 07 |
jari |
2089 |
public void printImage() { |
2 |
26 Feb 07 |
jari |
2090 |
PrinterJob pj = PrinterJob.getPrinterJob(); |
2 |
26 Feb 07 |
jari |
2091 |
pj.setPrintable(this, pj.defaultPage()); |
2 |
26 Feb 07 |
jari |
2092 |
if (pj.printDialog()) { |
2 |
26 Feb 07 |
jari |
2093 |
try { |
2 |
26 Feb 07 |
jari |
2094 |
pj.print(); |
2 |
26 Feb 07 |
jari |
2095 |
} catch (PrinterException pe) { |
2 |
26 Feb 07 |
jari |
2096 |
System.out.println(pe); |
2 |
26 Feb 07 |
jari |
2097 |
} |
2 |
26 Feb 07 |
jari |
2098 |
} |
2 |
26 Feb 07 |
jari |
2099 |
} |
2 |
26 Feb 07 |
jari |
2100 |
|
2 |
26 Feb 07 |
jari |
2101 |
public int print(Graphics graphics, PageFormat format, int pageNumber) { |
2 |
26 Feb 07 |
jari |
2102 |
if (pageNumber > 0) return Printable.NO_SUCH_PAGE; |
2 |
26 Feb 07 |
jari |
2103 |
Graphics2D g = (Graphics2D) graphics; |
2 |
26 Feb 07 |
jari |
2104 |
Component target = canvas; |
2 |
26 Feb 07 |
jari |
2105 |
|
2 |
26 Feb 07 |
jari |
2106 |
g.translate(format.getImageableX(), format.getImageableY()); |
2 |
26 Feb 07 |
jari |
2107 |
Dimension size = target.getSize(); |
2 |
26 Feb 07 |
jari |
2108 |
double pageWidth = format.getImageableWidth(); |
2 |
26 Feb 07 |
jari |
2109 |
double pageHeight = format.getImageableHeight(); |
2 |
26 Feb 07 |
jari |
2110 |
|
2 |
26 Feb 07 |
jari |
2111 |
/* |
2 |
26 Feb 07 |
jari |
//These two 'if' blocks control scale-to-fit WITHOUT aspect ratio |
2 |
26 Feb 07 |
jari |
if (size.width > pageWidth) |
2 |
26 Feb 07 |
jari |
2114 |
{ |
2 |
26 Feb 07 |
jari |
double factor = pageWidth / size.width; |
2 |
26 Feb 07 |
jari |
g.scale(factor, 1); |
2 |
26 Feb 07 |
jari |
pageWidth /= factor; |
2 |
26 Feb 07 |
jari |
2118 |
} |
2 |
26 Feb 07 |
jari |
if (size.height > pageHeight) |
2 |
26 Feb 07 |
jari |
2120 |
{ |
2 |
26 Feb 07 |
jari |
double factor = pageHeight / size.height; |
2 |
26 Feb 07 |
jari |
g.scale(1, factor); |
2 |
26 Feb 07 |
jari |
pageHeight /= factor; |
2 |
26 Feb 07 |
jari |
2124 |
} |
2 |
26 Feb 07 |
jari |
2125 |
*/ |
2 |
26 Feb 07 |
jari |
2126 |
|
2 |
26 Feb 07 |
jari |
//These two 'if' blocks control scale-to-fit WITH aspect ratio |
2 |
26 Feb 07 |
jari |
2128 |
if (size.width > pageWidth) { |
2 |
26 Feb 07 |
jari |
2129 |
double factor = pageWidth / size.width; |
2 |
26 Feb 07 |
jari |
2130 |
g.scale(factor, factor); |
2 |
26 Feb 07 |
jari |
2131 |
pageWidth /= factor; |
2 |
26 Feb 07 |
jari |
2132 |
pageHeight /= factor; |
2 |
26 Feb 07 |
jari |
2133 |
} |
2 |
26 Feb 07 |
jari |
2134 |
if (size.height > pageHeight) { |
2 |
26 Feb 07 |
jari |
2135 |
double factor = pageHeight / size.height; |
2 |
26 Feb 07 |
jari |
2136 |
g.scale(factor, factor); |
2 |
26 Feb 07 |
jari |
2137 |
pageWidth /= factor; |
2 |
26 Feb 07 |
jari |
2138 |
pageHeight /= factor; |
2 |
26 Feb 07 |
jari |
2139 |
} |
2 |
26 Feb 07 |
jari |
2140 |
|
2 |
26 Feb 07 |
jari |
2141 |
g.translate((pageWidth - size.width) / 2, (pageHeight - size.height) / 2); |
2 |
26 Feb 07 |
jari |
2142 |
g.drawRect(-1, -1, size.width + 2, size.height + 2); |
2 |
26 Feb 07 |
jari |
2143 |
g.setClip(0, 0, size.width, size.height); |
2 |
26 Feb 07 |
jari |
2144 |
|
2 |
26 Feb 07 |
jari |
2145 |
if (target instanceof JComponent) ((JComponent) target).setDoubleBuffered(false); |
2 |
26 Feb 07 |
jari |
2146 |
target.paintAll(g); |
2 |
26 Feb 07 |
jari |
2147 |
if (target instanceof JComponent) ((JComponent) target).setDoubleBuffered(true); |
2 |
26 Feb 07 |
jari |
2148 |
|
2 |
26 Feb 07 |
jari |
2149 |
return Printable.PAGE_EXISTS; |
2 |
26 Feb 07 |
jari |
2150 |
} |
2 |
26 Feb 07 |
jari |
2151 |
|
2 |
26 Feb 07 |
jari |
2152 |
public void systemDisable(int state) { |
2 |
26 Feb 07 |
jari |
2153 |
slideData = null; |
2 |
26 Feb 07 |
jari |
2154 |
|
2 |
26 Feb 07 |
jari |
2155 |
switch (state) { |
2 |
26 Feb 07 |
jari |
2156 |
case TMEV.SYSTEM: |
2 |
26 Feb 07 |
jari |
2157 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2158 |
newDatabaseItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2159 |
newFileItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2160 |
newReportItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2161 |
newSpotfireItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2162 |
saveImageItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2163 |
printImageItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2164 |
break; |
2 |
26 Feb 07 |
jari |
2165 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
2166 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2167 |
newReportItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2168 |
newSpotfireItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2169 |
newDatabaseItem.setEnabled(false); //disable until supported, 4.30.03 |
2 |
26 Feb 07 |
jari |
2170 |
break; |
2 |
26 Feb 07 |
jari |
2171 |
case TMEV.DB_AVAILABLE: |
2 |
26 Feb 07 |
jari |
2172 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2173 |
newDatabaseItem.setEnabled(false); //disable until supported, 4.30.03 |
2 |
26 Feb 07 |
jari |
2174 |
break; |
2 |
26 Feb 07 |
jari |
2175 |
case TMEV.DB_LOGIN: |
2 |
26 Feb 07 |
jari |
2176 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2177 |
newDatabaseItem.setEnabled(false); //disable until supported, 4.30.03 |
2 |
26 Feb 07 |
jari |
2178 |
break; |
2 |
26 Feb 07 |
jari |
2179 |
} |
2 |
26 Feb 07 |
jari |
2180 |
viewsMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2181 |
normalizationMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2182 |
sortMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2183 |
displayMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2184 |
controlMenu.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2185 |
|
2 |
26 Feb 07 |
jari |
2186 |
panel.systemDisable(state); |
2 |
26 Feb 07 |
jari |
2187 |
} |
2 |
26 Feb 07 |
jari |
2188 |
|
2 |
26 Feb 07 |
jari |
2189 |
public void systemEnable(int state) { |
2 |
26 Feb 07 |
jari |
2190 |
switch (state) { |
2 |
26 Feb 07 |
jari |
2191 |
case TMEV.SYSTEM: |
2 |
26 Feb 07 |
jari |
2192 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2193 |
break; |
2 |
26 Feb 07 |
jari |
2194 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
2195 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2196 |
newFileItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2197 |
newReportItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2198 |
newSpotfireItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2199 |
saveImageItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2200 |
printImageItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2201 |
viewsMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2202 |
normalizationMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2203 |
sortMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2204 |
displayMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2205 |
controlMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2206 |
break; |
2 |
26 Feb 07 |
jari |
2207 |
case TMEV.DB_AVAILABLE: |
2 |
26 Feb 07 |
jari |
2208 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2209 |
break; |
2 |
26 Feb 07 |
jari |
2210 |
case TMEV.DB_LOGIN: |
2 |
26 Feb 07 |
jari |
//System.out.println("Enable DB_LOGIN"); //disable until supported, 4.30.03 |
2 |
26 Feb 07 |
jari |
2212 |
fileMenu.setEnabled(true); |
2 |
26 Feb 07 |
jari |
//newDatabaseItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2214 |
newDatabaseItem.setEnabled(false); //disable until supported, 4.30.03 |
2 |
26 Feb 07 |
jari |
2215 |
break; |
2 |
26 Feb 07 |
jari |
2216 |
} |
2 |
26 Feb 07 |
jari |
2217 |
|
2 |
26 Feb 07 |
jari |
2218 |
panel.systemEnable(state); |
2 |
26 Feb 07 |
jari |
2219 |
} |
2 |
26 Feb 07 |
jari |
2220 |
|
2 |
26 Feb 07 |
jari |
2221 |
public void handleItems(Object target) { |
2 |
26 Feb 07 |
jari |
2222 |
if (target == newDatabaseItem) { |
2 |
26 Feb 07 |
jari |
2223 |
noNormalizationItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2224 |
} else if (target == newFileItem) { |
2 |
26 Feb 07 |
jari |
2225 |
noNormalizationItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2226 |
} else if (target == totalIntensityItem) { |
2 |
26 Feb 07 |
jari |
2227 |
setConfidenceItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2228 |
} else if (target == linearRegressionItem) { |
2 |
26 Feb 07 |
jari |
2229 |
setConfidenceItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2230 |
} else if (target == ratioStatisticsItem) { |
2 |
26 Feb 07 |
jari |
2231 |
setConfidenceItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2232 |
} else if (target == iterativeLogItem) { |
2 |
26 Feb 07 |
jari |
2233 |
setConfidenceItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2234 |
} else if (target == totalIntensityListItem) { |
2 |
26 Feb 07 |
jari |
2235 |
setConfidenceItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2236 |
} else if (target == linearRegressionListItem) { |
2 |
26 Feb 07 |
jari |
2237 |
setConfidenceItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2238 |
} else if (target == ratioStatisticsListItem) { |
2 |
26 Feb 07 |
jari |
2239 |
setConfidenceItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2240 |
} else if (target == noNormalizationItem) { |
2 |
26 Feb 07 |
jari |
2241 |
setConfidenceItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2242 |
} else if (target == logItem) { |
2 |
26 Feb 07 |
jari |
2243 |
panel.linearItem.setSelected(logItem.isSelected()); |
2 |
26 Feb 07 |
jari |
2244 |
} else if (target == setThresholdsItem) { |
2 |
26 Feb 07 |
jari |
2245 |
panel.thresholdCheckbox.setSelected(setThresholdsItem.isSelected()); |
2 |
26 Feb 07 |
jari |
2246 |
} else if (target == setScaleItem) { |
2 |
26 Feb 07 |
jari |
2247 |
panel.greenRedScaleCheckbox.setSelected(setScaleItem.isSelected()); |
2 |
26 Feb 07 |
jari |
2248 |
} else if (target == changeColorsItem) { |
2 |
26 Feb 07 |
jari |
2249 |
if (greenRedItem.getText().equals("Green / Red")) { |
2 |
26 Feb 07 |
jari |
2250 |
greenRedItem.setText("Blue / Red"); |
2 |
26 Feb 07 |
jari |
2251 |
overlayItem.setText("B/R Overlay"); |
2 |
26 Feb 07 |
jari |
2252 |
setScaleItem.setText("Use B/R Scale"); |
2 |
26 Feb 07 |
jari |
2253 |
panel.greenRedCheckbox.setText("B/R Bar Display"); |
2 |
26 Feb 07 |
jari |
2254 |
panel.overlayCheckbox.setText("B/R Overlay"); |
2 |
26 Feb 07 |
jari |
2255 |
panel.greenRedScaleCheckbox.setText("B/R Scale"); |
2 |
26 Feb 07 |
jari |
2256 |
} else if (greenRedItem.getText().equals("Blue / Red")) { |
2 |
26 Feb 07 |
jari |
2257 |
greenRedItem.setText("Green / Red"); |
2 |
26 Feb 07 |
jari |
2258 |
overlayItem.setText("G/R Overlay"); |
2 |
26 Feb 07 |
jari |
2259 |
setScaleItem.setText("Use G/R Scale"); |
2 |
26 Feb 07 |
jari |
2260 |
panel.greenRedCheckbox.setText("G/R Bar Display"); |
2 |
26 Feb 07 |
jari |
2261 |
panel.overlayCheckbox.setText("G/R Overlay"); |
2 |
26 Feb 07 |
jari |
2262 |
panel.greenRedScaleCheckbox.setText("G/R Scale"); |
2 |
26 Feb 07 |
jari |
2263 |
} |
2 |
26 Feb 07 |
jari |
2264 |
} else if (target == blueToRedItem) { |
2 |
26 Feb 07 |
jari |
2265 |
if (!panel.blueRedCheckbox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2266 |
panel.blueRedCheckbox.setSelected(true); |
2 |
26 Feb 07 |
jari |
2267 |
} |
2 |
26 Feb 07 |
jari |
2268 |
} else if (target == panel.blueRedCheckbox) { |
2 |
26 Feb 07 |
jari |
2269 |
if (panel.blueRedCheckbox.isSelected() && !blueToRedItem.isSelected()) { |
2 |
26 Feb 07 |
jari |
2270 |
blueToRedItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2271 |
} |
2 |
26 Feb 07 |
jari |
2272 |
} else if (target == greenRedItem) { |
2 |
26 Feb 07 |
jari |
2273 |
if (!panel.greenRedCheckbox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2274 |
panel.greenRedCheckbox.setSelected(true); |
2 |
26 Feb 07 |
jari |
2275 |
} |
2 |
26 Feb 07 |
jari |
2276 |
} else if (target == panel.greenRedCheckbox) { |
2 |
26 Feb 07 |
jari |
2277 |
if (panel.greenRedCheckbox.isSelected() && !greenRedItem.isSelected()) { |
2 |
26 Feb 07 |
jari |
2278 |
greenRedItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2279 |
} |
2 |
26 Feb 07 |
jari |
2280 |
panel.greenRedScaleCheckbox.setSelected(false); |
2 |
26 Feb 07 |
jari |
2281 |
setScaleItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
2282 |
} else if (target == overlayItem) { |
2 |
26 Feb 07 |
jari |
2283 |
if (!panel.overlayCheckbox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2284 |
panel.overlayCheckbox.setSelected(true); |
2 |
26 Feb 07 |
jari |
2285 |
} |
2 |
26 Feb 07 |
jari |
2286 |
} else if (target == panel.overlayCheckbox) { |
2 |
26 Feb 07 |
jari |
2287 |
if (panel.overlayCheckbox.isSelected() && !overlayItem.isSelected()) { |
2 |
26 Feb 07 |
jari |
2288 |
overlayItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2289 |
} |
2 |
26 Feb 07 |
jari |
2290 |
} |
2 |
26 Feb 07 |
jari |
2291 |
} |
2 |
26 Feb 07 |
jari |
2292 |
|
2 |
26 Feb 07 |
jari |
2293 |
public void close() { |
2 |
26 Feb 07 |
jari |
2294 |
mainframe.dispose(); |
2 |
26 Feb 07 |
jari |
2295 |
Manager.removeComponent(this); |
2 |
26 Feb 07 |
jari |
2296 |
} |
2 |
26 Feb 07 |
jari |
2297 |
|
2 |
26 Feb 07 |
jari |
2298 |
private class EventListener implements ActionListener, AdjustmentListener, ChangeListener, ItemListener, KeyListener, MouseListener, MouseMotionListener { |
2 |
26 Feb 07 |
jari |
2299 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
2300 |
Object source = event.getSource(); |
2 |
26 Feb 07 |
jari |
2301 |
handleItems(source); |
2 |
26 Feb 07 |
jari |
2302 |
|
2 |
26 Feb 07 |
jari |
2303 |
if (source == newDatabaseItem) { |
2 |
26 Feb 07 |
jari |
2304 |
SetDatabaseDialog sdd = new SetDatabaseDialog(getFrame()); |
2 |
26 Feb 07 |
jari |
2305 |
if (sdd.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
2306 |
loadDataFromDatabase(); |
2 |
26 Feb 07 |
jari |
2307 |
} |
2 |
26 Feb 07 |
jari |
2308 |
} else if (source == newFileItem) { |
2 |
26 Feb 07 |
jari |
2309 |
loadFile(); |
2 |
26 Feb 07 |
jari |
//setSlideData(slideData); |
2 |
26 Feb 07 |
jari |
2311 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2312 |
} else if (source == newReportItem) { |
2 |
26 Feb 07 |
jari |
2313 |
setReportFilename(); |
2 |
26 Feb 07 |
jari |
2314 |
} else if (source == saveImageItem) { |
2 |
26 Feb 07 |
jari |
2315 |
saveImage(); |
2 |
26 Feb 07 |
jari |
2316 |
} else if (source == printImageItem) { |
2 |
26 Feb 07 |
jari |
2317 |
printImage(); |
2 |
26 Feb 07 |
jari |
2318 |
} else if (source == newSpotfireItem) { |
2 |
26 Feb 07 |
jari |
// PC ONLY |
2 |
26 Feb 07 |
jari |
//displayApplet.exportSpotfire(displayApplet.getData()); |
2 |
26 Feb 07 |
jari |
2321 |
// |
2 |
26 Feb 07 |
jari |
2322 |
} else if (source == closeItem) { |
2 |
26 Feb 07 |
jari |
2323 |
close(); |
2 |
26 Feb 07 |
jari |
2324 |
} else if (source == newPlotItem) { |
2 |
26 Feb 07 |
jari |
2325 |
createScatterPlot(SingleArrayViewer.LINEAR); |
2 |
26 Feb 07 |
jari |
2326 |
} else if (source == newPlotLogItem) { |
2 |
26 Feb 07 |
jari |
2327 |
createScatterPlot(SingleArrayViewer.LOG); |
2 |
26 Feb 07 |
jari |
2328 |
} else if (source == newLogRatioProductItem) { |
2 |
26 Feb 07 |
jari |
2329 |
createRatioProductPlot(); |
2 |
26 Feb 07 |
jari |
2330 |
} else if (source == newLogRatioProductByBlockItem) { |
2 |
26 Feb 07 |
jari |
2331 |
createRatioProductPlotByBlock(); |
2 |
26 Feb 07 |
jari |
2332 |
} else if (source == newHistogramItem) { |
2 |
26 Feb 07 |
jari |
2333 |
createHistogram(SingleArrayViewer.LINEAR); |
2 |
26 Feb 07 |
jari |
2334 |
} else if (source == newHistogramLogItem) { |
2 |
26 Feb 07 |
jari |
2335 |
createHistogram(SingleArrayViewer.LOG); |
2 |
26 Feb 07 |
jari |
2336 |
} else if (source == subArrayItem) { |
2 |
26 Feb 07 |
jari |
2337 |
createSubArray(); |
2 |
26 Feb 07 |
jari |
2338 |
} else if (source == regionArrayItem) { |
2 |
26 Feb 07 |
jari |
2339 |
SetMetaLocationDialog smld = new SetMetaLocationDialog(getFrame()); |
2 |
26 Feb 07 |
jari |
2340 |
smld.addActionInfoListener(new ActionInfoListener() { |
2 |
26 Feb 07 |
jari |
2341 |
public void actionInfoPerformed(ActionInfoEvent event) { |
2 |
26 Feb 07 |
jari |
2342 |
Hashtable hash = event.getHashtable(); |
2 |
26 Feb 07 |
jari |
//Set row, column ((String) hash.get("row")), ((String) hash.get("column")); |
2 |
26 Feb 07 |
jari |
2344 |
createRegion(Integer.parseInt((String) hash.get("row")), Integer.parseInt((String) hash.get("column"))); |
2 |
26 Feb 07 |
jari |
2345 |
} |
2 |
26 Feb 07 |
jari |
2346 |
}); |
2 |
26 Feb 07 |
jari |
2347 |
smld.show(); |
2 |
26 Feb 07 |
jari |
2348 |
} else if (source == totalIntensityItem) { |
2 |
26 Feb 07 |
jari |
2349 |
normalizeData(SlideData.TOTAL_INTENSITY); |
2 |
26 Feb 07 |
jari |
2350 |
} else if (source == leastSquaresItem) { |
2 |
26 Feb 07 |
jari |
2351 |
normalizeData(SlideData.LEAST_SQUARES); |
2 |
26 Feb 07 |
jari |
2352 |
} else if (source == linearRegressionItem) { |
2 |
26 Feb 07 |
jari |
2353 |
normalizeData(SlideData.LINEAR_REGRESSION); |
2 |
26 Feb 07 |
jari |
2354 |
} else if (source == ratioStatisticsItem) { |
2 |
26 Feb 07 |
jari |
2355 |
normalizeData(SlideData.RATIO_STATISTICS_95); |
2 |
26 Feb 07 |
jari |
2356 |
} else if (source == iterativeLogItem) { |
2 |
26 Feb 07 |
jari |
2357 |
normalizeData(SlideData.ITERATIVE_LOG); |
2 |
26 Feb 07 |
jari |
2358 |
} else if (source == totalIntensityListItem) { |
2 |
26 Feb 07 |
jari |
2359 |
normalizeDataList(SlideData.TOTAL_INTENSITY_LIST); |
2 |
26 Feb 07 |
jari |
2360 |
} else if (source == leastSquaresListItem) { |
2 |
26 Feb 07 |
jari |
2361 |
normalizeDataList(SlideData.LEAST_SQUARES_LIST); |
2 |
26 Feb 07 |
jari |
2362 |
} else if (source == linearRegressionListItem) { |
2 |
26 Feb 07 |
jari |
2363 |
normalizeDataList(SlideData.LINEAR_REGRESSION_LIST); |
2 |
26 Feb 07 |
jari |
2364 |
} else if (source == ratioStatisticsListItem) { |
2 |
26 Feb 07 |
jari |
2365 |
normalizeDataList(SlideData.RATIO_STATISTICS_95_LIST); |
2 |
26 Feb 07 |
jari |
2366 |
} else if (source == iterativeLogListItem) { |
2 |
26 Feb 07 |
jari |
2367 |
normalizeDataList(SlideData.ITERATIVE_LOG_LIST); |
2 |
26 Feb 07 |
jari |
2368 |
} else if (source == noNormalizationItem) { |
2 |
26 Feb 07 |
jari |
2369 |
normalizeData(SlideData.NO_NORMALIZATION); |
2 |
26 Feb 07 |
jari |
2370 |
} else if (source == sortByLocationItem) { |
2 |
26 Feb 07 |
jari |
2371 |
sort(SlideDataSorter.SORT_BY_LOCATION); |
2 |
26 Feb 07 |
jari |
2372 |
} else if (source == sortByRatioItem) { |
2 |
26 Feb 07 |
jari |
2373 |
sort(SlideDataSorter.SORT_BY_RATIO); |
2 |
26 Feb 07 |
jari |
2374 |
} else if (source == logItem) { |
2 |
26 Feb 07 |
jari |
2375 |
if (logItem.isSelected()) canvas.setStyle(SingleArrayViewerCanvas.LOG); |
2 |
26 Feb 07 |
jari |
2376 |
else canvas.setStyle(SingleArrayViewerCanvas.LINEAR); |
2 |
26 Feb 07 |
jari |
2377 |
} else if (source == changeColorsItem) { |
2 |
26 Feb 07 |
jari |
2378 |
canvas.changeColorScheme(); |
2 |
26 Feb 07 |
jari |
2379 |
} else if (source == blueToRedItem) { |
2 |
26 Feb 07 |
jari |
2380 |
} else if (source == greenRedItem) { |
2 |
26 Feb 07 |
jari |
2381 |
} else if (source == overlayItem) { |
2 |
26 Feb 07 |
jari |
2382 |
} else if (source == defaultSize1Item) { |
2 |
26 Feb 07 |
jari |
2383 |
canvas.setElementSize(5, 2); |
2 |
26 Feb 07 |
jari |
2384 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2385 |
} else if (source == defaultSize2Item) { |
2 |
26 Feb 07 |
jari |
2386 |
canvas.setElementSize(10, 10); |
2 |
26 Feb 07 |
jari |
2387 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2388 |
} else if (source == defaultSize3Item) { |
2 |
26 Feb 07 |
jari |
2389 |
canvas.setElementSize(20, 5); |
2 |
26 Feb 07 |
jari |
2390 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2391 |
} else if (source == defaultSize4Item) { |
2 |
26 Feb 07 |
jari |
2392 |
canvas.setElementSize(50, 10); |
2 |
26 Feb 07 |
jari |
2393 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2394 |
} else if (source == setElementSizeItem) { |
2 |
26 Feb 07 |
jari |
2395 |
/* |
2 |
26 Feb 07 |
jari |
SetElementSizeDialog sesd = new SetElementSizeDialog(getFrame(), new Dimension(canvas.getXElementSize(), canvas.getYElementSize())); |
2 |
26 Feb 07 |
jari |
sesd.addActionInfoListener(new ActionInfoListener() { |
2 |
26 Feb 07 |
jari |
public void actionInfoPerformed(ActionInfoEvent event) { |
2 |
26 Feb 07 |
jari |
Hashtable hash = event.getHashtable(); |
2 |
26 Feb 07 |
jari |
int width = canvas.getXElementSize(); |
2 |
26 Feb 07 |
jari |
int height = canvas.getYElementSize(); |
2 |
26 Feb 07 |
jari |
try { |
2 |
26 Feb 07 |
jari |
width = Integer.parseInt((String)hash.get("width")); |
2 |
26 Feb 07 |
jari |
2404 |
} |
2 |
26 Feb 07 |
jari |
catch (Exception e) {;} |
2 |
26 Feb 07 |
jari |
try { |
2 |
26 Feb 07 |
jari |
height = Integer.parseInt((String) hash.get("height")); |
2 |
26 Feb 07 |
jari |
2408 |
} |
2 |
26 Feb 07 |
jari |
catch (Exception e) {;} |
2 |
26 Feb 07 |
jari |
canvas.setElementSize(width, height); |
2 |
26 Feb 07 |
jari |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2412 |
} |
2 |
26 Feb 07 |
jari |
2413 |
}); |
2 |
26 Feb 07 |
jari |
sesd.show();*/ |
2 |
26 Feb 07 |
jari |
2415 |
} else if (source == setUpperLimitsItem) { |
2 |
26 Feb 07 |
jari |
2416 |
SetUpperLimitsDialog suld = new SetUpperLimitsDialog(getFrame(), panel.xLastValue, panel.yLastValue); |
2 |
26 Feb 07 |
jari |
2417 |
if (suld.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
2418 |
setUpperLimits((long)suld.getUpperCY3(), (long)suld.getUpperCY5()); |
2 |
26 Feb 07 |
jari |
2419 |
} |
2 |
26 Feb 07 |
jari |
2420 |
} else if (source == setGreenRedThresholdsItem) { |
2 |
26 Feb 07 |
jari |
2421 |
SetGreenRedThresholdDialog sgrtd = new SetGreenRedThresholdDialog(getFrame(), new Double(canvas.getFactor())); |
2 |
26 Feb 07 |
jari |
2422 |
sgrtd.addActionInfoListener(new ActionInfoListener() { |
2 |
26 Feb 07 |
jari |
2423 |
public void actionInfoPerformed(ActionInfoEvent event) { |
2 |
26 Feb 07 |
jari |
2424 |
Hashtable hash = event.getHashtable(); |
2 |
26 Feb 07 |
jari |
2425 |
setFactor(Float.parseFloat((String) hash.get("factor"))); |
2 |
26 Feb 07 |
jari |
//Set factor ((String) hash.get("factor")) |
2 |
26 Feb 07 |
jari |
2427 |
} |
2 |
26 Feb 07 |
jari |
2428 |
}); |
2 |
26 Feb 07 |
jari |
2429 |
sgrtd.show(); |
2 |
26 Feb 07 |
jari |
2430 |
} else if (source == setConfidenceItem) { |
2 |
26 Feb 07 |
jari |
2431 |
SetConfidenceDialog scd = new SetConfidenceDialog(getFrame()); |
2 |
26 Feb 07 |
jari |
2432 |
scd.addActionInfoListener(new ActionInfoListener() { |
2 |
26 Feb 07 |
jari |
2433 |
public void actionInfoPerformed(ActionInfoEvent event) { |
2 |
26 Feb 07 |
jari |
2434 |
Hashtable hash = event.getHashtable(); |
2 |
26 Feb 07 |
jari |
//Set confidence ((String) hash.get("confidence")) |
2 |
26 Feb 07 |
jari |
2436 |
} |
2 |
26 Feb 07 |
jari |
2437 |
}); |
2 |
26 Feb 07 |
jari |
2438 |
scd.show(); |
2 |
26 Feb 07 |
jari |
2439 |
} else if (source == setThresholdsItem) { |
2 |
26 Feb 07 |
jari |
2440 |
if (setThresholdsItem.isSelected()) setThresholds(true); |
2 |
26 Feb 07 |
jari |
2441 |
else setThresholds(false); |
2 |
26 Feb 07 |
jari |
2442 |
} else if (source == setScaleItem) { |
2 |
26 Feb 07 |
jari |
2443 |
if (setScaleItem.isSelected()) canvas.setScale(true); |
2 |
26 Feb 07 |
jari |
2444 |
else canvas.setScale(false); |
2 |
26 Feb 07 |
jari |
2445 |
} |
2 |
26 Feb 07 |
jari |
//From the components contained within the panel |
2 |
26 Feb 07 |
jari |
2447 |
else if (source == panel.linearItem) { |
2 |
26 Feb 07 |
jari |
2448 |
if (panel.linearItem.isSelected()) { |
2 |
26 Feb 07 |
jari |
2449 |
logItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2450 |
canvas.setStyle(SingleArrayViewerCanvas.LOG); |
2 |
26 Feb 07 |
jari |
2451 |
} else { |
2 |
26 Feb 07 |
jari |
2452 |
logItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
2453 |
canvas.setStyle(SingleArrayViewerCanvas.LINEAR); |
2 |
26 Feb 07 |
jari |
2454 |
} |
2 |
26 Feb 07 |
jari |
2455 |
} else if (source == panel.thresholdCheckbox) { |
2 |
26 Feb 07 |
jari |
2456 |
if (panel.thresholdCheckbox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2457 |
setGreenRedThresholdsItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
//canvas.setStyle(SingleArrayViewerCanvas.LOG); |
2 |
26 Feb 07 |
jari |
2459 |
} else { |
2 |
26 Feb 07 |
jari |
2460 |
setGreenRedThresholdsItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
//canvas.setStyle(SingleArrayViewerCanvas.LINEAR); |
2 |
26 Feb 07 |
jari |
2462 |
} |
2 |
26 Feb 07 |
jari |
2463 |
} else if (source == panel.greenRedScaleCheckbox) { |
2 |
26 Feb 07 |
jari |
2464 |
if (panel.greenRedScaleCheckbox.isSelected()) { |
2 |
26 Feb 07 |
jari |
2465 |
setScaleItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2466 |
canvas.setScale(true); |
2 |
26 Feb 07 |
jari |
2467 |
} else { |
2 |
26 Feb 07 |
jari |
2468 |
setScaleItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
2469 |
canvas.setScale(false); |
2 |
26 Feb 07 |
jari |
2470 |
} |
2 |
26 Feb 07 |
jari |
2471 |
} else if (source == panel.blueRedCheckbox) { |
2 |
26 Feb 07 |
jari |
2472 |
} else if (source == panel.greenRedCheckbox) { |
2 |
26 Feb 07 |
jari |
2473 |
} else if (source == panel.overlayCheckbox) { |
2 |
26 Feb 07 |
jari |
2474 |
} |
2 |
26 Feb 07 |
jari |
2475 |
|
2 |
26 Feb 07 |
jari |
//From the keys defined with the JScrollPane |
2 |
26 Feb 07 |
jari |
2477 |
else if (event.getActionCommand() == "lineup") { |
2 |
26 Feb 07 |
jari |
2478 |
JScrollBar vBar = scrollPane.getVerticalScrollBar(); |
2 |
26 Feb 07 |
jari |
2479 |
vBar.setValue(vBar.getValue() - canvas.getYElementSize()); |
2 |
26 Feb 07 |
jari |
2480 |
} else if (event.getActionCommand() == "linedown") { |
2 |
26 Feb 07 |
jari |
2481 |
JScrollBar vBar = scrollPane.getVerticalScrollBar(); |
2 |
26 Feb 07 |
jari |
2482 |
vBar.setValue(vBar.getValue() + canvas.getYElementSize()); |
2 |
26 Feb 07 |
jari |
2483 |
} else if (event.getActionCommand() == "pageup") { |
2 |
26 Feb 07 |
jari |
2484 |
JScrollBar vBar = scrollPane.getVerticalScrollBar(); |
2 |
26 Feb 07 |
jari |
2485 |
vBar.setValue(vBar.getValue() - scrollPane.getViewport().getHeight()); |
2 |
26 Feb 07 |
jari |
2486 |
} else if (event.getActionCommand() == "pagedown") { |
2 |
26 Feb 07 |
jari |
2487 |
JScrollBar vBar = scrollPane.getVerticalScrollBar(); |
2 |
26 Feb 07 |
jari |
2488 |
vBar.setValue(vBar.getValue() + scrollPane.getViewport().getHeight()); |
2 |
26 Feb 07 |
jari |
2489 |
} else { |
2 |
26 Feb 07 |
jari |
2490 |
for (int i = 0; i < sortMenuItems.length; i++) { |
2 |
26 Feb 07 |
jari |
2491 |
if (event.getSource() == sortMenuItems[i]) sort(i); |
2 |
26 Feb 07 |
jari |
2492 |
} |
2 |
26 Feb 07 |
jari |
2493 |
} |
2 |
26 Feb 07 |
jari |
2494 |
} |
2 |
26 Feb 07 |
jari |
2495 |
|
2 |
26 Feb 07 |
jari |
2496 |
public void stateChanged(ChangeEvent event) { |
2 |
26 Feb 07 |
jari |
2497 |
Object source = event.getSource(); |
2 |
26 Feb 07 |
jari |
2498 |
|
2 |
26 Feb 07 |
jari |
2499 |
if (source == panel.xUpperLimitScrollbar) { |
2 |
26 Feb 07 |
jari |
2500 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
2501 |
panel.xLastValue = ((JSlider) source).getValue();//event.getValue(); |
2 |
26 Feb 07 |
jari |
2502 |
panel.xUpperLimitValueLabel.setText(panel.xLastValue + " / " + panel.xUpperLimitScrollbar.getMaximum()); |
2 |
26 Feb 07 |
jari |
2503 |
canvas.setTopCy3(panel.xLastValue); |
2 |
26 Feb 07 |
jari |
//panel.updateXUpperLimitScrollbar(panel.xLastValue); |
2 |
26 Feb 07 |
jari |
2505 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2506 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
2507 |
} else if (source == panel.yUpperLimitScrollbar) { |
2 |
26 Feb 07 |
jari |
2508 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
2509 |
panel.yLastValue = ((JSlider) source).getValue();//event.getValue(); |
2 |
26 Feb 07 |
jari |
2510 |
panel.yUpperLimitValueLabel.setText(panel.yLastValue + " / " + panel.yUpperLimitScrollbar.getMaximum()); |
2 |
26 Feb 07 |
jari |
2511 |
canvas.setTopCy5(panel.yLastValue); |
2 |
26 Feb 07 |
jari |
//panel.updateYUpperLimitScrollbar(panel.yLastValue); |
2 |
26 Feb 07 |
jari |
2513 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2514 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
2515 |
} else if (source == panel.thresholdScrollbar) { |
2 |
26 Feb 07 |
jari |
2516 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
2517 |
panel.tLastValue = ((JSlider) source).getValue();//event.getValue(); |
2 |
26 Feb 07 |
jari |
2518 |
setFactor((float) panel.tLastValue / 1000); |
2 |
26 Feb 07 |
jari |
2519 |
panel.updateThresholdScrollbar((double) panel.tLastValue / 1000); |
2 |
26 Feb 07 |
jari |
2520 |
if (panel.tLastValue > 0) panel.thresholdValueLabel.setText((double) panel.tLastValue / 1000 + ""); |
2 |
26 Feb 07 |
jari |
2521 |
if (panel.thresholdCheckbox.isSelected()) refreshSlide(); |
2 |
26 Feb 07 |
jari |
2522 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
2523 |
} |
2 |
26 Feb 07 |
jari |
2524 |
} |
2 |
26 Feb 07 |
jari |
2525 |
|
2 |
26 Feb 07 |
jari |
2526 |
public void adjustmentValueChanged(AdjustmentEvent event) { |
2 |
26 Feb 07 |
jari |
2527 |
} |
2 |
26 Feb 07 |
jari |
2528 |
|
2 |
26 Feb 07 |
jari |
2529 |
public void itemStateChanged(ItemEvent event) { |
2 |
26 Feb 07 |
jari |
2530 |
Object source = event.getSource(); |
2 |
26 Feb 07 |
jari |
2531 |
if (source == panel.blueRedCheckbox && event.getStateChange() == ItemEvent.SELECTED) { |
2 |
26 Feb 07 |
jari |
2532 |
changePaletteStyle(SingleArrayViewerCanvas.BLUETORED); |
2 |
26 Feb 07 |
jari |
2533 |
handleItems(source); |
2 |
26 Feb 07 |
jari |
2534 |
} else if (source == panel.greenRedCheckbox && event.getStateChange() == ItemEvent.SELECTED) { |
2 |
26 Feb 07 |
jari |
2535 |
changePaletteStyle(SingleArrayViewerCanvas.GREENRED); |
2 |
26 Feb 07 |
jari |
2536 |
handleItems(source); |
2 |
26 Feb 07 |
jari |
2537 |
} else if (source == panel.overlayCheckbox && event.getStateChange() == ItemEvent.SELECTED) { |
2 |
26 Feb 07 |
jari |
2538 |
changePaletteStyle(SingleArrayViewerCanvas.OVERLAY); |
2 |
26 Feb 07 |
jari |
2539 |
handleItems(source); |
2 |
26 Feb 07 |
jari |
2540 |
} else if (source == panel.thresholdCheckbox) { |
2 |
26 Feb 07 |
jari |
2541 |
if (canvas.getThresholds() == false) { |
2 |
26 Feb 07 |
jari |
2542 |
setThresholdsItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2543 |
setThresholds(true); |
2 |
26 Feb 07 |
jari |
2544 |
} else if (canvas.getThresholds() == true) { |
2 |
26 Feb 07 |
jari |
2545 |
setThresholdsItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
2546 |
setThresholds(false); |
2 |
26 Feb 07 |
jari |
2547 |
} |
2 |
26 Feb 07 |
jari |
2548 |
} else if (source == panel.greenRedScaleCheckbox) { |
2 |
26 Feb 07 |
jari |
2549 |
if (canvas.getScale() == false) { |
2 |
26 Feb 07 |
jari |
2550 |
setScaleItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
2551 |
canvas.setScale(true); |
2 |
26 Feb 07 |
jari |
2552 |
} else if (canvas.getScale() == true) { |
2 |
26 Feb 07 |
jari |
2553 |
setScaleItem.setSelected(false); |
2 |
26 Feb 07 |
jari |
2554 |
canvas.setScale(false); |
2 |
26 Feb 07 |
jari |
2555 |
} |
2 |
26 Feb 07 |
jari |
2556 |
} |
2 |
26 Feb 07 |
jari |
2557 |
} |
2 |
26 Feb 07 |
jari |
2558 |
|
2 |
26 Feb 07 |
jari |
2559 |
public void mouseClicked(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
2560 |
if (canvas.inPosition(event.getX(), event.getY())) { |
2 |
26 Feb 07 |
jari |
2561 |
if (! event.isShiftDown()) { |
2 |
26 Feb 07 |
jari |
2562 |
try { |
2 |
26 Feb 07 |
jari |
2563 |
ISlideDataElement element = canvas.getSlideDataElementAt(event.getX(), event.getY()); |
2 |
26 Feb 07 |
jari |
2564 |
if (element == null) { |
2 |
26 Feb 07 |
jari |
2565 |
return; |
2 |
26 Feb 07 |
jari |
2566 |
} |
2 |
26 Feb 07 |
jari |
2567 |
int row = canvas.findRow(event.getX(), event.getY()); |
2 |
26 Feb 07 |
jari |
2568 |
int col = canvas.findColumn(event.getX(), event.getY()); |
2 |
26 Feb 07 |
jari |
2569 |
final int columns = slideData.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
2570 |
int index = (row-1)*columns +col -1; |
2 |
26 Feb 07 |
jari |
// System.out.println("row, col, columns index "+ row +" "+col+" "+columns+ " "+((columns*(row-1))+(col-1))); |
2 |
26 Feb 07 |
jari |
2572 |
Manager.displaySlideElementInfo(getFrame(), slideData, element, ((columns*(row-1))+(col-1))); |
2 |
26 Feb 07 |
jari |
//canvas.findRow(event.getX(), event.getY())-1); |
2 |
26 Feb 07 |
jari |
2574 |
} catch (ArrayIndexOutOfBoundsException e) { |
2 |
26 Feb 07 |
jari |
2575 |
; |
2 |
26 Feb 07 |
jari |
2576 |
} |
2 |
26 Feb 07 |
jari |
2577 |
} |
2 |
26 Feb 07 |
jari |
2578 |
} |
2 |
26 Feb 07 |
jari |
2579 |
} |
2 |
26 Feb 07 |
jari |
2580 |
|
2 |
26 Feb 07 |
jari |
2581 |
public void mouseMoved(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
2582 |
if (slideData == null || event.isShiftDown()) |
2 |
26 Feb 07 |
jari |
2583 |
return; |
2 |
26 Feb 07 |
jari |
2584 |
if ((slideData.getSize() > 0)) { |
2 |
26 Feb 07 |
jari |
2585 |
int x = event.getX(); |
2 |
26 Feb 07 |
jari |
2586 |
int y = event.getY(); |
2 |
26 Feb 07 |
jari |
2587 |
if (canvas.inPosition(x, y)) { |
2 |
26 Feb 07 |
jari |
2588 |
if (canvas.getHighlight() == true) { |
2 |
26 Feb 07 |
jari |
2589 |
canvas.drawColoredBoxAt((Graphics2D)canvas.getGraphics(), x, y, Color.white); |
2 |
26 Feb 07 |
jari |
2590 |
} |
2 |
26 Feb 07 |
jari |
2591 |
setXOldEvent(x); |
2 |
26 Feb 07 |
jari |
2592 |
setYOldEvent(y); |
2 |
26 Feb 07 |
jari |
2593 |
} |
2 |
26 Feb 07 |
jari |
2594 |
} |
2 |
26 Feb 07 |
jari |
2595 |
} |
2 |
26 Feb 07 |
jari |
2596 |
|
2 |
26 Feb 07 |
jari |
2597 |
public void mouseEntered(MouseEvent event) {;} |
2 |
26 Feb 07 |
jari |
2598 |
public void mouseExited(MouseEvent event) {;} |
2 |
26 Feb 07 |
jari |
2599 |
public void mousePressed(MouseEvent event) {;} |
2 |
26 Feb 07 |
jari |
2600 |
public void mouseReleased(MouseEvent event) {;} |
2 |
26 Feb 07 |
jari |
2601 |
public void mouseDragged(MouseEvent event) {;} |
2 |
26 Feb 07 |
jari |
2602 |
public void keyPressed(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
2603 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
2604 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
2605 |
} |
2 |
26 Feb 07 |
jari |
2606 |
|
2 |
26 Feb 07 |
jari |
2607 |
public class SingleArrayViewerPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
2608 |
GridBagLayout displayPanelLayout; |
2 |
26 Feb 07 |
jari |
2609 |
ButtonGroup displayCheckboxGroup; |
2 |
26 Feb 07 |
jari |
2610 |
JRadioButton blueRedCheckbox; |
2 |
26 Feb 07 |
jari |
2611 |
JRadioButton greenRedCheckbox; |
2 |
26 Feb 07 |
jari |
2612 |
JRadioButton overlayCheckbox; |
2 |
26 Feb 07 |
jari |
2613 |
JCheckBox thresholdCheckbox; |
2 |
26 Feb 07 |
jari |
2614 |
JCheckBox greenRedScaleCheckbox; |
2 |
26 Feb 07 |
jari |
2615 |
JCheckBox linearItem; |
2 |
26 Feb 07 |
jari |
2616 |
JLabel xUpperLimitLabel; |
2 |
26 Feb 07 |
jari |
2617 |
JLabel yUpperLimitLabel; |
2 |
26 Feb 07 |
jari |
2618 |
JLabel xUpperLimitValueLabel; |
2 |
26 Feb 07 |
jari |
2619 |
JLabel yUpperLimitValueLabel; |
2 |
26 Feb 07 |
jari |
2620 |
JLabel thresholdValueLabel; |
2 |
26 Feb 07 |
jari |
2621 |
JSlider xUpperLimitScrollbar; |
2 |
26 Feb 07 |
jari |
2622 |
JSlider yUpperLimitScrollbar; |
2 |
26 Feb 07 |
jari |
2623 |
JSlider thresholdScrollbar; |
2 |
26 Feb 07 |
jari |
2624 |
|
2 |
26 Feb 07 |
jari |
2625 |
long xLastValue = 0, yLastValue = 0, tLastValue = 0; |
2 |
26 Feb 07 |
jari |
2626 |
|
2 |
26 Feb 07 |
jari |
2627 |
public SingleArrayViewerPanel() { |
2 |
26 Feb 07 |
jari |
2628 |
GridBagConstraints gbc; |
2 |
26 Feb 07 |
jari |
2629 |
|
2 |
26 Feb 07 |
jari |
2630 |
displayPanelLayout = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
2631 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
2632 |
|
2 |
26 Feb 07 |
jari |
2633 |
Font valueLabelFont = new Font("monospaced", Font.PLAIN, 9); |
2 |
26 Feb 07 |
jari |
2634 |
|
2 |
26 Feb 07 |
jari |
2635 |
blueRedCheckbox = new JRadioButton("Blue -> Red",false); |
2 |
26 Feb 07 |
jari |
2636 |
blueRedCheckbox.addItemListener(eventListener); |
2 |
26 Feb 07 |
jari |
2637 |
gbc = createConstraints(1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2638 |
displayPanelLayout.setConstraints(blueRedCheckbox, gbc); |
2 |
26 Feb 07 |
jari |
2639 |
buttonGroup.add(blueRedCheckbox); |
2 |
26 Feb 07 |
jari |
2640 |
|
2 |
26 Feb 07 |
jari |
2641 |
greenRedCheckbox = new JRadioButton("G/R Bar Display", false); |
2 |
26 Feb 07 |
jari |
2642 |
greenRedCheckbox.addItemListener(eventListener); |
2 |
26 Feb 07 |
jari |
2643 |
gbc = createConstraints(1, 2, GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2644 |
displayPanelLayout.setConstraints(greenRedCheckbox, gbc); |
2 |
26 Feb 07 |
jari |
2645 |
buttonGroup.add(greenRedCheckbox); |
2 |
26 Feb 07 |
jari |
2646 |
|
2 |
26 Feb 07 |
jari |
2647 |
overlayCheckbox = new JRadioButton("G/R Overlay", true); |
2 |
26 Feb 07 |
jari |
2648 |
overlayCheckbox.addItemListener(eventListener); |
2 |
26 Feb 07 |
jari |
2649 |
gbc = createConstraints(1, 3, GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2650 |
displayPanelLayout.setConstraints(overlayCheckbox, gbc); |
2 |
26 Feb 07 |
jari |
2651 |
buttonGroup.add(overlayCheckbox); |
2 |
26 Feb 07 |
jari |
2652 |
|
2 |
26 Feb 07 |
jari |
2653 |
greenRedScaleCheckbox = new JCheckBox("G/R Scale"); |
2 |
26 Feb 07 |
jari |
2654 |
greenRedScaleCheckbox.setSelected(true); |
2 |
26 Feb 07 |
jari |
2655 |
greenRedScaleCheckbox.addItemListener(eventListener); |
2 |
26 Feb 07 |
jari |
2656 |
gbc = createConstraints(1, 4, GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2657 |
displayPanelLayout.setConstraints(greenRedScaleCheckbox, gbc); |
2 |
26 Feb 07 |
jari |
2658 |
|
2 |
26 Feb 07 |
jari |
2659 |
linearItem = new JCheckBox("Log Scale"); |
2 |
26 Feb 07 |
jari |
2660 |
linearItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
2661 |
gbc = createConstraints(1, 5, GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2662 |
displayPanelLayout.setConstraints(linearItem, gbc); |
2 |
26 Feb 07 |
jari |
2663 |
|
2 |
26 Feb 07 |
jari |
2664 |
xUpperLimitLabel = new JLabel("Cy3 Upper Limit"); |
2 |
26 Feb 07 |
jari |
2665 |
gbc = createConstraints(1, 6, new Insets(10, 5, 0, 0), GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2666 |
displayPanelLayout.setConstraints(xUpperLimitLabel, gbc); |
2 |
26 Feb 07 |
jari |
2667 |
|
2 |
26 Feb 07 |
jari |
2668 |
xUpperLimitScrollbar = new JSlider(SwingConstants.HORIZONTAL, 0, 10000, 0); |
2 |
26 Feb 07 |
jari |
2669 |
xUpperLimitScrollbar.addChangeListener(eventListener); |
2 |
26 Feb 07 |
jari |
2670 |
gbc = createConstraints(1, 7, new Insets(10, 5, 0, 0), GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
2671 |
displayPanelLayout.setConstraints(xUpperLimitScrollbar, gbc); |
2 |
26 Feb 07 |
jari |
2672 |
|
2 |
26 Feb 07 |
jari |
2673 |
xUpperLimitValueLabel = new JLabel("0/0", Label.RIGHT); |
2 |
26 Feb 07 |
jari |
2674 |
xUpperLimitValueLabel.setFont(valueLabelFont); |
2 |
26 Feb 07 |
jari |
2675 |
gbc = createConstraints(1, 8, new Insets(10, 5, 10, 0), GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
2676 |
displayPanelLayout.setConstraints(xUpperLimitValueLabel, gbc); |
2 |
26 Feb 07 |
jari |
2677 |
|
2 |
26 Feb 07 |
jari |
2678 |
yUpperLimitLabel = new JLabel("Cy5 Upper Limit"); |
2 |
26 Feb 07 |
jari |
2679 |
gbc = createConstraints(1, 9, new Insets(10, 5, 0, 0), GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2680 |
displayPanelLayout.setConstraints(yUpperLimitLabel, gbc); |
2 |
26 Feb 07 |
jari |
2681 |
|
2 |
26 Feb 07 |
jari |
2682 |
yUpperLimitScrollbar = new JSlider(SwingConstants.HORIZONTAL, 0, 10000, 0); |
2 |
26 Feb 07 |
jari |
2683 |
yUpperLimitScrollbar.addChangeListener(eventListener); |
2 |
26 Feb 07 |
jari |
2684 |
gbc = createConstraints(1, 10, new Insets(10, 5, 0, 0), GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
2685 |
displayPanelLayout.setConstraints(yUpperLimitScrollbar, gbc); |
2 |
26 Feb 07 |
jari |
2686 |
|
2 |
26 Feb 07 |
jari |
2687 |
yUpperLimitValueLabel = new JLabel("0/0", Label.RIGHT); |
2 |
26 Feb 07 |
jari |
2688 |
yUpperLimitValueLabel.setFont(valueLabelFont); |
2 |
26 Feb 07 |
jari |
2689 |
gbc = createConstraints(1, 11, new Insets(10, 5, 10, 0), GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
2690 |
displayPanelLayout.setConstraints(yUpperLimitValueLabel, gbc); |
2 |
26 Feb 07 |
jari |
2691 |
|
2 |
26 Feb 07 |
jari |
2692 |
thresholdCheckbox = new JCheckBox("Expression Ratio"); |
2 |
26 Feb 07 |
jari |
2693 |
thresholdCheckbox.addItemListener(eventListener); |
2 |
26 Feb 07 |
jari |
2694 |
gbc = createConstraints(1, 12, GridBagConstraints.WEST, GridBagConstraints.NONE); |
2 |
26 Feb 07 |
jari |
2695 |
displayPanelLayout.setConstraints(thresholdCheckbox, gbc); |
2 |
26 Feb 07 |
jari |
2696 |
|
2 |
26 Feb 07 |
jari |
2697 |
thresholdScrollbar = new JSlider(SwingConstants.HORIZONTAL, 0, 10000, 2000); |
2 |
26 Feb 07 |
jari |
2698 |
thresholdScrollbar.addChangeListener(eventListener); |
2 |
26 Feb 07 |
jari |
2699 |
gbc = createConstraints(1, 13, new Insets(10, 5, 0, 0), GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
2700 |
displayPanelLayout.setConstraints(thresholdScrollbar, gbc); |
2 |
26 Feb 07 |
jari |
2701 |
|
2 |
26 Feb 07 |
jari |
2702 |
thresholdValueLabel = new JLabel("2.0", Label.RIGHT); |
2 |
26 Feb 07 |
jari |
2703 |
thresholdValueLabel.setFont(valueLabelFont); |
2 |
26 Feb 07 |
jari |
2704 |
gbc = createConstraints(1, 14, new Insets(10, 5, 10, 0), GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
2705 |
displayPanelLayout.setConstraints(thresholdValueLabel, gbc); |
2 |
26 Feb 07 |
jari |
2706 |
|
2 |
26 Feb 07 |
jari |
2707 |
setLayout(displayPanelLayout); |
2 |
26 Feb 07 |
jari |
2708 |
add(blueRedCheckbox); |
2 |
26 Feb 07 |
jari |
2709 |
add(greenRedCheckbox); |
2 |
26 Feb 07 |
jari |
2710 |
add(overlayCheckbox); |
2 |
26 Feb 07 |
jari |
2711 |
add(thresholdCheckbox); |
2 |
26 Feb 07 |
jari |
2712 |
add(greenRedScaleCheckbox); |
2 |
26 Feb 07 |
jari |
2713 |
add(linearItem); |
2 |
26 Feb 07 |
jari |
2714 |
add(xUpperLimitLabel); |
2 |
26 Feb 07 |
jari |
2715 |
add(yUpperLimitLabel); |
2 |
26 Feb 07 |
jari |
2716 |
add(xUpperLimitValueLabel); |
2 |
26 Feb 07 |
jari |
2717 |
add(yUpperLimitValueLabel); |
2 |
26 Feb 07 |
jari |
2718 |
add(thresholdValueLabel); |
2 |
26 Feb 07 |
jari |
2719 |
add(xUpperLimitScrollbar); |
2 |
26 Feb 07 |
jari |
2720 |
add(yUpperLimitScrollbar); |
2 |
26 Feb 07 |
jari |
2721 |
add(thresholdScrollbar); |
2 |
26 Feb 07 |
jari |
2722 |
} |
2 |
26 Feb 07 |
jari |
2723 |
|
2 |
26 Feb 07 |
jari |
2724 |
public void setXYScrollbars(long xMax, long yMax) { |
2 |
26 Feb 07 |
jari |
2725 |
if (xMax > yMax) { |
2 |
26 Feb 07 |
jari |
//xUpperLimitScrollbar.setValues((int) xMax, 1000, 0, (int) xMax); |
2 |
26 Feb 07 |
jari |
//yUpperLimitScrollbar.setValues((int) yMax, 1000, 0, (int) xMax); |
2 |
26 Feb 07 |
jari |
//xUpperLimitValueLabel.setText(xMax + " / " + xMax); |
2 |
26 Feb 07 |
jari |
//yUpperLimitValueLabel.setText(yMax + " / " + xMax); |
2 |
26 Feb 07 |
jari |
2730 |
xUpperLimitScrollbar.setMinimum(0); |
2 |
26 Feb 07 |
jari |
2731 |
xUpperLimitScrollbar.setMaximum((int) xMax); |
2 |
26 Feb 07 |
jari |
2732 |
xUpperLimitScrollbar.setValue((int) xMax); |
2 |
26 Feb 07 |
jari |
2733 |
yUpperLimitScrollbar.setMinimum(0); |
2 |
26 Feb 07 |
jari |
2734 |
yUpperLimitScrollbar.setMaximum((int) xMax); |
2 |
26 Feb 07 |
jari |
2735 |
yUpperLimitScrollbar.setValue((int) yMax); |
2 |
26 Feb 07 |
jari |
2736 |
xUpperLimitValueLabel.setText(xMax + " / " + xMax); |
2 |
26 Feb 07 |
jari |
2737 |
yUpperLimitValueLabel.setText(yMax + " / " + xMax); |
2 |
26 Feb 07 |
jari |
2738 |
} else { |
2 |
26 Feb 07 |
jari |
2739 |
xUpperLimitScrollbar.setMinimum(0); |
2 |
26 Feb 07 |
jari |
2740 |
xUpperLimitScrollbar.setMaximum((int) yMax); |
2 |
26 Feb 07 |
jari |
2741 |
xUpperLimitScrollbar.setValue((int) xMax); |
2 |
26 Feb 07 |
jari |
2742 |
yUpperLimitScrollbar.setMinimum(0); |
2 |
26 Feb 07 |
jari |
2743 |
yUpperLimitScrollbar.setMaximum((int) yMax); |
2 |
26 Feb 07 |
jari |
2744 |
yUpperLimitScrollbar.setValue((int) yMax); |
2 |
26 Feb 07 |
jari |
2745 |
xUpperLimitValueLabel.setText(xMax + " / " + yMax); |
2 |
26 Feb 07 |
jari |
2746 |
yUpperLimitValueLabel.setText(yMax + " / " + yMax); |
2 |
26 Feb 07 |
jari |
2747 |
} |
2 |
26 Feb 07 |
jari |
2748 |
xLastValue = xMax; |
2 |
26 Feb 07 |
jari |
2749 |
yLastValue = yMax; |
2 |
26 Feb 07 |
jari |
2750 |
} |
2 |
26 Feb 07 |
jari |
2751 |
|
2 |
26 Feb 07 |
jari |
2752 |
public void setThresholdScrollbar(double ratio) { |
2 |
26 Feb 07 |
jari |
2753 |
thresholdScrollbar.setMinimum(0); |
2 |
26 Feb 07 |
jari |
2754 |
thresholdScrollbar.setMaximum(10000); |
2 |
26 Feb 07 |
jari |
2755 |
thresholdScrollbar.setValue((int) (1000 * ratio)); |
2 |
26 Feb 07 |
jari |
2756 |
if (ratio >= 0) thresholdValueLabel.setText(ratio + ""); |
2 |
26 Feb 07 |
jari |
2757 |
else thresholdValueLabel.setText("Off"); |
2 |
26 Feb 07 |
jari |
2758 |
tLastValue = (long) (1000 * ratio); |
2 |
26 Feb 07 |
jari |
2759 |
} |
2 |
26 Feb 07 |
jari |
2760 |
|
2 |
26 Feb 07 |
jari |
2761 |
public void updateXUpperLimitScrollbar(long xMax) { |
2 |
26 Feb 07 |
jari |
2762 |
xUpperLimitScrollbar.setValue((int) xMax); |
2 |
26 Feb 07 |
jari |
2763 |
xUpperLimitValueLabel.setText(xMax + " / " + xUpperLimitScrollbar.getMaximum()); |
2 |
26 Feb 07 |
jari |
2764 |
xLastValue = xMax; |
2 |
26 Feb 07 |
jari |
2765 |
} |
2 |
26 Feb 07 |
jari |
2766 |
|
2 |
26 Feb 07 |
jari |
2767 |
public void updateYUpperLimitScrollbar(long yMax) { |
2 |
26 Feb 07 |
jari |
2768 |
yUpperLimitScrollbar.setValue((int) yMax); |
2 |
26 Feb 07 |
jari |
2769 |
yUpperLimitValueLabel.setText(yMax + " / " + yUpperLimitScrollbar.getMaximum()); |
2 |
26 Feb 07 |
jari |
2770 |
yLastValue = yMax; |
2 |
26 Feb 07 |
jari |
2771 |
} |
2 |
26 Feb 07 |
jari |
2772 |
|
2 |
26 Feb 07 |
jari |
2773 |
public void updateThresholdScrollbar(double ratio) { |
2 |
26 Feb 07 |
jari |
2774 |
thresholdScrollbar.setValue((int) (1000 * ratio)); |
2 |
26 Feb 07 |
jari |
2775 |
if (ratio >= 0) thresholdValueLabel.setText(ratio + ""); |
2 |
26 Feb 07 |
jari |
2776 |
else thresholdValueLabel.setText("Off"); |
2 |
26 Feb 07 |
jari |
2777 |
tLastValue = (long) (1000 * ratio); |
2 |
26 Feb 07 |
jari |
2778 |
} |
2 |
26 Feb 07 |
jari |
2779 |
|
2 |
26 Feb 07 |
jari |
2780 |
public GridBagConstraints createConstraints(int gridx, int gridy, int anchor, int fill) { |
2 |
26 Feb 07 |
jari |
2781 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
2782 |
gridBagConstraints.gridx = gridx; |
2 |
26 Feb 07 |
jari |
2783 |
gridBagConstraints.gridy = gridy; |
2 |
26 Feb 07 |
jari |
2784 |
gridBagConstraints.anchor = anchor; |
2 |
26 Feb 07 |
jari |
2785 |
gridBagConstraints.fill = fill; |
2 |
26 Feb 07 |
jari |
2786 |
return gridBagConstraints; |
2 |
26 Feb 07 |
jari |
2787 |
} |
2 |
26 Feb 07 |
jari |
2788 |
|
2 |
26 Feb 07 |
jari |
2789 |
public GridBagConstraints createConstraints(int gridx, int gridy, Insets insets, int anchor, int fill) { |
2 |
26 Feb 07 |
jari |
2790 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
2791 |
gridBagConstraints.gridx = gridx; |
2 |
26 Feb 07 |
jari |
2792 |
gridBagConstraints.gridy = gridy; |
2 |
26 Feb 07 |
jari |
2793 |
gridBagConstraints.insets = insets; |
2 |
26 Feb 07 |
jari |
2794 |
gridBagConstraints.anchor = anchor; |
2 |
26 Feb 07 |
jari |
2795 |
gridBagConstraints.fill = fill; |
2 |
26 Feb 07 |
jari |
2796 |
return gridBagConstraints; |
2 |
26 Feb 07 |
jari |
2797 |
} |
2 |
26 Feb 07 |
jari |
2798 |
|
2 |
26 Feb 07 |
jari |
2799 |
public GridBagConstraints createConstraints(int gridx, int gridy, int gridwidth, int gridheight, int anchor, int fill) { |
2 |
26 Feb 07 |
jari |
2800 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
2801 |
gridBagConstraints.gridx = gridx; |
2 |
26 Feb 07 |
jari |
2802 |
gridBagConstraints.gridy = gridy; |
2 |
26 Feb 07 |
jari |
2803 |
gridBagConstraints.anchor = anchor; |
2 |
26 Feb 07 |
jari |
2804 |
gridBagConstraints.fill = fill; |
2 |
26 Feb 07 |
jari |
2805 |
gridBagConstraints.gridwidth = gridwidth; |
2 |
26 Feb 07 |
jari |
2806 |
gridBagConstraints.gridheight = gridheight; |
2 |
26 Feb 07 |
jari |
2807 |
return gridBagConstraints; |
2 |
26 Feb 07 |
jari |
2808 |
} |
2 |
26 Feb 07 |
jari |
2809 |
|
2 |
26 Feb 07 |
jari |
2810 |
public void systemDisable(int state) { |
2 |
26 Feb 07 |
jari |
2811 |
switch (state) { |
2 |
26 Feb 07 |
jari |
2812 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
2813 |
blueRedCheckbox.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2814 |
greenRedCheckbox.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2815 |
overlayCheckbox.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2816 |
thresholdCheckbox.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2817 |
greenRedScaleCheckbox.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2818 |
linearItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2819 |
xUpperLimitScrollbar.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2820 |
yUpperLimitScrollbar.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2821 |
thresholdScrollbar.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2822 |
break; |
2 |
26 Feb 07 |
jari |
2823 |
} |
2 |
26 Feb 07 |
jari |
2824 |
} |
2 |
26 Feb 07 |
jari |
2825 |
|
2 |
26 Feb 07 |
jari |
2826 |
public void systemEnable(int state) { |
2 |
26 Feb 07 |
jari |
2827 |
switch (state) { |
2 |
26 Feb 07 |
jari |
2828 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
2829 |
blueRedCheckbox.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2830 |
greenRedCheckbox.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2831 |
overlayCheckbox.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2832 |
thresholdCheckbox.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2833 |
greenRedScaleCheckbox.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2834 |
linearItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2835 |
xUpperLimitScrollbar.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2836 |
yUpperLimitScrollbar.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2837 |
thresholdScrollbar.setEnabled(true); |
2 |
26 Feb 07 |
jari |
2838 |
break; |
2 |
26 Feb 07 |
jari |
2839 |
} |
2 |
26 Feb 07 |
jari |
2840 |
} |
2 |
26 Feb 07 |
jari |
2841 |
} |
2 |
26 Feb 07 |
jari |
2842 |
|
2 |
26 Feb 07 |
jari |
2843 |
private class SingleArrayViewerInfoBox extends JPanel { |
2 |
26 Feb 07 |
jari |
2844 |
private GBA gba; |
2 |
26 Feb 07 |
jari |
2845 |
private JLabel slideLabel; |
2 |
26 Feb 07 |
jari |
2846 |
private JLabel normalizationLabel; |
2 |
26 Feb 07 |
jari |
2847 |
|
2 |
26 Feb 07 |
jari |
2848 |
public SingleArrayViewerInfoBox() { |
2 |
26 Feb 07 |
jari |
2849 |
gba = new GBA(); |
2 |
26 Feb 07 |
jari |
2850 |
|
2 |
26 Feb 07 |
jari |
2851 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
2852 |
|
2 |
26 Feb 07 |
jari |
2853 |
slideLabel = new JLabel("Sample Text"); |
2 |
26 Feb 07 |
jari |
// gba.add(this, slideLabel, 0, 0, 1, 1, 1, 1, GBA.N, GBA.B); |
2 |
26 Feb 07 |
jari |
2855 |
|
2 |
26 Feb 07 |
jari |
2856 |
normalizationLabel = new JLabel("Normalization Text"); |
2 |
26 Feb 07 |
jari |
// gba.add(this, normalizationLabel, 0, 1, 1, 1, 1, 1, GBA.S, GBA.B); |
2 |
26 Feb 07 |
jari |
2858 |
} |
2 |
26 Feb 07 |
jari |
2859 |
|
2 |
26 Feb 07 |
jari |
2860 |
public JLabel getSlideLabel() {return this.slideLabel;} |
2 |
26 Feb 07 |
jari |
2861 |
public JLabel getNormalizationLabel() {return this.normalizationLabel;} |
2 |
26 Feb 07 |
jari |
2862 |
} |
2 |
26 Feb 07 |
jari |
2863 |
|
2 |
26 Feb 07 |
jari |
2864 |
private class SingleArrayViewerCanvas extends ArrayViewerCanvas { |
2 |
26 Feb 07 |
jari |
//For use with style |
2 |
26 Feb 07 |
jari |
2866 |
public final static int LINEAR = 0; |
2 |
26 Feb 07 |
jari |
2867 |
public final static int LOG = 1; |
2 |
26 Feb 07 |
jari |
//For use with paletteStyle |
2 |
26 Feb 07 |
jari |
2869 |
public final static int BLUETORED = 1; |
2 |
26 Feb 07 |
jari |
2870 |
public final static int GREENRED = 2; |
2 |
26 Feb 07 |
jari |
2871 |
public final static int OVERLAY = 3; |
2 |
26 Feb 07 |
jari |
//For use with colorScheme |
2 |
26 Feb 07 |
jari |
2873 |
public final static int RED_GREEN_COLOR_SCHEME = 0; |
2 |
26 Feb 07 |
jari |
2874 |
public final static int RED_BLUE_COLOR_SCHEME = 1; |
2 |
26 Feb 07 |
jari |
2875 |
|
2 |
26 Feb 07 |
jari |
//private int xsize; //The horizontal size of each element |
2 |
26 Feb 07 |
jari |
//private int ysize; //The vertical size of each element |
2 |
26 Feb 07 |
jari |
2878 |
private int maxRow; //? |
2 |
26 Feb 07 |
jari |
2879 |
private int maxColumn; //? |
2 |
26 Feb 07 |
jari |
2880 |
private Vector palette; //Stores the colors for the B->R scale |
2 |
26 Feb 07 |
jari |
2881 |
|
2 |
26 Feb 07 |
jari |
2882 |
private int style; //Sets log or linear -- maybe remove this? |
2 |
26 Feb 07 |
jari |
2883 |
private int paletteStyle; //Sets display type (B->R, Bar, Over) |
2 |
26 Feb 07 |
jari |
2884 |
private int colorScheme; //Sets GR and GB |
2 |
26 Feb 07 |
jari |
2885 |
|
2 |
26 Feb 07 |
jari |
2886 |
private double lowDifference; //Low bound for expression ratio -- maybe remove this? |
2 |
26 Feb 07 |
jari |
2887 |
private double highDifference; //High bound for expression ratio -- maybe remove this? |
2 |
26 Feb 07 |
jari |
2888 |
private float factor; //X factor for expression ratio |
2 |
26 Feb 07 |
jari |
2889 |
|
2 |
26 Feb 07 |
jari |
2890 |
private boolean scaleOn; //Toggles G/R scaling |
2 |
26 Feb 07 |
jari |
2891 |
private boolean thresholdsOn; //Toggles Expression Ratio |
2 |
26 Feb 07 |
jari |
2892 |
private boolean highlightOn; //Toggles white-box outlining |
2 |
26 Feb 07 |
jari |
2893 |
private int startx, stopx, starty, stopy, xspacing, yspacing, xgap, ygap; |
2 |
26 Feb 07 |
jari |
2894 |
private Font tinyFont, smallFont, largeFont; |
2 |
26 Feb 07 |
jari |
2895 |
private float topCy3 = 0, topCy5 = 0; |
2 |
26 Feb 07 |
jari |
2896 |
private int preXSpacing, postXSpacing, preYSpacing, postYSpacing; |
2 |
26 Feb 07 |
jari |
2897 |
private int xElementSize, yElementSize; |
2 |
26 Feb 07 |
jari |
2898 |
private int paletteSpacing = 0; |
2 |
26 Feb 07 |
jari |
2899 |
|
2 |
26 Feb 07 |
jari |
2900 |
public SingleArrayViewerCanvas(int preXSpacing, int postXSpacing, int preYSpacing, int postYSpacing) { |
2 |
26 Feb 07 |
jari |
2901 |
super(0, preXSpacing + postXSpacing, 0, preYSpacing + postYSpacing); |
2 |
26 Feb 07 |
jari |
2902 |
style = SingleArrayViewerCanvas.LINEAR; |
2 |
26 Feb 07 |
jari |
2903 |
paletteStyle = SingleArrayViewerCanvas.OVERLAY; |
2 |
26 Feb 07 |
jari |
2904 |
tinyFont = new Font("monospaced", Font.PLAIN, 8); |
2 |
26 Feb 07 |
jari |
2905 |
smallFont = new Font("serif", Font.PLAIN, 12); |
2 |
26 Feb 07 |
jari |
2906 |
largeFont = new Font("serif", Font.PLAIN, 16); |
2 |
26 Feb 07 |
jari |
2907 |
colorScheme = SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME; |
2 |
26 Feb 07 |
jari |
2908 |
|
2 |
26 Feb 07 |
jari |
2909 |
this.preXSpacing = preXSpacing; |
2 |
26 Feb 07 |
jari |
2910 |
this.postXSpacing = postXSpacing; |
2 |
26 Feb 07 |
jari |
2911 |
this.preYSpacing = preYSpacing; |
2 |
26 Feb 07 |
jari |
2912 |
this.postYSpacing = postYSpacing; |
2 |
26 Feb 07 |
jari |
2913 |
|
2 |
26 Feb 07 |
jari |
2914 |
scaleOn = true; |
2 |
26 Feb 07 |
jari |
2915 |
thresholdsOn = false; |
2 |
26 Feb 07 |
jari |
2916 |
highlightOn = true; |
2 |
26 Feb 07 |
jari |
2917 |
this.lowDifference = .33; |
2 |
26 Feb 07 |
jari |
2918 |
this.highDifference = .66; |
2 |
26 Feb 07 |
jari |
2919 |
factor = (float) 2.0; |
2 |
26 Feb 07 |
jari |
2920 |
paletteSpacing = 50; |
2 |
26 Feb 07 |
jari |
2921 |
|
2 |
26 Feb 07 |
jari |
2922 |
setElementSize(20, 5); |
2 |
26 Feb 07 |
jari |
2923 |
|
2 |
26 Feb 07 |
jari |
2924 |
palette = buildPalette(); |
2 |
26 Feb 07 |
jari |
2925 |
|
2 |
26 Feb 07 |
jari |
2926 |
setXOldEvent(-1); |
2 |
26 Feb 07 |
jari |
2927 |
setYOldEvent(-1); |
2 |
26 Feb 07 |
jari |
2928 |
} |
2 |
26 Feb 07 |
jari |
2929 |
|
2 |
26 Feb 07 |
jari |
2930 |
public void controlPaint(Graphics g1D) { |
2 |
26 Feb 07 |
jari |
2931 |
Graphics2D g = (Graphics2D) g1D; |
2 |
26 Feb 07 |
jari |
2932 |
if (slideData != null) |
2 |
26 Feb 07 |
jari |
2933 |
drawSlide(g); |
2 |
26 Feb 07 |
jari |
2934 |
} |
2 |
26 Feb 07 |
jari |
2935 |
|
2 |
26 Feb 07 |
jari |
2936 |
public void setSpacing(int preXSpacing, int postXSpacing, int preYSpacing, int postYSpacing) { |
2 |
26 Feb 07 |
jari |
2937 |
this.preXSpacing = preXSpacing; |
2 |
26 Feb 07 |
jari |
2938 |
this.postXSpacing = postXSpacing; |
2 |
26 Feb 07 |
jari |
2939 |
this.preYSpacing = preYSpacing; |
2 |
26 Feb 07 |
jari |
2940 |
this.postYSpacing = postYSpacing; |
2 |
26 Feb 07 |
jari |
2941 |
updateSizes(); |
2 |
26 Feb 07 |
jari |
2942 |
} |
2 |
26 Feb 07 |
jari |
2943 |
|
2 |
26 Feb 07 |
jari |
2944 |
public void setSize() { |
2 |
26 Feb 07 |
jari |
2945 |
if (slideData != null) { |
2 |
26 Feb 07 |
jari |
2946 |
int width = preXSpacing + getXSize() + postXSpacing; |
2 |
26 Feb 07 |
jari |
2947 |
int height = preYSpacing + getYSize() + postYSpacing; |
2 |
26 Feb 07 |
jari |
2948 |
setPreferredSize(new Dimension(width, height)); |
2 |
26 Feb 07 |
jari |
2949 |
scrollPane.setViewportView(canvas); |
2 |
26 Feb 07 |
jari |
2950 |
} |
2 |
26 Feb 07 |
jari |
2951 |
} |
2 |
26 Feb 07 |
jari |
2952 |
|
2 |
26 Feb 07 |
jari |
2953 |
public void setX2Size() { |
2 |
26 Feb 07 |
jari |
2954 |
if (slideData != null) { |
2 |
26 Feb 07 |
jari |
2955 |
int width = getX2Start() + getXSize() + postXSpacing; |
2 |
26 Feb 07 |
jari |
2956 |
int height = preYSpacing + getYSize() + postYSpacing; |
2 |
26 Feb 07 |
jari |
2957 |
setPreferredSize(new Dimension(width, height)); |
2 |
26 Feb 07 |
jari |
2958 |
scrollPane.setViewportView(canvas); |
2 |
26 Feb 07 |
jari |
2959 |
} |
2 |
26 Feb 07 |
jari |
2960 |
} |
2 |
26 Feb 07 |
jari |
2961 |
|
2 |
26 Feb 07 |
jari |
2962 |
public void setElementSize(int xElementSize, int yElementSize) { |
2 |
26 Feb 07 |
jari |
2963 |
this.xElementSize = xElementSize; |
2 |
26 Feb 07 |
jari |
2964 |
this.yElementSize = yElementSize; |
2 |
26 Feb 07 |
jari |
2965 |
updateSizes(); |
2 |
26 Feb 07 |
jari |
2966 |
} |
2 |
26 Feb 07 |
jari |
2967 |
|
2 |
26 Feb 07 |
jari |
2968 |
public void updateSizes() { |
2 |
26 Feb 07 |
jari |
2969 |
if (paletteStyle == SingleArrayViewerCanvas.BLUETORED) { |
2 |
26 Feb 07 |
jari |
2970 |
setX2Size(); |
2 |
26 Feb 07 |
jari |
2971 |
} else { |
2 |
26 Feb 07 |
jari |
2972 |
setSize(); |
2 |
26 Feb 07 |
jari |
2973 |
} |
2 |
26 Feb 07 |
jari |
//setPreferredSize(new Dimension(preXSpacing + getXSize() + postXSpacing, preYSpacing + getYSize() + postYSpacing)); |
2 |
26 Feb 07 |
jari |
2975 |
} |
2 |
26 Feb 07 |
jari |
2976 |
|
2 |
26 Feb 07 |
jari |
//public void setXElementSize(int xElementSize) {this.xElementSize = xElementSize;} |
2 |
26 Feb 07 |
jari |
//public void setYElementSize(int yElementSize) {this.yElementSize = yElementSize;} |
2 |
26 Feb 07 |
jari |
2979 |
public int getXElementSize() {return this.xElementSize;} |
2 |
26 Feb 07 |
jari |
2980 |
public int getYElementSize() {return this.yElementSize;} |
2 |
26 Feb 07 |
jari |
2981 |
|
2 |
26 Feb 07 |
jari |
2982 |
public int getXSize() { |
2 |
26 Feb 07 |
jari |
2983 |
int columnCount = 0; |
2 |
26 Feb 07 |
jari |
2984 |
if (slideData != null) columnCount = slideData.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
2985 |
if (columnCount > 0) return columnCount * xElementSize; |
2 |
26 Feb 07 |
jari |
2986 |
else return 0; |
2 |
26 Feb 07 |
jari |
2987 |
} |
2 |
26 Feb 07 |
jari |
2988 |
|
2 |
26 Feb 07 |
jari |
2989 |
public int getYSize() { |
2 |
26 Feb 07 |
jari |
2990 |
int rowCount = 0; |
2 |
26 Feb 07 |
jari |
2991 |
if (slideData != null) rowCount = slideData.getSlideMetaData().getRows(); |
2 |
26 Feb 07 |
jari |
2992 |
if (rowCount > 0) return rowCount * yElementSize; |
2 |
26 Feb 07 |
jari |
2993 |
else return 0; |
2 |
26 Feb 07 |
jari |
2994 |
} |
2 |
26 Feb 07 |
jari |
2995 |
|
2 |
26 Feb 07 |
jari |
2996 |
public void setScale(boolean setting) { |
2 |
26 Feb 07 |
jari |
2997 |
scaleOn = setting; |
2 |
26 Feb 07 |
jari |
2998 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
2999 |
} |
2 |
26 Feb 07 |
jari |
3000 |
public boolean getScale() {return this.scaleOn;} |
2 |
26 Feb 07 |
jari |
3001 |
public void setColorScheme(int colorScheme) {this.colorScheme = colorScheme;} |
2 |
26 Feb 07 |
jari |
3002 |
public int getColorScheme() {return this.colorScheme;} |
2 |
26 Feb 07 |
jari |
3003 |
public void changeColorScheme() { |
2 |
26 Feb 07 |
jari |
3004 |
if (colorScheme == SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME) { |
2 |
26 Feb 07 |
jari |
3005 |
colorScheme = SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME; |
2 |
26 Feb 07 |
jari |
3006 |
} else if (colorScheme == SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME) { |
2 |
26 Feb 07 |
jari |
3007 |
colorScheme = SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME; |
2 |
26 Feb 07 |
jari |
3008 |
} |
2 |
26 Feb 07 |
jari |
3009 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
3010 |
} |
2 |
26 Feb 07 |
jari |
3011 |
|
2 |
26 Feb 07 |
jari |
3012 |
public void setThresholds(boolean setting) { |
2 |
26 Feb 07 |
jari |
3013 |
thresholdsOn = setting; |
2 |
26 Feb 07 |
jari |
3014 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
3015 |
} |
2 |
26 Feb 07 |
jari |
3016 |
public boolean getThresholds() {return this.thresholdsOn;} |
2 |
26 Feb 07 |
jari |
3017 |
public boolean getHighlight() {return this.highlightOn;} |
2 |
26 Feb 07 |
jari |
3018 |
public void setHighlight(boolean setting) {this.highlightOn = setting;} |
2 |
26 Feb 07 |
jari |
3019 |
public float getFactor() {return this.factor;} |
2 |
26 Feb 07 |
jari |
3020 |
public void setFactor(float factor) { |
2 |
26 Feb 07 |
jari |
3021 |
this.factor = factor; |
2 |
26 Feb 07 |
jari |
3022 |
} |
2 |
26 Feb 07 |
jari |
3023 |
public double getLowDifference() {return this.lowDifference;} |
2 |
26 Feb 07 |
jari |
3024 |
public void setLowDifference(double difference) {this.lowDifference = difference;} |
2 |
26 Feb 07 |
jari |
3025 |
public double getHighDifference() {return this.highDifference;} |
2 |
26 Feb 07 |
jari |
3026 |
public void setHighDifference(double difference) {this.highDifference = difference;} |
2 |
26 Feb 07 |
jari |
3027 |
public void setTopCy3(float cy3) {this.topCy3 = cy3;} |
2 |
26 Feb 07 |
jari |
3028 |
public float getTopCy3() {return this.topCy3;} |
2 |
26 Feb 07 |
jari |
3029 |
public void setTopCy5(float cy5) {this.topCy5 = cy5;} |
2 |
26 Feb 07 |
jari |
3030 |
public float getTopCy5() {return this.topCy5;} |
2 |
26 Feb 07 |
jari |
3031 |
public void setUpperLimits(float cy3, float cy5) { |
2 |
26 Feb 07 |
jari |
3032 |
setTopCy3(cy3); |
2 |
26 Feb 07 |
jari |
3033 |
setTopCy5(cy5); |
2 |
26 Feb 07 |
jari |
3034 |
} |
2 |
26 Feb 07 |
jari |
3035 |
|
2 |
26 Feb 07 |
jari |
3036 |
/* |
2 |
26 Feb 07 |
jari |
public void setMaxColumn(int maxColumn) |
2 |
26 Feb 07 |
jari |
3038 |
{ |
2 |
26 Feb 07 |
jari |
this.maxColumn = maxColumn; |
2 |
26 Feb 07 |
jari |
this.xsize = this.xgap / this.maxColumn; |
2 |
26 Feb 07 |
jari |
3041 |
} |
2 |
26 Feb 07 |
jari |
3042 |
|
2 |
26 Feb 07 |
jari |
public void setMaxRow(int maxRow) |
2 |
26 Feb 07 |
jari |
3044 |
{ |
2 |
26 Feb 07 |
jari |
this.maxRow = maxRow; |
2 |
26 Feb 07 |
jari |
this.ysize = this.ygap / this.maxRow; |
2 |
26 Feb 07 |
jari |
3047 |
} |
2 |
26 Feb 07 |
jari |
3048 |
*/ |
2 |
26 Feb 07 |
jari |
3049 |
|
2 |
26 Feb 07 |
jari |
3050 |
public int getPaletteSpacing() {return this.paletteSpacing;} |
2 |
26 Feb 07 |
jari |
3051 |
public void setPaletteSpacing(int paletteSpacing) {this.paletteSpacing = paletteSpacing;} |
2 |
26 Feb 07 |
jari |
3052 |
|
2 |
26 Feb 07 |
jari |
3053 |
public void setStyle(int style) { |
2 |
26 Feb 07 |
jari |
3054 |
this.style = style; |
2 |
26 Feb 07 |
jari |
3055 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
3056 |
} |
2 |
26 Feb 07 |
jari |
3057 |
|
2 |
26 Feb 07 |
jari |
3058 |
public int getStyle() {return this.style;} |
2 |
26 Feb 07 |
jari |
3059 |
|
2 |
26 Feb 07 |
jari |
3060 |
public void setPaletteStyle(int style) { |
2 |
26 Feb 07 |
jari |
3061 |
setCursor(Cursor.WAIT_CURSOR); |
2 |
26 Feb 07 |
jari |
3062 |
this.paletteStyle = style; |
2 |
26 Feb 07 |
jari |
3063 |
if (this.paletteStyle == SingleArrayViewerCanvas.BLUETORED) { |
2 |
26 Feb 07 |
jari |
//eraseSlideDataElements2(); |
2 |
26 Feb 07 |
jari |
//drawSlide2(); |
2 |
26 Feb 07 |
jari |
//getFrame().pack(); |
2 |
26 Feb 07 |
jari |
//refreshSlide(); |
2 |
26 Feb 07 |
jari |
3068 |
} else if (this.paletteStyle == SingleArrayViewerCanvas.GREENRED) { |
2 |
26 Feb 07 |
jari |
//eraseSlideDataElements2(); |
2 |
26 Feb 07 |
jari |
//setSize(); |
2 |
26 Feb 07 |
jari |
//getFrame().pack(); |
2 |
26 Feb 07 |
jari |
3072 |
setScale(false); |
2 |
26 Feb 07 |
jari |
//refreshSlide(); |
2 |
26 Feb 07 |
jari |
3074 |
} else if (this.paletteStyle == SingleArrayViewerCanvas.OVERLAY) { |
2 |
26 Feb 07 |
jari |
//eraseSlideDataElements2(); |
2 |
26 Feb 07 |
jari |
//setSize(); |
2 |
26 Feb 07 |
jari |
//getFrame().pack(); |
2 |
26 Feb 07 |
jari |
//refreshSlide(); |
2 |
26 Feb 07 |
jari |
3079 |
} |
2 |
26 Feb 07 |
jari |
3080 |
updateSizes(); |
2 |
26 Feb 07 |
jari |
3081 |
refreshSlide(); |
2 |
26 Feb 07 |
jari |
3082 |
setCursor(Cursor.DEFAULT_CURSOR); |
2 |
26 Feb 07 |
jari |
3083 |
} |
2 |
26 Feb 07 |
jari |
3084 |
|
2 |
26 Feb 07 |
jari |
3085 |
public int getPaletteStyle() {return this.paletteStyle;} |
2 |
26 Feb 07 |
jari |
3086 |
|
2 |
26 Feb 07 |
jari |
3087 |
public void slideDataElementAt(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3088 |
ISlideDataElement slideDataElement = null; |
2 |
26 Feb 07 |
jari |
3089 |
int column, row; |
2 |
26 Feb 07 |
jari |
3090 |
|
2 |
26 Feb 07 |
jari |
3091 |
column = findColumn(targetx, targety); |
2 |
26 Feb 07 |
jari |
3092 |
row = findRow(targetx, targety); |
2 |
26 Feb 07 |
jari |
3093 |
final int columns = slideData.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
3094 |
if (column > 0 && row > 0) { |
2 |
26 Feb 07 |
jari |
3095 |
slideDataElement = (ISlideDataElement)slideData.getSlideDataElement(indices[(row-1)*columns +column -1]); |
2 |
26 Feb 07 |
jari |
3096 |
} |
2 |
26 Feb 07 |
jari |
//System.out.println(column + ", " + row); |
2 |
26 Feb 07 |
jari |
//if (slideDataElement != null) displaySlideElementInfo(slideDataElement); |
2 |
26 Feb 07 |
jari |
3099 |
if (slideDataElement != null) { |
2 |
26 Feb 07 |
jari |
//System.out.println(slideDataElement.getRatio(SlideDataElement.CY5, ISlideDataElement.CY3, ISlideDataElement.LINEAR)); |
2 |
26 Feb 07 |
jari |
3101 |
|
2 |
26 Feb 07 |
jari |
3102 |
int trueRow, trueColumn; |
2 |
26 Feb 07 |
jari |
3103 |
float cy3, cy5; |
2 |
26 Feb 07 |
jari |
3104 |
String[] fieldNames; |
2 |
26 Feb 07 |
jari |
3105 |
String displayString; |
2 |
26 Feb 07 |
jari |
3106 |
int stringLength = 0; |
2 |
26 Feb 07 |
jari |
3107 |
|
2 |
26 Feb 07 |
jari |
3108 |
trueRow = slideDataElement.getRow(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
3109 |
trueColumn = slideDataElement.getColumn(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
3110 |
cy3 = slideDataElement.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
3111 |
cy5 = slideDataElement.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
3112 |
fieldNames = getFieldNames(); |
2 |
26 Feb 07 |
jari |
3113 |
|
2 |
26 Feb 07 |
jari |
3114 |
String rowColLabel = "Row : Column"; |
2 |
26 Feb 07 |
jari |
3115 |
String cy3cy5Label = "Cy3 : Cy5"; |
2 |
26 Feb 07 |
jari |
3116 |
stringLength = 12; |
2 |
26 Feb 07 |
jari |
3117 |
|
2 |
26 Feb 07 |
jari |
3118 |
for (int i = 0; i < fieldNames.length; i++) { |
2 |
26 Feb 07 |
jari |
3119 |
stringLength = Math.max(stringLength, fieldNames[i].length()); |
2 |
26 Feb 07 |
jari |
3120 |
} |
2 |
26 Feb 07 |
jari |
3121 |
|
2 |
26 Feb 07 |
jari |
3122 |
displayString = rowColLabel + space(12, stringLength) + trueRow + " : " + trueColumn + "\n"; |
2 |
26 Feb 07 |
jari |
3123 |
displayString += cy3cy5Label + space(9, stringLength) + cy3 + " : " + cy5; |
2 |
26 Feb 07 |
jari |
3124 |
|
2 |
26 Feb 07 |
jari |
3125 |
for (int i = 0; i < fieldNames.length; i++) { |
2 |
26 Feb 07 |
jari |
3126 |
displayString += "\n" + fieldNames[i] + space(fieldNames[i].length(), stringLength) + slideDataElement.getFieldAt(i); |
2 |
26 Feb 07 |
jari |
3127 |
} |
2 |
26 Feb 07 |
jari |
3128 |
|
2 |
26 Feb 07 |
jari |
//System.out.println("In use?"); |
2 |
26 Feb 07 |
jari |
//InfoDisplay infoDisplay = new InfoDisplay(getFrame(), displayString, 20, 80); |
2 |
26 Feb 07 |
jari |
3131 |
} |
2 |
26 Feb 07 |
jari |
3132 |
} |
2 |
26 Feb 07 |
jari |
3133 |
|
2 |
26 Feb 07 |
jari |
3134 |
public ISlideDataElement getSlideDataElementAt(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3135 |
ISlideDataElement slideDataElement = null; |
2 |
26 Feb 07 |
jari |
3136 |
int row, column; |
2 |
26 Feb 07 |
jari |
3137 |
|
2 |
26 Feb 07 |
jari |
3138 |
row = findRow(targetx, targety); |
2 |
26 Feb 07 |
jari |
3139 |
column = findColumn(targetx, targety); |
2 |
26 Feb 07 |
jari |
3140 |
final int columns = slideData.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
3141 |
if (column > 0 && row > 0) { |
2 |
26 Feb 07 |
jari |
3142 |
int index = (row-1)*columns +column -1; |
2 |
26 Feb 07 |
jari |
3143 |
if (index < indices.length) { |
2 |
26 Feb 07 |
jari |
3144 |
return(ISlideDataElement)slideData.getSlideDataElement(indices[index]); |
2 |
26 Feb 07 |
jari |
3145 |
} |
2 |
26 Feb 07 |
jari |
3146 |
} |
2 |
26 Feb 07 |
jari |
3147 |
return null; |
2 |
26 Feb 07 |
jari |
3148 |
} |
2 |
26 Feb 07 |
jari |
3149 |
|
2 |
26 Feb 07 |
jari |
3150 |
public int findColumn(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3151 |
int column = 0; |
2 |
26 Feb 07 |
jari |
3152 |
if (inHorizontalPositionOne(targetx, targety)) { |
2 |
26 Feb 07 |
jari |
3153 |
column = (targetx-preXSpacing)/xElementSize +1; |
2 |
26 Feb 07 |
jari |
3154 |
} else if (inHorizontalPositionTwo(targetx, targety)) { |
2 |
26 Feb 07 |
jari |
3155 |
column = (targetx-getX2Start())/xElementSize +1; |
2 |
26 Feb 07 |
jari |
3156 |
} |
2 |
26 Feb 07 |
jari |
3157 |
return column; |
2 |
26 Feb 07 |
jari |
3158 |
} |
2 |
26 Feb 07 |
jari |
3159 |
|
2 |
26 Feb 07 |
jari |
3160 |
public int findRow(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3161 |
int row = 0; |
2 |
26 Feb 07 |
jari |
3162 |
if (inVerticalPosition(targetx, targety)) { |
2 |
26 Feb 07 |
jari |
3163 |
row = (targety - preYSpacing)/yElementSize +1; |
2 |
26 Feb 07 |
jari |
3164 |
} |
2 |
26 Feb 07 |
jari |
3165 |
return row; |
2 |
26 Feb 07 |
jari |
3166 |
} |
2 |
26 Feb 07 |
jari |
3167 |
|
2 |
26 Feb 07 |
jari |
3168 |
public boolean inHorizontalPositionOne(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3169 |
if ((targetx - preXSpacing) > 0 && (targetx - preXSpacing - getXSize()) < 0) return true; |
2 |
26 Feb 07 |
jari |
3170 |
else return false; |
2 |
26 Feb 07 |
jari |
3171 |
} |
2 |
26 Feb 07 |
jari |
3172 |
|
2 |
26 Feb 07 |
jari |
3173 |
public boolean inHorizontalPositionTwo(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3174 |
if (paletteStyle != SingleArrayViewerCanvas.BLUETORED) |
2 |
26 Feb 07 |
jari |
3175 |
return false; |
2 |
26 Feb 07 |
jari |
3176 |
if ((targetx - getX2Start()) > 0 && (targetx - getX2Start() - getXSize()) < 0) |
2 |
26 Feb 07 |
jari |
3177 |
return true; |
2 |
26 Feb 07 |
jari |
3178 |
else |
2 |
26 Feb 07 |
jari |
3179 |
return false; |
2 |
26 Feb 07 |
jari |
3180 |
} |
2 |
26 Feb 07 |
jari |
3181 |
|
2 |
26 Feb 07 |
jari |
3182 |
public boolean inHorizontalPosition(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3183 |
if ((inHorizontalPositionOne(targetx, targety)) || (inHorizontalPositionTwo(targetx, targety))) |
2 |
26 Feb 07 |
jari |
3184 |
return true; |
2 |
26 Feb 07 |
jari |
3185 |
else |
2 |
26 Feb 07 |
jari |
3186 |
return false; |
2 |
26 Feb 07 |
jari |
3187 |
} |
2 |
26 Feb 07 |
jari |
3188 |
|
2 |
26 Feb 07 |
jari |
3189 |
public boolean inVerticalPosition(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3190 |
if ((targety - preYSpacing) > 0 && (targety - preYSpacing - getYSize()) < 0) return true; |
2 |
26 Feb 07 |
jari |
3191 |
else return false; |
2 |
26 Feb 07 |
jari |
3192 |
} |
2 |
26 Feb 07 |
jari |
3193 |
|
2 |
26 Feb 07 |
jari |
3194 |
public boolean inPositionOne(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3195 |
if ((inHorizontalPositionOne(targetx, targety)) && (inVerticalPosition(targetx, targety))) return true; |
2 |
26 Feb 07 |
jari |
3196 |
else return false; |
2 |
26 Feb 07 |
jari |
3197 |
} |
2 |
26 Feb 07 |
jari |
3198 |
|
2 |
26 Feb 07 |
jari |
3199 |
public boolean inPositionTwo(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3200 |
if (paletteStyle != SingleArrayViewerCanvas.BLUETORED) |
2 |
26 Feb 07 |
jari |
3201 |
return false; |
2 |
26 Feb 07 |
jari |
3202 |
if ((inHorizontalPositionTwo(targetx, targety)) && (inVerticalPosition(targetx, targety))) |
2 |
26 Feb 07 |
jari |
3203 |
return true; |
2 |
26 Feb 07 |
jari |
3204 |
else |
2 |
26 Feb 07 |
jari |
3205 |
return false; |
2 |
26 Feb 07 |
jari |
3206 |
} |
2 |
26 Feb 07 |
jari |
3207 |
|
2 |
26 Feb 07 |
jari |
3208 |
public boolean inPosition(int targetx, int targety) { |
2 |
26 Feb 07 |
jari |
3209 |
if ((inHorizontalPosition(targetx, targety)) && (inVerticalPosition(targetx, targety))) |
2 |
26 Feb 07 |
jari |
3210 |
return true; |
2 |
26 Feb 07 |
jari |
3211 |
else |
2 |
26 Feb 07 |
jari |
3212 |
return false; |
2 |
26 Feb 07 |
jari |
3213 |
} |
2 |
26 Feb 07 |
jari |
3214 |
|
2 |
26 Feb 07 |
jari |
3215 |
public void drawColoredBoxAt(Graphics2D g, int targetx, int targety, Color targetColor) { |
2 |
26 Feb 07 |
jari |
3216 |
boolean legal = false, draw = false; |
2 |
26 Feb 07 |
jari |
3217 |
int column = 0, row = 0, oldColumn = 0, oldRow = 0, location = 0, oldLocation = 0, xpos, ypos; |
2 |
26 Feb 07 |
jari |
3218 |
int xOldEvent = getXOldEvent(); |
2 |
26 Feb 07 |
jari |
3219 |
int yOldEvent = getYOldEvent(); |
2 |
26 Feb 07 |
jari |
3220 |
|
2 |
26 Feb 07 |
jari |
3221 |
column = findColumn(targetx, targety); |
2 |
26 Feb 07 |
jari |
3222 |
row = findRow(targetx, targety); |
2 |
26 Feb 07 |
jari |
3223 |
|
2 |
26 Feb 07 |
jari |
3224 |
oldColumn = findColumn(xOldEvent, yOldEvent); |
2 |
26 Feb 07 |
jari |
3225 |
oldRow = findRow(xOldEvent, yOldEvent); |
2 |
26 Feb 07 |
jari |
3226 |
if (oldColumn == column && oldRow == row) { |
2 |
26 Feb 07 |
jari |
3227 |
if (paletteStyle != SingleArrayViewerCanvas.BLUETORED) |
2 |
26 Feb 07 |
jari |
3228 |
return; |
2 |
26 Feb 07 |
jari |
3229 |
} |
2 |
26 Feb 07 |
jari |
3230 |
|
2 |
26 Feb 07 |
jari |
// clear old selection |
2 |
26 Feb 07 |
jari |
3232 |
if (inPositionOne(xOldEvent, yOldEvent)) { |
2 |
26 Feb 07 |
jari |
3233 |
xpos = getXpos(oldColumn); |
2 |
26 Feb 07 |
jari |
3234 |
ypos = getYpos(oldRow); |
2 |
26 Feb 07 |
jari |
3235 |
drawRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3236 |
draw = true; |
2 |
26 Feb 07 |
jari |
3237 |
} else if (inPositionTwo(xOldEvent, yOldEvent)) { |
2 |
26 Feb 07 |
jari |
3238 |
xpos = getXpos(oldColumn); |
2 |
26 Feb 07 |
jari |
3239 |
ypos = getYpos(oldRow); |
2 |
26 Feb 07 |
jari |
3240 |
drawRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3241 |
draw = true; |
2 |
26 Feb 07 |
jari |
3242 |
} |
2 |
26 Feb 07 |
jari |
//draw target |
2 |
26 Feb 07 |
jari |
3244 |
if (inPositionOne(targetx, targety)) { |
2 |
26 Feb 07 |
jari |
3245 |
xpos = getXpos(column); |
2 |
26 Feb 07 |
jari |
3246 |
ypos = getYpos(row); |
2 |
26 Feb 07 |
jari |
3247 |
drawRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, targetColor); |
2 |
26 Feb 07 |
jari |
3248 |
draw = true; |
2 |
26 Feb 07 |
jari |
3249 |
legal = true; |
2 |
26 Feb 07 |
jari |
3250 |
} else if (inPositionTwo(targetx, targety)) { |
2 |
26 Feb 07 |
jari |
3251 |
xpos = getXpos(column); |
2 |
26 Feb 07 |
jari |
3252 |
ypos = getYpos(row); |
2 |
26 Feb 07 |
jari |
3253 |
drawRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, targetColor); |
2 |
26 Feb 07 |
jari |
3254 |
draw = true; |
2 |
26 Feb 07 |
jari |
3255 |
legal = true; |
2 |
26 Feb 07 |
jari |
3256 |
} |
2 |
26 Feb 07 |
jari |
//if (draw == true) paint(getGraphics()); |
2 |
26 Feb 07 |
jari |
3258 |
} |
2 |
26 Feb 07 |
jari |
3259 |
|
2 |
26 Feb 07 |
jari |
3260 |
public int getXpos(int column) { |
2 |
26 Feb 07 |
jari |
3261 |
int xpos; |
2 |
26 Feb 07 |
jari |
3262 |
xpos = (column - 1) * xElementSize; |
2 |
26 Feb 07 |
jari |
3263 |
return xpos; |
2 |
26 Feb 07 |
jari |
3264 |
} |
2 |
26 Feb 07 |
jari |
3265 |
|
2 |
26 Feb 07 |
jari |
3266 |
public int getYpos(int row) { |
2 |
26 Feb 07 |
jari |
3267 |
int ypos; |
2 |
26 Feb 07 |
jari |
3268 |
ypos = (row - 1) * yElementSize; |
2 |
26 Feb 07 |
jari |
3269 |
return ypos; |
2 |
26 Feb 07 |
jari |
3270 |
} |
2 |
26 Feb 07 |
jari |
3271 |
|
2 |
26 Feb 07 |
jari |
3272 |
public void drawSlide(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
3273 |
ISlideDataElement slideDataElement; |
2 |
26 Feb 07 |
jari |
3274 |
|
2 |
26 Feb 07 |
jari |
3275 |
if (slideData == null){ |
2 |
26 Feb 07 |
jari |
3276 |
System.out.println("IN SAV canvas null data"); |
2 |
26 Feb 07 |
jari |
3277 |
return; |
2 |
26 Feb 07 |
jari |
3278 |
} |
2 |
26 Feb 07 |
jari |
3279 |
int index; |
2 |
26 Feb 07 |
jari |
3280 |
final int rows = slideData.getSlideMetaData().getRows(); |
2 |
26 Feb 07 |
jari |
3281 |
final int columns = slideData.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
3282 |
if (columns==0) { |
2 |
26 Feb 07 |
jari |
3283 |
System.out.println("IN SAV canvas columns = 0"); |
2 |
26 Feb 07 |
jari |
3284 |
return; |
2 |
26 Feb 07 |
jari |
3285 |
} |
2 |
26 Feb 07 |
jari |
3286 |
int row, column; |
2 |
26 Feb 07 |
jari |
3287 |
final int SIZE = indices.length; |
2 |
26 Feb 07 |
jari |
3288 |
if (paletteStyle == SingleArrayViewerCanvas.BLUETORED) { |
2 |
26 Feb 07 |
jari |
//setX2Size(); |
2 |
26 Feb 07 |
jari |
3290 |
eraseAll(g); |
2 |
26 Feb 07 |
jari |
3291 |
eraseFoot(g); |
2 |
26 Feb 07 |
jari |
3292 |
drawSlideFileName(g, slideData.getSlideDataName()); |
2 |
26 Feb 07 |
jari |
3293 |
|
2 |
26 Feb 07 |
jari |
3294 |
for (int i = 0; i < SIZE; i++) { |
2 |
26 Feb 07 |
jari |
3295 |
slideDataElement = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
3296 |
row = i/columns +1; |
2 |
26 Feb 07 |
jari |
3297 |
column = i % columns +1; |
2 |
26 Feb 07 |
jari |
3298 |
if (slideDataElement != null) { |
2 |
26 Feb 07 |
jari |
3299 |
drawSlideDataElement(g, indices[i], row, column); |
2 |
26 Feb 07 |
jari |
3300 |
drawSlideDataElement2(g, indices[i], row, column); |
2 |
26 Feb 07 |
jari |
3301 |
} else { |
2 |
26 Feb 07 |
jari |
3302 |
drawNullElement(g, i); |
2 |
26 Feb 07 |
jari |
3303 |
drawNullElement2(g, i); |
2 |
26 Feb 07 |
jari |
3304 |
} |
2 |
26 Feb 07 |
jari |
3305 |
} |
2 |
26 Feb 07 |
jari |
3306 |
|
2 |
26 Feb 07 |
jari |
3307 |
if (SIZE < rows*columns) { |
2 |
26 Feb 07 |
jari |
3308 |
for (int i = SIZE; i < rows*columns; i++) { |
2 |
26 Feb 07 |
jari |
3309 |
drawNullElement(g, i); |
2 |
26 Feb 07 |
jari |
3310 |
drawNullElement2(g, i); |
2 |
26 Feb 07 |
jari |
3311 |
} |
2 |
26 Feb 07 |
jari |
3312 |
} |
2 |
26 Feb 07 |
jari |
3313 |
drawScale(g); |
2 |
26 Feb 07 |
jari |
3314 |
setFoot(g); |
2 |
26 Feb 07 |
jari |
3315 |
} else { |
2 |
26 Feb 07 |
jari |
//setSize(); |
2 |
26 Feb 07 |
jari |
3317 |
eraseAll(g); |
2 |
26 Feb 07 |
jari |
3318 |
drawSlideFileName(g, slideData.getSlideDataName()); |
2 |
26 Feb 07 |
jari |
3319 |
for (int i = 0; i < SIZE; i++) { |
2 |
26 Feb 07 |
jari |
3320 |
slideDataElement = (ISlideDataElement)slideData.getSlideDataElement(indices[i]); |
2 |
26 Feb 07 |
jari |
3321 |
row = i/columns +1; |
2 |
26 Feb 07 |
jari |
3322 |
column = i % columns +1; |
2 |
26 Feb 07 |
jari |
3323 |
if (slideDataElement != null) |
2 |
26 Feb 07 |
jari |
3324 |
drawSlideDataElement(g, indices[i], row, column); |
2 |
26 Feb 07 |
jari |
3325 |
else |
2 |
26 Feb 07 |
jari |
3326 |
drawNullElement(g,i); |
2 |
26 Feb 07 |
jari |
3327 |
} |
2 |
26 Feb 07 |
jari |
3328 |
if (SIZE < rows*columns) { |
2 |
26 Feb 07 |
jari |
3329 |
for (int i = SIZE; i < rows*columns; i++) { |
2 |
26 Feb 07 |
jari |
3330 |
drawNullElement(g, i); |
2 |
26 Feb 07 |
jari |
3331 |
} |
2 |
26 Feb 07 |
jari |
3332 |
} |
2 |
26 Feb 07 |
jari |
3333 |
} |
2 |
26 Feb 07 |
jari |
3334 |
} |
2 |
26 Feb 07 |
jari |
3335 |
|
2 |
26 Feb 07 |
jari |
3336 |
/* |
2 |
26 Feb 07 |
jari |
public void drawSlide2(Graphics2D g) |
2 |
26 Feb 07 |
jari |
3338 |
{ |
2 |
26 Feb 07 |
jari |
ISlideDataElement slideDataElement; |
2 |
26 Feb 07 |
jari |
3340 |
|
2 |
26 Feb 07 |
jari |
if(slideData != null) |
2 |
26 Feb 07 |
jari |
3342 |
{ |
2 |
26 Feb 07 |
jari |
setSize(getX2Start() + getXSize() + postXSpacing, preYSpacing + getYSize() + postYSpacing); |
2 |
26 Feb 07 |
jari |
3344 |
|
2 |
26 Feb 07 |
jari |
eraseSlideDataElements2(g); |
2 |
26 Feb 07 |
jari |
eraseFoot(g); |
2 |
26 Feb 07 |
jari |
for(int i = 0; i < slideData.size(); i++) |
2 |
26 Feb 07 |
jari |
3348 |
{ |
2 |
26 Feb 07 |
jari |
try |
2 |
26 Feb 07 |
jari |
3350 |
{ |
2 |
26 Feb 07 |
jari |
slideDataElement = slideData.getElementAt(i); |
2 |
26 Feb 07 |
jari |
if (slideDataElement != null) drawSlideDataElement2(g, slideDataElement); |
2 |
26 Feb 07 |
jari |
else drawNullElement2(g, i); |
2 |
26 Feb 07 |
jari |
3354 |
} |
2 |
26 Feb 07 |
jari |
catch (NullPointerException npe) {;} |
2 |
26 Feb 07 |
jari |
3356 |
} |
2 |
26 Feb 07 |
jari |
setFoot(g); |
2 |
26 Feb 07 |
jari |
3358 |
} |
2 |
26 Feb 07 |
jari |
3359 |
} |
2 |
26 Feb 07 |
jari |
3360 |
*/ |
2 |
26 Feb 07 |
jari |
3361 |
|
2 |
26 Feb 07 |
jari |
3362 |
public void eraseAll(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
3363 |
eraseSlideDataElements(g); |
2 |
26 Feb 07 |
jari |
3364 |
eraseSlideDataElements2(g); |
2 |
26 Feb 07 |
jari |
3365 |
eraseSlideFileName(g); |
2 |
26 Feb 07 |
jari |
3366 |
eraseFoot(g); |
2 |
26 Feb 07 |
jari |
3367 |
} |
2 |
26 Feb 07 |
jari |
3368 |
|
2 |
26 Feb 07 |
jari |
3369 |
public void eraseSlideDataElements(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
3370 |
fillRect(g, 0, 0, getXSize(), getYSize(), Color.white); |
2 |
26 Feb 07 |
jari |
3371 |
} |
2 |
26 Feb 07 |
jari |
3372 |
|
2 |
26 Feb 07 |
jari |
3373 |
public void eraseSlideDataElements2(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
3374 |
fillRect(g, getX2Start(), 0, getXSize(), getYSize(), Color.white); |
2 |
26 Feb 07 |
jari |
3375 |
} |
2 |
26 Feb 07 |
jari |
3376 |
|
2 |
26 Feb 07 |
jari |
3377 |
public void eraseSlideFileName(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
3378 |
fillRect(g, preXSpacing, 0, getXSize(), preYSpacing - 20, Color.white); |
2 |
26 Feb 07 |
jari |
3379 |
} |
2 |
26 Feb 07 |
jari |
3380 |
|
2 |
26 Feb 07 |
jari |
3381 |
public void eraseFoot(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
3382 |
fillRect(g, 0, 0, 2 * getXSize(), preYSpacing, Color.white); |
2 |
26 Feb 07 |
jari |
3383 |
fillRect(g, preXSpacing + 1, preYSpacing, preXSpacing, getYSize() + preYSpacing, Color.white); |
2 |
26 Feb 07 |
jari |
3384 |
} |
2 |
26 Feb 07 |
jari |
3385 |
|
2 |
26 Feb 07 |
jari |
3386 |
public Color getFalseColor(long value) { |
2 |
26 Feb 07 |
jari |
3387 |
Color falseColor = null; |
2 |
26 Feb 07 |
jari |
3388 |
Double scale = new Double(0.0); |
2 |
26 Feb 07 |
jari |
3389 |
|
2 |
26 Feb 07 |
jari |
3390 |
try { |
2 |
26 Feb 07 |
jari |
3391 |
if (style == SingleArrayViewerCanvas.LOG) { |
2 |
26 Feb 07 |
jari |
3392 |
if (value == 0) scale = new Double(255 * ((double) Math.log((double) 1.0) / Math.log((double) getTopCy3()))); |
2 |
26 Feb 07 |
jari |
3393 |
else scale = new Double(255 * ((double) Math.log((double) value) / Math.log((double) getTopCy3()))); |
2 |
26 Feb 07 |
jari |
3394 |
} else if (style == SingleArrayViewerCanvas.LINEAR) { |
2 |
26 Feb 07 |
jari |
3395 |
scale = new Double(255 * ((double) value) / getTopCy3()); |
2 |
26 Feb 07 |
jari |
3396 |
} |
2 |
26 Feb 07 |
jari |
3397 |
|
2 |
26 Feb 07 |
jari |
3398 |
if (scale.doubleValue() > 255.0) scale = new Double(255); |
2 |
26 Feb 07 |
jari |
3399 |
else if (scale.doubleValue() < 0) scale = new Double(0); //To avoid those negatives... |
2 |
26 Feb 07 |
jari |
3400 |
try { |
2 |
26 Feb 07 |
jari |
3401 |
falseColor = (Color) palette.elementAt(scale.intValue()); |
2 |
26 Feb 07 |
jari |
3402 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
3403 |
System.out.println("!!!!!"); |
2 |
26 Feb 07 |
jari |
3404 |
} |
2 |
26 Feb 07 |
jari |
3405 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
3406 |
System.out.println("Exception (SingleArrayViewerCanvas.getFalseColor()): " + e); |
2 |
26 Feb 07 |
jari |
3407 |
} |
2 |
26 Feb 07 |
jari |
3408 |
|
2 |
26 Feb 07 |
jari |
3409 |
return falseColor; |
2 |
26 Feb 07 |
jari |
3410 |
|
2 |
26 Feb 07 |
jari |
3411 |
} |
2 |
26 Feb 07 |
jari |
3412 |
|
2 |
26 Feb 07 |
jari |
3413 |
public Color getFalseColor2(long value) { |
2 |
26 Feb 07 |
jari |
3414 |
Color falseColor = new Color(0, 0, 0); |
2 |
26 Feb 07 |
jari |
3415 |
Double scale = new Double(0.0); |
2 |
26 Feb 07 |
jari |
3416 |
|
2 |
26 Feb 07 |
jari |
3417 |
try { |
2 |
26 Feb 07 |
jari |
3418 |
if (this.style == SingleArrayViewerCanvas.LOG) { |
2 |
26 Feb 07 |
jari |
3419 |
if (value == 0) scale = new Double(255 * ((double) Math.log((double) 1.0) / Math.log((double) getTopCy5()))); |
2 |
26 Feb 07 |
jari |
3420 |
else scale = new Double(255 * ((double) Math.log((double) value) / Math.log((double) getTopCy5()))); |
2 |
26 Feb 07 |
jari |
3421 |
} else if (this.style == SingleArrayViewerCanvas.LINEAR) { |
2 |
26 Feb 07 |
jari |
3422 |
scale = new Double(255 * ((double) value) / getTopCy5()); |
2 |
26 Feb 07 |
jari |
3423 |
} |
2 |
26 Feb 07 |
jari |
3424 |
|
2 |
26 Feb 07 |
jari |
3425 |
if (scale.doubleValue() > 255.0) scale = new Double(255); |
2 |
26 Feb 07 |
jari |
3426 |
else if (scale.doubleValue() < 0) scale = new Double(0); //To avoid those negatives... |
2 |
26 Feb 07 |
jari |
3427 |
falseColor = (Color) palette.elementAt(scale.intValue()); |
2 |
26 Feb 07 |
jari |
3428 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
3429 |
System.out.println("Exception (SingleArrayViewerCanvas.getFalseColor()): " + e); |
2 |
26 Feb 07 |
jari |
3430 |
} |
2 |
26 Feb 07 |
jari |
3431 |
|
2 |
26 Feb 07 |
jari |
3432 |
return falseColor; |
2 |
26 Feb 07 |
jari |
3433 |
|
2 |
26 Feb 07 |
jari |
3434 |
} |
2 |
26 Feb 07 |
jari |
3435 |
|
2 |
26 Feb 07 |
jari |
3436 |
public Color getGreenScaleColor(long value) { |
2 |
26 Feb 07 |
jari |
3437 |
Color greenScaleColor = null; |
2 |
26 Feb 07 |
jari |
3438 |
float temp; |
2 |
26 Feb 07 |
jari |
3439 |
try { |
2 |
26 Feb 07 |
jari |
3440 |
if (scaleOn == true) { |
2 |
26 Feb 07 |
jari |
3441 |
if (style == SingleArrayViewerCanvas.LOG) { |
2 |
26 Feb 07 |
jari |
3442 |
if (value == 0) { |
2 |
26 Feb 07 |
jari |
3443 |
temp = new Double((float) Math.log((float) 1.0) / Math.log((float) getTopCy3())).floatValue(); |
2 |
26 Feb 07 |
jari |
3444 |
if (temp > 255) temp = 255; |
2 |
26 Feb 07 |
jari |
3445 |
if (temp < 0) temp = 0; |
2 |
26 Feb 07 |
jari |
//COLOR |
2 |
26 Feb 07 |
jari |
3447 |
if (colorScheme == SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME) greenScaleColor = new Color(0, temp, 0); |
2 |
26 Feb 07 |
jari |
3448 |
else if (colorScheme == SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME) greenScaleColor = new Color(0, 0, temp); |
2 |
26 Feb 07 |
jari |
3449 |
} else { |
2 |
26 Feb 07 |
jari |
3450 |
temp = new Double((float) Math.log((float) value) / Math.log((float) getTopCy3())).floatValue(); |
2 |
26 Feb 07 |
jari |
3451 |
if (temp > 255) temp = 255; |
2 |
26 Feb 07 |
jari |
3452 |
if (temp < 0) temp = 0; |
2 |
26 Feb 07 |
jari |
//COLOR |
2 |
26 Feb 07 |
jari |
3454 |
if (colorScheme == SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME) greenScaleColor = new Color(0, temp, 0); |
2 |
26 Feb 07 |
jari |
3455 |
else if (colorScheme == SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME) greenScaleColor = new Color(0, 0, temp); |
2 |
26 Feb 07 |
jari |
3456 |
} |
2 |
26 Feb 07 |
jari |
3457 |
} else if (style == SingleArrayViewerCanvas.LINEAR) { |
2 |
26 Feb 07 |
jari |
3458 |
temp = (float) value / getTopCy3(); |
2 |
26 Feb 07 |
jari |
3459 |
if (temp > 1) temp = 1; |
2 |
26 Feb 07 |
jari |
3460 |
if (temp < 0) temp = 0; |
2 |
26 Feb 07 |
jari |
//COLOR |
2 |
26 Feb 07 |
jari |
3462 |
if (colorScheme == SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME) greenScaleColor = new Color(0, temp, 0); |
2 |
26 Feb 07 |
jari |
3463 |
else if (colorScheme == SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME) greenScaleColor = new Color(0, 0, temp); |
2 |
26 Feb 07 |
jari |
3464 |
} |
2 |
26 Feb 07 |
jari |
3465 |
} else if (scaleOn == false) { |
2 |
26 Feb 07 |
jari |
3466 |
if (value == 0) greenScaleColor = new Color(0, 0, 0); |
2 |
26 Feb 07 |
jari |
//COLOR |
2 |
26 Feb 07 |
jari |
3468 |
else { |
2 |
26 Feb 07 |
jari |
3469 |
if (colorScheme == SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME) greenScaleColor = new Color(0, 255, 0); |
2 |
26 Feb 07 |
jari |
3470 |
else if (colorScheme == SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME) greenScaleColor = new Color(0, 0, 255); |
2 |
26 Feb 07 |
jari |
3471 |
} |
2 |
26 Feb 07 |
jari |
3472 |
} |
2 |
26 Feb 07 |
jari |
3473 |
} catch (IllegalArgumentException iae) { |
2 |
26 Feb 07 |
jari |
3474 |
; |
2 |
26 Feb 07 |
jari |
3475 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
3476 |
System.out.println("Exception (SingleArrayViewerCanvas.getGreenScaleColor()): " + e); |
2 |
26 Feb 07 |
jari |
3477 |
} |
2 |
26 Feb 07 |
jari |
3478 |
|
2 |
26 Feb 07 |
jari |
3479 |
return greenScaleColor; |
2 |
26 Feb 07 |
jari |
3480 |
} |
2 |
26 Feb 07 |
jari |
3481 |
|
2 |
26 Feb 07 |
jari |
3482 |
public Color getRedScaleColor(long value) { |
2 |
26 Feb 07 |
jari |
3483 |
Color redScaleColor = null; |
2 |
26 Feb 07 |
jari |
3484 |
float temp; |
2 |
26 Feb 07 |
jari |
3485 |
|
2 |
26 Feb 07 |
jari |
3486 |
try { |
2 |
26 Feb 07 |
jari |
3487 |
if (scaleOn == true) { |
2 |
26 Feb 07 |
jari |
3488 |
if (style == SingleArrayViewerCanvas.LOG) { |
2 |
26 Feb 07 |
jari |
3489 |
if (value == 0) { |
2 |
26 Feb 07 |
jari |
3490 |
temp = new Double((float) Math.log((float) 1.0) / Math.log((float) getTopCy5())).floatValue(); |
2 |
26 Feb 07 |
jari |
3491 |
if (temp > 255) temp = 255; |
2 |
26 Feb 07 |
jari |
3492 |
if (temp < 0) temp = 0; |
2 |
26 Feb 07 |
jari |
3493 |
redScaleColor = new Color(temp, 0, 0); |
2 |
26 Feb 07 |
jari |
3494 |
} else { |
2 |
26 Feb 07 |
jari |
3495 |
temp = new Double((float) Math.log((float) value) / Math.log((float) getTopCy5())).floatValue(); |
2 |
26 Feb 07 |
jari |
3496 |
if (temp > 255) temp = 255; |
2 |
26 Feb 07 |
jari |
3497 |
if (temp < 0) temp = 0; |
2 |
26 Feb 07 |
jari |
3498 |
redScaleColor = new Color(temp, 0, 0); |
2 |
26 Feb 07 |
jari |
3499 |
} |
2 |
26 Feb 07 |
jari |
3500 |
} else if (style == SingleArrayViewerCanvas.LINEAR) { |
2 |
26 Feb 07 |
jari |
3501 |
temp = (float) value / getTopCy5(); |
2 |
26 Feb 07 |
jari |
3502 |
if (temp > 1) temp = 1; |
2 |
26 Feb 07 |
jari |
3503 |
if (temp < 0) temp = 0; |
2 |
26 Feb 07 |
jari |
3504 |
redScaleColor = new Color(temp, 0, 0); |
2 |
26 Feb 07 |
jari |
3505 |
} |
2 |
26 Feb 07 |
jari |
3506 |
} else if (scaleOn == false) { |
2 |
26 Feb 07 |
jari |
3507 |
if (value == 0) redScaleColor = new Color(0, 0, 0); |
2 |
26 Feb 07 |
jari |
3508 |
else redScaleColor = new Color(255, 0, 0); |
2 |
26 Feb 07 |
jari |
3509 |
} |
2 |
26 Feb 07 |
jari |
3510 |
} catch (IllegalArgumentException iae) { |
2 |
26 Feb 07 |
jari |
3511 |
; |
2 |
26 Feb 07 |
jari |
3512 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
3513 |
System.out.println("Exception (SingleArrayViewerCanvas.getRedScaleColor()): " + e); |
2 |
26 Feb 07 |
jari |
3514 |
} |
2 |
26 Feb 07 |
jari |
3515 |
return redScaleColor; |
2 |
26 Feb 07 |
jari |
3516 |
} |
2 |
26 Feb 07 |
jari |
3517 |
|
2 |
26 Feb 07 |
jari |
3518 |
public void drawSlideDataElement(Graphics2D g, int dataRow, int row, int column) { |
2 |
26 Feb 07 |
jari |
3519 |
Color color; |
2 |
26 Feb 07 |
jari |
//int row, column, |
2 |
26 Feb 07 |
jari |
3521 |
int adjustedInt; |
2 |
26 Feb 07 |
jari |
3522 |
long adjustedLong; |
2 |
26 Feb 07 |
jari |
3523 |
|
2 |
26 Feb 07 |
jari |
//row = slideDataElement.getRow(SlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
//column = slideDataElement.getColumn(SlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
3526 |
|
2 |
26 Feb 07 |
jari |
3527 |
float cy3 = slideData.getCY3(dataRow); |
2 |
26 Feb 07 |
jari |
3528 |
float cy5 = slideData.getCY5(dataRow); |
2 |
26 Feb 07 |
jari |
// System.out.println("cy3 = "+cy3+" cy5 = "+cy5); |
2 |
26 Feb 07 |
jari |
3530 |
int xpos = getXpos(column); |
2 |
26 Feb 07 |
jari |
3531 |
int ypos = getYpos(row); |
2 |
26 Feb 07 |
jari |
3532 |
|
2 |
26 Feb 07 |
jari |
3533 |
switch (paletteStyle) { |
2 |
26 Feb 07 |
jari |
3534 |
case SingleArrayViewerCanvas.BLUETORED: |
2 |
26 Feb 07 |
jari |
3535 |
if (thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
3536 |
if ((cy3+cy5 > 0) && ((cy3/(cy3+cy5) > highDifference) || (cy3/(cy3+cy5) < lowDifference))) { |
2 |
26 Feb 07 |
jari |
3537 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, getFalseColor((long)cy3)); |
2 |
26 Feb 07 |
jari |
3538 |
} else if (cy3 == 0 && cy5 == 0) { |
2 |
26 Feb 07 |
jari |
3539 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.gray); |
2 |
26 Feb 07 |
jari |
3540 |
} else { |
2 |
26 Feb 07 |
jari |
3541 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3542 |
} |
2 |
26 Feb 07 |
jari |
3543 |
} else { |
2 |
26 Feb 07 |
jari |
3544 |
if (cy3 == 0 && cy5 == 0) { |
2 |
26 Feb 07 |
jari |
3545 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.gray); |
2 |
26 Feb 07 |
jari |
3546 |
} else { |
2 |
26 Feb 07 |
jari |
3547 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, getFalseColor((long)cy3)); |
2 |
26 Feb 07 |
jari |
3548 |
} |
2 |
26 Feb 07 |
jari |
3549 |
} |
2 |
26 Feb 07 |
jari |
3550 |
break; |
2 |
26 Feb 07 |
jari |
3551 |
case SingleArrayViewerCanvas.GREENRED: |
2 |
26 Feb 07 |
jari |
3552 |
if (cy3 + cy5 == 0) adjustedInt = 0; |
2 |
26 Feb 07 |
jari |
3553 |
else adjustedInt = (int) (xElementSize * cy3 / (cy3 + cy5)); |
2 |
26 Feb 07 |
jari |
3554 |
if (adjustedInt > xElementSize) adjustedInt = xElementSize; |
2 |
26 Feb 07 |
jari |
3555 |
|
2 |
26 Feb 07 |
jari |
3556 |
if (cy3 <= 0 && cy5 <= 0) fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.gray); |
2 |
26 Feb 07 |
jari |
3557 |
else { |
2 |
26 Feb 07 |
jari |
3558 |
if (thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
3559 |
if ((cy3 + cy5 > 0) && ((cy3/(cy3+cy5) > highDifference) || (cy3/(cy3+cy5) < lowDifference))) { |
2 |
26 Feb 07 |
jari |
3560 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, getRedScaleColor((long)cy5)); |
2 |
26 Feb 07 |
jari |
3561 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, adjustedInt, yElementSize, getGreenScaleColor((long)cy3)); |
2 |
26 Feb 07 |
jari |
3562 |
} else { |
2 |
26 Feb 07 |
jari |
3563 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3564 |
} |
2 |
26 Feb 07 |
jari |
3565 |
} else { |
2 |
26 Feb 07 |
jari |
3566 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, getRedScaleColor((long)cy5)); |
2 |
26 Feb 07 |
jari |
3567 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, adjustedInt, yElementSize, getGreenScaleColor((long)cy3)); |
2 |
26 Feb 07 |
jari |
3568 |
} |
2 |
26 Feb 07 |
jari |
3569 |
} |
2 |
26 Feb 07 |
jari |
3570 |
break; |
2 |
26 Feb 07 |
jari |
3571 |
case SingleArrayViewerCanvas.OVERLAY: |
2 |
26 Feb 07 |
jari |
3572 |
if (thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
3573 |
if ((cy3+cy5 > 0) && ((cy3/(cy3+cy5) > highDifference) || (cy3/(cy3+cy5) < lowDifference))) { |
2 |
26 Feb 07 |
jari |
//COLOR |
2 |
26 Feb 07 |
jari |
3575 |
if (colorScheme == SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME) { |
2 |
26 Feb 07 |
jari |
3576 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, |
2 |
26 Feb 07 |
jari |
3577 |
new Color(getRedScaleColor((long)cy5).getRed(), getGreenScaleColor((long)cy3).getGreen(), 0)); |
2 |
26 Feb 07 |
jari |
3578 |
} else if (colorScheme == SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME) { |
2 |
26 Feb 07 |
jari |
3579 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, |
2 |
26 Feb 07 |
jari |
3580 |
new Color(getRedScaleColor((long)cy5).getRed(), 0, getGreenScaleColor((long)cy3).getBlue())); |
2 |
26 Feb 07 |
jari |
3581 |
} |
2 |
26 Feb 07 |
jari |
3582 |
} else if (cy3 == 0 && cy5 == 0) { |
2 |
26 Feb 07 |
jari |
3583 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.gray); |
2 |
26 Feb 07 |
jari |
3584 |
} else { |
2 |
26 Feb 07 |
jari |
3585 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3586 |
} |
2 |
26 Feb 07 |
jari |
3587 |
} else { |
2 |
26 Feb 07 |
jari |
//COLOR |
2 |
26 Feb 07 |
jari |
3589 |
if (cy3 == 0 && cy5 == 0) { |
2 |
26 Feb 07 |
jari |
3590 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.gray); |
2 |
26 Feb 07 |
jari |
3591 |
} else { |
2 |
26 Feb 07 |
jari |
3592 |
if (colorScheme == SingleArrayViewerCanvas.RED_GREEN_COLOR_SCHEME) { |
2 |
26 Feb 07 |
jari |
3593 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, |
2 |
26 Feb 07 |
jari |
3594 |
new Color(getRedScaleColor((long)cy5).getRed(), getGreenScaleColor((long)cy3).getGreen(), 0)); |
2 |
26 Feb 07 |
jari |
3595 |
} else if (colorScheme == SingleArrayViewerCanvas.RED_BLUE_COLOR_SCHEME) { |
2 |
26 Feb 07 |
jari |
3596 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, |
2 |
26 Feb 07 |
jari |
3597 |
new Color(getRedScaleColor((long)cy5).getRed(), 0, getGreenScaleColor((long)cy3).getBlue())); |
2 |
26 Feb 07 |
jari |
3598 |
} |
2 |
26 Feb 07 |
jari |
3599 |
} |
2 |
26 Feb 07 |
jari |
3600 |
} |
2 |
26 Feb 07 |
jari |
3601 |
break; |
2 |
26 Feb 07 |
jari |
3602 |
default: |
2 |
26 Feb 07 |
jari |
3603 |
break; |
2 |
26 Feb 07 |
jari |
3604 |
} |
2 |
26 Feb 07 |
jari |
3605 |
drawRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3606 |
} |
2 |
26 Feb 07 |
jari |
3607 |
|
2 |
26 Feb 07 |
jari |
3608 |
public void drawSlideDataElement2(Graphics2D g, int dataRow, int row, int column) { |
2 |
26 Feb 07 |
jari |
3609 |
Color color; |
2 |
26 Feb 07 |
jari |
//int row, column, |
2 |
26 Feb 07 |
jari |
3611 |
int adjustedInt; |
2 |
26 Feb 07 |
jari |
3612 |
long adjustedLong; |
2 |
26 Feb 07 |
jari |
3613 |
|
2 |
26 Feb 07 |
jari |
//row = slideDataElement.getRow(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
//column = slideDataElement.getColumn(ISlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
//float cy3 = slideDataElement.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
//float cy5 = slideDataElement.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
3618 |
float cy3 = slideData.getCY3(dataRow); |
2 |
26 Feb 07 |
jari |
3619 |
float cy5 = slideData.getCY5(dataRow); |
2 |
26 Feb 07 |
jari |
3620 |
int xpos = getXpos(column); |
2 |
26 Feb 07 |
jari |
3621 |
int ypos = getYpos(row); |
2 |
26 Feb 07 |
jari |
3622 |
|
2 |
26 Feb 07 |
jari |
3623 |
if (thresholdsOn == true) { |
2 |
26 Feb 07 |
jari |
3624 |
if ((cy3 + cy5 > 0) && ((cy3 / (cy3 + cy5) > highDifference) || (cy3 / (cy3 + cy5) < lowDifference))) { |
2 |
26 Feb 07 |
jari |
3625 |
fillRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, getFalseColor2((long)cy5)); |
2 |
26 Feb 07 |
jari |
3626 |
drawRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3627 |
} else { |
2 |
26 Feb 07 |
jari |
3628 |
fillRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3629 |
} |
2 |
26 Feb 07 |
jari |
3630 |
} else { |
2 |
26 Feb 07 |
jari |
3631 |
fillRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, getFalseColor2((long)cy5)); |
2 |
26 Feb 07 |
jari |
3632 |
drawRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3633 |
} |
2 |
26 Feb 07 |
jari |
3634 |
} |
2 |
26 Feb 07 |
jari |
3635 |
|
2 |
26 Feb 07 |
jari |
3636 |
public int getX2Start() { |
2 |
26 Feb 07 |
jari |
3637 |
return(preXSpacing + getXSize() + getPaletteSpacing()); |
2 |
26 Feb 07 |
jari |
3638 |
} |
2 |
26 Feb 07 |
jari |
3639 |
|
2 |
26 Feb 07 |
jari |
3640 |
public void drawNullElement(Graphics2D g, int location) { |
2 |
26 Feb 07 |
jari |
3641 |
int row, column, xpos, ypos; |
2 |
26 Feb 07 |
jari |
3642 |
|
2 |
26 Feb 07 |
jari |
3643 |
row = (location / slideData.getSlideMetaData().getColumns()) + 1; |
2 |
26 Feb 07 |
jari |
3644 |
column = (location % slideData.getSlideMetaData().getColumns()) + 1; |
2 |
26 Feb 07 |
jari |
3645 |
xpos = getXpos(column); |
2 |
26 Feb 07 |
jari |
3646 |
ypos = getYpos(row); |
2 |
26 Feb 07 |
jari |
3647 |
|
2 |
26 Feb 07 |
jari |
3648 |
fillRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.gray); |
2 |
26 Feb 07 |
jari |
3649 |
drawRect(g, xpos + preXSpacing, ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3650 |
} |
2 |
26 Feb 07 |
jari |
3651 |
|
2 |
26 Feb 07 |
jari |
3652 |
public void drawNullElement2(Graphics2D g, int location) { |
2 |
26 Feb 07 |
jari |
3653 |
int row, column, xpos, ypos; |
2 |
26 Feb 07 |
jari |
3654 |
|
2 |
26 Feb 07 |
jari |
3655 |
row = (location / slideData.getSlideMetaData().getColumns()) + 1; |
2 |
26 Feb 07 |
jari |
3656 |
column = (location % slideData.getSlideMetaData().getColumns()) + 1; |
2 |
26 Feb 07 |
jari |
3657 |
xpos = getXpos(column); |
2 |
26 Feb 07 |
jari |
3658 |
ypos = getYpos(row); |
2 |
26 Feb 07 |
jari |
3659 |
|
2 |
26 Feb 07 |
jari |
3660 |
fillRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, Color.gray); |
2 |
26 Feb 07 |
jari |
3661 |
drawRect(g, xpos + getX2Start(), ypos + preYSpacing, xElementSize, yElementSize, Color.black); |
2 |
26 Feb 07 |
jari |
3662 |
} |
2 |
26 Feb 07 |
jari |
3663 |
|
2 |
26 Feb 07 |
jari |
3664 |
public void drawSlideFileName(Graphics2D g, String filename) { |
2 |
26 Feb 07 |
jari |
3665 |
drawString(g, filename, (16 * getXSize() / 40) + preXSpacing, preYSpacing / 2, Color.black, largeFont); |
2 |
26 Feb 07 |
jari |
3666 |
} |
2 |
26 Feb 07 |
jari |
3667 |
|
2 |
26 Feb 07 |
jari |
3668 |
public void setFoot(Graphics2D g) //And head, really... |
2 |
26 Feb 07 |
jari |
3669 |
{ |
2 |
26 Feb 07 |
jari |
3670 |
int xGap = getXSize(); |
2 |
26 Feb 07 |
jari |
3671 |
int yGap = getYSize(); |
2 |
26 Feb 07 |
jari |
3672 |
|
2 |
26 Feb 07 |
jari |
3673 |
drawString(g, "Cy3", (19 * xGap / 40) + preXSpacing, preYSpacing + yGap + postYSpacing - 10, Color.black, largeFont); |
2 |
26 Feb 07 |
jari |
3674 |
drawString(g, "Cy5", (19 * xGap / 40) + 2 * preXSpacing + xGap + 15, preYSpacing + yGap + postYSpacing - 10, Color.black, largeFont); |
2 |
26 Feb 07 |
jari |
3675 |
drawString(g, Long.toString((long)getTopCy3()), (16 * xGap / 20) + preXSpacing, preYSpacing - 5, Color.black, smallFont); |
2 |
26 Feb 07 |
jari |
3676 |
drawString(g, Long.toString((long)getTopCy5()), preXSpacing + xGap + getPaletteSpacing(), preYSpacing - 5, Color.black, smallFont); |
2 |
26 Feb 07 |
jari |
3677 |
} |
2 |
26 Feb 07 |
jari |
3678 |
|
2 |
26 Feb 07 |
jari |
3679 |
public void drawScale(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
3680 |
int width = 0, height = 0; |
2 |
26 Feb 07 |
jari |
3681 |
int leftPosition = 0, topPosition; |
2 |
26 Feb 07 |
jari |
3682 |
|
2 |
26 Feb 07 |
jari |
3683 |
if ((xElementSize / 2) < 1) width = 1; |
2 |
26 Feb 07 |
jari |
3684 |
else width = (int) (((double) xElementSize) / 2.0); |
2 |
26 Feb 07 |
jari |
3685 |
if ((getYSize() / palette.size()) < 1) height = 1; |
2 |
26 Feb 07 |
jari |
3686 |
else height = (int) ((double) getYSize() / palette.size()); |
2 |
26 Feb 07 |
jari |
3687 |
leftPosition = preXSpacing + getXSize() + ((getPaletteSpacing() - width) / 2); |
2 |
26 Feb 07 |
jari |
3688 |
topPosition = preYSpacing + (getYSize() - (height * palette.size())) / 2; |
2 |
26 Feb 07 |
jari |
3689 |
|
2 |
26 Feb 07 |
jari |
3690 |
for (int i = 0; i < palette.size(); i++) { |
2 |
26 Feb 07 |
jari |
3691 |
fillRect(g, leftPosition, topPosition + i * height, width, height, (Color) palette.elementAt(255 - i)); |
2 |
26 Feb 07 |
jari |
3692 |
} |
2 |
26 Feb 07 |
jari |
3693 |
} |
2 |
26 Feb 07 |
jari |
3694 |
} |
2 |
26 Feb 07 |
jari |
3695 |
|
2 |
26 Feb 07 |
jari |
3696 |
private void setXOldEvent(int x) { |
2 |
26 Feb 07 |
jari |
3697 |
oldX = x; |
2 |
26 Feb 07 |
jari |
3698 |
} |
2 |
26 Feb 07 |
jari |
3699 |
|
2 |
26 Feb 07 |
jari |
3700 |
private void setYOldEvent(int y) { |
2 |
26 Feb 07 |
jari |
3701 |
oldY = y; |
2 |
26 Feb 07 |
jari |
3702 |
} |
2 |
26 Feb 07 |
jari |
3703 |
|
2 |
26 Feb 07 |
jari |
3704 |
private int getXOldEvent() { |
2 |
26 Feb 07 |
jari |
3705 |
return oldX; |
2 |
26 Feb 07 |
jari |
3706 |
} |
2 |
26 Feb 07 |
jari |
3707 |
|
2 |
26 Feb 07 |
jari |
3708 |
private int getYOldEvent() { |
2 |
26 Feb 07 |
jari |
3709 |
return oldY; |
2 |
26 Feb 07 |
jari |
3710 |
} |
2 |
26 Feb 07 |
jari |
3711 |
|
2 |
26 Feb 07 |
jari |
3712 |
|
2 |
26 Feb 07 |
jari |
3713 |
public Vector buildPalette() { |
2 |
26 Feb 07 |
jari |
3714 |
Vector palette = new Vector(256); |
2 |
26 Feb 07 |
jari |
3715 |
Color newColor; |
2 |
26 Feb 07 |
jari |
3716 |
double r, g, b; |
2 |
26 Feb 07 |
jari |
3717 |
|
2 |
26 Feb 07 |
jari |
3718 |
newColor = new Color(0, 0, 0); |
2 |
26 Feb 07 |
jari |
3719 |
palette.addElement(newColor); |
2 |
26 Feb 07 |
jari |
3720 |
|
2 |
26 Feb 07 |
jari |
3721 |
for (int i = 1; i < 256; i++) { |
2 |
26 Feb 07 |
jari |
3722 |
i = 255 - i; |
2 |
26 Feb 07 |
jari |
3723 |
|
2 |
26 Feb 07 |
jari |
3724 |
r = 0; g = 0; b = 0; |
2 |
26 Feb 07 |
jari |
3725 |
|
2 |
26 Feb 07 |
jari |
3726 |
if (i < 33) r = 255; |
2 |
26 Feb 07 |
jari |
3727 |
else if (i > 32 && i < 108) r = Math.abs( 255 * Math.cos((i - 32) * Math.PI / 151)); |
2 |
26 Feb 07 |
jari |
3728 |
else if (i > 107) r = 0; |
2 |
26 Feb 07 |
jari |
3729 |
|
2 |
26 Feb 07 |
jari |
3730 |
if (i < 5) g = 0; |
2 |
26 Feb 07 |
jari |
3731 |
else if (i > 4 && i < 101) g = Math.abs((255 * Math.cos((i - 100) * Math.PI / 189))); |
2 |
26 Feb 07 |
jari |
3732 |
else if (i > 100 && i < 229) g = Math.abs((255 * Math.cos((i - 100) * Math.PI / 294))); |
2 |
26 Feb 07 |
jari |
3733 |
else if (i > 230) g = 0; |
2 |
26 Feb 07 |
jari |
3734 |
|
2 |
26 Feb 07 |
jari |
3735 |
if (i < 72) b = 0; |
2 |
26 Feb 07 |
jari |
3736 |
else if (i > 71 && i < 200) b = Math.abs((255 * Math.cos((i - 199) * Math.PI / 256))); |
2 |
26 Feb 07 |
jari |
3737 |
else if (i > 199) b = Math.abs((255 * Math.cos((i - 199) * Math.PI / 175))); |
2 |
26 Feb 07 |
jari |
3738 |
|
2 |
26 Feb 07 |
jari |
3739 |
newColor = new Color((float) r / 255, (float) g / 255, (float) b / 255); |
2 |
26 Feb 07 |
jari |
3740 |
palette.addElement(newColor); |
2 |
26 Feb 07 |
jari |
3741 |
|
2 |
26 Feb 07 |
jari |
3742 |
i = 255 - i; |
2 |
26 Feb 07 |
jari |
3743 |
} |
2 |
26 Feb 07 |
jari |
3744 |
|
2 |
26 Feb 07 |
jari |
3745 |
return palette; |
2 |
26 Feb 07 |
jari |
3746 |
} |
2 |
26 Feb 07 |
jari |
3747 |
|
2 |
26 Feb 07 |
jari |
3748 |
private class SingleArrayViewerFrame extends Frame { |
2 |
26 Feb 07 |
jari |
3749 |
protected void processWindowEvent(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
3750 |
if (e.getID() == WindowEvent.WINDOW_CLOSING) dispose(); |
2 |
26 Feb 07 |
jari |
3751 |
super.processWindowEvent(e); |
2 |
26 Feb 07 |
jari |
3752 |
} |
2 |
26 Feb 07 |
jari |
3753 |
} |
2 |
26 Feb 07 |
jari |
3754 |
} |