You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/03/16 17:16:58 UTC
svn commit: r754926 [2/38] - in /incubator/pivot/tags/v1.0: ./ charts-test/
charts-test/src/ charts-test/src/pivot/ charts-test/src/pivot/charts/
charts-test/src/pivot/charts/test/ charts/ charts/lib/ charts/src/
charts/src/pivot/ charts/src/pivot/char...
Added: incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/area_charts.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/area_charts.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/area_charts.wtkx (added)
+++ incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/area_charts.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+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.
+-->
+
+<TabPane tabOrientation="vertical" selectedIndex="0"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008"
+ xmlns:collections="pivot.collections"
+ xmlns:content="pivot.charts.content" xmlns:charts="pivot.charts"
+ xmlns="pivot.wtk">
+ <tabs>
+ <charts:AreaChartView wtkx:id="categoryAreaChartView" TabPane.name="Category"
+ seriesNameKey="name" title="Category Area Chart Example"
+ horizontalAxisLabel="Categories" verticalAxisLabel="Values"
+ showLegend="true">
+ <categories>
+ <charts:ChartView.Category key="a" label="A"/>
+ <charts:ChartView.Category key="b" label="B"/>
+ <charts:ChartView.Category key="c" label="C"/>
+ <charts:ChartView.Category key="d" label="D"/>
+ <charts:ChartView.Category key="e" label="E"/>
+ </categories>
+
+ <chartData>
+ <collections:ArrayList>
+ <content:CategorySeries name="Example Series 1" a="43.2" b="27.9" c="79.5" d="10.0" e="20.2"/>
+ <content:CategorySeries name="Example Series 2" a="27.9" b="43.2" c="79.5" d="19.0" e="31.6"/>
+ <content:CategorySeries name="Example Series 3" a="79.5" b="27.9" c="43.2" d="50.3" e="81.9"/>
+ </collections:ArrayList>
+ </chartData>
+ </charts:AreaChartView>
+
+ <charts:AreaChartView wtkx:id="xyAreaChartView" TabPane.name="XY"
+ seriesNameKey="name" title="XY Area Chart Example"
+ horizontalAxisLabel="X" verticalAxisLabel="Y">
+ <chartData>
+ <collections:ArrayList>
+ <content:ValueSeries name="Example Series 1">
+ <content:Point x="1.0" y="1.0"/>
+ <content:Point x="2.0" y="4.0"/>
+ <content:Point x="3.0" y="3.0"/>
+ <content:Point x="4.0" y="5.0"/>
+ </content:ValueSeries>
+ <content:ValueSeries name="Example Series 2">
+ <content:Point x="1.0" y="5.0"/>
+ <content:Point x="2.0" y="7.0"/>
+ <content:Point x="3.0" y="6.0"/>
+ <content:Point x="4.0" y="8.0"/>
+ </content:ValueSeries>
+ <content:ValueSeries name="Example Series 3">
+ <content:Point x="3.0" y="4.0"/>
+ <content:Point x="4.0" y="3.0"/>
+ <content:Point x="5.0" y="2.0"/>
+ <content:Point x="6.0" y="3.0"/>
+ </content:ValueSeries>
+ </collections:ArrayList>
+ </chartData>
+ </charts:AreaChartView>
+ </tabs>
+</TabPane>
Added: incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/bar_charts.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/bar_charts.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/bar_charts.wtkx (added)
+++ incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/bar_charts.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+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.
+-->
+
+<TabPane tabOrientation="vertical" selectedIndex="0"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008"
+ xmlns:collections="pivot.collections"
+ xmlns:content="pivot.charts.content" xmlns:charts="pivot.charts"
+ xmlns="pivot.wtk">
+ <tabs>
+ <charts:BarChartView wtkx:id="categoryBarChartView" TabPane.name="Category"
+ seriesNameKey="name" title="Category Bar Chart Example"
+ horizontalAxisLabel="Categories" verticalAxisLabel="Values"
+ showLegend="true"
+ styles="{stacked:true, threeDimensional:true}">
+ <categories>
+ <charts:ChartView.Category key="a" label="A"/>
+ <charts:ChartView.Category key="b" label="B"/>
+ <charts:ChartView.Category key="c" label="C"/>
+ </categories>
+
+ <chartData>
+ <collections:ArrayList>
+ <content:CategorySeries name="Example Series 1" a="43.2" b="27.9" c="79.5"/>
+ <content:CategorySeries name="Example Series 2" a="27.9" b="43.2" c="79.5"/>
+ <content:CategorySeries name="Example Series 3" a="79.5" b="27.9" c="43.2"/>
+ </collections:ArrayList>
+ </chartData>
+ </charts:BarChartView>
+
+ <charts:BarChartView wtkx:id="xyBarChartView" TabPane.name="XY"
+ seriesNameKey="name" title="XY Bar Chart Example"
+ horizontalAxisLabel="X" verticalAxisLabel="Y">
+ <chartData>
+ <collections:ArrayList>
+ <content:ValueSeries name="Example Series 1">
+ <content:Interval x="1.0" y="1.0" width="2"/>
+ <content:Interval x="2.0" y="4.0" width="1"/>
+ <content:Interval x="3.0" y="3.0" width="3"/>
+ <content:Interval x="4.0" y="5.0" width="1"/>
+ </content:ValueSeries>
+ <content:ValueSeries name="Example Series 2">
+ <content:Interval x="1.0" y="5.0" width="2"/>
+ <content:Interval x="2.0" y="7.0" width="2"/>
+ <content:Interval x="3.0" y="6.0" width="2"/>
+ <content:Interval x="4.0" y="8.0" width="1"/>
+ </content:ValueSeries>
+ <content:ValueSeries name="Example Series 3">
+ <content:Interval x="3.0" y="4.0" width="1"/>
+ <content:Interval x="4.0" y="3.0" width="2"/>
+ <content:Interval x="5.0" y="2.0" width="1"/>
+ <content:Interval x="6.0" y="3.0" width="1"/>
+ </content:ValueSeries>
+ </collections:ArrayList>
+ </chartData>
+ </charts:BarChartView>
+ </tabs>
+</TabPane>
Added: incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/charts_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/charts_test.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/charts_test.wtkx (added)
+++ incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/charts_test.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+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.
+-->
+
+<TabPane selectedIndex="0"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008"
+ xmlns="pivot.wtk" xmlns:charts="pivot.charts">
+ <tabs>
+ <wtkx:include src="pie_charts.wtkx" namespace="pieCharts" TabPane.name="Pie Chart"/>
+ <wtkx:include src="bar_charts.wtkx" namespace="barCharts" TabPane.name="Bar Chart"/>
+ <wtkx:include src="line_charts.wtkx" namespace="lineCharts" TabPane.name="Line Chart"/>
+ <wtkx:include src="area_charts.wtkx" namespace="areaCharts" TabPane.name="Area Chart"/>
+ <wtkx:include src="high_low_charts.wtkx" namespace="highLowCharts" TabPane.name="High Low Chart"/>
+ </tabs>
+</TabPane>
+
+
Added: incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/high_low_charts.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/high_low_charts.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/high_low_charts.wtkx (added)
+++ incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/high_low_charts.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+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.
+-->
+
+<charts:HighLowChartView wtkx:id="highLowChartView"
+ seriesNameKey="name" title="High Low Chart Example"
+ horizontalAxisLabel="Date" verticalAxisLabel="Value"
+ styles="{candlestick:true}"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008"
+ xmlns:collections="pivot.collections"
+ xmlns:content="pivot.charts.content" xmlns:charts="pivot.charts"
+ xmlns="pivot.wtk">
+ <chartData>
+ <collections:ArrayList>
+ <content:ValueSeries name="Example Series 1">
+ <content:Candlestick date="8/26/2008" open="155.84" high="178.50" low="155.84" close="165.00"/>
+ <content:Candlestick date="8/27/2008" open="172.84" high="173.50" low="169.04" close="174.00"/>
+ <content:Candlestick date="8/28/2008" open="170.44" high="176.50" low="162.04" close="173.00"/>
+ <content:Candlestick date="8/29/2008" open="155.84" high="178.50" low="155.84" close="165.00"/>
+ <content:Candlestick date="8/30/2008" open="172.33" high="175.50" low="166.04" close="172.00"/>
+ <content:Candlestick date="8/31/2008" open="155.84" high="178.50" low="155.84" close="165.00"/>
+ </content:ValueSeries>
+ </collections:ArrayList>
+ </chartData>
+</charts:HighLowChartView>
Added: incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/line_charts.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/line_charts.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/line_charts.wtkx (added)
+++ incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/line_charts.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+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.
+-->
+
+<TabPane tabOrientation="vertical" selectedIndex="0"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008"
+ xmlns:collections="pivot.collections"
+ xmlns:content="pivot.charts.content" xmlns:charts="pivot.charts"
+ xmlns="pivot.wtk">
+ <tabs>
+ <charts:LineChartView wtkx:id="categoryLineChartView" TabPane.name="Category"
+ seriesNameKey="name" title="Category Line Chart Example"
+ horizontalAxisLabel="Categories" verticalAxisLabel="Values"
+ showLegend="false"
+ styles="{threeDimensional:true}">
+ <categories>
+ <charts:ChartView.Category key="a" label="A"/>
+ <charts:ChartView.Category key="b" label="B"/>
+ <charts:ChartView.Category key="c" label="C"/>
+ <charts:ChartView.Category key="d" label="D"/>
+ <charts:ChartView.Category key="e" label="E"/>
+ </categories>
+
+ <chartData>
+ <collections:ArrayList>
+ <content:CategorySeries name="Example Series 1" a="43.2" b="27.9" c="79.5" d="10.0" e="20.2"/>
+ <content:CategorySeries name="Example Series 2" a="27.9" b="43.2" c="79.5" d="19.0" e="31.6"/>
+ <content:CategorySeries name="Example Series 3" a="79.5" b="27.9" c="43.2" d="50.3" e="81.9"/>
+ </collections:ArrayList>
+ </chartData>
+ </charts:LineChartView>
+
+ <charts:LineChartView wtkx:id="xyLineChartView" TabPane.name="XY"
+ seriesNameKey="name" title="XY Line Chart Example"
+ horizontalAxisLabel="X" verticalAxisLabel="Y">
+ <chartData>
+ <collections:ArrayList>
+ <content:ValueSeries name="Example Series 1">
+ <content:Point x="1.0" y="1.0"/>
+ <content:Point x="2.0" y="4.0"/>
+ <content:Point x="3.0" y="3.0"/>
+ <content:Point x="4.0" y="5.0"/>
+ </content:ValueSeries>
+ <content:ValueSeries name="Example Series 2">
+ <content:Point x="1.0" y="5.0"/>
+ <content:Point x="2.0" y="7.0"/>
+ <content:Point x="3.0" y="6.0"/>
+ <content:Point x="4.0" y="8.0"/>
+ </content:ValueSeries>
+ <content:ValueSeries name="Example Series 3">
+ <content:Point x="3.0" y="4.0"/>
+ <content:Point x="4.0" y="3.0"/>
+ <content:Point x="5.0" y="2.0"/>
+ <content:Point x="6.0" y="3.0"/>
+ </content:ValueSeries>
+ </collections:ArrayList>
+ </chartData>
+ </charts:LineChartView>
+ </tabs>
+</TabPane>
Added: incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/pie_charts.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/pie_charts.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/pie_charts.wtkx (added)
+++ incubator/pivot/tags/v1.0/charts-test/src/pivot/charts/test/pie_charts.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+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.
+-->
+
+<charts:PieChartView wtkx:id="pieChartView"
+ seriesNameKey="name" title="Pie Chart Example"
+ styles="{explodePercentages:{a:0.30}}"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008"
+ xmlns:collections="pivot.collections"
+ xmlns:content="pivot.charts.content" xmlns:charts="pivot.charts"
+ xmlns="pivot.wtk">
+ <categories>
+ <charts:ChartView.Category key="a" label="A"/>
+ <charts:ChartView.Category key="b" label="B"/>
+ <charts:ChartView.Category key="c" label="C"/>
+ </categories>
+
+ <chartData>
+ <collections:ArrayList>
+ <content:CategorySeries name="Example Series 1" a="43.2" b="27.9" c="79.5"/>
+ </collections:ArrayList>
+ </chartData>
+</charts:PieChartView>
Added: incubator/pivot/tags/v1.0/charts/.classpath
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/.classpath?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/.classpath (added)
+++ incubator/pivot/tags/v1.0/charts/.classpath Mon Mar 16 16:16:40 2009
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/wtk"/>
+ <classpathentry kind="lib" path="lib/jcommon-1.0.12.jar"/>
+ <classpathentry kind="lib" path="lib/jfreechart-1.0.9.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: incubator/pivot/tags/v1.0/charts/.project
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/.project?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/.project (added)
+++ incubator/pivot/tags/v1.0/charts/.project Mon Mar 16 16:16:40 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>charts</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: incubator/pivot/tags/v1.0/charts/lib/jcommon-1.0.12.jar
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/lib/jcommon-1.0.12.jar?rev=754926&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0/charts/lib/jcommon-1.0.12.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0/charts/lib/jfreechart-1.0.9.jar
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/lib/jfreechart-1.0.9.jar?rev=754926&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0/charts/lib/jfreechart-1.0.9.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/AreaChartView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/AreaChartView.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/AreaChartView.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/AreaChartView.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import pivot.charts.skin.AreaChartViewSkin;
+
+/**
+ * Presents chart data using an area plot.
+ *
+ * @author gbrown
+ */
+public class AreaChartView extends ChartView {
+ public AreaChartView() {
+ setSkin(new AreaChartViewSkin());
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/BarChartView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/BarChartView.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/BarChartView.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/BarChartView.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import pivot.charts.skin.BarChartViewSkin;
+
+/**
+ * Presents chart data using a bar plot.
+ *
+ * @author gbrown
+ */
+public class BarChartView extends ChartView {
+ public BarChartView() {
+ setSkin(new BarChartViewSkin());
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartView.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartView.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartView.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,497 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import java.util.Comparator;
+
+import pivot.collections.ArrayList;
+import pivot.collections.List;
+import pivot.collections.ListListener;
+import pivot.collections.Sequence;
+import pivot.util.ListenerList;
+import pivot.wtk.Component;
+
+/**
+ * Abstract base class for chart views.
+ *
+ * @author gbrown
+ */
+public abstract class ChartView extends Component {
+ /**
+ * Represents a chart category.
+ */
+ public static class Category {
+ private ChartView chartView = null;
+
+ private String key;
+ private String label;
+
+ public Category() {
+ this(null, null);
+ }
+
+ public Category(String key) {
+ this(key, key);
+ }
+
+ public Category(String key, String label) {
+ this.key = key;
+ this.label = label;
+ }
+
+ public ChartView getChartView() {
+ return chartView;
+ }
+
+ private void setChartView(ChartView chartView) {
+ this.chartView = chartView;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ if (key == null) {
+ throw new IllegalArgumentException("key is null.");
+ }
+
+ String previousKey = this.key;
+
+ if (previousKey != key) {
+ this.key = key;
+
+ if (chartView != null) {
+ chartView.chartViewCategoryListeners.categoryKeyChanged(chartView,
+ chartView.categories.indexOf(this), previousKey);
+ }
+ }
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ if (label == null) {
+ throw new IllegalArgumentException("label is null.");
+ }
+
+ String previousLabel = this.label;
+
+ if (previousLabel != label) {
+ this.label = label;
+
+ if (chartView != null) {
+ chartView.chartViewCategoryListeners.categoryLabelChanged(chartView,
+ chartView.categories.indexOf(this), previousLabel);
+ }
+ }
+ }
+ }
+
+ /**
+ * Represents an element of a chart, such as a bar or a pie wedge.
+ */
+ public static class Element {
+ private int seriesIndex;
+ private int elementIndex;
+
+ public Element(int seriesIndex, int elementIndex) {
+ this.seriesIndex = seriesIndex;
+ this.elementIndex = elementIndex;
+ }
+
+ /**
+ * Returns the element's series index.
+ *
+ * @return
+ * The element's series index.
+ */
+ public int getSeriesIndex() {
+ return seriesIndex;
+ }
+
+ /**
+ * Returns the element's index within its series. For a category series,
+ * the element index represents the index of the category in the
+ * category sequence. Otherwise, it represents the index of the item
+ * within the series.
+ *
+ * @return
+ * The element index.
+ */
+ public int getElementIndex() {
+ return elementIndex;
+ }
+
+ public String toString() {
+ String string = getClass().getName()
+ + seriesIndex + ", " + elementIndex;
+ return string;
+ }
+ }
+
+ /**
+ * Chart view skin interface.
+ */
+ public interface Skin {
+ public Element getElementAt(int x, int y);
+ }
+
+ /**
+ * Internal class for managing the chart's category list.
+ */
+ public final class CategorySequence implements Sequence<Category> {
+ public int add(Category category) {
+ int i = getLength();
+ insert(category, i);
+
+ return i;
+ }
+
+ public void insert(Category category, int index) {
+ if (category == null) {
+ throw new IllegalArgumentException("category is null.");
+ }
+
+ if (category.getChartView() != null) {
+ throw new IllegalArgumentException("category is already in use by another chart view.");
+ }
+
+ categories.insert(category, index);
+ category.setChartView(ChartView.this);
+
+ chartViewCategoryListeners.categoryInserted(ChartView.this, index);
+ }
+
+ public Category update(int index, Category category) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int remove(Category category) {
+ int index = indexOf(category);
+ if (index != -1) {
+ remove(index, 1);
+ }
+
+ return index;
+ }
+
+ public Sequence<Category> remove(int index, int count) {
+ Sequence<Category> removed = categories.remove(index, count);
+
+ if (count > 0) {
+ for (int i = 0, n = removed.getLength(); i < n; i++) {
+ removed.get(i).setChartView(null);
+ }
+
+ chartViewCategoryListeners.categoriesRemoved(ChartView.this, index, removed);
+ }
+
+ return removed;
+ }
+
+ public Category get(int index) {
+ return categories.get(index);
+ }
+
+ public int indexOf(Category category) {
+ return categories.indexOf(category);
+ }
+
+ public int getLength() {
+ return categories.getLength();
+ }
+ }
+
+ /**
+ * List event handler.
+ */
+ private class ListHandler implements ListListener<Object> {
+ public void itemInserted(List<Object> list, int index) {
+ // Notify listeners that items were inserted
+ chartViewSeriesListeners.seriesInserted(ChartView.this, index);
+ }
+
+ public void itemsRemoved(List<Object> list, int index, Sequence<Object> items) {
+ if (items == null) {
+ // All items were removed; clear the selection and notify
+ // listeners
+ chartViewSeriesListeners.seriesRemoved(ChartView.this, index, -1);
+ } else {
+ // Notify listeners that items were removed
+ int count = items.getLength();
+ chartViewSeriesListeners.seriesRemoved(ChartView.this, index, count);
+ }
+ }
+
+ public void itemUpdated(List<Object> list, int index, Object previousItem) {
+ chartViewSeriesListeners.seriesUpdated(ChartView.this, index);
+ }
+
+ public void comparatorChanged(List<Object> list,
+ Comparator<Object> previousComparator) {
+ if (list.getComparator() != null) {
+ chartViewSeriesListeners.seriesSorted(ChartView.this);
+ }
+ }
+ }
+
+ /**
+ * Chart view listener list.
+ */
+ private class ChartViewListenerList extends ListenerList<ChartViewListener>
+ implements ChartViewListener {
+ public void chartDataChanged(ChartView chartView, List<?> previousChartData) {
+ for (ChartViewListener listener : this) {
+ listener.chartDataChanged(chartView, previousChartData);
+ }
+ }
+
+ public void seriesNameKeyChanged(ChartView chartView, String previousSeriesNameKey) {
+ for (ChartViewListener listener : this) {
+ listener.seriesNameKeyChanged(chartView, previousSeriesNameKey);
+ }
+ }
+
+ public void titleChanged(ChartView chartView, String previousTitle) {
+ for (ChartViewListener listener : this) {
+ listener.titleChanged(chartView, previousTitle);
+ }
+ }
+
+ public void horizontalAxisLabelChanged(ChartView chartView, String previousXAxisLabel) {
+ for (ChartViewListener listener : this) {
+ listener.horizontalAxisLabelChanged(chartView, previousXAxisLabel);
+ }
+ }
+
+ public void verticalAxisLabelChanged(ChartView chartView, String previousYAxisLabel) {
+ for (ChartViewListener listener : this) {
+ listener.verticalAxisLabelChanged(chartView, previousYAxisLabel);
+ }
+ }
+
+ public void showLegendChanged(ChartView chartView) {
+ for (ChartViewListener listener : this) {
+ listener.showLegendChanged(chartView);
+ }
+ }
+ }
+
+ /**
+ * Chart view category listener list.
+ */
+ private class ChartViewCategoryListenerList extends ListenerList<ChartViewCategoryListener>
+ implements ChartViewCategoryListener {
+ public void categoryInserted(ChartView chartView, int index) {
+ for (ChartViewCategoryListener listener : this) {
+ listener.categoryInserted(chartView, index);
+ }
+ }
+
+ public void categoriesRemoved(ChartView chartView, int index, Sequence<ChartView.Category> categories) {
+ for (ChartViewCategoryListener listener : this) {
+ listener.categoriesRemoved(chartView, index, categories);
+ }
+ }
+
+ public void categoryKeyChanged(ChartView chartView, int index, String previousKey) {
+ for (ChartViewCategoryListener listener : this) {
+ listener.categoryKeyChanged(chartView, index, previousKey);
+ }
+ }
+
+ public void categoryLabelChanged(ChartView chartView, int index, String previousLabel) {
+ for (ChartViewCategoryListener listener : this) {
+ listener.categoryLabelChanged(chartView, index, previousLabel);
+ }
+ }
+ }
+
+ /**
+ * Chart view series listener list.
+ */
+ private class ChartViewSeriesListenerList extends ListenerList<ChartViewSeriesListener>
+ implements ChartViewSeriesListener {
+ public void seriesInserted(ChartView chartView, int index) {
+ for (ChartViewSeriesListener listener : this) {
+ listener.seriesInserted(chartView, index);
+ }
+ }
+
+ public void seriesRemoved(ChartView chartView, int index, int count) {
+ for (ChartViewSeriesListener listener : this) {
+ listener.seriesRemoved(chartView, index, count);
+ }
+ }
+
+ public void seriesUpdated(ChartView chartView, int index) {
+ for (ChartViewSeriesListener listener : this) {
+ listener.seriesUpdated(chartView, index);
+ }
+ }
+
+ public void seriesSorted(ChartView chartView) {
+ for (ChartViewSeriesListener listener : this) {
+ listener.seriesSorted(chartView);
+ }
+ }
+ }
+
+ private List<?> chartData;
+ private String seriesNameKey;
+
+ private String title = null;
+ private String horizontalAxisLabel = null;
+ private String verticalAxisLabel = null;
+ private boolean showLegend;
+
+ private ArrayList<Category> categories = new ArrayList<Category>();
+ private CategorySequence categorySequence = new CategorySequence();
+
+ private ListHandler chartDataHandler = new ListHandler();
+
+ private ChartViewListenerList chartViewListeners = new ChartViewListenerList();
+ private ChartViewCategoryListenerList chartViewCategoryListeners = new ChartViewCategoryListenerList();
+ private ChartViewSeriesListenerList chartViewSeriesListeners = new ChartViewSeriesListenerList();
+
+ public static final String DEFAULT_SERIES_NAME_KEY = "name";
+
+ public ChartView() {
+ this(DEFAULT_SERIES_NAME_KEY, new ArrayList<Object>());
+ }
+
+ public ChartView(String seriesNameKey, List<?> chartData) {
+ setSeriesNameKey(seriesNameKey);
+ setTitle(title);
+ setChartData(chartData);
+ setShowLegend(showLegend);
+ }
+
+ public CategorySequence getCategories() {
+ return categorySequence;
+ }
+
+ public List<?> getChartData() {
+ return chartData;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setChartData(List<?> chartData) {
+ if (chartData == null) {
+ throw new IllegalArgumentException("chartData is null.");
+ }
+
+ List<?> previousChartData = this.chartData;
+
+ if (previousChartData != chartData) {
+ if (previousChartData != null) {
+ ((List<Object>)previousChartData).getListListeners().remove(chartDataHandler);
+ }
+
+ ((List<Object>)chartData).getListListeners().add(chartDataHandler);
+
+ this.chartData = chartData;
+ chartViewListeners.chartDataChanged(this, previousChartData);
+ }
+ }
+
+ public String getSeriesNameKey() {
+ return seriesNameKey;
+ }
+
+ public void setSeriesNameKey(String seriesNameKey) {
+ if (seriesNameKey == null) {
+ throw new IllegalArgumentException("seriesNameKey is null.");
+ }
+
+ String previousSeriesNameKey = this.seriesNameKey;
+
+ if (previousSeriesNameKey != seriesNameKey) {
+ this.seriesNameKey = seriesNameKey;
+ chartViewListeners.seriesNameKeyChanged(this, previousSeriesNameKey);
+ }
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ String previousTitle = this.title;
+
+ if (previousTitle != title) {
+ this.title = title;
+ chartViewListeners.titleChanged(this, previousTitle);
+ }
+ }
+
+ public String getHorizontalAxisLabel() {
+ return horizontalAxisLabel;
+ }
+
+ public void setHorizontalAxisLabel(String horizontalAxisLabel) {
+ String previousHorizontalAxisLabel = this.horizontalAxisLabel;
+
+ if (previousHorizontalAxisLabel != horizontalAxisLabel) {
+ this.horizontalAxisLabel = horizontalAxisLabel;
+ chartViewListeners.horizontalAxisLabelChanged(this, previousHorizontalAxisLabel);
+ }
+ }
+
+ public String getVerticalAxisLabel() {
+ return verticalAxisLabel;
+ }
+
+ public void setVerticalAxisLabel(String verticalAxisLabel) {
+ String previousVerticalAxisLabel = this.verticalAxisLabel;
+
+ if (previousVerticalAxisLabel != verticalAxisLabel) {
+ this.verticalAxisLabel = verticalAxisLabel;
+ chartViewListeners.verticalAxisLabelChanged(this, previousVerticalAxisLabel);
+ }
+ }
+
+ public boolean getShowLegend() {
+ return showLegend;
+ }
+
+ public void setShowLegend(boolean showLegend) {
+ if (this.showLegend != showLegend) {
+ this.showLegend = showLegend;
+ chartViewListeners.showLegendChanged(this);
+ }
+ }
+
+ public Element getElementAt(int x, int y) {
+ return ((Skin)getSkin()).getElementAt(x, y);
+ }
+
+ public ListenerList<ChartViewListener> getChartViewListeners() {
+ return chartViewListeners;
+ }
+
+ public ListenerList<ChartViewCategoryListener> getChartViewCategoryListeners() {
+ return chartViewCategoryListeners;
+ }
+
+ public ListenerList<ChartViewSeriesListener> getChartViewSeriesListeners() {
+ return chartViewSeriesListeners;
+ }
+}
+
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewCategoryListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewCategoryListener.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewCategoryListener.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewCategoryListener.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import pivot.collections.Sequence;
+
+/**
+ * Chart view category listener interface.
+ *
+ * @author gbrown
+ */
+public interface ChartViewCategoryListener {
+ /**
+ * Fired when a category is inserted into a chart view.
+ *
+ * @param chartView
+ * @param index
+ */
+ public void categoryInserted(ChartView chartView, int index);
+
+ /**
+ * Fired when a category is removed from a chart view.
+ *
+ * @param chartView
+ * @param index
+ * @param categories
+ */
+ public void categoriesRemoved(ChartView chartView, int index, Sequence<ChartView.Category> categories);
+
+ /**
+ * Fired when a chart view's category key changes.
+ *
+ * @param chartView
+ * @param index
+ * @param previousKey
+ */
+ public void categoryKeyChanged(ChartView chartView, int index, String previousKey);
+
+ /**
+ * Fired when a chart view's category label changes.
+ *
+ * @param chartView
+ * @param index
+ * @param previousLabel
+ */
+ public void categoryLabelChanged(ChartView chartView, int index, String previousLabel);
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewListener.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewListener.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewListener.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import pivot.collections.List;
+
+/**
+ * Chart view listener interface.
+ *
+ * @author gbrown
+ */
+public interface ChartViewListener {
+ /**
+ * Fired when a chart view's data changes.
+ *
+ * @param chartView
+ * @param previousChartData
+ */
+ public void chartDataChanged(ChartView chartView, List<?> previousChartData);
+
+ /**
+ * Fired when a chart view's series name key changes.
+ *
+ * @param chartView
+ * @param previousSeriesNameKey
+ */
+ public void seriesNameKeyChanged(ChartView chartView, String previousSeriesNameKey);
+
+ /**
+ * Fired when a chart view's title changes.
+ *
+ * @param chartView
+ * @param previousTitle
+ */
+ public void titleChanged(ChartView chartView, String previousTitle);
+
+ /**
+ * Fired when a chart view's horizontal axis label changes.
+ *
+ * @param chartView
+ * @param previousHorizontalAxisLabel
+ */
+ public void horizontalAxisLabelChanged(ChartView chartView, String previousHorizontalAxisLabel);
+
+ /**
+ * Fired when a chart view's vertical axis label changes.
+ *
+ * @param chartView
+ * @param previousVerticalAxisLabel
+ */
+ public void verticalAxisLabelChanged(ChartView chartView, String previousVerticalAxisLabel);
+
+ /**
+ * Fired when a chart view's "show legend" flag changes.
+ *
+ * @param chartView
+ */
+ public void showLegendChanged(ChartView chartView);
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewSeriesListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewSeriesListener.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewSeriesListener.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/ChartViewSeriesListener.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+/**
+ * Chart view series listener interface.
+ *
+ * @author gbrown
+ */
+public interface ChartViewSeriesListener {
+ /**
+ * Fired when a series is inserted into a chart view's data set.
+ *
+ * @param chartView
+ * @param index
+ */
+ public void seriesInserted(ChartView chartView, int index);
+
+ /**
+ * Fired when a series is removed from a chart view's data set.
+ *
+ * @param chartView
+ * @param index
+ * @param count
+ */
+ public void seriesRemoved(ChartView chartView, int index, int count);
+
+ /**
+ * Fired when a series is updated in a chart view's data set.
+ * @param chartView
+ * @param index
+ */
+ public void seriesUpdated(ChartView chartView, int index);
+
+ /**
+ * Fired when a chart view's series data is sorted.
+ *
+ * @param chartView
+ */
+ public void seriesSorted(ChartView chartView);
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/HighLowChartView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/HighLowChartView.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/HighLowChartView.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/HighLowChartView.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import pivot.charts.skin.HighLowChartViewSkin;
+
+/**
+ * Presents chart data using "open/high/low/close" plot.
+ *
+ * @author gbrown
+ */
+public class HighLowChartView extends ChartView {
+ public HighLowChartView() {
+ setSkin(new HighLowChartViewSkin());
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/LineChartView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/LineChartView.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/LineChartView.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/LineChartView.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import pivot.charts.skin.LineChartViewSkin;
+
+/**
+ * Presents chart data using a line plot.
+ *
+ * @author gbrown
+ */
+public class LineChartView extends ChartView {
+ public LineChartView() {
+ setSkin(new LineChartViewSkin());
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/PieChartView.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/PieChartView.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/PieChartView.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/PieChartView.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts;
+
+import pivot.charts.skin.PieChartViewSkin;
+
+/**
+ * Presents chart data using a pie plot.
+ *
+ * @author gbrown
+ */
+public class PieChartView extends ChartView {
+ public PieChartView() {
+ setSkin(new PieChartViewSkin());
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Candlestick.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Candlestick.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Candlestick.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Candlestick.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.content;
+
+import java.util.Date;
+
+/**
+ * Represents value data for high/low chart views.
+ *
+ * @author gbrown
+ */
+public class Candlestick {
+ private Date date = null;
+ private float open = 0;
+ private float high = 0;
+ private float low = 0;
+ private float close = 0;
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ @SuppressWarnings("deprecation")
+ public final void setDate(String date) {
+ setDate(new Date(Date.parse(date)));
+ }
+
+ public float getOpen() {
+ return open;
+ }
+
+ public void setOpen(float open) {
+ this.open = open;
+ }
+
+ public float getHigh() {
+ return high;
+ }
+
+ public void setHigh(float high) {
+ this.high = high;
+ }
+
+ public float getLow() {
+ return low;
+ }
+
+ public void setLow(float low) {
+ this.low = low;
+ }
+
+ public float getClose() {
+ return close;
+ }
+
+ public void setClose(float close) {
+ this.close = close;
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/CategorySeries.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/CategorySeries.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/CategorySeries.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/CategorySeries.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.content;
+
+import pivot.collections.HashMap;
+
+/**
+ * Represents series data for category chart views.
+ *
+ * @author gbrown
+ */
+public class CategorySeries extends HashMap<String, Object> {
+ public static final long serialVersionUID = 0;
+
+ public static final String NAME_KEY = "name";
+
+ public CategorySeries() {
+ this(null);
+ }
+
+ public CategorySeries(String name) {
+ put(NAME_KEY, name);
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Interval.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Interval.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Interval.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Interval.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.content;
+
+/**
+ * Represents value data for interval chart views.
+ *
+ * @author gbrown
+ */
+public class Interval extends Point {
+ private float width = 0;
+
+ public float getWidth() {
+ return width;
+ }
+
+ public void setWidth(float width) {
+ this.width = width;
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Point.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Point.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Point.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/Point.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.content;
+
+/**
+ * Represents value data for x/y chart views.
+ *
+ * @author gbrown
+ */
+public class Point {
+ private float x = 0;
+ private float y = 0;
+
+ public float getX() {
+ return x;
+ }
+
+ public void setX(float x) {
+ this.x = x;
+ }
+
+ public float getY() {
+ return y;
+ }
+
+ public void setY(float y) {
+ this.y = y;
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/ValueSeries.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/ValueSeries.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/ValueSeries.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/ValueSeries.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.content;
+
+import pivot.collections.ArrayList;
+
+/**
+ * Represents series data for value chart views.
+ *
+ * @author gbrown
+ */
+public class ValueSeries<T> extends ArrayList<T> {
+ public static final long serialVersionUID = 0;
+
+ private String name = null;
+
+ public ValueSeries() {
+ this(null);
+ }
+
+ public ValueSeries(String name) {
+ setName(name);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/package.html
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/package.html?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/package.html (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/content/package.html Mon Mar 16 16:16:40 2009
@@ -0,0 +1,6 @@
+<html>
+<head></head>
+<body>
+<p>Contains classes representing chart data.</p>
+</body>
+</html>
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/package.html
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/package.html?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/package.html (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/package.html Mon Mar 16 16:16:40 2009
@@ -0,0 +1,6 @@
+<html>
+<head></head>
+<body>
+<p>Contains a collection of components for use in charting applications.</p>
+</body>
+</html>
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/AreaChartViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/AreaChartViewSkin.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/AreaChartViewSkin.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/AreaChartViewSkin.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.skin;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.entity.CategoryItemEntity;
+import org.jfree.chart.entity.ChartEntity;
+import org.jfree.chart.entity.XYItemEntity;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.category.CategoryDataset;
+
+import pivot.charts.AreaChartView;
+import pivot.charts.ChartView;
+import pivot.collections.List;
+
+/**
+ * Area chart view skin.
+ *
+ * @author gbrown
+ */
+public class AreaChartViewSkin extends ChartViewSkin {
+ public ChartView.Element getElementAt(int x, int y) {
+ ChartView.Element element = null;
+
+ ChartEntity chartEntity = getChartEntityAt(x, y);
+ if (chartEntity instanceof CategoryItemEntity) {
+ CategoryItemEntity categoryItemEntity = (CategoryItemEntity)chartEntity;
+ CategoryDataset dataset = categoryItemEntity.getDataset();
+
+ String columnKey = (String)categoryItemEntity.getColumnKey();
+ int columnIndex = dataset.getColumnIndex(columnKey);
+
+ String rowKey = (String)categoryItemEntity.getRowKey();
+ int rowIndex = dataset.getRowIndex(rowKey);
+
+ element = new ChartView.Element(rowIndex, columnIndex);
+ } else if (chartEntity instanceof XYItemEntity) {
+ XYItemEntity xyItemEntity = (XYItemEntity)chartEntity;
+ element = new ChartView.Element(xyItemEntity.getSeriesIndex(),
+ xyItemEntity.getItem());
+ }
+
+ return element;
+ }
+
+ @Override
+ protected JFreeChart createChart() {
+ AreaChartView chartView = (AreaChartView)getComponent();
+
+ String title = chartView.getTitle();
+ String horizontalAxisLabel = chartView.getHorizontalAxisLabel();
+ String verticalAxisLabel = chartView.getVerticalAxisLabel();
+ boolean showLegend = chartView.getShowLegend();
+
+ String seriesNameKey = chartView.getSeriesNameKey();
+ List<?> chartData = chartView.getChartData();
+
+ JFreeChart chart;
+ ChartView.CategorySequence categories = chartView.getCategories();
+ if (categories.getLength() > 0) {
+ CategorySeriesDataset dataset = new CategorySeriesDataset(categories, seriesNameKey, chartData);
+ chart = ChartFactory.createAreaChart(title, horizontalAxisLabel, verticalAxisLabel,
+ dataset, PlotOrientation.VERTICAL, showLegend, false, false);
+ } else {
+ chart = ChartFactory.createXYAreaChart(title, horizontalAxisLabel, verticalAxisLabel,
+ new XYSeriesDataset(seriesNameKey, chartData),
+ PlotOrientation.VERTICAL, showLegend, false, false);
+ }
+
+ return chart;
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/BarChartViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/BarChartViewSkin.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/BarChartViewSkin.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/BarChartViewSkin.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.skin;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.entity.ChartEntity;
+import org.jfree.chart.entity.CategoryItemEntity;
+import org.jfree.chart.entity.XYItemEntity;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.category.CategoryDataset;
+
+import pivot.charts.BarChartView;
+import pivot.charts.ChartView;
+import pivot.collections.List;
+
+/**
+ * Bar chart view skin.
+ *
+ * @author gbrown
+ */
+public class BarChartViewSkin extends ChartViewSkin {
+ private boolean stacked = false;
+ private boolean threeDimensional = false;
+
+ public ChartView.Element getElementAt(int x, int y) {
+ ChartView.Element element = null;
+
+ ChartEntity chartEntity = getChartEntityAt(x, y);
+ if (chartEntity instanceof CategoryItemEntity) {
+ CategoryItemEntity categoryItemEntity = (CategoryItemEntity)chartEntity;
+ CategoryDataset dataset = categoryItemEntity.getDataset();
+
+ String columnKey = (String)categoryItemEntity.getColumnKey();
+ int columnIndex = dataset.getColumnIndex(columnKey);
+
+ String rowKey = (String)categoryItemEntity.getRowKey();
+ int rowIndex = dataset.getRowIndex(rowKey);
+
+ element = new ChartView.Element(rowIndex, columnIndex);
+ } else if (chartEntity instanceof XYItemEntity) {
+ XYItemEntity xyItemEntity = (XYItemEntity)chartEntity;
+ element = new ChartView.Element(xyItemEntity.getSeriesIndex(),
+ xyItemEntity.getItem());
+ }
+
+ return element;
+ }
+
+ protected JFreeChart createChart() {
+ BarChartView chartView = (BarChartView)getComponent();
+
+ String title = chartView.getTitle();
+ String horizontalAxisLabel = chartView.getHorizontalAxisLabel();
+ String verticalAxisLabel = chartView.getVerticalAxisLabel();
+ boolean showLegend = chartView.getShowLegend();
+
+ String seriesNameKey = chartView.getSeriesNameKey();
+ List<?> chartData = chartView.getChartData();
+
+ // TODO Make plot orientation a style property
+
+ JFreeChart chart;
+ ChartView.CategorySequence categories = chartView.getCategories();
+ if (categories.getLength() > 0) {
+ CategorySeriesDataset dataset = new CategorySeriesDataset(categories, seriesNameKey, chartData);
+
+ if (stacked && threeDimensional) {
+ chart = ChartFactory.createStackedBarChart3D(title, horizontalAxisLabel, verticalAxisLabel,
+ dataset, PlotOrientation.VERTICAL, showLegend, false, false);
+ } else if (stacked) {
+ chart = ChartFactory.createStackedBarChart(title, horizontalAxisLabel, verticalAxisLabel,
+ dataset, PlotOrientation.VERTICAL, showLegend, false, false);
+ } else if (threeDimensional) {
+ chart = ChartFactory.createBarChart3D(title, horizontalAxisLabel, verticalAxisLabel,
+ dataset, PlotOrientation.VERTICAL, showLegend, false, false);
+ } else {
+ chart = ChartFactory.createBarChart(title, horizontalAxisLabel, verticalAxisLabel,
+ dataset, PlotOrientation.VERTICAL, showLegend, false, false);
+ }
+ } else {
+ // TODO Make the dateAxis argument a style property
+ chart = ChartFactory.createXYBarChart(title, horizontalAxisLabel, false, verticalAxisLabel,
+ new IntervalSeriesDataset(seriesNameKey, chartData),
+ PlotOrientation.VERTICAL, showLegend, false, false);
+ }
+
+ return chart;
+ }
+
+ public boolean isStacked() {
+ return stacked;
+ }
+
+ public void setStacked(boolean stacked) {
+ this.stacked = stacked;
+ repaintComponent();
+ }
+
+ public boolean isThreeDimensional() {
+ return threeDimensional;
+ }
+
+ public void setThreeDimensional(boolean threeDimensional) {
+ this.threeDimensional = threeDimensional;
+ repaintComponent();
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/CategorySeriesDataset.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/CategorySeriesDataset.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/CategorySeriesDataset.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/CategorySeriesDataset.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.skin;
+
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.general.DatasetChangeListener;
+import org.jfree.data.general.DatasetGroup;
+
+import pivot.beans.BeanDictionary;
+import pivot.charts.ChartView;
+import pivot.collections.Dictionary;
+import pivot.collections.List;
+
+/**
+ * Implementation of JFreeChart CategoryDataset.
+ *
+ * @author gbrown
+ */
+@SuppressWarnings("unchecked")
+public class CategorySeriesDataset implements CategoryDataset {
+ private ChartView.CategorySequence categories;
+ private String seriesNameKey;
+ private List<?> chartData;
+
+ private DatasetGroup datasetGroup = null;
+
+ public CategorySeriesDataset(ChartView.CategorySequence categories,
+ String seriesNameKey, List<?> chartData) {
+ if (categories == null) {
+ throw new IllegalArgumentException("categories is null.");
+ }
+
+ if (seriesNameKey == null) {
+ throw new IllegalArgumentException("seriesNameKey is null.");
+ }
+
+ if (chartData == null) {
+ throw new IllegalArgumentException("chartData is null.");
+ }
+
+ this.categories = categories;
+ this.seriesNameKey = seriesNameKey;
+ this.chartData = chartData;
+ }
+
+ public DatasetGroup getGroup() {
+ return datasetGroup;
+ }
+
+ public void setGroup(DatasetGroup datasetGroup) {
+ this.datasetGroup = datasetGroup;
+ }
+
+ public int getColumnCount() {
+ return categories.getLength();
+ }
+
+ public int getRowCount() {
+ return chartData.getLength();
+ }
+
+ public int getColumnIndex(Comparable categoryLabel) {
+ if (categoryLabel == null) {
+ throw new IllegalArgumentException("categoryLabel is null.");
+ }
+
+ int columnIndex = -1;
+ for (int i = 0, n = categories.getLength(); i < n && columnIndex == -1; i++) {
+ ChartView.Category category = categories.get(i);
+
+ if (categoryLabel.compareTo(category.getLabel()) == 0) {
+ columnIndex = i;
+ }
+ }
+
+ return columnIndex;
+ }
+
+ public Comparable getColumnKey(int categoryIndex) {
+ if (categoryIndex < 0
+ || categoryIndex > categories.getLength() - 1) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ return categories.get(categoryIndex).getLabel();
+ }
+
+ public java.util.List getColumnKeys() {
+ java.util.ArrayList columnKeys = new java.util.ArrayList(categories.getLength());
+ for (int i = 0, n = categories.getLength(); i < n; i++) {
+ columnKeys.add(categories.get(i).getLabel());
+ }
+
+ return columnKeys;
+ }
+
+ public int getRowIndex(Comparable seriesName) {
+ if (seriesName == null) {
+ throw new IllegalArgumentException("seriesName is null.");
+ }
+
+ int rowIndex = -1;
+ for (int i = 0, n = chartData.getLength(); i < n && rowIndex == -1; i++) {
+ Dictionary<String, ?> seriesDictionary = getSeriesDictionary(i);
+
+ if (seriesName.compareTo(seriesDictionary.get(seriesNameKey)) == 0) {
+ rowIndex = i;
+ }
+ }
+
+ return rowIndex;
+ }
+
+ public Comparable getRowKey(int seriesIndex) {
+ Dictionary<String, ?> seriesDictionary = getSeriesDictionary(seriesIndex);
+ return (String)seriesDictionary.get(seriesNameKey);
+ }
+
+ public java.util.List getRowKeys() {
+ java.util.ArrayList rowKeys = new java.util.ArrayList(chartData.getLength());
+ for (int i = 0, n = chartData.getLength(); i < n; i++) {
+ rowKeys.add(getRowKey(i));
+ }
+
+ return rowKeys;
+ }
+
+ public Number getValue(int seriesIndex, int categoryIndex) {
+ Dictionary<String, ?> seriesDictionary = getSeriesDictionary(seriesIndex);
+
+ if (categoryIndex < 0
+ || categoryIndex > categories.getLength() - 1) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ ChartView.Category category = categories.get(categoryIndex);
+ String categoryKey = category.getKey();
+
+ Object value = seriesDictionary.get(categoryKey);
+ if (value instanceof String) {
+ value = Double.parseDouble((String)value);
+ }
+
+ return (Number)value;
+ }
+
+ public Number getValue(Comparable seriesName, Comparable categoryLabel) {
+ return getValue(getRowIndex(seriesName), getColumnIndex(categoryLabel));
+ }
+
+ protected Dictionary<String, ?> getSeriesDictionary(int seriesIndex) {
+ if (seriesIndex < 0
+ || seriesIndex > chartData.getLength() - 1) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ Object series = chartData.get(seriesIndex);
+
+ Dictionary<String, ?> seriesDictionary;
+ if (series instanceof Dictionary<?, ?>) {
+ seriesDictionary = (Dictionary<String, ?>)series;
+ } else {
+ seriesDictionary = new BeanDictionary(series);
+ }
+
+ return seriesDictionary;
+ }
+
+ public void addChangeListener(DatasetChangeListener listener) {
+ // No-op
+ }
+
+ public void removeChangeListener(DatasetChangeListener listener) {
+ // No-op
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/ChartViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/ChartViewSkin.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/ChartViewSkin.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/ChartViewSkin.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.skin;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+import org.jfree.chart.ChartRenderingInfo;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.entity.ChartEntity;
+import org.jfree.chart.entity.EntityCollection;
+
+import pivot.charts.ChartView;
+import pivot.charts.ChartViewCategoryListener;
+import pivot.charts.ChartViewListener;
+import pivot.charts.ChartViewSeriesListener;
+import pivot.collections.List;
+import pivot.collections.Sequence;
+import pivot.wtk.Component;
+import pivot.wtk.Dimensions;
+import pivot.wtk.skin.ComponentSkin;
+
+/**
+ * Abstract base class for chart view skins.
+ *
+ * @author gbrown
+ */
+public abstract class ChartViewSkin extends ComponentSkin
+ implements ChartView.Skin,
+ ChartViewListener, ChartViewCategoryListener, ChartViewSeriesListener {
+ private BufferedImage bufferedImage = null;
+
+ private JFreeChart chart = null;
+ private ChartRenderingInfo chartRenderingInfo = new ChartRenderingInfo();
+
+ private Color backgroundColor = null;
+
+ private static final int PREFERRED_WIDTH = 320;
+ private static final int PREFERRED_HEIGHT = 240;
+
+ @Override
+ public void install(Component component) {
+ super.install(component);
+
+ // Add listeners
+ ChartView chartView = (ChartView)component;
+ chartView.getChartViewListeners().add(this);
+ chartView.getChartViewCategoryListeners().add(this);
+ chartView.getChartViewSeriesListeners().add(this);
+ }
+
+ @Override
+ public void uninstall() {
+ // Remove listeners
+ ChartView chartView = (ChartView)getComponent();
+ chartView.getChartViewListeners().remove(this);
+ chartView.getChartViewCategoryListeners().remove(this);
+ chartView.getChartViewSeriesListeners().remove(this);
+
+ super.uninstall();
+ }
+
+ public int getPreferredWidth(int height) {
+ return PREFERRED_WIDTH;
+ }
+
+
+ public int getPreferredHeight(int width) {
+ return PREFERRED_HEIGHT;
+ }
+
+ public Dimensions getPreferredSize() {
+ return new Dimensions(getPreferredWidth(-1), getPreferredHeight(-1));
+ }
+
+ public void layout() {
+ // No-op
+ }
+
+ public void paint(Graphics2D graphics) {
+ int width = getWidth();
+ int height = getHeight();
+
+ if (bufferedImage == null
+ || bufferedImage.getWidth() != width
+ || bufferedImage.getHeight() != height) {
+ chart = createChart();
+
+ bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D bufferedImageGraphics = (Graphics2D)bufferedImage.getGraphics();
+
+ java.awt.Rectangle area = new java.awt.Rectangle(0, 0, width, height);
+ chart.setBackgroundPaint(backgroundColor);
+ chart.draw(bufferedImageGraphics, area, chartRenderingInfo);
+
+ bufferedImageGraphics.dispose();
+ }
+
+ graphics.drawImage(bufferedImage, 0, 0, null);
+ }
+
+ @Override
+ public void repaintComponent() {
+ super.repaintComponent();
+ bufferedImage = null;
+ }
+
+ protected abstract JFreeChart createChart();
+
+ protected ChartEntity getChartEntityAt(int x, int y) {
+ ChartEntity result = null;
+
+ if (chartRenderingInfo != null) {
+ EntityCollection entities = chartRenderingInfo.getEntityCollection();
+ result = (entities != null) ? entities.getEntity(x, y) : null;
+ }
+
+ return result;
+ }
+
+ public Color getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ public void setBackgroundColor(Color backgroundColor) {
+ this.backgroundColor = backgroundColor;
+ repaintComponent();
+ }
+
+ // Chart view events
+ public void chartDataChanged(ChartView chartView, List<?> previousChartData) {
+ repaintComponent();
+ }
+
+ public void seriesNameKeyChanged(ChartView chartView, String previousSeriesNameKey) {
+ repaintComponent();
+ }
+
+ public void titleChanged(ChartView chartView, String previousTitle) {
+ repaintComponent();
+ }
+
+ public void horizontalAxisLabelChanged(ChartView chartView, String previousHorizontalAxisLabel) {
+ repaintComponent();
+ }
+
+ public void verticalAxisLabelChanged(ChartView chartView, String previousVerticalAxisLabel) {
+ repaintComponent();
+ }
+
+ public void showLegendChanged(ChartView chartView) {
+ repaintComponent();
+ }
+
+ // Chart view category events
+ public void categoryInserted(ChartView chartView, int index) {
+ repaintComponent();
+ }
+
+ public void categoriesRemoved(ChartView chartView, int index, Sequence<ChartView.Category> categories) {
+ repaintComponent();
+ }
+
+ public void categoryKeyChanged(ChartView chartView, int index, String previousKey) {
+ repaintComponent();
+ }
+
+ public void categoryLabelChanged(ChartView chartView, int index, String previousLabel) {
+ repaintComponent();
+ }
+
+ // Chart view series events
+ public void seriesInserted(ChartView chartView, int index) {
+ repaintComponent();
+ }
+
+ public void seriesRemoved(ChartView chartView, int index, int count) {
+ repaintComponent();
+ }
+
+ public void seriesUpdated(ChartView chartView, int index) {
+ repaintComponent();
+ }
+
+ public void seriesSorted(ChartView chartView) {
+ repaintComponent();
+ }
+}
Added: incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/HighLowChartViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/HighLowChartViewSkin.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/HighLowChartViewSkin.java (added)
+++ incubator/pivot/tags/v1.0/charts/src/pivot/charts/skin/HighLowChartViewSkin.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * 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 pivot.charts.skin;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.entity.ChartEntity;
+import org.jfree.chart.entity.XYItemEntity;
+
+import pivot.charts.ChartView;
+import pivot.charts.HighLowChartView;
+import pivot.collections.List;
+
+/**
+ * High/low chart view skin.
+ *
+ * @author gbrown
+ */
+public class HighLowChartViewSkin extends ChartViewSkin {
+ private boolean candlestick = false;
+
+ public ChartView.Element getElementAt(int x, int y) {
+ ChartView.Element element = null;
+
+ ChartEntity chartEntity = getChartEntityAt(x, y);
+ if (chartEntity instanceof XYItemEntity) {
+ XYItemEntity xyItemEntity = (XYItemEntity)chartEntity;
+ element = new ChartView.Element(xyItemEntity.getSeriesIndex(),
+ xyItemEntity.getItem());
+ }
+
+ return element;
+ }
+
+ @Override
+ protected JFreeChart createChart() {
+ HighLowChartView chartView = (HighLowChartView)getComponent();
+
+ String title = chartView.getTitle();
+ String horizontalAxisLabel = chartView.getHorizontalAxisLabel();
+ String verticalAxisLabel = chartView.getVerticalAxisLabel();
+ boolean showLegend = chartView.getShowLegend();
+
+ String seriesNameKey = chartView.getSeriesNameKey();
+ List<?> chartData = chartView.getChartData();
+
+ JFreeChart chart;
+ OHLCSeriesDataset dataset = new OHLCSeriesDataset(seriesNameKey, chartData);
+
+ if (candlestick) {
+ chart = ChartFactory.createCandlestickChart(title,
+ horizontalAxisLabel, verticalAxisLabel, dataset, showLegend);
+ } else {
+ chart = ChartFactory.createHighLowChart(title,
+ horizontalAxisLabel, verticalAxisLabel, dataset, showLegend);
+ }
+
+ return chart;
+ }
+
+ public boolean isCandlestick() {
+ return candlestick;
+ }
+
+ public void setCandlestick(boolean candlestick) {
+ this.candlestick = candlestick;
+ repaintComponent();
+ }
+}