(2) (2005 - Guangdong) In the same Cartesian coordinate system, the graphs of the functions $y=f(x)$ and $y=g(x)$ are symmetric with respect to the line $y=x$. Now, the graph of $y=g(x)$ is translated 2 units to the left along the $x$-axis and then 1 unit upward along the $y$-axis. The resulting graph is a broken line composed of two line segments (as shown in Figure 3-6). Then the expression for the function $f(x)$ is ( ).
(A) $f(x)=\left\{\begin{array}{ll}2 x+2, & -1 \leqslant x \leqslant 0 \\ \frac{x}{2}+2, & 0<x \leqslant 2\end{array}\right.$
(B) $f(x)=\left\{\begin{array}{lc}2 x-2, & -1 \leqslant x \leqslant 0, \\ \frac{x}{2}-2, & 0<x \leqslant 2\end{array}\right.$
(C) $f(x)=\left\{\begin{array}{ll}2 x-2, & 1 \leqslant x \leqslant 2, \\ \frac{x}{2}+1, & 2<x \leqslant 4\end{array}\right.$
(D) $f(x)=\left\{\begin{array}{ll}2 x-6, & 1 \leqslant x \leqslant 2, \\ \frac{x}{2}-3, & 2<x \leqslant 4\end{array}\right.$
Figure 3-6
Solve: Translating the given graph down by 1 unit and then to the right by 2 units yields the graph of the function $y=g(x)$. Then, reflecting this graph about the line $y=x$ gives the graph of the function $y=f(x)$ (as shown in Figure 3-7). Therefore, $f(x)=$ $\left\{\begin{array}{ll}2 x+2, & -1 \leqslant x \leqslant 0, \\ \frac{x}{2}+2, & 0<x \leqslant 2,\end{array}\right.$ The answer is $\mathrm{A}$.
Figure 3-7