use MyTk::GraphScale; use MyTk::Dialog; use strict; use Rect; #======================================================== # Line #======================================================== package Line; #@ISA = qw(Tk::Frame); #公開したいサブルーチン #@EXPORT = qw(); sub new { my ($module, $width, $color) = @_; my $this = {}; bless $this; $this->SetStyle($width, $color) if(defined $width); return $this; } sub DESTROY { my $this = shift; } sub Width { return shift->{'Width'}; } sub Color { return shift->{'Color'}; } sub SetStyle { my ($this, $width, $color) = @_; $this->{'Width'} = $width; $this->{'Color'} = $color; } sub Draw { my ($this, $canvas, $x0, $y0, $x1, $y1, $tag) = @_; $canvas->MoveTo($x0, $y0); $canvas->LineTo($x1, $y1, $this->{'Width'}, $this->{'Color'}, $tag); } #======================================================== # Symbol #======================================================== package Symbol; #@ISA = qw(Tk::Frame); #公開したいサブルーチン #@EXPORT = qw(); BEGIN { } sub new { my ($module, $type, $size, $fillcolor, $linewidth, $linecolor) = @_; my $this = {}; bless $this; $this->SetStyle($type, $size, $fillcolor, $linewidth, $linecolor) if(defined $type); return $this; } sub DESTROY { my $this = shift; } sub Type { return shift->{'Type'}; } sub Size { return shift->{'Size'}; } sub LineWidth { return shift->{'LineWidth'}; } sub LineColor { return shift->{'LineColor'}; } sub FillColor { return shift->{'FillColor'}; } sub SetStyle { my ($this, $type, $size, $fillcolor, $linewidth, $linecolor) = @_; #print "type: $type size: $size\n"; $this->{'Type'} = $type if(defined $type); $this->{'Size'} = $size if(defined $size); $this->{'r'} = $size/2.0 if(defined $size); $this->{'FillColor'} = $fillcolor if(defined $fillcolor); $this->{'LineWidth'} = $linewidth if(defined $linewidth); $this->{'LineColor'} = $linecolor if(defined $linecolor); } sub Draw { my ($this, $canvas, $x0, $y0, $tag, $ColorIntensity) = @_; my $type = $this->{'Type'}; if($type eq 'circle') { my $r = $this->{'r'}; $canvas->DrawOval($x0-$r, $y0-$r, $x0+$r, $y0+$r, $this->{'LineWidth'}, $this->{'FillColor'}, $this->{'LineColor'}, $tag); } elsif($type eq 'dot') { # $canvas->DrawOval($x0, $y0, $x0, $y0, # '', $this->{'FillColor'}, '', $tag); $canvas->DrawLine($x0, $y0, $x0+1, $y0, 1, $this->{'LineColor'}, $tag); } elsif($type eq 'cross') { my $r = $this->{'r'}; $canvas->DrawLine($x0-$r, $y0, $x0+$r, $y0, $this->{'LineWidth'}, $this->{'LineColor'}, $tag); $canvas->DrawLine($x0, $y0-$r, $x0, $y0+$r, $this->{'LineWidth'}, $this->{'LineColor'}, $tag); } elsif($type eq 'square') { my $r = $this->{'r'}; $canvas->DrawBox($x0-$r, $y0-$r, $x0+$r, $y0+$r, $this->{'LineWidth'}, $this->{'FillColor'}, $this->{'LineColor'}, $tag); } elsif($type eq 'hbar') { my $r = $this->{'r'}; $canvas->DrawLine($x0-$r, $y0, $x0+$r, $y0, $this->{'LineWidth'}, $this->{'LineColor'}, $tag); } elsif($type eq 'vbar') { my $r = $this->{'r'}; $canvas->DrawLine($x0, $y0-$r, $x0, $y0+$r, $this->{'LineWidth'}, $this->{'LineColor'}, $tag); } } 1;