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: Drawable.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.2 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 21:00:04 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.util.awt; |
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.Cursor; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Graphics; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.Point; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
22 |
|
2 |
26 Feb 07 |
jari |
23 |
public abstract class Drawable extends JPanel { |
2 |
26 Feb 07 |
jari |
24 |
protected int startX, stopX, startY, stopY; |
2 |
26 Feb 07 |
jari |
25 |
|
2 |
26 Feb 07 |
jari |
26 |
public Drawable(int startX, int stopX, int startY, int stopY) { |
2 |
26 Feb 07 |
jari |
27 |
this.startX = startX; |
2 |
26 Feb 07 |
jari |
28 |
this.stopX = stopX; |
2 |
26 Feb 07 |
jari |
29 |
this.startY = startY; |
2 |
26 Feb 07 |
jari |
30 |
this.stopY = stopY; |
2 |
26 Feb 07 |
jari |
//setSize(startX + stopX, startY + stopY); |
2 |
26 Feb 07 |
jari |
32 |
setDoubleBuffered(true); |
2 |
26 Feb 07 |
jari |
33 |
} |
2 |
26 Feb 07 |
jari |
34 |
|
2 |
26 Feb 07 |
jari |
35 |
protected void paintComponent(Graphics g) { |
2 |
26 Feb 07 |
jari |
36 |
super.paintComponent(g); |
2 |
26 Feb 07 |
jari |
37 |
controlPaint(g); |
2 |
26 Feb 07 |
jari |
38 |
} |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
public void setCursor(int cursor) { |
2 |
26 Feb 07 |
jari |
41 |
setCursor(Cursor.getPredefinedCursor(cursor)); |
2 |
26 Feb 07 |
jari |
42 |
} |
2 |
26 Feb 07 |
jari |
43 |
|
2 |
26 Feb 07 |
jari |
44 |
public void drawPoint(Graphics2D g, Point point, Color color) { |
2 |
26 Feb 07 |
jari |
45 |
drawPoint(g, point.x, point.y, color); |
2 |
26 Feb 07 |
jari |
46 |
} |
2 |
26 Feb 07 |
jari |
47 |
|
2 |
26 Feb 07 |
jari |
48 |
public void drawPoint(Graphics2D g, int x, int y, Color color) { |
2 |
26 Feb 07 |
jari |
49 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
50 |
g.drawLine(x, y, x, y); |
2 |
26 Feb 07 |
jari |
51 |
} |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
public void drawPoint(Graphics2D g, Point point) { |
2 |
26 Feb 07 |
jari |
54 |
drawPoint(g, point, getBackground()); |
2 |
26 Feb 07 |
jari |
55 |
} |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
public void drawPoint(Graphics2D g, int x, int y) { |
2 |
26 Feb 07 |
jari |
58 |
drawPoint(g, x, y, getBackground()); |
2 |
26 Feb 07 |
jari |
59 |
} |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
public void drawLine(Graphics2D g, int x1, int y1, int x2, int y2, Color color) { |
2 |
26 Feb 07 |
jari |
62 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
63 |
g.drawLine(x1, y1, x2, y2); |
2 |
26 Feb 07 |
jari |
64 |
} |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
public void drawLine(Graphics2D g, int x1, int y1, int x2, int y2) { |
2 |
26 Feb 07 |
jari |
67 |
drawLine(g, x1, y1, x2, y2, getBackground()); |
2 |
26 Feb 07 |
jari |
68 |
} |
2 |
26 Feb 07 |
jari |
69 |
|
2 |
26 Feb 07 |
jari |
70 |
public final void drawRect(Graphics2D g, int x, int y, int width, int height, Color color) { |
2 |
26 Feb 07 |
jari |
71 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
72 |
g.drawRect(x, y, width, height); |
2 |
26 Feb 07 |
jari |
73 |
} |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
public final void fillRect(Graphics2D g, int x, int y, int width, int height, Color color) { |
2 |
26 Feb 07 |
jari |
76 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
77 |
g.fillRect(x, y, width, height); |
2 |
26 Feb 07 |
jari |
78 |
} |
2 |
26 Feb 07 |
jari |
79 |
|
2 |
26 Feb 07 |
jari |
80 |
public void drawString(Graphics2D g, String string, int x, int y, Color color, Font font) { |
2 |
26 Feb 07 |
jari |
81 |
g.setFont(font); |
2 |
26 Feb 07 |
jari |
82 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
83 |
g.drawString(string, x, y); |
2 |
26 Feb 07 |
jari |
84 |
} |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
public void drawString(Graphics2D g, String string, int x, int y, Color color) { |
2 |
26 Feb 07 |
jari |
87 |
g.setColor(color); |
2 |
26 Feb 07 |
jari |
88 |
g.drawString(string, x, y); |
2 |
26 Feb 07 |
jari |
89 |
} |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
public abstract void controlPaint(Graphics g); |
2 |
26 Feb 07 |
jari |
92 |
} |