2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2006, 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 |
package org.tigr.microarray.mev.cluster.gui.impl.lem; |
2 |
26 Feb 07 |
jari |
6 |
|
2 |
26 Feb 07 |
jari |
7 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
8 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
9 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
10 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
11 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
12 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
15 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
16 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
17 |
import javax.swing.JTextPane; |
2 |
26 Feb 07 |
jari |
18 |
|
2 |
26 Feb 07 |
jari |
19 |
import org.tigr.microarray.mev.cluster.gui.impl.ViewerAdapter; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
/** |
2 |
26 Feb 07 |
jari |
* @author braisted |
2 |
26 Feb 07 |
jari |
23 |
* |
2 |
26 Feb 07 |
jari |
* LEMInfoViewer displays text describing locus mapping |
2 |
26 Feb 07 |
jari |
25 |
*/ |
2 |
26 Feb 07 |
jari |
26 |
public class LEMInfoViewer extends ViewerAdapter { |
2 |
26 Feb 07 |
jari |
27 |
|
2 |
26 Feb 07 |
jari |
28 |
private JComponent header; |
2 |
26 Feb 07 |
jari |
29 |
private JTextPane content; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
private JLabel label; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>LEMInfoViewer</code> with specified |
2 |
26 Feb 07 |
jari |
* clusters and number of genes. |
2 |
26 Feb 07 |
jari |
36 |
*/ |
2 |
26 Feb 07 |
jari |
37 |
public LEMInfoViewer(String locusField, String startField, String endField, boolean hasMultipleChr, String chrField, boolean useFileInput, String coordFileName, |
2 |
26 Feb 07 |
jari |
38 |
int totSpotCount, int lemSpotCount, int numberOfMappedSpots, String [] chrNames, int [] mappingCounts, int [] locusCounts) { |
2 |
26 Feb 07 |
jari |
39 |
header = createHeader(); |
2 |
26 Feb 07 |
jari |
40 |
content = createContent(locusField, startField, endField, hasMultipleChr, chrField, useFileInput, coordFileName, totSpotCount, lemSpotCount, numberOfMappedSpots, chrNames, mappingCounts, locusCounts); |
2 |
26 Feb 07 |
jari |
41 |
setMaxWidth(content, header); |
2 |
26 Feb 07 |
jari |
42 |
} |
2 |
26 Feb 07 |
jari |
43 |
|
2 |
26 Feb 07 |
jari |
44 |
public LEMInfoViewer(JComponent content, JComponent header){ |
2 |
26 Feb 07 |
jari |
45 |
this.content = (JTextPane)content; |
2 |
26 Feb 07 |
jari |
46 |
this.header = header; |
2 |
26 Feb 07 |
jari |
47 |
setMaxWidth(content, header); |
2 |
26 Feb 07 |
jari |
48 |
} |
2 |
26 Feb 07 |
jari |
49 |
/** |
2 |
26 Feb 07 |
jari |
* Returns component to be inserted into the framework scroll pane. |
2 |
26 Feb 07 |
jari |
51 |
*/ |
2 |
26 Feb 07 |
jari |
52 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
//return label; |
2 |
26 Feb 07 |
jari |
54 |
return content; |
2 |
26 Feb 07 |
jari |
55 |
} |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the viewer header. |
2 |
26 Feb 07 |
jari |
59 |
*/ |
2 |
26 Feb 07 |
jari |
60 |
public JComponent getHeaderComponent() { |
2 |
26 Feb 07 |
jari |
61 |
return header; |
2 |
26 Feb 07 |
jari |
62 |
} |
2 |
26 Feb 07 |
jari |
63 |
|
2 |
26 Feb 07 |
jari |
64 |
/** |
2 |
26 Feb 07 |
jari |
* Creates the viewer header. |
2 |
26 Feb 07 |
jari |
66 |
*/ |
2 |
26 Feb 07 |
jari |
67 |
private JComponent createHeader() { |
2 |
26 Feb 07 |
jari |
68 |
JPanel panel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
69 |
panel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
70 |
GridBagConstraints gbc = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
71 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
2 |
26 Feb 07 |
jari |
72 |
gbc.insets = new Insets(10, 0, 10, 0); |
2 |
26 Feb 07 |
jari |
73 |
panel.add(new JLabel("<html><body bgcolor='#FFFFFF'><font face='serif' color='#000080'><h1>LEM Construction Summary<h1></font></body></html>"), gbc); |
2 |
26 Feb 07 |
jari |
74 |
return panel; |
2 |
26 Feb 07 |
jari |
75 |
} |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
77 |
/** |
2 |
26 Feb 07 |
jari |
* Creates the viewer content component. |
2 |
26 Feb 07 |
jari |
79 |
*/ |
2 |
26 Feb 07 |
jari |
80 |
private JTextPane createContent(String locusField, String startField, String endField, boolean hasMultipleChr, String chrField, boolean useFileInput, String coordFileName, |
2 |
26 Feb 07 |
jari |
81 |
int totSpotCount, int lemSpotCount, int numberOfMappedSpots, String [] chrNames, int [] mappingCounts, int [] locusCounts) { |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
JTextPane area = new JTextPane(); |
2 |
26 Feb 07 |
jari |
84 |
area.setContentType("text/html"); |
2 |
26 Feb 07 |
jari |
85 |
area.setEditable(false); |
2 |
26 Feb 07 |
jari |
86 |
area.setMargin(new Insets(0, 10, 0, 0)); |
2 |
26 Feb 07 |
jari |
87 |
Font font = new Font("Serif", Font.PLAIN, 10); |
2 |
26 Feb 07 |
jari |
88 |
area.setFont(font); |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
90 |
String text = "<html><body><font face=\"sanserif\">";// color='#000080'>"; |
2 |
26 Feb 07 |
jari |
91 |
|
2 |
26 Feb 07 |
jari |
92 |
text += "<h2>Parameters</h2>"; |
2 |
26 Feb 07 |
jari |
93 |
text += "<b>Locus ID Annotation Field:</b>"+locusField+"<br>"; |
2 |
26 Feb 07 |
jari |
94 |
text += "<b>Use Coordinate File:</b>"+(useFileInput?"Yes":"No")+"<br>"; |
2 |
26 Feb 07 |
jari |
95 |
if(useFileInput) |
2 |
26 Feb 07 |
jari |
96 |
text += "<b>Coordinate File:</b>"+coordFileName+"<br>"; |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
text += "<b>Multiple Chromosomes Indicated:</b>"+(hasMultipleChr?"Yes":"No")+"<br>"; |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
if(!useFileInput) { |
2 |
26 Feb 07 |
jari |
101 |
if(hasMultipleChr) |
2 |
26 Feb 07 |
jari |
102 |
text += "<b>Chromosome ID Annotation Field:</b>"+chrField+"<br>"; |
2 |
26 Feb 07 |
jari |
103 |
|
2 |
26 Feb 07 |
jari |
104 |
text += "<b>5' End Annotation Field:</b>"+startField+"<br>"; |
2 |
26 Feb 07 |
jari |
105 |
text += "<b>3' End Annotation Field:</b>"+endField+"<br>"; |
2 |
26 Feb 07 |
jari |
106 |
} |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
108 |
text += "<h2>Global Mapping Information</h2>"; |
2 |
26 Feb 07 |
jari |
109 |
if(totSpotCount != lemSpotCount) { |
2 |
26 Feb 07 |
jari |
110 |
text += "<b>Number of Spots Loaded in MeV: </b>"+String.valueOf(totSpotCount)+"<br>"; |
2 |
26 Feb 07 |
jari |
111 |
text += "<b>Number of Spots Entering LEM (after filtering): </b>"+String.valueOf(lemSpotCount)+"<br>"; |
2 |
26 Feb 07 |
jari |
112 |
} else { |
2 |
26 Feb 07 |
jari |
113 |
text += "<b>Number of Spots Entering LEM: </b>"+String.valueOf(lemSpotCount)+"<br>"; |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
text += "<b>Number of Spots Mapped to Loci: </b>"+String.valueOf(numberOfMappedSpots)+"<br>"; |
2 |
26 Feb 07 |
jari |
117 |
text += "<b>Fraction of Spots Mapped to Loci: </b>"+String.valueOf((numberOfMappedSpots)/(float)lemSpotCount)+"<br>"; |
2 |
26 Feb 07 |
jari |
118 |
text += "<b>Number of Unique Chromosome IDs: </b>"+String.valueOf(locusCounts.length)+"<br>"; |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
text += "<h2>Chromosomal Mapping Information</h2>"; |
2 |
26 Feb 07 |
jari |
121 |
|
2 |
26 Feb 07 |
jari |
122 |
for(int i = 0; i < chrNames.length; i++) { |
2 |
26 Feb 07 |
jari |
123 |
text += "<b>Chromosome ID:</b>"+(String)chrNames[i]+"<br>"; |
2 |
26 Feb 07 |
jari |
124 |
text += "<b>Number of Unique Locus IDs Found:</b>"+String.valueOf(locusCounts[i])+"<br>"; |
2 |
26 Feb 07 |
jari |
125 |
text += "<b>Number of Spots Mapped to Loci on Chromosome:</b>"+String.valueOf(mappingCounts[i])+"<br><br>"; |
2 |
26 Feb 07 |
jari |
126 |
} |
2 |
26 Feb 07 |
jari |
127 |
|
2 |
26 Feb 07 |
jari |
128 |
text += "</font></body></html>"; |
2 |
26 Feb 07 |
jari |
129 |
|
2 |
26 Feb 07 |
jari |
130 |
area.setText(text); |
2 |
26 Feb 07 |
jari |
131 |
area.setCaretPosition(0); |
2 |
26 Feb 07 |
jari |
132 |
|
2 |
26 Feb 07 |
jari |
133 |
label = new JLabel(text); |
2 |
26 Feb 07 |
jari |
134 |
return area; |
2 |
26 Feb 07 |
jari |
135 |
} |
2 |
26 Feb 07 |
jari |
136 |
|
2 |
26 Feb 07 |
jari |
137 |
/** |
2 |
26 Feb 07 |
jari |
* Synchronize content and header sizes. |
2 |
26 Feb 07 |
jari |
139 |
*/ |
2 |
26 Feb 07 |
jari |
140 |
private void setMaxWidth(JComponent content, JComponent header) { |
2 |
26 Feb 07 |
jari |
141 |
int c_width = content.getPreferredSize().width; |
2 |
26 Feb 07 |
jari |
142 |
int h_width = header.getPreferredSize().width; |
2 |
26 Feb 07 |
jari |
143 |
if (c_width > h_width) { |
2 |
26 Feb 07 |
jari |
144 |
header.setPreferredSize(new Dimension(c_width, header.getPreferredSize().height)); |
2 |
26 Feb 07 |
jari |
145 |
} else { |
2 |
26 Feb 07 |
jari |
146 |
content.setPreferredSize(new Dimension(h_width, content.getPreferredSize().height)); |
2 |
26 Feb 07 |
jari |
147 |
} |
2 |
26 Feb 07 |
jari |
148 |
} |
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into the scroll pane row header |
2 |
26 Feb 07 |
jari |
151 |
*/ |
2 |
26 Feb 07 |
jari |
152 |
public JComponent getRowHeaderComponent() { |
2 |
26 Feb 07 |
jari |
153 |
return null; |
2 |
26 Feb 07 |
jari |
154 |
} |
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
156 |
} |