KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > TransformCollapse


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.batik.svggen;
18
19 import java.awt.Graphics2D JavaDoc;
20
21 /**
22  * This test validates that transforms are collapsed when they
23  * should.
24  *
25  * @author <a HREF="mailto:vhardy@apache.org">Vincent Hardy</a>
26  * @version $Id: TransformCollapse.java,v 1.4 2005/04/01 02:28:16 deweese Exp $
27  */

28 public class TransformCollapse implements Painter {
29     public void paint(Graphics2D JavaDoc g){
30         g.translate(10, 10);
31         g.translate(20, 30);
32
33         // Should see a translate(30, 40) in the output SVg
34
g.drawString("translate collapse", 0, 0);
35
36         g.scale(2, 2);
37         g.scale(2, 4);
38         
39         // Should see a scale(4, 8)
40
g.drawString("scale collapse", 10, 10);
41
42         g.scale(.25, .125);
43         g.rotate(Math.toRadians(90));
44         g.rotate(Math.toRadians(-60));
45
46         // Should see a rotate(30)
47
g.drawString("rotate collapse", 0, 40);
48         
49         g.rotate(Math.toRadians(-30));
50         // Should get identity
51
g.drawString("identity", 0, 80);
52     }
53 }
54
Popular Tags