01: /*
02: * Swing Explorer. Tool for developers exploring Java/Swing-based application internals.
03: * Copyright (C) 2008, Maxim Zakharenkov
04: *
05: * This program is free software; you can redistribute it and/or modify
06: * it under the terms of the GNU General Public License as published by
07: * the Free Software Foundation; either version 2 of the License, or
08: * (at your option) any later version.
09: *
10: * This program is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU General Public License for more details.
14: *
15: * You should have received a copy of the GNU General Public License along
16: * with this program; if not, write to the Free Software Foundation, Inc.,
17: * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18: *
19: * $Header: /cvs/swingexplorer/src/org/swingexplorer/graphics/Generator.java,v 1.2 2008/02/06 08:36:09 maxz1 Exp $
20: */
21: package org.swingexplorer.graphics;
22:
23: import static java.lang.System.out;
24:
25: import java.awt.Graphics2D;
26: import java.lang.reflect.Method;
27: import java.lang.reflect.Modifier;
28:
29: /**
30: *
31: * @author Maxim Zakharenkov
32: */
33: public class Generator {
34:
35: public static void main(String[] args) {
36:
37: for (Method meth : Graphics2D.class.getMethods()) {
38:
39: if ((Modifier.ABSTRACT & meth.getModifiers()) == Modifier.ABSTRACT) {
40: dump(meth);
41: }
42: }
43: }
44:
45: static void dump(Method meth) {
46: String template = "@Override\n"
47: + "public %1$s %2$s(%3$s) { \n "
48: + "operation(\"%2$s\" %4$s); \n " + "}";
49:
50: String returnType = meth.getReturnType().getName();
51: String methodName = meth.getName();
52:
53: String paramDecl = "";
54: String args = "";
55: int i = 0;
56: for (Class type : meth.getParameterTypes()) {
57: String comma = i > 0 ? ", " : "";
58: paramDecl = paramDecl + comma + type.getName() + " p" + i;
59: args = args + ", " + type.getName() + ".class, p" + i;
60: i++;
61: }
62:
63: out.printf(template, returnType, methodName, paramDecl, args);
64: }
65:
66: // @Override
67: // public void drawGlyphVector(GlyphVector g, float x, float y) {
68: // operation("drawGlyphVector", GlyphVector.class, g, float.class, x, float.class, y);
69: // }
70: }
71:
72: /*
73: * $Log: Generator.java,v $
74: * Revision 1.2 2008/02/06 08:36:09 maxz1
75: * Changed license header
76: *
77: * Revision 1.1 2007/06/27 19:41:39 maxz1
78: * new
79: *
80: */
|