summaryrefslogtreecommitdiff
path: root/lib/Graph
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-05-21 16:33:56 +0200
committerfranck cuny <franck@lumberjaph.net>2011-05-21 16:33:56 +0200
commit5b471951b6e269cc29f3b23148944ba3bc1c9e6c (patch)
treec0d88840feb5b4e40db1d182eb722c8f7f7b58fa /lib/Graph
parentadd attribute 'visualization' (diff)
downloadgraph-gexf-5b471951b6e269cc29f3b23148944ba3bc1c9e6c.tar.gz
udpate roles for viz
Signed-off-by: franck cuny <franck@lumberjaph.net>
Diffstat (limited to 'lib/Graph')
-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',