01: /*
02: * SwingML Copyright (C) 2002 SwingML Team
03: *
04: * This library is free software; you can redistribute it and/or modify it under
05: * the terms of the GNU Lesser General Public License as published by the Free
06: * Software Foundation; either version 2 of the License, or (at your option) any
07: * later version.
08: *
09: * This library is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12: * details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with this library; if not, write to the Free Software Foundation, Inc.,
16: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: * Authors: Bram Stieperaere <bramez@users.sourceforge.net>
19: */
20:
21: package org.swingml.xml.mapper;
22:
23: import java.awt.*;
24:
25: import org.swingml.*;
26: import org.swingml.model.*;
27: import org.swingml.xml.*;
28: import org.w3c.dom.*;
29:
30: public class JLabelMapper extends MapperUtil implements Mapper {
31:
32: public Object getModelToMap(Node aNode, Object aParent,
33: Container aContainer) {
34: JLabelModel theModel = new JLabelModel();
35: SwingMLModel theContainer = (SwingMLModel) aParent;
36: theContainer.addChild(theModel);
37: theModel.setParent(theContainer);
38: return theModel;
39: }
40:
41: public void mapModel(Node aNode, Object aParent,
42: Container aContainer) {
43: JLabelModel theModel = (JLabelModel) this .getModelToMap(aNode,
44: aParent, aContainer);
45: this .mapModelAttributes(aNode, theModel, aParent);
46: }
47:
48: public void mapModelAttributes(Node aNode, Object aModel,
49: Object aParent) {
50: JLabelModel theModel = (JLabelModel) aModel;
51: super .mapCommonAttributes(theModel, aNode);
52:
53: Node theResultNode = super.getAttribute(aNode, Constants.ALIGN);
54: if (theResultNode != null) {
55: theModel.setAlign(theResultNode.getNodeValue());
56: }
57:
58: theResultNode = super.getAttribute(aNode, Constants.FONT);
59: if (theResultNode != null) {
60: theModel.setFontName(theResultNode.getNodeValue());
61:
62: }
63:
64: theResultNode = super.getAttribute(aNode, Constants.FONT_SIZE);
65: if (theResultNode != null) {
66: theModel.setFontSize(theResultNode.getNodeValue());
67: }
68:
69: theResultNode = super.getAttribute(aNode, Constants.WRAP_TEXT);
70: if (theResultNode != null) {
71: theModel.setWrapText(Boolean.valueOf(
72: theResultNode.getNodeValue()).booleanValue());
73: }
74: }
75: }
|