-
Notifications
You must be signed in to change notification settings - Fork 1
/
leftPanel.java
87 lines (72 loc) · 2.23 KB
/
leftPanel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright distributed.net 1997-2001 - All Rights Reserved
// For use in distributed.net projects only.
// Any other distribution or use of this source violates copyright.
//
import java.awt.*;
import java.awt.image.*;
public class leftPanel
extends Panel
{
private java.awt.Image img;
private int width=20;
private int height=200;
public leftPanel()
{
super();
setBackground(Color.lightGray);
}
private void createImage2()
{
java.awt.Image img2 = createImage(height,width);
Graphics g = img2.getGraphics();
g.setColor(Color.lightGray);
g.fillRect(0,0,height,width);
g.setColor(Color.black);
FontMetrics fm = g.getFontMetrics();
String str = "Work Unit keyrate (kkeys/sec)";
int length = fm.stringWidth(str);
g.drawString(str,(height/2)-length/2,fm.getHeight());
g.dispose();
g.finalize();
img2.flush();
int[] pixels = new int[height*width];
PixelGrabber pg = new PixelGrabber(img2, 0, 0, height, width, pixels, 0, height);
try {
pg.grabPixels();
} catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels!");
return;
}
/* Rotate the Image */
int pixels2[] = new int[height*width];
for (int x = 0; x < width; x++)
for (int y = 0; y < height; y++)
{
int c = pixels[y+(x)*height];
// Due a bug in the MS-JavaVM the Background for Images are not the same
// as for Panel's so. mark it as non-opaque ..
if (c != 0xff000000)
{
c = 0;
}
pixels2[x+(height-y-1)*width] = c;
}
img = createImage(new MemoryImageSource(width, height, pixels2, 0, width));
repaint();
}
public Dimension getPreferredSize()
{
return new Dimension(width,height);
}
public void paint(Graphics g)
{
Dimension d = getSize();
if (img != null)
{
int p = (d.height-height)/2;
g.drawImage(img,0,p,null);
} else {
createImage2();
}
}
}