summaryrefslogtreecommitdiff
path: root/lib/Graph/GEXF
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Graph/GEXF')
-rw-r--r--lib/Graph/GEXF/Role/Viz/Color.pm16
-rw-r--r--lib/Graph/GEXF/Role/Viz/Position.pm12
-rw-r--r--lib/Graph/GEXF/Role/Viz/Shape.pm28
-rw-r--r--lib/Graph/GEXF/Role/Viz/Size.pm20
4 files changed, 76 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..166186f
--- /dev/null
+++ b/lib/Graph/GEXF/Role/Viz/Color.pm
@@ -0,0 +1,16 @@
+package Graph::GEXF::Role::Viz::Color;
+
+use Moose::Role;
+use Moose::Util::TypeConstraints;
+
+subtype RGBColor => as 'Int' => where { $_ >= 0 && $_ <= 255 };
+
+has [qw/r g b/] => (
+ is => 'rw',
+ isa => 'RGBColor',
+);
+
+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..4871df2
--- /dev/null
+++ b/lib/Graph/GEXF/Role/Viz/Position.pm
@@ -0,0 +1,12 @@
+package Graph::GEXF::Role::Viz::Position;
+
+use Moose::Role;
+
+has [qw/x y z/] => (
+ is => 'rw',
+ isa => 'Num',
+);
+
+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..f522786
--- /dev/null
+++ b/lib/Graph/GEXF/Role/Viz/Shape.pm
@@ -0,0 +1,28 @@
+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 = lcfirst( $p->for ) . 'Shape';
+
+ has shape => (
+ is => 'rw',
+ isa => $type,
+ );
+};
+
+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..d192db6
--- /dev/null
+++ b/lib/Graph/GEXF/Role/Viz/Size.pm
@@ -0,0 +1,20 @@
+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',
+ );
+};
+
+1;