martin.berg
unread,Aug 24, 2009, 8:01:47 AM8/24/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to juicekit
Hi,
I've been trying to set the label background so that the labels a
better highlighted, even tried to modify the lib
but could not get it to work.
Is it possible to set the label background without modifying the lib
or how in sudo code would you modify it to add this, even hardcode it.
??
Thannks
Some code(I wrote a custom renderer 'extends ShapeRenderer for this
class CustRenderer extends ShapeRenderer {
private var hColor:uint;
private var hLimit:uint;
private var hField:String;
private var depth:uint;
private static var array:Array;
private static var lList:ArrayCollection;
array = new Array(20);
lList = new ArrayCollection(array);
public function CustRenderer(defaultSize:Number = 6, hColor:uint =
0xFF0000, hLimit:uint = 0, hField:String = "PercentOpened", depth:uint
= 0) {
super(defaultSize);
this.hColor = hColor;
this.hLimit = hLimit;
this.hField = hField;
this.depth = depth;
}
override public function render(d:DataSprite):void {
var lineAlpha:Number = d.lineAlpha;
var fillAlpha:Number = d.fillAlpha;
var size:Number = d.size * defaultSize;
var g:Graphics = d.graphics;
g.clear();
var label:TextSprite = d.props["#label#"];
if (fillAlpha > 0) g.beginFill(d.fillColor, fillAlpha);
if (lineAlpha > 0) g.lineStyle(d.lineWidth, d.lineColor, lineAlpha);
switch (d.shape) {
case null:
break;
case Shapes.BLOCK: {
//Alert.show(depth.toString(), "-");
/*if(d.parent.hasOwnProperty("#label#") && d.parent.y == d.y){
Alert.show("?", "?");
g.drawRect(d.u-d.x, d.u-d.x + 14, d.w, d.h - 14);
}else
g.drawRect(d.u-d.x, d.v-d.y, d.w, d.h);*/
if(label == null || label.text.length == 0) {
//if(lList.contains(d.y.toString() + "-" + (depth -1).toString
()))
//if(lList.contains((d.v-d.y).toString() + "-" + depth.toString
()))
//if(d.h > 14)
var colides:int = 1;
for(var i:int = 0; i < lList.length; i++) {
var po:PanelObject = lList[i];
if(po != null && d.y == po.y && po.d == (this.depth - 1))
colides = 2;
}
if(colides == 2 && d.h > 14)
g.drawRect(d.u-d.x, d.v-d.y + 14, d.w, d.h - 14);
else
g.drawRect(d.u-d.x, d.v-d.y, d.w, d.h);
} else {
colides = 1;
for(var i:int = 0; i < lList.length; i++) {
var po:PanelObject = lList[i];
if(po != null && d.y == po.y && po.d == this.depth) {
//Alert.show("" +po.y.toString(), "1");
colides = 2;
}
}
if(colides == 1)
lList.addItem(new PanelObject(d.x ,d.y, d.w, this.depth));
//Alert.show((d.v-d.y).toString() + "-" + depth.toString
());
//}
g.drawRect(d.u-d.x, d.v-d.y, d.w, d.h);
}
break;
} case Shapes.POLYGON:
if (d.points!=null)
Shapes.drawPolygon(g, d.points);
break;
case Shapes.POLYBLOB:
if (d.points!=null)
Shapes.drawCardinal(g, d.points,
d.points.length/2, 0.15, true);
break;
case Shapes.VERTICAL_BAR:
g.drawRect(-size/2, -d.h, size, d.h);
break;
case Shapes.HORIZONTAL_BAR:
g.drawRect(-d.w, -size/2, d.w, size);
break;
case Shapes.WEDGE:
Shapes.drawWedge(g, d.origin.x-d.x, d.origin.y-d.y, d.h, d.v, d.u,
d.u+d.w);
break;
default:
Shapes.getShape(d.shape)(g, size);
}
if (fillAlpha > 0) g.endFill();
// Highlight
var num:Number = int(d.data[hField]);
if(num <= hLimit) {
g.beginFill(hColor, 1);
g.drawRect(d.u-d.x, d.v-d.y, d.w, d.h);
g.endFill();
}
if(label != null && label.text.length > 0 ) {
//Alert.show(label.text, "-");
g.beginFill(0xFFFF00, 1);
g.drawRect(d.u-d.x, d.v-d.y, d.w, 14);
g.endFill();
} else {
//g.beginFill(0xFF00FF, 1);
//g.drawRect(d.u-d.x, d.v-d.y -14, d.w, 14);
//g.endFill();
}
// Paint label background
//if(label == null) {
//g.beginFill(0xFFFFFF, 1);
//g.drawRect(d.u-d.x, d.v-d.y, d.w, 14);
//g.endFill();
//}
}
}
class PanelObject {
var x:int;
var y:int;
var w:int;
var d:uint;
public function PanelObject(x:int, y:int, w:int, d:uint) {
this.d = d;
this.x = x;
this.y = y;
this.w = w;
}
}
Unfortunately it does not do it correctly