To calculate trends one needs to have the national average. For your example, let's say in Year 1 A wins 55-45, and in Year 2 it's 50-50.
Swings are simple.
Using your example:
Year 1:
State 1: State 2: State 3:
A: 60% A: 90% A: 30%
B: 40% B: 10% B: 70%
Year 2:
State 1: State 2: State 3:
A: 40% A: 75% A: 45%
B: 60% B: 25% B: 55%
In State 1, A won 60% of the vote in Year 1 and 40% in Year 2. As there is a 20% difference, the vote swung 20% away from A, or 20% toward B. For State 2, A went from 90% of the vote to 75% of the vote, so the vote swung 15% away from it. In State 3, A went from 30% to 45%, so the vote swung 15% toward it.
Swings will not always be so clear cut. In a case like 1992 where there is a strong third party, both parties could have negative swings in a state.
I find it easier to use margins of victory instead of raw numbers, for for you example with state 1, A won by 10% in Year 1 and lost by 10% in Year 2. The difference between 10 and -10 is 20, so the swing is 20%.
To use a real life example, Obama won the state of Indiana by 1.03% in 2008. In 2012, he lost it by 10.20%. The difference between these results in 11.23%, so it swung 11.23% between 2008 and 2012.
Trends are a bit different. They are the state's swing relative to the national swing. Using State 1 as an example with a national A victory of 55-45, with a 60-40 margin this means it voted for by by a margin of 5% more than the national average. One might interpret this as "A+5" (this is not PVI however). In Year 2, with a 40-60 loss and a 50-50 national margin, State 1 is now 10% less "A" than the nation, or B+10. As there is a 15 point difference here, from years 1 to 2 State 1 trended 15 points toward B, even though it swung 20 point.
State 3 is the opposite case, as it went from B+25 (30% A compared to 55% nationally), to B+5 (45% A compared to 50% nationally). Despite swinging just 15%, it trended 20%.
In the 2008 election in Mississippi, McCain won by 13.17%. Since he lost nationally by 7.2%, Mississippi is R+20.37%. In 2012, Romney only won by 11.50%, and lost nationally by 3.9%. So, it is now just R+15.40%. As the difference between these margins is 4.97%, Mississippi trended Democratic 4.97%, even though it only swung 1.67%.
So that's basically it. Hope this helped!