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 |
This software is provided "AS IS". TIGR makes no warranties, express |
2 |
26 Feb 07 |
jari |
or implied, including no representation or warranty with respect to |
2 |
26 Feb 07 |
jari |
the performance of the software and derivatives or their safety, |
2 |
26 Feb 07 |
jari |
effectiveness, or commercial viability. TIGR does not warrant the |
2 |
26 Feb 07 |
jari |
merchantability or fitness of the software and derivatives for any |
2 |
26 Feb 07 |
jari |
particular purpose, or that they may be exploited without infringing |
2 |
26 Feb 07 |
jari |
the copyrights, patent rights or property rights of others. TIGR shall |
2 |
26 Feb 07 |
jari |
not be liable for any claim, demand or action for any loss, harm, |
2 |
26 Feb 07 |
jari |
illness or other damage or injury arising from access to or use of the |
2 |
26 Feb 07 |
jari |
software or associated information, including without limitation any |
2 |
26 Feb 07 |
jari |
direct, indirect, incidental, exemplary, special or consequential |
2 |
26 Feb 07 |
jari |
damages. |
2 |
26 Feb 07 |
jari |
17 |
|
2 |
26 Feb 07 |
jari |
This software program may not be sold, leased, transferred, exported |
2 |
26 Feb 07 |
jari |
or otherwise disclaimed to anyone, in whole or in part, without the |
2 |
26 Feb 07 |
jari |
prior written consent of TIGR. |
2 |
26 Feb 07 |
jari |
21 |
*/ |
2 |
26 Feb 07 |
jari |
22 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: CGHPositionGraphCombinedHeader.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.1 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/03 14:36:29 $ |
2 |
26 Feb 07 |
jari |
* $Author: raktim $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
28 |
*/ |
2 |
26 Feb 07 |
jari |
29 |
package org.tigr.microarray.mev.cgh.CGHGuiObj.CGHPositionGraph; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
32 |
import java.awt.FontMetrics; |
2 |
26 Feb 07 |
jari |
33 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
34 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
35 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
36 |
import java.awt.RenderingHints; |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
/** |
2 |
26 Feb 07 |
jari |
* @author Adam Margolin |
2 |
26 Feb 07 |
jari |
* @author Raktim Sinha |
2 |
26 Feb 07 |
jari |
41 |
* |
2 |
26 Feb 07 |
jari |
42 |
*/ |
2 |
26 Feb 07 |
jari |
43 |
public class CGHPositionGraphCombinedHeader extends CGHPositionGraphHeader { |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
|
2 |
26 Feb 07 |
jari |
46 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>MultipleArrayHeader</code> with specified |
2 |
26 Feb 07 |
jari |
* insets and trace space. |
2 |
26 Feb 07 |
jari |
49 |
*/ |
2 |
26 Feb 07 |
jari |
50 |
public CGHPositionGraphCombinedHeader(Insets insets) { |
2 |
26 Feb 07 |
jari |
51 |
super(insets); |
2 |
26 Feb 07 |
jari |
52 |
} |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
/** |
2 |
26 Feb 07 |
jari |
* Paints the header into specified graphics. |
2 |
26 Feb 07 |
jari |
56 |
*/ |
2 |
26 Feb 07 |
jari |
57 |
public void paint(Graphics g1D) { |
2 |
26 Feb 07 |
jari |
58 |
super.paint(g1D); |
2 |
26 Feb 07 |
jari |
59 |
if (this.model == null || this.model.getNumExperiments() == 0) { |
2 |
26 Feb 07 |
jari |
60 |
return; |
2 |
26 Feb 07 |
jari |
61 |
} |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
63 |
Graphics2D g = (Graphics2D)g1D; |
2 |
26 Feb 07 |
jari |
64 |
int width; |
2 |
26 Feb 07 |
jari |
65 |
if(!this.isTracing) |
2 |
26 Feb 07 |
jari |
66 |
width = this.model.getNumExperiments() * this.elementWidth; |
2 |
26 Feb 07 |
jari |
67 |
else |
2 |
26 Feb 07 |
jari |
68 |
width = (this.model.getNumExperiments() - 1) * (this.elementWidth + rectSpacing) + this.elementWidth ; |
2 |
26 Feb 07 |
jari |
//g.drawImage(this.negColorImage, insets.left, 0, (int)(width/2f), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
//g.drawImage(this.posColorImage, (int)(width/2f)+insets.left, 0, (int)(width/2.0), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
//System.out.println("header draw image"); |
2 |
26 Feb 07 |
jari |
//BufferedImage negColorImage = model.getNegColorImage(); |
2 |
26 Feb 07 |
jari |
//int rgb = negColorImage.getRGB(255, 0); |
2 |
26 Feb 07 |
jari |
//System.out.println("RGB = " + rgb); |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
width = model.getNumExperiments() * (elementWidth + rectSpacing);// + insets.left; |
2 |
26 Feb 07 |
jari |
77 |
|
2 |
26 Feb 07 |
jari |
78 |
g.drawImage(model.getNegColorImage(), insets.left, 0, (int)(width/2f), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
79 |
g.drawImage(model.getPosColorImage(), (int)(width/2f)+insets.left, 0, (int)(width/2.0), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
//g.drawImage(model.getNegColorImage(), insets.left, 0, (int)(width), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
//g.drawImage(model.getPosColorImage(), (int)(width/2f)+insets.left, 0, (int)(width), RECT_HEIGHT, null); |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
FontMetrics hfm = g.getFontMetrics(); |
2 |
26 Feb 07 |
jari |
84 |
int descent = hfm.getDescent(); |
2 |
26 Feb 07 |
jari |
85 |
int fHeight = hfm.getHeight(); |
2 |
26 Feb 07 |
jari |
86 |
|
2 |
26 Feb 07 |
jari |
87 |
g.setColor(Color.white); |
2 |
26 Feb 07 |
jari |
88 |
if (isAntiAliasing) { |
2 |
26 Feb 07 |
jari |
89 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF); |
2 |
26 Feb 07 |
jari |
90 |
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
2 |
26 Feb 07 |
jari |
91 |
} |
2 |
26 Feb 07 |
jari |
92 |
int textWidth; |
2 |
26 Feb 07 |
jari |
93 |
g.drawString(String.valueOf(this.minValue), insets.left, RECT_HEIGHT+fHeight); |
2 |
26 Feb 07 |
jari |
//g.drawString(String.valueOf(model.getMinRatioScale()), insets.left, RECT_HEIGHT+fHeight); |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
textWidth = hfm.stringWidth("0:0"); |
2 |
26 Feb 07 |
jari |
97 |
g.drawString("0:0", (int)(width/2f)-textWidth/2 + insets.left, RECT_HEIGHT+fHeight); |
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
textWidth = hfm.stringWidth(String.valueOf(this.maxValue)); |
2 |
26 Feb 07 |
jari |
100 |
g.drawString(String.valueOf(this.maxValue), (width-textWidth)+insets.left, RECT_HEIGHT+fHeight); |
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
drawColumnHeaders(g); |
2 |
26 Feb 07 |
jari |
104 |
} |
2 |
26 Feb 07 |
jari |
105 |
|
2 |
26 Feb 07 |
jari |
106 |
/** |
2 |
26 Feb 07 |
jari |
* Draws microarrays names. |
2 |
26 Feb 07 |
jari |
108 |
*/ |
2 |
26 Feb 07 |
jari |
109 |
private void drawColumnHeaders(Graphics2D g) { |
2 |
26 Feb 07 |
jari |
110 |
final int size = model.getNumExperiments(); |
2 |
26 Feb 07 |
jari |
111 |
if (size == 0) { |
2 |
26 Feb 07 |
jari |
112 |
return; |
2 |
26 Feb 07 |
jari |
113 |
} |
2 |
26 Feb 07 |
jari |
114 |
|
2 |
26 Feb 07 |
jari |
115 |
FontMetrics hfm = g.getFontMetrics(); |
2 |
26 Feb 07 |
jari |
116 |
int descent = hfm.getDescent(); |
2 |
26 Feb 07 |
jari |
117 |
g.rotate(-Math.PI/2); |
2 |
26 Feb 07 |
jari |
118 |
String name; |
2 |
26 Feb 07 |
jari |
119 |
for (int feature = 0; feature < size; feature++) { |
2 |
26 Feb 07 |
jari |
120 |
name = model.getExperimentName(model.getExperimentIndexAt(feature)); |
2 |
26 Feb 07 |
jari |
121 |
int xCoord = feature * (elementWidth + rectSpacing) + elementWidth / 2 + insets.left; |
2 |
26 Feb 07 |
jari |
122 |
xCoord += descent; |
2 |
26 Feb 07 |
jari |
//g.drawString(name, insets.bottom - getSize().height +5, insets.left + descent + (elementWidth+getSpacing())*feature + elementWidth/2); |
2 |
26 Feb 07 |
jari |
124 |
g.drawString(name, insets.bottom - getSize().height +5, xCoord); |
2 |
26 Feb 07 |
jari |
125 |
} |
2 |
26 Feb 07 |
jari |
126 |
g.rotate(Math.PI/2); |
2 |
26 Feb 07 |
jari |
127 |
} |
2 |
26 Feb 07 |
jari |
128 |
|
2 |
26 Feb 07 |
jari |
129 |
|
2 |
26 Feb 07 |
jari |
130 |
} |