summaryrefslogtreecommitdiff
path: root/lib/Graph/GEXF/Role/Viz
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Graph/GEXF/Role/Viz')
-rw-r--r--lib/Graph/GEXF/Role/Viz/Color.pm20
-rw-r--r--lib/Graph/GEXF/Role/Viz/Shape.pm11
2 files changed, 27 insertions, 4 deletions
diff --git a/lib/Graph/GEXF/Role/Viz/Color.pm b/lib/Graph/GEXF/Role/Viz/Color.pm
index 166186f..e168ad1 100644
--- a/lib/Graph/GEXF/Role/Viz/Color.pm
+++ b/lib/Graph/GEXF/Role/Viz/Color.pm
@@ -3,14 +3,28 @@ package Graph::GEXF::Role::Viz::Color;
use Moose::Role;
use Moose::Util::TypeConstraints;
-subtype RGBColor => as 'Int' => where { $_ >= 0 && $_ <= 255 };
+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',
+ is => 'rw',
+ isa => 'RGBColor',
+ default => 0,
+ trigger => sub {$_has_colors++},
+);
+
+has a => (
+ is => 'rw',
+ isa => 'Alpha',
+ default => 1,
);
+sub has_colors { $_has_colors }
+
no Moose::Util::TypeConstraints;
no Moose::Role;
+
1;
diff --git a/lib/Graph/GEXF/Role/Viz/Shape.pm b/lib/Graph/GEXF/Role/Viz/Shape.pm
index f522786..f8e57de 100644
--- a/lib/Graph/GEXF/Role/Viz/Shape.pm
+++ b/lib/Graph/GEXF/Role/Viz/Shape.pm
@@ -14,7 +14,16 @@ parameter for => (
role {
my $p = shift;
- my $type = lcfirst( $p->for ) . 'Shape';
+ my ( $type, $default );
+
+ $type = lcfirst( $p->for ) . 'Shape';
+
+ if ( $p->for eq 'node' ) {
+ $default = 'disc';
+ }
+ else {
+ $default = 'solid';
+ }
has shape => (
is => 'rw',