1
2 package org.freehep.graphicsio.test;
3
4 import java.awt.Color;
5 import java.awt.Dimension;
6 import java.awt.Graphics;
7 import java.awt.Insets;
8
9 import org.freehep.graphics2d.VectorGraphics;
10
11
12
13
14
15 public class TestOffset extends TestingPanel {
16
17 public TestOffset(String[] args) throws Exception {
18 super(args);
19 setName("Offset");
20 }
21
22 public void paintComponent(Graphics g) {
23
24 if (g == null)
25 return;
26
27 VectorGraphics vg = VectorGraphics.create(g);
28
29 Dimension dim = getSize();
30 Insets insets = getInsets();
31
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 vg.setColor(Color.black);
37
38 vg.setLineWidth(4.0);
39 double w = dim.width, h = dim.height;
40 vg.translate(w / 2, h / 2);
41 double xhi = w / 2 - 10, yhi = h / 2 - 10;
42 vg.drawLine(-xhi, -yhi, xhi, yhi);
43 vg.drawLine(-xhi, yhi, xhi, -yhi);
44 vg.drawRect(-xhi, -yhi, w - 20, h - 20);
45 }
46
47 public static void main(String[] args) throws Exception {
48 new TestOffset(args).runTest();
49 }
50 }