| 1 |
// Copyright 2004, FreeHEP. |
| 2 |
package org.freehep.graphicsio.test; |
| 3 |
|
| 4 |
import java.awt.BasicStroke; |
| 5 |
import java.awt.Color; |
| 6 |
import java.awt.Dimension; |
| 7 |
import java.awt.Graphics; |
| 8 |
import java.awt.Insets; |
| 9 |
import java.awt.geom.Ellipse2D; |
| 10 |
|
| 11 |
import org.freehep.graphics2d.VectorGraphics; |
| 12 |
|
| 13 |
/** |
| 14 |
* |
| 15 |
* @author Mark Donszelmann |
| 16 |
* @version $Id: freehep-graphicsio-tests/src/main/java/org/freehep/graphicsio/test/TestResolution.java f493ff6e61b2 2005/12/01 18:46:43 duns $ |
| 17 |
*/ |
| 18 |
public class TestResolution extends TestingPanel { |
| 19 |
|
| 20 |
public TestResolution(String[] args) throws Exception { |
| 21 |
super(args); |
| 22 |
setName("Resolution"); |
| 23 |
} |
| 24 |
|
| 25 |
public void paintComponent(Graphics g) { |
| 26 |
if (g == null) |
| 27 |
return; |
| 28 |
|
| 29 |
VectorGraphics vg = VectorGraphics.create(g); |
| 30 |
|
| 31 |
Dimension dim = getSize(); |
| 32 |
Insets insets = getInsets(); |
| 33 |
|
| 34 |
vg.setColor(Color.white); |
| 35 |
vg.fillRect(insets.left, insets.top, dim.width - insets.left |
| 36 |
- insets.right, dim.height - insets.top - insets.bottom); |
| 37 |
|
| 38 |
double w = dim.width / 3; |
| 39 |
double h = dim.height / 5; |
| 40 |
double s = 0.0000001; |
| 41 |
for (int i = 0; i < 15; i++) { |
| 42 |
VectorGraphics vgs = (VectorGraphics) vg.create(); |
| 43 |
if (i < 5) { |
| 44 |
vgs.translate(0, i * h); |
| 45 |
} else if (i < 10) { |
| 46 |
vgs.translate(w, (i - 5) * h); |
| 47 |
} else { |
| 48 |
vgs.translate(2 * w, (i - 10) * h); |
| 49 |
} |
| 50 |
vgs.translate(w / 2, h / 2); |
| 51 |
|
| 52 |
double sc = 0.5 * Math.min(w, h) / 2; |
| 53 |
vgs.scale(sc, sc); |
| 54 |
vgs.scale(1 / s, 1 / s); |
| 55 |
|
| 56 |
vgs.setStroke(new BasicStroke((float) (0.5 * s), |
| 57 |
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); |
| 58 |
|
| 59 |
vgs.setColor(Color.black); |
| 60 |
vgs.draw(new Ellipse2D.Double(-1 * s, -1 * s, 2 * s, 2 * s)); |
| 61 |
vgs.dispose(); |
| 62 |
|
| 63 |
s *= 10; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
public static void main(String[] args) throws Exception { |
| 68 |
new TestResolution(args).runTest(); |
| 69 |
} |
| 70 |
} |