# NOTE: Derived from blib/lib/Tk/TreeGraph.pm.
# Changes made here will be lost when autosplit is run again.
# See AutoSplit.pm.
package Tk::TreeGraph;

#line 1116 "blib/lib/Tk/TreeGraph.pm (autosplit into blib/lib/auto/Tk/TreeGraph/modifyNode.al)"
sub modifyNode
  {
    my $dw = shift ;
    my %args = @_ ;

    my $nodeId = $args{-nodeId} || $args{nodeId} || $dw->getCurrentNodeId; # optional

    croak "modifyNode: missing nodeId parameter" 
      unless defined $nodeId;

    my $rid = $dw->{node}{rectangle}{$nodeId} ; # retrieve id of rectangle
    my $tid = $dw->{node}{text}{$nodeId} ; 

    croak "modifyNode: unknown nodeId : $nodeId" unless defined $rid ;

    my $nc = $args{-nodeColor} || $args{nodeColor} ;
    if (defined $nc)
      {
        $dw->itemconfigure($rid, -outline => $nc) ;
      }

    my $text_parm = defined $args{-text} ? $args{-text} : $args{text} ;
    if (defined $text_parm)
      {
        my $text = ref $text_parm ? join("\n",$text_parm) : $text_parm;
        chomp $text ;

        $text = $nodeId."\n$text" if $dw->cget('-nodeTag') ;
        my $count = $text ;
        $count =~ s/[^\n]// ;

        my $oldText = $dw->itemcget($tid, '-text' ) ;
        $oldText =~ s/[^\n]// ;

        if (length($count) > length($oldText))
          {
            croak "modifyNode error: New text is longer than the old one. It will no fit in the node" ;
          }

        $dw->itemconfigure($tid, -text => $text) ;
      }

    my $ntc = $args{-nodeTextColor} || $args{nodeTextColor} ;
    if (defined $ntc)
      {
        $dw->itemconfigure($tid, -fill => $ntc) ;
      }

    my $nf = $args{-nodeFill} || $args{nodeFill} ;
    if (defined $nf)
      {
        $dw->itemconfigure($rid, -fill => $nf) ;
      }
  }

# end of Tk::TreeGraph::modifyNode
1;
