# vim: syntax=perl

# arbitrary info extracted from the CIA fact book


{
"-name" => "Population and Area Statistics", # workaround for some perl bug
-type => "sortable",
-dispheight => 3,
-compare=>sub {
    print "bug! <", join(",",%{ $_[0] }), ">:<", join(",",%{ $_[1] }), ">\n"
	if (not defined $_[0]->{population} or
	    not defined $_[1]->{population});
    $_[0]->{population} <=> $_[1]->{population}
},
# -compare=>sub { $_[0] cmp $_[1] },
#-appearance => {
#    focus => { -outline => "DarkGreen", -fill => "LightGreen" },
#    done => { -outline => "DarkMagenta", -fill => "Magenta" }
#},

# Settings ("init" or "done") in the -appearance option are used by
# some algorithms to restore the appearance of vertices. So better
# place things like -outline -fill -thick there, not in -node_opts.
-node_opts=>{
    -shape => "rectangle", -size => Vector->new(70,50),
    -display => sub {
	my ($n, $p, $a) = @{ $_[0]->cget(-content) }{qw(name population area)};
	$n = "?" unless defined $n;
	$p = 0 unless defined $p;
	if ($p >= 1e6) {
	    $p = sprintf "%.1fm", $p/1e6;
	} elsif ($p >= 1e3) {
	    $p = sprintf "%.1fk", $p/1e3;
	}
	$a = 0 unless defined $a;
	$a = sprintf "%dk", $a/1e3;
	return "$n\n$p\n$a";
    }
},
-init_data => [
#    {
#	population => 'no',
#	area => 5,
#	name => 'Ashmore and Cartier Islands'
#    },
    {
	population => 42510537,
	area => 678500,
	name => 'Burma'
    },
    {
	population => 358098,
	area => 5770,
	name => 'Brunei'
    },
    {
	population => 4608595,
	area => '692.7',
	name => 'Singapore'
    },
    {
	population => 13124764,
	area => 181040,
	name => 'Cambodia'
    },
    {
	population => 433,
	area => 135,
	name => 'Christmas Island'
    },
    {
	population => 630,
	area => 14,
	name => 'Cocos (Keeling) Islands'
    },
    {
	population => 5921545,
	area => 236800,
	name => 'Laos'
    },
    {
	population => 2712315,
	area => 9600,
	name => 'Mongolia'
    },
    {
	population => 997853,
	area => 15007,
	name => 'East Timor'
    },
    {
	population => 7394170,
	area => 1092,
	name => 'Hong Kong'
    },
    {
	population => 234893453,
	area => 1919440,
	name => 'Indonesia'
    },
    {
	population => 469903,
	area => '25.4',
	name => 'Macau'
    },
    {
	population => 22603001,
	area => 35980,
	name => 'Taiwan'
    },
    {
	population => 23092940,
	area => 329750,
	name => 'Malaysia'
    },
#    {
#	population => 'no',
#	area => 0,
#	name => 'Paracel Islands'
#    },
#    {
#	population => 'no',
#	area => 5,
#	name => 'Spratly Islands'
#    },
    {
	population => 150694740,
	area => 803940,
	name => 'Pakistan'
    },
    {
	population => 127214499,
	area => 377835,
	name => 'Japan'
    },
    {
	population => 64265276,
	area => 514000,
	name => 'Thailand'
    },
    {
	population => 84619974,
	area => 300000,
	name => 'Philippines'
    },
    {
	population => 81624716,
	area => 329560,
	name => 'Vietnam'
    },
    {
	population => 2139549,
	area => 47000,
	name => 'Bhutan'
    },
],


-operation => [
    remove => { population => 630 },
    remove => { population => 234893453 },
    remove => { population => 13124764 },
    remove => { population => 4608595 },
    insert => {
	population => 28717213,
	area => 647500,
	name => 'Afghanistan'
    },
    insert => {
	population => 138448210,
	area => 144000,
	name => 'Bangladesh'
    },
    insert => {
	population => 22466481,
	area => 120540,
	name => 'Korea North'
    },
    insert => {
	population => 19742439,
	area => 65610,
	name => 'Sri Lanka'
    },
    insert => {
	population => 1286975468,
	area => 9596960,
	name => 'China'
    },
    insert => {
	population => 1049700118,
	area => 3287590,
	name => 'India'
    },
    insert => {
	population => 48289037,
	area => 98480,
	name => 'Korea South'
    },
    insert => {
	population => 26469569,
	area => 140800,
	name => 'Nepal'
    },
#    rot_ccw => { population => 358098 },
#    rot_ccw => { population => 7394170 },
#    rot_cw  => { population => 150694740 },
],
};

