| 1 | package Math::Geometry::Construction::Point; | ||||||||||
| 2 | |||||||||||
| 3 | 15 | ▶ | use 5.008008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 15 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 15 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | C<Math::Geometry::Construction::Point> - abstract point base class | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 0.018 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 15 | our $VERSION = '0.018'; | |||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | ########################################################################### | ||||||||||
| 22 | # # | ||||||||||
| 23 | # Class Variables and Methods # | ||||||||||
| 24 | # # | ||||||||||
| 25 | ########################################################################### | ||||||||||
| 26 | |||||||||||
| 27 | 15 | our $ID_TEMPLATE = 'P%09d'; | |||||||||
| 28 | |||||||||||
| 29 | 242 | ▶ | sub id_template { return $ID_TEMPLATE } | ||||||||
|
Subroutine
id_template: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 30 | |||||||||||
| 31 | ########################################################################### | ||||||||||
| 32 | # # | ||||||||||
| 33 | # Accessors # | ||||||||||
| 34 | # # | ||||||||||
| 35 | ########################################################################### | ||||||||||
| 36 | |||||||||||
| 37 | 15 | with 'Math::Geometry::Construction::Role::Object'; | |||||||||
| 38 | 15 | with 'Math::Geometry::Construction::Role::Output'; | |||||||||
| 39 | |||||||||||
| 40 | 15 | has 'size' => (isa => 'Num', | |||||||||
| 41 | is => 'rw', | ||||||||||
| 42 | trigger => \&_size_trigger, | ||||||||||
| 43 | builder => '_build_size', | ||||||||||
| 44 | lazy => 1); | ||||||||||
| 45 | |||||||||||
| 46 | 15 | has 'radius' => (isa => 'Num', | |||||||||
| 47 | is => 'rw', | ||||||||||
| 48 | trigger => \&_radius_trigger, | ||||||||||
| 49 | builder => '_build_radius', | ||||||||||
| 50 | lazy => 1); | ||||||||||
| 51 | |||||||||||
| 52 | 357 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 53 | 357 | my ($self) = @_; | |||||||||
| 54 | |||||||||||
| 55 | 357 | ▶ | $self->style('stroke', 'black') unless($self->style('stroke')); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 357 | ▶ | $self->style('fill', 'white') unless($self->style('fill')); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 2 | ▶ | sub _size_trigger { | ||||||||
|
Subroutine
_size_trigger: called CC=1 SCAR=0.0
| |||||||||||
| 60 | 2 | my ($self, $new, $old) = @_; | |||||||||
| 61 | |||||||||||
| 62 | # dirty | ||||||||||
| 63 | 2 | $self->{radius} = $new / 2; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 7 | ▶ | sub _build_size { | ||||||||
|
Subroutine
_build_size: called CC=1 SCAR=0.0
| |||||||||||
| 67 | 7 | my ($self) = @_; | |||||||||
| 68 | |||||||||||
| 69 | 7 | return $self->construction->point_size; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | sub _radius_trigger { | ||||||||
|
Subroutine
_radius_trigger: not called CC=1 SCAR=6.9
| |||||||||||
| 73 | 0 | my ($self, $new, $old) = @_; | |||||||||
| 74 | |||||||||||
| 75 | 0 | warn("The 'radius' attribute of Math::Geometry::Construction::Point ". | |||||||||
| 76 | "is deprecated and might be removed in a future version. Use ". | ||||||||||
| 77 | "'size' with the double value (diameter of the circle) ". | ||||||||||
| 78 | "instead.\n"); | ||||||||||
| 79 | |||||||||||
| 80 | 0 | $self->size(2 * $new); | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 2 | ▶ | sub _build_radius { | ||||||||
|
Subroutine
_build_radius: called CC=1 SCAR=0.0
| |||||||||||
| 84 | 2 | return($_[0]->_build_size / 2); | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | ########################################################################### | ||||||||||
| 88 | # # | ||||||||||
| 89 | # Retrieve Data # | ||||||||||
| 90 | # # | ||||||||||
| 91 | ########################################################################### | ||||||||||
| 92 | |||||||||||
| 93 | 0 | ▶ | sub position { croak "Method position must be overloaded" } | ||||||||
|
Subroutine
position: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 94 | |||||||||||
| 95 | sub id { croak "Method id must be overloaded" } | ||||||||||
| 96 | |||||||||||
| 97 | 29 | ▶ | sub draw { | ||||||||
|
Subroutine
draw: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||
| 98 | 29 | my ($self, %args) = @_; | |||||||||
| 99 | 29 | ▶ | return undef if $self->hidden; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | |||||||||||
| 101 | 9 | my $position = $self->position; | |||||||||
| 102 | 9 | ▶ | if(!defined($position)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | 0 | warn sprintf("Undefined position of point %s, ". | |||||||||
| 104 | "nothing to draw.\n", $self->id); | ||||||||||
| 105 | 0 | return undef; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 9 | $self->construction->draw_circle(cx => $position->[0], | |||||||||
| 109 | cy => $position->[1], | ||||||||||
| 110 | r => $self->size / 2, | ||||||||||
| 111 | style => $self->style_hash, | ||||||||||
| 112 | id => $self->id); | ||||||||||
| 113 | |||||||||||
| 114 | 9 | $self->draw_label('x' => $position->[0], 'y' => $position->[1]); | |||||||||
| 115 | |||||||||||
| 116 | 9 | return undef; | |||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | ########################################################################### | ||||||||||
| 120 | # # | ||||||||||
| 121 | # Change Data # | ||||||||||
| 122 | # # | ||||||||||
| 123 | ########################################################################### | ||||||||||
| 124 | |||||||||||
| 125 | 15 | 1; | |||||||||
| 126 | |||||||||||
| 127 | |||||||||||
| 128 | __END__ | ||||||||||