package SQL::Translator::Producer::Diagram;
-# -------------------------------------------------------------------
-# Copyright (C) 2002-2011 SQLFairy Authors
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; version 2.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307 USA
-# -------------------------------------------------------------------
-
=head1 NAME
SQL::Translator::Producer::Diagram - ER diagram producer for SQL::Translator
=cut
use strict;
+use warnings;
use GD;
use Data::Dumper;
use SQL::Translator::Schema::Constants;
use SQL::Translator::Utils qw(debug);
-use vars qw[ $VERSION $DEBUG ];
-$VERSION = '1.59';
+our $DEBUG;
+our $VERSION = '1.59';
$DEBUG = 0 unless defined $DEBUG;
use constant VALID_FONT_SIZE => {
my %skip_field = map { $_, 1 } (
ref $args->{'skip_fields'} eq 'ARRAY'
? @{ $args->{'skip_fields'} }
- : split ( /\s*,\s*/, $args->{'skip_fields'} )
+ : split ( /\s*,\s*/, $args->{'skip_fields'}||'' )
);
my %skip_table = map { $_, 1 } (
ref $args->{'skip_tables'} eq 'ARRAY'
? @{ $args->{'skip_tables'} }
- : split ( /\s*,\s*/, $args->{'skip_tables'} )
+ : split ( /\s*,\s*/, $args->{'skip_tables'}||'' )
);
my @skip_tables_like = map { qr/$_/ } (
ref $args->{'skip_tables_like'} eq 'ARRAY'
? @{ $args->{'skip_tables_like'} }
- : split ( /\s*,\s*/, $args->{'skip_tables_like'} )
+ : split ( /\s*,\s*/, $args->{'skip_tables_like'}||'' )
);
my @table_names;
my $nlen = length $name;
my $dlen = length $desc;
- $max_name = $nlen if $nlen > $max_name;
- $max_desc = $dlen if $dlen > $max_desc;
+ $max_name = $nlen if $nlen > ($max_name||0);
+ $max_desc = $dlen if $dlen > ($max_desc||0);
push @fld_desc, [ $name, $desc, $f->{'name'}, $is_pk, $attr ];
}
];
push @shapes, [ 'rectangle', @bounds, 'black' ];
- $max_x = $this_max_x if $this_max_x > $max_x;
+ $max_x = $this_max_x if $this_max_x > ($max_x||0);
$y += 25;
if ( ++$no_this_col == $no_per_col ) {# if we've filled up this column
$no_this_col = 0; # reset the number of tables
$max_x += $gutter; # push the x over for next column
$this_col_x = $max_x; # remember the max x for this col
- $max_y = $y if $y > $max_y; # note the max y
+ $max_y = $y if $y > ($max_y||0); # note the max y
$y = $orig_y; # reset the y for next column
}
}
my $longest;
for my $len ( map { length $_ } values %legend ) {
- $longest = $len if $len > $longest;
+ $longest = $len if $len > ($longest||0);
}
$longest += 2;