Great point about Toyotomi Hideyoshi's attempt to conquer Korean and China! I guess the legacy of the Edo period was a kind of reset on that ambition, because the country was closed and not looking for a fight. I would say it was actually the failure of the shogunate to stand up to Commodore Perry that ended Edo and kicked off the outward-looking Meiji.
I'm no expert in this area, but I enjoy learning about it.
(Again my views only.) I think it was a direct reaction to the aggression of 1853. It was preceded by posturing/maneuvering in the South Pacific if I'm not mistaken. To be clear, I don't think it was justified or proportionate, but I do think those events were closely linked in that Japan saw Americans as encroaching on their sovereignty and an imminent threat from the "East".
I'm no expert in this area, but I enjoy learning about it.