From b4522c6e3834a40113f423caa5493a5be669c091 Mon Sep 17 00:00:00 2001
From: Tim Molter <tim.molter@gmail.com>
Date: Wed, 20 Jul 2011 15:07:35 +0200
Subject: [PATCH] refactored build path

---
 .classpath                             |   2 +-
 {extlib => lib}/servlet-api.jar        | Bin
 src/com/xeiam/examples/Example1.java   |   6 ++--
 src/com/xeiam/examples/Example3.java   |   2 +-
 src/com/xeiam/swing/SwingWrapper.java  |  31 +++++++++++++----
 src/com/xeiam/xcharts/Chart.java       |   6 ++--
 src/com/xeiam/xcharts/JChartPanel.java |  44 -------------------------
 7 files changed, 33 insertions(+), 58 deletions(-)
 rename {extlib => lib}/servlet-api.jar (100%)
 delete mode 100644 src/com/xeiam/xcharts/JChartPanel.java

diff --git a/.classpath b/.classpath
index db747496..ee4c62bf 100644
--- a/.classpath
+++ b/.classpath
@@ -2,6 +2,6 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="lib" path="extlib/servlet-api.jar"/>
+	<classpathentry kind="lib" path="lib/servlet-api.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/extlib/servlet-api.jar b/lib/servlet-api.jar
similarity index 100%
rename from extlib/servlet-api.jar
rename to lib/servlet-api.jar
diff --git a/src/com/xeiam/examples/Example1.java b/src/com/xeiam/examples/Example1.java
index 29b096f6..4903089b 100644
--- a/src/com/xeiam/examples/Example1.java
+++ b/src/com/xeiam/examples/Example1.java
@@ -25,11 +25,11 @@ import com.xeiam.xcharts.Chart;
  */
 public class Example1 {
 
-    private static final double[] xData = { 0.0, 1.0, 2.0 };
-    private static final double[] yData = { 0.0, 1.0, 2.0 };
-
     public static void main(String[] args) {
 
+        double[] xData = { 0.0, 1.0, 2.0 };
+        double[] yData = { 0.0, 1.0, 2.0 };
+
         // Create Chart
         Chart chart = new Chart(500, 400);
         chart.setChartTitle("Sample Chart");
diff --git a/src/com/xeiam/examples/Example3.java b/src/com/xeiam/examples/Example3.java
index 5c4c2de1..293ac651 100644
--- a/src/com/xeiam/examples/Example3.java
+++ b/src/com/xeiam/examples/Example3.java
@@ -19,7 +19,7 @@ import com.xeiam.swing.SwingWrapper;
 import com.xeiam.xcharts.Chart;
 
 /**
- * Create 14 different curves on one chart
+ * Create multiple curves on one chart
  * 
  * @author timmolter
  */
diff --git a/src/com/xeiam/swing/SwingWrapper.java b/src/com/xeiam/swing/SwingWrapper.java
index 7424de6d..b2154aaf 100644
--- a/src/com/xeiam/swing/SwingWrapper.java
+++ b/src/com/xeiam/swing/SwingWrapper.java
@@ -15,6 +15,9 @@
  */
 package com.xeiam.swing;
 
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
 import java.awt.GridLayout;
 
 import javax.swing.BoxLayout;
@@ -22,7 +25,6 @@ import javax.swing.JFrame;
 import javax.swing.JPanel;
 
 import com.xeiam.xcharts.Chart;
-import com.xeiam.xcharts.JChartPanel;
 
 /**
  * @author timmolter
@@ -69,10 +71,8 @@ public class SwingWrapper {
                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
 
-                for (int i = 0; i < charts.length; i++) {
-                    JPanel chartPanel = new JChartPanel(charts[i]);
-                    frame.getContentPane().add(chartPanel);
-                }
+                JPanel chartPanel = new ChartJPanel(charts[0]);
+                frame.getContentPane().add(chartPanel);
 
                 // Display the window.
                 frame.pack();
@@ -99,7 +99,7 @@ public class SwingWrapper {
                 for (int i = 0; i < charts.length; i++) {
 
                     if (charts[i] != null) {
-                        JPanel chartPanel = new JChartPanel(charts[i]);
+                        JPanel chartPanel = new ChartJPanel(charts[i]);
                         frame.getContentPane().add(chartPanel);
                     } else {
                         JPanel chartPanel = new JPanel();
@@ -114,4 +114,23 @@ public class SwingWrapper {
             }
         });
     }
+
+    private class ChartJPanel extends JPanel {
+
+        private Chart chart;
+
+        public ChartJPanel(Chart chart) {
+            this.chart = chart;
+        }
+
+        @Override
+        public void paint(Graphics g) {
+            chart.paint((Graphics2D) g);
+        }
+
+        @Override
+        public Dimension getPreferredSize() {
+            return new Dimension(chart.getWidth(), chart.getHeight());
+        }
+    }
 }
diff --git a/src/com/xeiam/xcharts/Chart.java b/src/com/xeiam/xcharts/Chart.java
index dd44967e..f93caa87 100644
--- a/src/com/xeiam/xcharts/Chart.java
+++ b/src/com/xeiam/xcharts/Chart.java
@@ -69,13 +69,13 @@ public class Chart {
 
     }
 
-    // INTERNAL GETTERS & SETTERS
+    // GETTERS & SETTERS
 
-    protected int getWidth() {
+    public int getWidth() {
         return width;
     }
 
-    protected int getHeight() {
+    public int getHeight() {
         return height;
     }
 
diff --git a/src/com/xeiam/xcharts/JChartPanel.java b/src/com/xeiam/xcharts/JChartPanel.java
deleted file mode 100644
index 946cf3c6..00000000
--- a/src/com/xeiam/xcharts/JChartPanel.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2011 Xeiam LLC.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.xeiam.xcharts;
-
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-
-import javax.swing.JPanel;
-
-/**
- * @author timmolter
- */
-public class JChartPanel extends JPanel {
-
-    private Chart chart;
-
-    public JChartPanel(Chart pChart) {
-        chart = pChart;
-    }
-
-    @Override
-    public void paint(Graphics graphics) {
-        chart.paint((Graphics2D) graphics);
-    }
-
-    @Override
-    public Dimension getPreferredSize() {
-        return new Dimension(chart.getWidth(), chart.getHeight());
-    }
-}
-- 
GitLab