[jboss-cvs] JBossAS SVN: r91411 - in projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher: layout and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jul 19 22:03:31 EDT 2009


Author: alesj
Date: 2009-07-19 22:03:30 -0400 (Sun, 19 Jul 2009)
New Revision: 91411

Added:
   projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/analysis/
   projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/GraphLayoutMapping.java
Removed:
   projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/layout/GraphLayoutMapping.java
Modified:
   projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java
Log:
A bit of refactoring.

Modified: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java	2009-07-19 11:59:35 UTC (rev 91410)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/GrapherServlet.java	2009-07-20 02:03:30 UTC (rev 91411)
@@ -37,7 +37,7 @@
 import org.jboss.mc.servlet.vdf.api.KernelControllerVDFConnector;
 import org.jboss.mctools.grapher.graph.GraphCreator;
 import org.jboss.mctools.grapher.layout.GraphLayout;
-import org.jboss.mctools.grapher.layout.GraphLayoutMapping;
+import org.jboss.mctools.grapher.map.GraphLayoutMapping;
 import org.jboss.mctools.grapher.map.GraphCreatorMapper;
 import org.jboss.mctools.grapher.map.ExcludeTypes;
 import org.jboss.mctools.grapher.render.GIFRenderer;

Deleted: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/layout/GraphLayoutMapping.java
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/layout/GraphLayoutMapping.java	2009-07-19 11:59:35 UTC (rev 91410)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/layout/GraphLayoutMapping.java	2009-07-20 02:03:30 UTC (rev 91411)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.mctools.grapher.layout;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import org.jboss.mctools.grapher.GrapherConstants;
-
-/**
- * Map simple name to full layout class name.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public final class GraphLayoutMapping
-{
-   private static final Map<String, String> map = new HashMap<String, String>();
-
-   static
-   {
-      map.put("simple", "com.jgraph.layout.graph.JGraphSimpleLayout");
-      map.put("tree", "com.jgraph.layout.tree.JGraphTreeLayout");
-      map.put("spring", "com.jgraph.layout.graph.JGraphSpringLayout");
-      map.put("hierarchical", "com.jgraph.layout.hierarchical.JGrapHierarchicalhLayout");
-      map.put("compound", "com.jgraph.layout.graph.JGraphCompoundTreeLayout");
-      map.put("compact", "com.jgraph.layout.graph.JGraphCompactTreeLayout");
-      map.put("moen", "com.jgraph.layout.graph.JGraphMoenLayout");
-      map.put("radial", "com.jgraph.layout.graph.JGraphRadialTreeLayout");
-      map.put("annealing", "com.jgraph.layout.graph.JGraphAnnealingLayout");
-      map.put("fr", "com.jgraph.layout.graph.JGraphFRLayout");
-      map.put("organic", "com.jgraph.layout.organic.JGraphOrganicLayout");
-      map.put("self", "com.jgraph.layout.organic.JGraphSelfOrganizingOrganicLayout");
-      map.put("isom", "com.jgraph.layout.graph.JGraphISOMLayout");
-      map.put("org", "com.jgraph.layout.tree.OrganizationalLayout");
-   }
-
-   /**
-    * Get layout.
-    *
-    * @param key the layout key
-    * @return the layout
-    */
-   public static GraphLayout getLayout(String key)
-   {
-      if (key == null)
-         return GrapherConstants.LAYOUT;
-
-      String className = map.get(key);
-      if (className == null)
-         return GrapherConstants.LAYOUT;
-
-      if ("simple".equals(key)) // treat simple differently
-         return new ReflectionGraphLayout(className, new Class<?>[]{int.class}, new Object[]{2});
-      else
-         return new ReflectionGraphLayout(className);
-   }
-}

Copied: projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/GraphLayoutMapping.java (from rev 91387, projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/layout/GraphLayoutMapping.java)
===================================================================
--- projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/GraphLayoutMapping.java	                        (rev 0)
+++ projects/mc-tools/grapher/trunk/src/main/java/org/jboss/mctools/grapher/map/GraphLayoutMapping.java	2009-07-20 02:03:30 UTC (rev 91411)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.mctools.grapher.map;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.mctools.grapher.GrapherConstants;
+import org.jboss.mctools.grapher.layout.GraphLayout;
+import org.jboss.mctools.grapher.layout.ReflectionGraphLayout;
+
+/**
+ * Map simple name to full layout class name.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public final class GraphLayoutMapping
+{
+   private static final Map<String, String> map = new HashMap<String, String>();
+
+   static
+   {
+      // a ctor hack
+      map.put("simple0", "com.jgraph.layout.graph.JGraphSimpleLayout");
+      map.put("simple1", "com.jgraph.layout.graph.JGraphSimpleLayout");
+      map.put("simple2", "com.jgraph.layout.graph.JGraphSimpleLayout");
+
+      map.put("tree", "com.jgraph.layout.tree.JGraphTreeLayout");
+      map.put("spring", "com.jgraph.layout.graph.JGraphSpringLayout");
+      map.put("hierarchical", "com.jgraph.layout.hierarchical.JGrapHierarchicalhLayout");
+      map.put("compound", "com.jgraph.layout.graph.JGraphCompoundTreeLayout");
+      map.put("compact", "com.jgraph.layout.graph.JGraphCompactTreeLayout");
+      map.put("moen", "com.jgraph.layout.graph.JGraphMoenLayout");
+      map.put("radial", "com.jgraph.layout.graph.JGraphRadialTreeLayout");
+      map.put("annealing", "com.jgraph.layout.graph.JGraphAnnealingLayout");
+      map.put("fr", "com.jgraph.layout.graph.JGraphFRLayout");
+      map.put("organic", "com.jgraph.layout.organic.JGraphOrganicLayout");
+      map.put("self", "com.jgraph.layout.organic.JGraphSelfOrganizingOrganicLayout");
+      map.put("isom", "com.jgraph.layout.graph.JGraphISOMLayout");
+      map.put("org", "com.jgraph.layout.tree.OrganizationalLayout");
+   }
+
+   /**
+    * Get layout.
+    *
+    * @param key the layout key
+    * @return the layout
+    */
+   public static GraphLayout getLayout(String key)
+   {
+      if (key == null)
+         return GrapherConstants.LAYOUT;
+
+      String className = map.get(key);
+      if (className == null)
+         return GrapherConstants.LAYOUT;
+
+      // treat simple differently
+      if (key.startsWith("simple"))
+      {
+         int arg = Integer.parseInt(key.substring("simple".length()));
+         return new ReflectionGraphLayout(className, new Class<?>[]{int.class}, new Object[]{arg});
+      }
+      else
+      {
+         return new ReflectionGraphLayout(className);
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list