App-SourcePlot
view release on metacpan or search on metacpan
lib/App/SourcePlot.pm view on Meta::CPAN
return 0 if $RESPONSE == -1;
return $RESPONSE;
}
=item B<isWithin>
Checks whether a source is already part of a list. The source is compared
to sources from the list by invoking the C<summary> method on their
C<Astro::Coords> objects.
next if isWithin($source, @list);
=cut
sub isWithin {
my $element = shift;
my @array = @_;
my $len = @array;
foreach (@array) {
if ($element->coords()->summary() eq $_->coords()->summary()) {
return 1;
}
}
return 0;
}
=item B<remove>
Removes entries from the list which match the given source. The comparison
is performed in the same way as C<isWithin>.
remove($source, \@list)
=cut
sub remove {
my $element = shift;
my $array = shift;
my $len = @$array;
my @temp;
my $flag = 0;
for (my $index = 0; $index < $len; $index ++) {
if ($element->coords()->summary() eq $$array[$index]->coords()->summary()) {
$flag = -1;
}
else {
$temp[$index + $flag] = $$array[$index];
}
}
@$array = @temp;
}
=item B<update_status>
Invokes the update method of the main window.
=cut
sub update_status {
$MW->update;
}
=item B<changeDate>
Changes the date to a new date.
=cut
sub changeDate {
$dateBut->configure(-state => 'disabled');
my @months = qw/
January February March April May June July August
September October November December/;
my $name;
my $Top = $MW->Toplevel;
$Top->title('Source Plot UT Date');
$Top->resizable(0, 0);
my $topFrame = $Top->Frame(
-relief => 'groove',
-borderwidth => 2,
)->pack(-padx => 10, -pady => 10);
# create the day entry
$topFrame->Label(-text => "Day:")->grid(-column => 0, -row => 0);
my $dayEnt = $topFrame->Entry(
-relief => 'sunken',
-width => 10,
)->grid(-column => 1, -row => 0, -padx => 10, -pady => 5);
# create the month menu button
$topFrame->Label(
-text => "Month:",
)->grid(-column => 0, -row => 1, -padx => 5, -pady => 5);
my $strp = DateTime::Format::Strptime->new(
pattern => '%Y/%m/%d',
time_zone => 'UTC',
on_error => 'croak');
my $dt = $strp->parse_datetime($DATE);
my $monthEnt = $months[$dt->month() - 1];
my $mb = $topFrame->Menubutton(
-text => $monthEnt,
-relief => 'raised',
-width => 10);
foreach $name (@months) {
$mb->command(
-label => $name,
-command => sub {
$mb->configure(-text => $name);
$monthEnt = $name;
},
);
}
( run in 0.943 second using v1.01-cache-2.11-cpan-140bd7fdf52 )