martin.berg
unread,Sep 8, 2009, 9:07:47 AM9/8/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to juicekit
Hmm
I kinda got something working
class CustomShapeRenderer extends ShapeRenderer {
public var t:TreeMapControl;
public function CustomShapeRenderer(t:TreeMapControl,
defaultSize:Number=6) {
super();
this.t = t as TreeMapControl;
}
override public function render(d:DataSprite):void {
var ns:NodeSprite = d as NodeSprite;
var lineAlpha:Number = d.lineAlpha;
var fillAlpha:Number = d.fillAlpha;
var lineColor:Number = d.lineColor;
var fillColor:Number = d.fillColor;
var size:Number = d.size * defaultSize;
var g:Graphics = d.graphics;
g.clear();
// Determine if to show level
if(t.getCurrentRootLevel() != ns.depth - 1) {
trace("return " + t.getCurrentRootLevel() + " - " + ns.depth);
// make sure to draw leaves
if(ns.childDegree == 0 && t.getCurrentRootLevel() == ns.depth) {
} else{
return;}
} else { trace("draw");}
if (fillAlpha > 0) g.beginFill(fillColor, 1);
if (lineAlpha > 0) g.lineStyle(d.lineWidth, d.lineColor,
lineAlpha);
const lw:Number = d.lineWidth;
switch (d.shape) {
case null:
break;
case Shapes.TREEMAPBLOCK:
//Alert.show("TREEMAPBLOCK", "-");
// This draws a rectangle inside of a rectangle.
// This serves as a replacement for Shapes.BLOCK
// This behaves in an identical fashion to the original flash
line border
// in that the borders are drawn on the outside of the shape.
// Shapes are scaled down by the amount of the linewidth area
in the
// treemap layout to achieve smooth treemap nirvana.
g.lineStyle(0.0, 0, 0);
if (lineColor == 0xffffff && lineAlpha == 1.0) {
g.beginFill(0xffff00, 0.99);
} else {
g.beginFill(0xffff00, lineAlpha);
}
g.drawRect(d.u-d.x-d.lineWidth/2, d.v-d.y-d.lineWidth/2, d.w
+d.lineWidth, d.h+d.lineWidth);
// Rectangles with a white (0xffffffff) fill are rendered as
transparent in flash graphics.
// We slightly decrease the alpha in these cases to avoid
errors.
if (fillColor == 0xffffff && fillAlpha == 1.0) {
g.beginFill(0xff00ff, 0.99);
} else {
g.beginFill(0xff00ff, fillAlpha);
}
g.drawRect(d.u-d.x, d.v-d.y, d.w, d.h);
break;
case Shapes.BLOCK:
trace(ns.depth + "draw " + size + " " + (d.u-d.x) + "," +
(d.v-d.y) + "," + d.w +"," + d.h + "," + fillColor + "," + fillAlpha);
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.clear();
if (lw > 0) {
g.beginFill(d.lineColor, d.lineAlpha);
g.drawRect(-size/2, -d.h, size, d.h);
}
g.beginFill(d.fillColor, fillAlpha);
if (d.h > 0) {
g.drawRect(-size/2+lw, -d.h+lw, size-lw*2, d.h-lw*2);
}
else {
// Reversed bars
g.drawRect(-size/2+lw, -d.h-lw, size-lw*2, d.h+lw*2);
}
break;
case Shapes.HORIZONTAL_BAR:
g.clear();
if (lw > 0) {
g.beginFill(d.lineColor, d.lineAlpha);
g.drawRect(-d.w, -size/2, d.w, size);
}
g.beginFill(d.fillColor, fillAlpha);
if (d.w > 0) {
g.drawRect(-d.w+lw, -size/2+lw, d.w-lw*2, size-lw*2);
}
else {
// Reversed bars
g.drawRect(-d.w-lw, -size/2+lw, d.w+lw*2, size-lw*2);
}
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();
}
}
The whole thing is in
// Determine if to show level
if(t.getCurrentRootLevel() != ns.depth - 1) {
trace("return " + t.getCurrentRootLevel() + " - " + ns.depth);
// make sure to draw leaves
if(ns.childDegree == 0 && t.getCurrentRootLevel() == ns.depth) {
} else{
return;}
}
Except the colors dont work on higher levels, its just a single
brownish color