@@ -263,6 +263,7 @@ This method is useful for adding some styles to a particular edge before being p
263263 - _graph_ Access a <Graph> instance.
264264 - _op_ Access a <Hypertree.Op> instance.
265265 - _fx_ Access a <Hypertree.Plot> instance.
266+ - _labels_ Access a <Hypertree.Label> instance.
266267*/
267268
268269this . Hypertree = new Class ( {
@@ -321,7 +322,7 @@ this.Hypertree = new Class({
321322 }
322323 } ;
323324 this . graph = new Graph ( this . graphOptions ) ;
324- this . labels = new Hypertree . Label [ canvas . getConfig ( ) . labels ] ( ) ;
325+ this . labels = new Hypertree . Label [ canvas . getConfig ( ) . labels ] ( this ) ;
325326 this . fx = new Hypertree . Plot ( this ) ;
326327 this . op = new Hypertree . Op ( this ) ;
327328 this . json = null ;
@@ -608,13 +609,14 @@ Hypertree.Plot = new Class({
608609 Implements : Graph . Plot ,
609610
610611 initialize : function ( viz ) {
611- this . viz = viz ;
612- this . config = viz . config ;
612+ this . viz = viz ;
613+ this . config = viz . config ;
613614 this . node = this . config . Node ;
614615 this . edge = this . config . Edge ;
615- this . animation = new Animation ;
616- this . nodeTypes = new Hypertree . Plot . NodeTypes ;
617- this . edgeTypes = new Hypertree . Plot . EdgeTypes ;
616+ this . animation = new Animation ;
617+ this . nodeTypes = new Hypertree . Plot . NodeTypes ;
618+ this . edgeTypes = new Hypertree . Plot . EdgeTypes ;
619+ this . labels = viz . labels ;
618620 } ,
619621
620622 /*
@@ -737,7 +739,26 @@ Hypertree.Label = {};
737739
738740*/
739741Hypertree . Label . Native = new Class ( {
740- Implements : Graph . Label . Native
742+ Extends : Graph . Label . Native ,
743+
744+ /*
745+ Method: plotLabel
746+
747+ Plots a label for a given node.
748+
749+ Parameters:
750+
751+ canvas - A <Canvas> instance.
752+ node - A <Graph.Node>.
753+ controller - A configuration object. See also <Hypertree>, <RGraph>, <ST>.
754+
755+ */
756+ plotLabel : function ( canvas , node , controller ) {
757+ var ctx = canvas . getCtx ( ) ;
758+ var coord = node . pos . getc ( true ) ;
759+ var scale = node . _scale ;
760+ ctx . fillText ( node . name , coord . x * scale , coord . y * scale ) ;
761+ }
741762} ) ;
742763
743764/*
@@ -776,13 +797,13 @@ Hypertree.Label.SVG = new Class({
776797 placeLabel : function ( tag , node , controller ) {
777798 var pos = node . pos . getc ( true ) , canvas = this . viz . canvas ;
778799 var radius = canvas . getSize ( ) ;
800+ var scale = node . _scale ;
779801 var labelPos = {
780- x : Math . round ( pos . x + radius . width / 2 ) ,
781- y : Math . round ( pos . y + radius . height / 2 )
802+ x : Math . round ( pos . x * scale + radius . width / 2 ) ,
803+ y : Math . round ( pos . y * scale + radius . height / 2 )
782804 } ;
783805 tag . setAttribute ( 'x' , labelPos . x ) ;
784806 tag . setAttribute ( 'y' , labelPos . y ) ;
785-
786807 controller . onPlaceLabel ( tag , node ) ;
787808 }
788809} ) ;
@@ -822,11 +843,11 @@ Hypertree.Label.HTML = new Class({
822843 placeLabel : function ( tag , node , controller ) {
823844 var pos = node . pos . getc ( true ) , canvas = this . viz . canvas ;
824845 var radius = canvas . getSize ( ) ;
846+ var scale = node . _scale ;
825847 var labelPos = {
826- x : Math . round ( pos . x + radius . width / 2 ) ,
827- y : Math . round ( pos . y + radius . height / 2 )
848+ x : Math . round ( pos . x * scale + radius . width / 2 ) ,
849+ y : Math . round ( pos . y * scale + radius . height / 2 )
828850 } ;
829-
830851 var style = tag . style ;
831852 style . left = labelPos . x + 'px' ;
832853 style . top = labelPos . y + 'px' ;
0 commit comments