Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/mvsteenb/javauitransformer/xmltransformer/layout/awt/XmlFlowLayoutManager.java


1   package com.mvsteenb.javauitransformer.xmltransformer.layout.awt;
2   
3   import com.mvsteenb.javauitransformer.xmltransformer.components.awt.XmlContainer;
4   import com.mvsteenb.javauitransformer.xmltransformer.components.awt.XmlComponent;
5   import com.mvsteenb.javauitransformer.xmltransformer.components.exception.UnknownComponentException;
6   import com.mvsteenb.javauitransformer.xmltransformer.layout.XmlLayoutManagerAdapter;
7   import com.mvsteenb.javauitransformer.xmltransformer.layout.exception.UnknownLayoutManagerException;
8   import com.mvsteenb.javauitransformer.xmltransformer.util.XmlTransformerPrintBuffer;
9   
10  import java.awt.*;
11  
12  /**
13   * com.mvsteenb.javauitransformer.xmltransformer.layout
14   *
15   * <p><b>About</b></p>
16   *
17   * <p>
18   *   This class is part of the JavaUITransformer version @build.version@ (build #@build.number@) which was built on @build.date@.
19   * </p>
20   *
21   * <p><b>Description</b></p>
22   *
23   * <p>
24   *   <font color="red">warning : this layout manager is deprecated and might be removed in later versions ! Use the
25   *   <b>XmlRasterScreenScraperLayoutManager</b> instead !
26   * </p>
27   *
28   * <p>
29   *   <font color="red">warning : this layout manager is deprecated and might be removed in later versions ! Use the
30   *   <b>link:XmlRasterScreenScraperLayoutManager</b> instead !</font>
31   * </p>
32   *
33   * <p><b>Free Software</b></p>
34   *
35   * <p>
36   *   Copyright (C) 2003 Mario Van Steenberghe
37   * </p>
38   *
39   * <p>
40   *   <small>
41   *     This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
42   *     General Public License as published by the Free Software Foundation; either version 2.1 of the License, or
43   *     (at your option) any later version. This library is distributed in the hope that it will be useful,
44   *     but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
45   *     PURPOSE.  See the GNU Lesser General Public License for more details. You should have received a copy of the
46   *     GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc.,
47   *     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
48   *   </small>
49   * </p>
50   *
51   * <p>
52   *   <small>
53   *     Please contact me at mario.vansteenberghe@pandora.be for more information.
54   *   </small>
55   * </p>
56   *
57   * <p><b>Revision History</b></p>
58   *
59   * <p>
60   *   Aug 23, 2003 : mvsteenb : Initial Revision
61   * </p>
62   *
63   */
64  
65  public class XmlFlowLayoutManager extends XmlLayoutManagerAdapter {
66  
67    /**
68     * Constructor
69     * @deprecated use XmlRasterScreenScraperLayoutManager for all your layouts
70     */
71  
72    public XmlFlowLayoutManager(XmlContainer c, FlowLayout l) {
73      super(c, l);
74    }
75  
76    /**
77     * Lays out given container's components and returns XML string representation
78     */
79  
80    public void toXml(int indent, XmlTransformerPrintBuffer w) {
81      w.println("<!-- Flow Layout -->", indent);
82  
83      if (getXmlContainer() == null || getContainer() == null)
84        return;
85  
86      Insets insets = getContainer().getInsets();
87  
88      int currentComponentWidth = insets.left;
89      int maxWidth = getContainer().getSize().width - insets.right;
90      int hGap = ((FlowLayout) l).getHgap();
91      //int vGap = ((FlowLayout) l).getVgap();
92  
93      for (int i=0; i < getContainer().getComponentCount(); i++) {
94  
95        try {
96          Component javaComponent = getContainer().getComponent(i);
97          XmlComponent c = getXmlContainer().getComponentMapper().findComponent(javaComponent);
98  
99          if (currentComponentWidth > maxWidth) {
100           addNewLineTag(indent, w);
101           currentComponentWidth = insets.left;
102         }
103 
104         if (i > 0 && i < getContainer().getComponentCount()) {
105           addHorizontalGapTag(indent+2, w, hGap);
106         }
107 
108         if (c != null && javaComponent.isVisible()) {
109           c.toXml(indent, w);
110         }
111       }
112       catch(UnknownComponentException e) {
113         w.println("<!-- unknown component :" + getContainer().getComponent(i).getClass().getName() + "-->", indent);
114       }
115       catch(UnknownLayoutManagerException e) {
116         w.println("<!-- unknown layout manager :" + getContainer().getLayout().getClass().getName() + "-->", indent);
117       }
118 
119     }
120 
121     w.println("<!-- End Flow Layout -->", indent);
122   }
123 
124 }