You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2014/10/13 23:16:13 UTC
[1/2] git commit: [flex-asjs] [refs/heads/develop] - Convert chart
axis classes to flex.core.graphics for axis line and tick marks. Axis classes
can now specify axis line Stroke and axis tick mark Stroke.
Repository: flex-asjs
Updated Branches:
refs/heads/develop 615588a1b -> aaf60ed30
Convert chart axis classes to flex.core.graphics for axis line and tick marks. Axis classes can now specify axis line Stroke and axis tick mark Stroke.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/b5c2ae07
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/b5c2ae07
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/b5c2ae07
Branch: refs/heads/develop
Commit: b5c2ae079cd6eb7547d1cc6dd230244f305a5fd2
Parents: 615588a
Author: Peter Ent <pe...@apache.org>
Authored: Mon Oct 13 17:10:05 2014 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Mon Oct 13 17:10:05 2014 -0400
----------------------------------------------------------------------
.../apache/flex/charts/beads/AxisBaseBead.as | 152 +++++++++++++++++++
.../charts/beads/HorizontalCategoryAxisBead.as | 60 +++-----
.../charts/beads/HorizontalLinearAxisBead.as | 58 +++----
.../charts/beads/VerticalCategoryAxisBead.as | 59 +++----
.../flex/charts/beads/VerticalLinearAxisBead.as | 61 ++++----
.../org/apache/flex/charts/core/IAxisBead.as | 51 +++++++
.../flex/charts/core/IHorizontalAxisBead.as | 2 +-
.../flex/charts/core/IVerticalAxisBead.as | 2 +-
8 files changed, 300 insertions(+), 145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/AxisBaseBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/AxisBaseBead.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/AxisBaseBead.as
new file mode 100644
index 0000000..9e517d9
--- /dev/null
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/AxisBaseBead.as
@@ -0,0 +1,152 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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 org.apache.flex.charts.beads
+{
+ import org.apache.flex.charts.core.IAxisBead;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.graphics.IStroke;
+ import org.apache.flex.core.graphics.Path;
+ import org.apache.flex.core.graphics.SolidColorStroke;
+
+ public class AxisBaseBead implements IAxisBead
+ {
+ public function AxisBaseBead()
+ {
+ // create default dark stroke for the axis line and tick marks
+ // in case they are not set otherwise.
+
+ var blackLine:SolidColorStroke = new SolidColorStroke();
+ blackLine.color = 0x111111;
+ blackLine.weight = 1;
+ blackLine.alpha = 1.0;
+
+ axisStroke = blackLine;
+ tickStroke = blackLine;
+ }
+
+ private var _placement:String = "unset";
+
+ /**
+ * The placement of the axis with respect to the chart area. Valid
+ * values are: top, bottom (for IHorizontalAxisBeads), left, and right
+ * (for IVerticalAxisBeads).
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get placement():String
+ {
+ return _placement;
+ }
+ public function set placement(value:String):void
+ {
+ _placement = value;
+ }
+
+ private var _axisStroke:IStroke;
+
+ /**
+ * The stroke used to draw the line for the axis.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get axisStroke():IStroke
+ {
+ return _axisStroke;
+ }
+ public function set axisStroke(value:IStroke):void
+ {
+ _axisStroke = value;
+ }
+
+ private var _tickStroke:IStroke;
+
+ /**
+ * The stroke used to draw each tick mark.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get tickStroke():IStroke
+ {
+ return _tickStroke;
+ }
+ public function set tickStroke(value:IStroke):void
+ {
+ _tickStroke = value;
+ }
+
+ private var _strand:IStrand;
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ }
+ public function get strand():IStrand
+ {
+ return _strand;
+ }
+
+ protected function drawAxisPath(originX:Number, originY:Number, xoffset:Number, yoffset:Number):Path
+ {
+ var axisPath:Path = new Path();
+ axisPath.stroke = axisStroke;
+ UIBase(strand).addElement(axisPath);
+ var pathLine:String = "l "+String(xoffset)+" "+String(yoffset);
+ axisPath.drawPath(originX, originY, pathLine);
+
+ return axisPath;
+ }
+
+ private var tickPathString:String = null;
+
+ protected function addTickMark(xpos:Number, ypos:Number, xoffset:Number, yoffset:Number):void
+ {
+ if (tickPathString == null) tickPathString = "";
+ tickPathString = tickPathString + " M "+String(xpos)+" "+String(ypos);
+ tickPathString = tickPathString + " l " + String(xoffset)+" "+String(yoffset);
+ }
+
+ protected function drawTickPath(originX:Number, originY:Number):void
+ {
+ var tickPath:Path = new Path();
+ tickPath.stroke = tickStroke;
+ UIBase(strand).addElement(tickPath);
+ tickPath.drawPath( originX, originY, tickPathString );
+
+ tickPathString = null;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
index a9ac931..dd9e76b 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalCategoryAxisBead.as
@@ -18,14 +18,13 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.charts.beads
{
- import org.apache.flex.charts.core.IChart;
import org.apache.flex.charts.core.IHorizontalAxisBead;
import org.apache.flex.charts.core.IVerticalAxisBead;
- import org.apache.flex.core.FilledRectangle;
import org.apache.flex.core.IBead;
import org.apache.flex.core.ISelectionModel;
import org.apache.flex.core.IStrand;
import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.graphics.Path;
import org.apache.flex.events.Event;
import org.apache.flex.events.IEventDispatcher;
import org.apache.flex.html.Label;
@@ -42,7 +41,7 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public class HorizontalCategoryAxisBead implements IBead, IHorizontalAxisBead
+ public class HorizontalCategoryAxisBead extends AxisBaseBead implements IBead, IHorizontalAxisBead
{
/**
* constructor.
@@ -54,6 +53,9 @@ package org.apache.flex.charts.beads
*/
public function HorizontalCategoryAxisBead()
{
+ super();
+
+ placement = "bottom";
}
private var _axisHeight:Number = 30;
@@ -116,8 +118,6 @@ package org.apache.flex.charts.beads
_gap = value;
}
- private var _strand:IStrand;
-
/**
* @copy org.apache.flex.core.IBead#strand
*
@@ -126,12 +126,12 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public function set strand(value:IStrand):void
+ override public function set strand(value:IStrand):void
{
- _strand = value;
+ super.strand = value;
// in order to draw or create the labels, need to know when the series has been created.
- IEventDispatcher(_strand).addEventListener("layoutComplete",handleItemsCreated);
+ IEventDispatcher(value).addEventListener("layoutComplete",handleItemsCreated);
}
/**
@@ -139,60 +139,42 @@ package org.apache.flex.charts.beads
*/
private function handleItemsCreated(event:Event):void
{
- var model:ArraySelectionModel = _strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+ var model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
var items:Array;
if (model.dataProvider is Array) items = model.dataProvider as Array;
else return;
var yAxis:IVerticalAxisBead;
- if (_strand.getBeadByType(IVerticalAxisBead)) yAxis = _strand.getBeadByType(IVerticalAxisBead) as IVerticalAxisBead;
+ if (strand.getBeadByType(IVerticalAxisBead)) yAxis = strand.getBeadByType(IVerticalAxisBead) as IVerticalAxisBead;
var yAxisOffset:Number = yAxis == null ? 0 : yAxis.axisWidth;
var xpos:Number = yAxisOffset;
var xAxisHeightOffset:Number = axisHeight;
- var useWidth:Number = UIBase(_strand).width-yAxisOffset;
-
- // draw the horzontal axis
- var horzLine:FilledRectangle = new FilledRectangle();
- horzLine.fillColor = 0x111111;
- horzLine.x = xpos;
- horzLine.y = UIBase(_strand).height - xAxisHeightOffset;
- horzLine.height = 1;
- horzLine.width = useWidth;
- UIBase(_strand).addElement(horzLine);
-
+ var useWidth:Number = UIBase(strand).width-yAxisOffset;
+ var originX:Number = xpos;
+ var originY:Number = UIBase(strand).height - xAxisHeightOffset;
+
// place the labels below the axis enough to account for the tick marks
- var labelY:Number = UIBase(_strand).height + 8;
+ var labelY:Number = UIBase(strand).height + 8;
var itemWidth:Number = (useWidth - gap*(items.length-1))/items.length;
- trace("strand width: "+UIBase(_strand).width);
- trace(items.length+" items = itemWidth: "+itemWidth);
- trace("yAxisOffset: "+yAxisOffset+" gap: "+gap+" = useWidth: "+useWidth);
- trace("xpos: "+xpos);
-
for(var i:int=0; i < items.length; i++) {
var label:Label = new Label();
label.text = items[i][categoryField];
label.x = xpos;
label.y = labelY - xAxisHeightOffset;
- UIBase(_strand).addElement(label);
+ UIBase(strand).addElement(label);
- // add a tick mark, too
- var tick:FilledRectangle = new FilledRectangle();
- tick.fillColor = 0x111111;
- tick.x = xpos + itemWidth/2;
- tick.y = UIBase(_strand).height - xAxisHeightOffset;
- tick.width = 1;
- tick.height = 5;
- UIBase(_strand).addElement(tick);
+ // add a tick mark, too
+ addTickMark(xpos + itemWidth/2 - originX, UIBase(strand).height - xAxisHeightOffset - originY, 0, 5);
xpos += itemWidth + gap;
-
- trace(" -- xpos is now: "+xpos);
}
- trace(" ");
+ // draw the axis and the tick marks
+ drawAxisPath(originX, originY, useWidth, 0);
+ drawTickPath(originX, originY);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
index 68dbb4a..432fec1 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/HorizontalLinearAxisBead.as
@@ -21,11 +21,11 @@ package org.apache.flex.charts.beads
import org.apache.flex.charts.core.IChart;
import org.apache.flex.charts.core.IHorizontalAxisBead;
import org.apache.flex.charts.core.IVerticalAxisBead;
- import org.apache.flex.core.FilledRectangle;
import org.apache.flex.core.IBead;
import org.apache.flex.core.ISelectionModel;
import org.apache.flex.core.IStrand;
import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.graphics.Path;
import org.apache.flex.events.Event;
import org.apache.flex.events.IEventDispatcher;
import org.apache.flex.html.Label;
@@ -40,7 +40,7 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public class HorizontalLinearAxisBead implements IBead, IHorizontalAxisBead
+ public class HorizontalLinearAxisBead extends AxisBaseBead implements IBead, IHorizontalAxisBead
{
/**
* constructor.
@@ -52,6 +52,9 @@ package org.apache.flex.charts.beads
*/
public function HorizontalLinearAxisBead()
{
+ super();
+
+ placement = "bottom";
}
private var _axisHeight:Number = 30;
@@ -134,8 +137,6 @@ package org.apache.flex.charts.beads
_maxValue = value;
}
- private var _strand:IStrand;
-
/**
* @copy org.apache.flex.core.IBead#strand
*
@@ -144,12 +145,12 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public function set strand(value:IStrand):void
+ override public function set strand(value:IStrand):void
{
- _strand = value;
+ super.strand = value;
// in order to draw or create the labels, need to know when the series has been created.
- IEventDispatcher(_strand).addEventListener("layoutComplete",handleItemsCreated);
+ IEventDispatcher(strand).addEventListener("layoutComplete",handleItemsCreated);
}
/**
@@ -180,32 +181,22 @@ package org.apache.flex.charts.beads
*/
private function handleItemsCreated(event:Event):void
{
- var model:ArraySelectionModel = _strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+ var model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
var items:Array;
if (model.dataProvider is Array) items = model.dataProvider as Array;
else return;
- var series:Array = IChart(_strand).series;
+ var series:Array = IChart(strand).series;
var yAxis:IVerticalAxisBead;
- if (_strand.getBeadByType(IVerticalAxisBead)) yAxis = _strand.getBeadByType(IVerticalAxisBead) as IVerticalAxisBead;
+ if (strand.getBeadByType(IVerticalAxisBead)) yAxis = strand.getBeadByType(IVerticalAxisBead) as IVerticalAxisBead;
var yAxisOffset:Number = yAxis == null ? 0 : yAxis.axisWidth;
var xpos:Number = yAxisOffset;
var xAxisHeightOffset:Number = axisHeight;
- var useWidth:Number = UIBase(_strand).width - yAxisOffset;
-
- // draw the horzontal axis
- var horzLine:FilledRectangle = new FilledRectangle();
- horzLine.fillColor = 0x111111;
- horzLine.x = xpos;
- horzLine.y = UIBase(_strand).height - xAxisHeightOffset;
- horzLine.height = 1;
- horzLine.width = useWidth;
- UIBase(_strand).addElement(horzLine);
-
- // place the labels below the axis enough to account for the tick marks
- var labelY:Number = UIBase(_strand).height + 8;
+ var useWidth:Number = UIBase(strand).width - yAxisOffset;
+ var originX:Number = xpos;
+ var originY:Number = UIBase(strand).height - xAxisHeightOffset;
// determine minimum and maximum values, if needed
if (isNaN(minValue)) {
@@ -230,29 +221,26 @@ package org.apache.flex.charts.beads
var tickSpacing:Number = useWidth/numTicks;
var tickValue:Number = minValue;
- // adjust xpos to the first tick position
-// xpos += tickSpacing;
+ // place the labels below the axis enough to account for the tick marks
+ var labelY:Number = UIBase(strand).height + 8;
for(i=0; i < numTicks+1; i++) {
var label:Label = new Label();
label.text = formatLabel(tickValue);
label.x = xpos - label.width/2;
label.y = labelY - xAxisHeightOffset;
+ UIBase(strand).addElement(label);
- UIBase(_strand).addElement(label);
-
- // add a tick mark, too
- var tick:FilledRectangle = new FilledRectangle();
- tick.fillColor = 0x111111;
- tick.x = xpos;
- tick.y = UIBase(_strand).height - xAxisHeightOffset;
- tick.width = 1;
- tick.height = 5;
- UIBase(_strand).addElement(tick);
+ // add a tick mark, too
+ addTickMark(xpos - originX, UIBase(strand).height - xAxisHeightOffset - originY, 0, 5);
xpos += tickSpacing;
tickValue += tickStep;
}
+
+ // draw the axis and tick marks
+ drawAxisPath(originX, originY, useWidth, 0);
+ drawTickPath(originX, originY);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
index b703f06..ebab6da 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalCategoryAxisBead.as
@@ -21,11 +21,11 @@ package org.apache.flex.charts.beads
import org.apache.flex.charts.core.IChart;
import org.apache.flex.charts.core.IHorizontalAxisBead;
import org.apache.flex.charts.core.IVerticalAxisBead;
- import org.apache.flex.core.FilledRectangle;
import org.apache.flex.core.IBead;
import org.apache.flex.core.ISelectionModel;
import org.apache.flex.core.IStrand;
import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.graphics.Path;
import org.apache.flex.events.Event;
import org.apache.flex.events.IEventDispatcher;
import org.apache.flex.html.Label;
@@ -42,7 +42,7 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public class VerticalCategoryAxisBead implements IBead, IVerticalAxisBead
+ public class VerticalCategoryAxisBead extends AxisBaseBead implements IBead, IVerticalAxisBead
{
/**
* constructor.
@@ -54,10 +54,11 @@ package org.apache.flex.charts.beads
*/
public function VerticalCategoryAxisBead()
{
+ super();
+
+ placement = "left";
}
-
- private var _strand:IStrand;
-
+
/**
* @copy org.apache.flex.core.IBead#strand
*
@@ -66,14 +67,14 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public function set strand(value:IStrand):void
+ override public function set strand(value:IStrand):void
{
- _strand = value;
+ super.strand = value;
// in order to draw or create the labels, need to know when the series has been created.
- IEventDispatcher(_strand).addEventListener("layoutComplete",handleItemsCreated);
+ IEventDispatcher(strand).addEventListener("layoutComplete",handleItemsCreated);
}
-
+
private var _categoryField:String;
/**
@@ -140,31 +141,24 @@ package org.apache.flex.charts.beads
*/
private function handleItemsCreated(event:Event):void
{
- var model:ArraySelectionModel = _strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+ var model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
var items:Array;
if (model.dataProvider is Array) items = model.dataProvider as Array;
else return;
- var series:Array = IChart(_strand).series;
+ var series:Array = IChart(strand).series;
var xAxis:IHorizontalAxisBead;
- if (_strand.getBeadByType(IHorizontalAxisBead)) xAxis = _strand.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
+ if (strand.getBeadByType(IHorizontalAxisBead)) xAxis = strand.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
var xAxisOffset:Number = xAxis == null ? 0 : xAxis.axisHeight;
var yAxisWidthOffset:Number = axisWidth;
- var useHeight:Number = (UIBase(_strand).height-xAxisOffset) / items.length;
+ var useHeight:Number = (UIBase(strand).height-xAxisOffset) / items.length;
var seriesHeight:Number = useHeight/series.length;
var xpos:Number = yAxisWidthOffset;
- var ypos:Number = UIBase(_strand).height - xAxisOffset - seriesHeight - gap;
-
- // draw the vertical axis
- var horzLine:FilledRectangle = new FilledRectangle();
- horzLine.fillColor = 0x111111;
- horzLine.x = yAxisWidthOffset;
- horzLine.y = 0;
- horzLine.height = UIBase(_strand).height - xAxisOffset;
- horzLine.width = 1;
- UIBase(_strand).addElement(horzLine);
+ var ypos:Number = UIBase(strand).height - xAxisOffset - seriesHeight - gap;
+ var originX:Number = yAxisWidthOffset;
+ var originY:Number = 0;
// place the labels left of the axis enough to account for the tick marks
var labelX:Number = 0;
@@ -175,20 +169,17 @@ package org.apache.flex.charts.beads
label.x = 0;
label.y = (ypos + useHeight/2) - label.height/2;
label.width = yAxisWidthOffset;
-
- UIBase(_strand).addElement(label);
-
- // add a tick mark, too
- var tick:FilledRectangle = new FilledRectangle();
- tick.fillColor = 0x111111;
- tick.x = yAxisWidthOffset - 5;
- tick.y = ypos + useHeight/2;
- tick.width = 5;
- tick.height = 1;
- UIBase(_strand).addElement(tick);
+ UIBase(strand).addElement(label);
+
+ // add a tick mark
+ addTickMark(yAxisWidthOffset - 5 - originX, ypos + useHeight/2 - originY, 5, 0);
ypos -= useHeight;
}
+
+ // draw the axis and tick marks
+ drawAxisPath(originX, originY, 0, UIBase(strand).height - xAxisOffset);
+ drawTickPath(originX, originY);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
index 930270f..8e8e183 100644
--- a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
+++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/charts/beads/VerticalLinearAxisBead.as
@@ -21,11 +21,11 @@ package org.apache.flex.charts.beads
import org.apache.flex.charts.core.IChart;
import org.apache.flex.charts.core.IHorizontalAxisBead;
import org.apache.flex.charts.core.IVerticalAxisBead;
- import org.apache.flex.core.FilledRectangle;
import org.apache.flex.core.IBead;
import org.apache.flex.core.ISelectionModel;
import org.apache.flex.core.IStrand;
import org.apache.flex.core.UIBase;
+ import org.apache.flex.core.graphics.Path;
import org.apache.flex.events.Event;
import org.apache.flex.events.IEventDispatcher;
import org.apache.flex.html.Label;
@@ -40,14 +40,15 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public class VerticalLinearAxisBead implements IBead, IVerticalAxisBead
+ public class VerticalLinearAxisBead extends AxisBaseBead implements IBead, IVerticalAxisBead
{
public function VerticalLinearAxisBead()
{
+ super();
+
+ placement = "left";
}
-
- private var _strand:IStrand;
-
+
/**
* @copy org.apache.flex.core.IBead#strand
*
@@ -56,12 +57,12 @@ package org.apache.flex.charts.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public function set strand(value:IStrand):void
+ override public function set strand(value:IStrand):void
{
- _strand = value;
+ super.strand = value;
// in order to draw or create the labels, need to know when the series has been created.
- IEventDispatcher(_strand).addEventListener("layoutComplete",handleItemsCreated);
+ IEventDispatcher(strand).addEventListener("layoutComplete",handleItemsCreated);
}
private var _axisWidth:Number = 50;
@@ -164,33 +165,23 @@ package org.apache.flex.charts.beads
*/
private function handleItemsCreated(event:Event):void
{
- var model:ArraySelectionModel = _strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
+ var model:ArraySelectionModel = strand.getBeadByType(ISelectionModel) as ArraySelectionModel;
var items:Array;
if (model.dataProvider is Array) items = model.dataProvider as Array;
else return;
- var series:Array = IChart(_strand).series;
+ var series:Array = IChart(strand).series;
var xAxis:IHorizontalAxisBead;
- if (_strand.getBeadByType(IHorizontalAxisBead)) xAxis = _strand.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
+ if (strand.getBeadByType(IHorizontalAxisBead)) xAxis = strand.getBeadByType(IHorizontalAxisBead) as IHorizontalAxisBead;
var xAxisOffset:Number = xAxis == null ? 0 : xAxis.axisHeight;
var yAxisWidthOffset:Number = axisWidth;
- var useHeight:Number = UIBase(_strand).height-xAxisOffset;
+ var useHeight:Number = UIBase(strand).height-xAxisOffset;
var xpos:Number = yAxisWidthOffset;
var ypos:Number = useHeight;
-
- // draw the vertical axis
- var horzLine:FilledRectangle = new FilledRectangle();
- horzLine.fillColor = 0x111111;
- horzLine.x = yAxisWidthOffset;
- horzLine.y = 0;
- horzLine.height = useHeight;
- horzLine.width = 1;
- UIBase(_strand).addElement(horzLine);
-
- // place the labels below the axis enough to account for the tick marks
- var labelY:Number = UIBase(_strand).height + 8;
+ var originX:Number = yAxisWidthOffset;
+ var originY:Number = 0;
// determine minimum and maximum values, if needed
if (isNaN(minValue)) {
@@ -218,27 +209,27 @@ package org.apache.flex.charts.beads
// adjust ypos to the first tick position
ypos = useHeight;// - tickSpacing;
+ // place the labels below the axis enough to account for the tick marks
+ var labelY:Number = UIBase(strand).height + 8;
+
for(i=0; i < numTicks+1; i++) {
var label:Label = new Label();
label.text = formatLabel(tickValue);
label.x = 0;
label.y = ypos - label.height/2;
-
- UIBase(_strand).addElement(label);
-
- // add a tick mark, too
- var tick:FilledRectangle = new FilledRectangle();
- tick.fillColor = 0x111111;
- tick.x = xpos - 5;
- tick.y = ypos;
- tick.width = 5;
- tick.height = 1;
- UIBase(_strand).addElement(tick);
+ UIBase(strand).addElement(label);
+
+ // add a tick mark, too.
+ addTickMark(xpos - 5 - originX, ypos - originY, 5, 0);
ypos -= tickSpacing;
tickValue += tickStep;
}
+ // draw the axis and the tick marks
+ drawAxisPath(originX, originY, 0, useHeight);
+ drawTickPath(originX, originY);
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IAxisBead.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IAxisBead.as
new file mode 100644
index 0000000..4cae731
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IAxisBead.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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 org.apache.flex.charts.core
+{
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.graphics.IStroke;
+
+ public interface IAxisBead extends IBead
+ {
+ /**
+ * The placement of the axis with respect to the chart area. Valid
+ * values are: top, bottom (for IHorizontalAxisBeads), left, and right
+ * (for IVerticalAxisBeads).
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ function get placement():String;
+ function set placement(value:String):void;
+
+ /**
+ * The stroke used for the axis line
+ */
+ function get axisStroke():IStroke;
+ function set axisStroke(value:IStroke):void;
+
+ /**
+ * The stroked used for the tick marks
+ */
+ function get tickStroke():IStroke;
+ function set tickStroke(value:IStroke):void;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
index fa49a6e..a1795ae 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IHorizontalAxisBead.as
@@ -27,7 +27,7 @@ package org.apache.flex.charts.core
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public interface IHorizontalAxisBead
+ public interface IHorizontalAxisBead extends IAxisBead
{
/**
* The overall height of the axis, including its labels.
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b5c2ae07/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
index 5d04231..4fd76ef 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/charts/core/IVerticalAxisBead.as
@@ -27,7 +27,7 @@ package org.apache.flex.charts.core
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public interface IVerticalAxisBead
+ public interface IVerticalAxisBead extends IAxisBead
{
/**
* The overall width of the horizontal axis.
[2/2] git commit: [flex-asjs] [refs/heads/develop] - JavaScript
version of axis changes that use flex.core.graphics for renderer axis and
tick marks.
Posted by pe...@apache.org.
JavaScript version of axis changes that use flex.core.graphics for renderer axis and tick marks.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/aaf60ed3
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/aaf60ed3
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/aaf60ed3
Branch: refs/heads/develop
Commit: aaf60ed30c84f53d932116225f5bdc7be44dace0
Parents: b5c2ae0
Author: Peter Ent <pe...@apache.org>
Authored: Mon Oct 13 17:16:01 2014 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Mon Oct 13 17:16:01 2014 -0400
----------------------------------------------------------------------
.../org/apache/flex/charts/core/IAxisBead.js | 79 ++++++++++++++++++++
.../flex/charts/core/IHorizontalAxisBead.js | 6 +-
.../flex/charts/core/IVerticalAxisBead.js | 6 +-
3 files changed, 89 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/aaf60ed3/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IAxisBead.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IAxisBead.js b/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IAxisBead.js
new file mode 100644
index 0000000..25d1c3c
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IAxisBead.js
@@ -0,0 +1,79 @@
+/**
+ * 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.
+ *
+ * org.apache.flex.charts.core.IAxisBead
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes}
+ */
+
+goog.provide('org.apache.flex.charts.core.IAxisBead');
+
+goog.require('org.apache.flex.core.IBead');
+
+
+
+/**
+ * @interface
+ * @extends {org.apache.flex.core.IBead}
+ */
+org.apache.flex.charts.core.IAxisBead = function() {
+};
+
+
+/**
+ * @return {string}
+ */
+org.apache.flex.charts.core.IAxisBead.prototype.get_placement = function() {};
+
+
+/**
+ * @param {string} value
+ */
+org.apache.flex.charts.core.IAxisBead.prototype.set_placement = function(value) {};
+
+
+/**
+ * @return {Object}
+ */
+org.apache.flex.charts.core.IAxisBead.prototype.get_axisStroke = function() {};
+
+
+/**
+ * @param {Object} value
+ */
+org.apache.flex.charts.core.IAxisBead.prototype.set_axisStroke = function(value) {};
+
+
+/**
+ * @return {Object}
+ */
+org.apache.flex.charts.core.IAxisBead.prototype.get_tickStroke = function() {};
+
+
+/**
+ * @param {Object} value
+ */
+org.apache.flex.charts.core.IAxisBead.prototype.set_tickStroke = function(value) {};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+org.apache.flex.charts.core.IAxisBead.prototype.FLEXJS_CLASS_INFO = {
+ names: [{ name: 'IAxisBead', qName: 'org.apache.flex.charts.core.IAxisBead'}],
+ interfaces: [org.apache.flex.core.IBead]
+ };
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/aaf60ed3/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IHorizontalAxisBead.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IHorizontalAxisBead.js b/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IHorizontalAxisBead.js
index 0b0cf7b..f397df3 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IHorizontalAxisBead.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IHorizontalAxisBead.js
@@ -20,10 +20,13 @@
goog.provide('org.apache.flex.charts.core.IHorizontalAxisBead');
+goog.require('org.apache.flex.charts.core.IAxisBead');
+
/**
* @interface
+ * @extends {org.apache.flex.charts.core.IAxisBead}
*/
org.apache.flex.charts.core.IHorizontalAxisBead = function() {
};
@@ -35,7 +38,8 @@ org.apache.flex.charts.core.IHorizontalAxisBead = function() {
* @type {Object.<string, Array.<Object>>}
*/
org.apache.flex.charts.core.IHorizontalAxisBead.prototype.FLEXJS_CLASS_INFO = {
- names: [{ name: 'IHorizontalAxisBead', qName: 'org.apache.flex.charts.core.IHorizontalAxisBead'}]
+ names: [{ name: 'IHorizontalAxisBead', qName: 'org.apache.flex.charts.core.IHorizontalAxisBead'}],
+ interfaces: [org.apache.flex.charts.core.IAxisBead]
};
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/aaf60ed3/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IVerticalAxisBead.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IVerticalAxisBead.js b/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IVerticalAxisBead.js
index 5460719..5bdec4f 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IVerticalAxisBead.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/charts/core/IVerticalAxisBead.js
@@ -20,10 +20,13 @@
goog.provide('org.apache.flex.charts.core.IVerticalAxisBead');
+goog.require('org.apache.flex.charts.core.IAxisBead');
+
/**
* @interface
+ * @extends {org.apache.flex.charts.core.IAxisBead}
*/
org.apache.flex.charts.core.IVerticalAxisBead = function() {
};
@@ -35,7 +38,8 @@ org.apache.flex.charts.core.IVerticalAxisBead = function() {
* @type {Object.<string, Array.<Object>>}
*/
org.apache.flex.charts.core.IVerticalAxisBead.prototype.FLEXJS_CLASS_INFO = {
- names: [{ name: 'IVerticalAxisBead', qName: 'org.apache.flex.charts.core.IVerticalAxisBead'}]
+ names: [{ name: 'IVerticalAxisBead', qName: 'org.apache.flex.charts.core.IVerticalAxisBead'}],
+ interfaces: [org.apache.flex.charts.core.IAxisBead]
};