1 package Text::Tradition::Collation::Segment;
6 extends 'Graph::Easy::Node';
8 # A segment is a special 'invisible' node that is a set of Readings.
9 # We should never display these, but it is useful to have them
10 # available for many-to-many relationship mappings.
14 isa => 'ArrayRef[Text::Tradition::Collation::Reading]',
18 sub FOREIGNBUILDARGS {
22 # Name the segment after its member elements.
23 my $nodename = join( ' ', map { $_->name } @{$args{'members'}} );
24 return ( 'name', $nodename );
28 my( $self, $args ) = @_;
29 $self->set_attribute( 'class', 'segment' );
31 foreach my $r ( @{$self->members} ) {
32 my $seg_edge = $r->parent->add_edge( $r, $self, 'segment' );
33 $seg_edge->set_attribute( 'class', 'segment' );
37 # For now, a segment has no position in the graph. Eventually it might
38 # have the position of its first member.
44 __PACKAGE__->meta->make_immutable;
48 ######################################################
49 ## copied from Graph::Easy::Parser docs
50 ######################################################
51 # when overriding nodes, we also need ::Anon
53 package Text::Tradition::Collation::Segment::Anon;
56 extends 'Text::Tradition::Collation::Segment';
57 extends 'Graph::Easy::Node::Anon';
59 __PACKAGE__->meta->make_immutable;
62 # use base qw/Text::Tradition::Collation::Segment/;
63 # use base qw/Graph::Easy::Node::Anon/;
65 ######################################################
68 package Text::Tradition::Collation::Segment::Empty;
71 extends 'Graph::Easy::Node::Empty';
73 __PACKAGE__->meta->make_immutable;
76 # use base qw/Text::Tradition::Collation::Segment/;
78 ######################################################