diff options
Diffstat (limited to 'lib/Graph/GEXF/Role/Viz')
| -rw-r--r-- | lib/Graph/GEXF/Role/Viz/Color.pm | 32 | ||||
| -rw-r--r-- | lib/Graph/GEXF/Role/Viz/Position.pm | 18 | ||||
| -rw-r--r-- | lib/Graph/GEXF/Role/Viz/Shape.pm | 39 | ||||
| -rw-r--r-- | lib/Graph/GEXF/Role/Viz/Size.pm | 21 |
4 files changed, 110 insertions, 0 deletions
diff --git a/lib/Graph/GEXF/Role/Viz/Color.pm b/lib/Graph/GEXF/Role/Viz/Color.pm new file mode 100644 index 0000000..d7c30f1 --- /dev/null +++ b/lib/Graph/GEXF/Role/Viz/Color.pm @@ -0,0 +1,32 @@ +package Graph::GEXF::Role::Viz::Color; + +use Moose::Role; +use Moose::Util::TypeConstraints; + +subtype RGBColor => as 'Num' => where { $_ >= 0 && $_ <= 255 }; +subtype Alpha => as 'Num' => where { $_ > 0 and $_ <= 1 }; + +my $_has_colors = 0; + +has [qw/r g b/] => ( + is => 'rw', + isa => 'RGBColor', + default => 0, + trigger => sub {$_has_colors++}, + traits => ['Chained'], +); + +has a => ( + is => 'rw', + isa => 'Alpha', + default => 1, + traits => ['Chained'], +); + +sub has_colors { $_has_colors } + +no Moose::Util::TypeConstraints; +no Moose::Role; + + +1; diff --git a/lib/Graph/GEXF/Role/Viz/Position.pm b/lib/Graph/GEXF/Role/Viz/Position.pm new file mode 100644 index 0000000..c9e79c3 --- /dev/null +++ b/lib/Graph/GEXF/Role/Viz/Position.pm @@ -0,0 +1,18 @@ +package Graph::GEXF::Role::Viz::Position; + +use Moose::Role; + +my $_has_position = 0; + +has [qw/x y z/] => ( + is => 'rw', + isa => 'Num', + trigger => sub { $_has_position++ }, + traits => ['Chained'], +); + +sub has_position { $_has_position } + +no Moose::Role; + +1; diff --git a/lib/Graph/GEXF/Role/Viz/Shape.pm b/lib/Graph/GEXF/Role/Viz/Shape.pm new file mode 100644 index 0000000..b092d6d --- /dev/null +++ b/lib/Graph/GEXF/Role/Viz/Shape.pm @@ -0,0 +1,39 @@ +package Graph::GEXF::Role::Viz::Shape; + +use Moose::Util::TypeConstraints; +use MooseX::Role::Parameterized; + +enum EdgeShape => qw(solid doted dashed double); +enum NodeShape => qw(disc square triangle diamond); + +parameter for => ( + is => 'ro', + required => 1, +); + +role { + my $p = shift; + + my ( $type, $default ); + + $type = ucfirst( $p->for ) . 'Shape'; + + if ( $p->for eq 'node' ) { + $default = 'disc'; + } + else { + $default = 'solid'; + } + + has shape => ( + is => 'rw', + isa => $type, + default => $default, + traits => ['Chained'], + ); +}; + +no Moose::Util::TypeConstraints; + +1; + diff --git a/lib/Graph/GEXF/Role/Viz/Size.pm b/lib/Graph/GEXF/Role/Viz/Size.pm new file mode 100644 index 0000000..aef1574 --- /dev/null +++ b/lib/Graph/GEXF/Role/Viz/Size.pm @@ -0,0 +1,21 @@ +package Graph::GEXF::Role::Viz::Size; + +use MooseX::Role::Parameterized; + +parameter as => ( + is => 'ro', + required => 1, +); + +role { + my $p = shift; + + has $p->as => ( + is => 'rw', + isa => 'Num', + default => '1.0', + traits => ['Chained'], + ); +}; + +1; |
