Skip to content
Snippets Groups Projects
Commit b4522c6e authored by Tim Molter's avatar Tim Molter
Browse files

refactored build path

parent 32776713
Branches
Tags
No related merge requests found
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <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="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"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>
File moved
...@@ -25,11 +25,11 @@ import com.xeiam.xcharts.Chart; ...@@ -25,11 +25,11 @@ import com.xeiam.xcharts.Chart;
*/ */
public class Example1 { 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) { public static void main(String[] args) {
double[] xData = { 0.0, 1.0, 2.0 };
double[] yData = { 0.0, 1.0, 2.0 };
// Create Chart // Create Chart
Chart chart = new Chart(500, 400); Chart chart = new Chart(500, 400);
chart.setChartTitle("Sample Chart"); chart.setChartTitle("Sample Chart");
......
...@@ -19,7 +19,7 @@ import com.xeiam.swing.SwingWrapper; ...@@ -19,7 +19,7 @@ import com.xeiam.swing.SwingWrapper;
import com.xeiam.xcharts.Chart; import com.xeiam.xcharts.Chart;
/** /**
* Create 14 different curves on one chart * Create multiple curves on one chart
* *
* @author timmolter * @author timmolter
*/ */
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
*/ */
package com.xeiam.swing; package com.xeiam.swing;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout; import java.awt.GridLayout;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
...@@ -22,7 +25,6 @@ import javax.swing.JFrame; ...@@ -22,7 +25,6 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import com.xeiam.xcharts.Chart; import com.xeiam.xcharts.Chart;
import com.xeiam.xcharts.JChartPanel;
/** /**
* @author timmolter * @author timmolter
...@@ -69,10 +71,8 @@ public class SwingWrapper { ...@@ -69,10 +71,8 @@ public class SwingWrapper {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
for (int i = 0; i < charts.length; i++) { JPanel chartPanel = new ChartJPanel(charts[0]);
JPanel chartPanel = new JChartPanel(charts[i]);
frame.getContentPane().add(chartPanel); frame.getContentPane().add(chartPanel);
}
// Display the window. // Display the window.
frame.pack(); frame.pack();
...@@ -99,7 +99,7 @@ public class SwingWrapper { ...@@ -99,7 +99,7 @@ public class SwingWrapper {
for (int i = 0; i < charts.length; i++) { for (int i = 0; i < charts.length; i++) {
if (charts[i] != null) { if (charts[i] != null) {
JPanel chartPanel = new JChartPanel(charts[i]); JPanel chartPanel = new ChartJPanel(charts[i]);
frame.getContentPane().add(chartPanel); frame.getContentPane().add(chartPanel);
} else { } else {
JPanel chartPanel = new JPanel(); JPanel chartPanel = new JPanel();
...@@ -114,4 +114,23 @@ public class SwingWrapper { ...@@ -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());
}
}
} }
...@@ -69,13 +69,13 @@ public class Chart { ...@@ -69,13 +69,13 @@ public class Chart {
} }
// INTERNAL GETTERS & SETTERS // GETTERS & SETTERS
protected int getWidth() { public int getWidth() {
return width; return width;
} }
protected int getHeight() { public int getHeight() {
return height; return height;
} }
......
/**
* 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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment