[overlord-commits] Overlord SVN: r174 - in sam/trunk/modules/fx/src/main/java: org and 5 other directories.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Wed Jul 16 06:47:43 EDT 2008


Author: heiko.braun at jboss.com
Date: 2008-07-16 06:47:43 -0400 (Wed, 16 Jul 2008)
New Revision: 174

Added:
   sam/trunk/modules/fx/src/main/java/org/
   sam/trunk/modules/fx/src/main/java/org/jboss/
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/Chart.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartBuilder.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMapping.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistry.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistryFactory.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMetadata.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServer.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServerFactory.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/PropertyMapping.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/BarChartBuilder.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/JFreeChartImpl.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/LineChartBuilder.java
   sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/PieChartBuilder.java
Removed:
   sam/trunk/modules/fx/src/main/java/java/
Log:
Cleanup fx module

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/Chart.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/Chart.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/Chart.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+import java.io.OutputStream;
+
+/**
+ * A chart repesentation.<br>
+ * Can be an in-memory representation or a link to a physical
+ * artifact (caching).
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface Chart<T>
+{
+   String getName();
+      
+   void writeTo(OutputStream out);
+
+   T getUnderlying();
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/Chart.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartBuilder.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartBuilder.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartBuilder.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+import org.jboss.sam.EventMessage;
+
+/**
+ * Builds charts from payload and mapping information.
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface ChartBuilder
+{
+   ChartMetadata getMetadata();
+   
+   Chart buildChart(EventMessage[] events, ChartMapping mapping);
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartBuilder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMapping.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMapping.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMapping.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+import java.util.Collections;
+import java.util.List;
+import java.io.Serializable;
+
+/**
+ * An immutable mapping of index and data values,
+ * that can be passed to a {@link org.jboss.sam.chart.ChartBuilder} to construct
+ * {@link org.jboss.sam.chart.Chart}'s. Each instance is identifed by an alias name
+ * and will be maintained through a {@link ChartMappingRegistry}.
+ * <p>
+ * ChartMappings should be created once and reused.
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public final class ChartMapping implements Serializable
+{
+   String aliasName;
+
+   List<PropertyMapping> indexMappings;
+
+   List<PropertyMapping> propertyMappings;
+
+   public ChartMapping(String aliasName, List<PropertyMapping> indexMappings, List<PropertyMapping> propertyMappings)
+   {
+      this.aliasName = aliasName;
+      this.indexMappings = Collections.unmodifiableList(indexMappings);
+      this.propertyMappings = Collections.unmodifiableList(propertyMappings);
+   }
+
+   String getAliasName()
+   {
+      return this.aliasName;   
+   }
+
+   /**
+    * Returns an immutable index mapping for a key.
+    * The key is specified in {@link org.jboss.sam.chart.ChartMetadata}
+    * @return
+    */
+   public PropertyMapping getIndexMapping(String key)
+   {
+      PropertyMapping indexMapping = resolveKey(key, indexMappings);
+      if(null==indexMapping)
+         throw new IllegalArgumentException("Failed to resolved index mapping by key: "+ key);
+
+      return indexMapping;
+   }
+
+   /**
+    * Returns an immutable data mapping
+    * @return
+    */
+   public PropertyMapping getPropertyMapping(String key)
+   {
+      PropertyMapping dataMapping = resolveKey(key, propertyMappings);
+      if(null==dataMapping)
+         throw new IllegalArgumentException("Failed to resolved data mapping by key: "+ key);
+
+      return dataMapping;
+   }
+
+   private PropertyMapping resolveKey(String key, List<PropertyMapping> mappings)
+   {
+      PropertyMapping mapping = null;
+      for(PropertyMapping index : mappings)
+      {
+         if(index.getTargetKey().equals(key))
+         {
+            mapping = index;
+            break;
+         }
+      }
+
+      return mapping;
+   }
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMapping.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistry.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistry.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistry.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+/**
+ * Maintains {@link ChartMapping}'s.
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface ChartMappingRegistry
+{
+   void registerChartMapping(ChartMapping chartMaping);
+
+   ChartMapping getChartMapping(String aliasName);
+   
+   void clearChartMapping(String aliasName);
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistry.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistryFactory.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistryFactory.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistryFactory.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public abstract class ChartMappingRegistryFactory
+{
+   abstract ChartMappingRegistry createChartMappingRegistry();
+
+   public static ChartMappingRegistryFactory newInstance()
+   {
+      return new DefaultChartMappingRegistryFactory();
+   }
+
+   static class DefaultChartMappingRegistryFactory extends ChartMappingRegistryFactory
+   {
+
+      ChartMappingRegistry createChartMappingRegistry()
+      {
+         throw new RuntimeException("Not implemented");
+      }
+   }
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMappingRegistryFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMetadata.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMetadata.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMetadata.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+import java.util.Iterator;
+
+/**
+ * Metadata for chart types associated with a {@link org.jboss.sam.chart.ChartBuilder}
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface ChartMetadata
+{
+   String getTypeName();
+
+   Iterator<String> getSupportedIndexNames();
+
+   Iterator<String> getSupportedPropertyNames();
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartMetadata.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServer.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServer.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServer.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+import org.jboss.sam.EventMessage;
+
+/**
+ * Allows creation and retrieval of {@link org.jboss.sam.chart.Chart} repesentations.
+ * A chart server will be associated with a {@link org.jboss.sam.chart.ChartMappingRegistry} that stores
+ * the preconfigured mappings.
+ *  
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public interface ChartServer
+{
+   /**
+    * Get chart by name
+    * @param chartName
+    * @return
+    */
+   Chart getChart(String chartName);
+
+   /**
+    * Create a new chart under a given name
+    * @param chartName
+    * @param payloads
+    * @return
+    */
+   Chart createChart(String chartName, String chartMappingAlias, EventMessage[] payloads);
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServerFactory.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServerFactory.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServerFactory.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public abstract class ChartServerFactory
+{
+   abstract ChartServer createChartServer();
+
+   public static ChartServerFactory newInstance()
+   {
+      return new DefaultChartServerFactory();
+   }
+
+   static class DefaultChartServerFactory extends ChartServerFactory
+   {
+      ChartServer createChartServer()
+      {
+         throw new RuntimeException("Not implemented");
+      }
+   }
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/ChartServerFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/PropertyMapping.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/PropertyMapping.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/PropertyMapping.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart;
+
+import org.jboss.sam.EventMessage;
+
+import java.io.Serializable;
+
+/**
+ * Maps {@link org.jboss.sam.EventMessage} properties
+ * to chart attributes, like X-Axis and Y-Axis values.<br>
+ * Supports constants.
+ *
+ * @see org.jboss.sam.chart.ChartMapping
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public final class PropertyMapping implements Serializable
+{
+   /**
+    * The key to which a mapped property will be assigned
+    */
+   private String targetKey;
+
+   /**
+    * Name of the mapped {@link org.jboss.sam.EventMessage} property
+    */
+   private String sourcePropertyName;
+   
+   private String constantValue = null;
+  
+   public PropertyMapping(String targetKey, String sourcePropertyName)
+   {
+      this.targetKey = targetKey;
+      this.sourcePropertyName = sourcePropertyName;
+   }
+
+   public String getTargetKey()
+   {
+      return targetKey;
+   }
+
+   public PropertyMapping constant(String constant)
+   {
+      this.constantValue = constant.intern();
+      return this;
+   }
+
+   /**
+    * Retrieve an {@link org.jboss.sam.EventMessage} value
+    * by mapping to {@link #sourcePropertyName}
+    * @param payload
+    * @return
+    */
+   public Object map(EventMessage payload)
+   {
+      Object mapping;
+      if(null==constantValue)
+         mapping = payload.getProperty(sourcePropertyName);
+      else
+         mapping = constantValue;
+
+      return mapping;
+   }
+
+
+   public String toString()
+   {
+      String prop = sourcePropertyName != null ? sourcePropertyName : "CONSTANT";
+      return targetKey +"->"+prop;
+   }
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/PropertyMapping.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/BarChartBuilder.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/BarChartBuilder.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/BarChartBuilder.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart.internal.jfree;
+
+import org.jboss.sam.EventMessage;
+import org.jboss.sam.chart.Chart;
+import org.jboss.sam.chart.ChartBuilder;
+import org.jboss.sam.chart.ChartMapping;
+import org.jboss.sam.chart.ChartMetadata;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class BarChartBuilder implements ChartBuilder
+{
+   private String chartTitle;
+   private String domainAxisLabel, rangeAxisLabel;
+
+   public final static String INDEX_1 = "series";
+   public final static String INDEX_2 = "x_value";
+   public final static String PROP_1 = "y_value";
+
+   public static List<String> INDEXES = new ArrayList<String>();
+   public static List<String> PROPS = new ArrayList<String>();
+
+   static
+   {
+      INDEXES.add(INDEX_1);
+      INDEXES.add(INDEX_2);
+
+      PROPS.add(PROP_1);
+   }
+   
+   public BarChartBuilder(String chartTitle, String domainAxisLabel, String rangeAxisLabel)
+   {
+      this.chartTitle = chartTitle;
+      this.domainAxisLabel = domainAxisLabel;
+      this.rangeAxisLabel = rangeAxisLabel;
+   }
+
+   public ChartMetadata getMetadata()
+   {
+      return new ChartMetadata() {
+
+         public String getTypeName()
+         {
+            return "BarChart"; 
+         }
+
+         public Iterator<String> getSupportedIndexNames()
+         {
+            return INDEXES.iterator();
+         }
+
+         public Iterator<String> getSupportedPropertyNames()
+         {
+            return PROPS.iterator(); 
+         }
+      };
+   }
+
+   public Chart buildChart(EventMessage[] events, ChartMapping mapping)
+   {
+      CategoryDataset dataset = createDataset(events, mapping);
+
+      JFreeChart chart = org.jfree.chart.ChartFactory.createBarChart(
+        chartTitle,               // chart title
+        domainAxisLabel,          // domain axis label
+        rangeAxisLabel,           // range axis label
+        dataset,                  // data
+        PlotOrientation.VERTICAL,
+        true,                     // include legend
+        true,                     // tooltips?
+        false                     // URLs?
+      );
+
+      //customize(chart);
+
+      return new JFreeChartImpl(chart);
+   }
+
+   private CategoryDataset createDataset(EventMessage[] payloads, ChartMapping mapping)
+   {
+      DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+
+      for(EventMessage event : payloads)
+      {
+         Number number = (Number) (mapping.getPropertyMapping(PROP_1)).map(event);
+         Comparable c1 = (Comparable) (mapping.getIndexMapping(INDEX_1)).map(event);
+         Comparable c2 = (Comparable) (mapping.getIndexMapping(INDEX_2)).map(event);
+         dataset.addValue(
+           number,      // value
+           c1,          // seriesName
+           c2           // category
+         );         
+      }            
+
+      return dataset;
+   }
+
+   /**
+    * Example customization
+    *
+    * @todo Create common look and feel
+    *
+    * @param chart
+    */
+   /*private void customize(JFreeChart chart)
+   {
+      // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
+      // set the background color for the chart...
+      chart.setBackgroundPaint(new Color(0xBBBBDD));
+      // get a reference to the plot for further customisation...
+      CategoryPlot plot = chart.getCategoryPlot();
+      // set the range axis to display integers only...
+      NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
+      rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
+      // disable bar outlines...
+      BarRenderer renderer = (BarRenderer) plot.getRenderer();
+      renderer.setCreateEntities(true);
+
+      // set up gradient paints for series...
+      GradientPaint gp0 = new GradientPaint(
+        0.0f, 0.0f, Color.blue,
+        0.0f, 0.0f, Color.lightGray
+      );
+      GradientPaint gp1 = new GradientPaint(
+        0.0f, 0.0f, Color.green,
+        0.0f, 0.0f, Color.lightGray
+      );
+      GradientPaint gp2 = new GradientPaint(
+        0.0f, 0.0f, Color.red,
+        0.0f, 0.0f, Color.lightGray
+      );
+      renderer.setSeriesPaint(0, gp0);
+      renderer.setSeriesPaint(1, gp1);
+      renderer.setSeriesPaint(2, gp2);
+
+      // OPTIONAL CUSTOMISATION COMPLETED.
+   } */
+
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/BarChartBuilder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/JFreeChartImpl.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/JFreeChartImpl.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/JFreeChartImpl.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart.internal.jfree;
+
+import org.jboss.sam.chart.Chart;
+import org.jboss.sam.chart.ChartMetadata;
+import org.jfree.chart.JFreeChart;
+
+import java.io.OutputStream;
+import java.util.UUID;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class JFreeChartImpl implements Chart<JFreeChart>
+{
+   private ChartMetadata metadata;
+
+   private JFreeChart delegate;
+
+   private String name;
+
+   public JFreeChartImpl(String name, JFreeChart delegate)
+   {
+      this.name = name;
+      this.delegate = delegate;
+   }
+
+   public JFreeChartImpl(JFreeChart delegate)
+   {
+      this(UUID.randomUUID().toString(), delegate);
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void writeTo(OutputStream out)
+   {
+      throw new RuntimeException("Not implemented");
+   }
+
+   public JFreeChart getUnderlying()
+   {
+      return delegate;
+   }
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/JFreeChartImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/LineChartBuilder.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/LineChartBuilder.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/LineChartBuilder.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart.internal.jfree;
+
+import org.jboss.sam.EventMessage;
+import org.jboss.sam.chart.Chart;
+import org.jboss.sam.chart.ChartBuilder;
+import org.jboss.sam.chart.ChartMapping;
+import org.jboss.sam.chart.ChartMetadata;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+
+import java.util.Iterator;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class LineChartBuilder implements ChartBuilder
+{
+   private String chartTitle;
+   private String xAxisLabel,yAxisLabel;
+
+   public final static String INDEX_1 = "series";
+   public final static String INDEX_2 = "x_value";
+   public final static String DATA_1 = "y_value";
+
+   public LineChartBuilder(String chartTitle, String xAxisLabel, String yAxisLabel)
+   {
+      this.chartTitle = chartTitle;
+      this.xAxisLabel = xAxisLabel;
+      this.yAxisLabel = yAxisLabel;
+   }
+
+   public ChartMetadata getMetadata()
+   {
+      return null;
+   }
+
+   public Chart buildChart(EventMessage[] events, ChartMapping mapping)
+   {
+      XYSeriesCollection dataset = createDataset(events, mapping);
+
+      JFreeChart chart = ChartFactory.createXYLineChart(
+        chartTitle,      // chart title
+        xAxisLabel,                      // x axis label
+        yAxisLabel,                      // y axis label
+        dataset,                  // data
+        PlotOrientation.VERTICAL,
+        true,                     // include legend
+        true,                     // tooltips
+        false                     // urls
+      );
+
+      return new JFreeChartImpl(chart);
+   }
+
+   private XYSeriesCollection createDataset(EventMessage[] events, ChartMapping mapping)
+   {
+
+      XYSeriesCollection dataset = new XYSeriesCollection();
+
+      for(EventMessage event : events)
+      {
+         XYSeries series = getOrCreateSeries(
+           dataset,
+           (String)mapping.getIndexMapping(INDEX_1).map(event)
+         );
+         series.add(
+           (Double)mapping.getIndexMapping(INDEX_2).map(event),
+           (Double)mapping.getPropertyMapping(DATA_1).map(event)
+         );
+      }
+
+      return dataset;
+   }
+
+   private XYSeries getOrCreateSeries(XYSeriesCollection dataset, Comparable key)
+   {
+      XYSeries match = null;
+      Iterator it = dataset.getSeries().iterator();
+      while(it.hasNext())
+      {
+         XYSeries series = (XYSeries)it.next();
+         if(series.getKey().equals(key))
+         {
+            match = series;
+            break;
+         }
+      }
+
+      if(null==match)
+      {
+         match = new XYSeries(key);
+         dataset.addSeries(match);
+      }
+
+      return match;
+   }
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/LineChartBuilder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/PieChartBuilder.java
===================================================================
--- sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/PieChartBuilder.java	                        (rev 0)
+++ sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/PieChartBuilder.java	2008-07-16 10:47:43 UTC (rev 174)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.sam.chart.internal.jfree;
+
+import org.jboss.sam.EventMessage;
+import org.jboss.sam.chart.Chart;
+import org.jboss.sam.chart.ChartBuilder;
+import org.jboss.sam.chart.ChartMapping;
+import org.jboss.sam.chart.ChartMetadata;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.data.general.DefaultPieDataset;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class PieChartBuilder implements ChartBuilder
+{
+   private String chartName;
+   //private DefaultPieDataset dataset;
+
+   public final static String INDEX_1 = "category";
+   public final static String DATA_1 = "percentage";
+   
+   public PieChartBuilder(String chartName)
+   {
+      this.chartName = chartName;
+   }
+
+
+   public ChartMetadata getMetadata()
+   {
+      return null;  
+   }
+
+   public Chart buildChart(EventMessage[] events, ChartMapping mapping)
+   {
+      DefaultPieDataset dataset = createDataset(events, mapping);
+      
+      JFreeChart chart = ChartFactory.createPieChart(
+          chartName,
+          dataset,
+          true,    // legend?
+          true,    // tooltips?
+          false    // URLs?
+      );
+
+      return new JFreeChartImpl(chart);
+   }
+
+   private DefaultPieDataset createDataset(EventMessage[] events, ChartMapping mapping)
+   {
+      DefaultPieDataset dataset = new DefaultPieDataset();
+
+      for(EventMessage event : events)
+      {
+         dataset.setValue(
+           (String)mapping.getIndexMapping(INDEX_1).map(event),   // category
+           (Double)mapping.getPropertyMapping(DATA_1).map(event)      // percentage
+         );
+      }
+
+      return dataset;
+   }
+}


Property changes on: sam/trunk/modules/fx/src/main/java/org/jboss/sam/chart/internal/jfree/PieChartBuilder.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the overlord-commits mailing list