package AA::NetV;

our @ISA = ('AA::Vertex');

sub new($$$$) {
	my ($class, $id) = @_;
	my $v = AA::Vertex::new($class, $id);
	$v->Set('x', 100);
	$v->DefSet('y0', 100);
	$v->DefSet('h', 0);
	$v->DefSet('xs', '');
	$v->DefSet('hint', 0);
	$v->Bind('y', sub { $v->Get("y0") - 50*$v->Get("h") });
	$v->{XS} = AA::Label->new("$id-label");
	$v->{XS}->MultiSet(
		'x' => sub { $v->Get('x') },
		'y' => sub { $v->Get('y') + 80 },
		'size' => 50,
		'text' => sub { $v->Get('xs') },
		'color' => sub { $v->Get('xs') ? [1,0,0] : [1,1,1] },
	);
	$v->Bind('color', sub { $v->Get('hint') ? [0,0.7,0] : [0.7,0,0.7] });
	return $v;
}

package AA::NetE;

our @ISA = ('AA');

sub new($$$$) {
	my ($class, $id, $v, $w) = @_;
	my $e = AA::new($class, $id);
	$e->{E} = AA::Edge->new("$id-e", $v, $w);
	$e->{E}->Set('arrow', 1);
	$e->{E}->Set('color', [1,0,0]);
	$e->DefSet('c', 1);
	$e->DefSet('f', 0);
	$e->DefSet('d', 9);
	$e->DefDep('ends', $e->{E}, 'ends');
	$e->{E}->Bind('width', sub { $e->Get('f') * 5 + 1 });
#	$e->{E}->Bind('overshoot', sub { $e->Get('f') * 3 + 3});
	$e->{E}->Bind('arrow-size', sub { $e->Get('f') * 5 + 20});
	return $e;
}

sub Draw($$) {
	my ($e, $cairo) = @_;
	my ($x1, $y1, $x2, $y2) = @{$e->Get('ends')};
	$cairo->new_path;
	$cairo->set_source_rgb(0.3, 1, 0);
	$cairo->set_line_width($e->Get('c') * 5 + 1);
	$cairo->move_to($x1, $y1);
	$cairo->line_to($x2, $y2);
	$cairo->stroke;
}

1;
