| 1 |
// University of California, Santa Cruz, USA and |
| 2 |
// CERN, Geneva, Switzerland, Copyright (c) 2000 |
| 3 |
package org.freehep.graphicsio.test; |
| 4 |
|
| 5 |
import java.awt.Color; |
| 6 |
import java.awt.Dimension; |
| 7 |
import java.awt.Font; |
| 8 |
import java.awt.Graphics; |
| 9 |
import java.awt.Insets; |
| 10 |
|
| 11 |
import org.freehep.graphics2d.TagString; |
| 12 |
import org.freehep.graphics2d.VectorGraphics; |
| 13 |
|
| 14 |
/** |
| 15 |
* @author Charles Loomis |
| 16 |
* @version $Id: freehep-graphicsio-tests/src/main/java/org/freehep/graphicsio/test/TestText2D.java f493ff6e61b2 2005/12/01 18:46:43 duns $ |
| 17 |
*/ |
| 18 |
public class TestText2D extends TestingPanel { |
| 19 |
|
| 20 |
public TestText2D(String[] args) throws Exception { |
| 21 |
super(args); |
| 22 |
setName("Tag Strings"); |
| 23 |
} |
| 24 |
|
| 25 |
public void paintComponent(Graphics g) { |
| 26 |
if (g != null) { |
| 27 |
|
| 28 |
VectorGraphics vg = VectorGraphics.create(g); |
| 29 |
|
| 30 |
Dimension dim = getSize(); |
| 31 |
Insets insets = getInsets(); |
| 32 |
vg.setColor(Color.white); |
| 33 |
vg.fillRect(insets.left, insets.top, dim.width - insets.left |
| 34 |
- insets.right, dim.height - insets.top - insets.bottom); |
| 35 |
|
| 36 |
int dw = dim.width / 3; |
| 37 |
int dh = dim.height / 10; |
| 38 |
|
| 39 |
vg.setColor(Color.green); |
| 40 |
for (int y = 0; y < 8; y++) { |
| 41 |
int iy = (int) ((y + 0.5) * dh); |
| 42 |
vg.drawLine(0, iy, dim.width, iy); |
| 43 |
} |
| 44 |
|
| 45 |
for (int x = 0; x < 3; x++) { |
| 46 |
int ix = (int) ((x + 0.5) * dw); |
| 47 |
vg.drawLine(ix, 0, ix, dim.height); |
| 48 |
} |
| 49 |
|
| 50 |
String saying = "<Vector<sup><b>\\Graphics%</b></sup> " |
| 51 |
+ "& Card<i><sub>)Adapter)</sub></i>>"; |
| 52 |
TagString text = new TagString(saying); |
| 53 |
|
| 54 |
vg.setColor(Color.red); |
| 55 |
vg.setFont(new Font("SansSerif", Font.PLAIN, 10)); |
| 56 |
|
| 57 |
for (int y = 0; y < 8; y++) { |
| 58 |
int iy = (int) ((y + 0.5) * dh); |
| 59 |
for (int x = 0; x < 3; x++) { |
| 60 |
int ix = (int) ((x + 0.5) * dw); |
| 61 |
if (y == 4) { |
| 62 |
vg.drawString(text, ix, iy, 3 - x, y % 4, true, |
| 63 |
Color.cyan, 2, true, Color.black); |
| 64 |
} else if (y == 5) { |
| 65 |
vg.drawString(text, ix, iy, 3 - x, y % 4, false, |
| 66 |
Color.cyan, 2, true, Color.black); |
| 67 |
} else if (y == 6) { |
| 68 |
vg.drawString(text, ix, iy, 3 - x, y % 4, true, |
| 69 |
Color.cyan, 2, false, Color.black); |
| 70 |
} else if (y == 7) { |
| 71 |
vg.drawString(text, ix, iy, 3 - x, y % 4, false, |
| 72 |
Color.cyan, 2, false, Color.black); |
| 73 |
} else { |
| 74 |
vg.drawString(text, ix, iy, 3 - x, y % 4); |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
public static void main(String[] args) throws Exception { |
| 82 |
new TestText2D(args).runTest(); |
| 83 |
} |
| 84 |
} |