KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > SAbstractLayoutManager


1 /*
2  * $Id: SAbstractLayoutManager.java,v 1.5 2005/01/23 19:31:36 blueshift Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings;
15
16 import org.wings.io.Device;
17 import org.wings.plaf.LayoutCG;
18 import org.wings.session.SessionManager;
19
20 import java.io.IOException JavaDoc;
21
22 /**
23  * This is an abstract implementation of an layout manager.
24  *
25  * @author <a HREF="mailto:engels@mercatis.de">Holger Engels</a>
26  * @version $Revision: 1.5 $
27  */

28 public abstract class SAbstractLayoutManager
29         implements SLayoutManager {
30     /**
31      * The code generation delegate, which is responsible for
32      * the visual representation of a layout.
33      */

34     protected transient LayoutCG cg;
35
36     /**
37      * The container using this layout
38      */

39     protected SContainer container;
40
41     /**
42      * Preferred size of component in pixel.
43      */

44     protected SDimension preferredSize = null;
45
46
47     protected SAbstractLayoutManager() {
48         updateCG();
49     }
50
51     protected void setCG(LayoutCG newCG) {
52         cg = newCG;
53     }
54
55     /**
56      * Return the look and feel delegate.
57      *
58      * @return the componet's cg
59      */

60     public LayoutCG getCG() {
61         return cg;
62     }
63
64     /**
65      * Notification from the CGFactory that the L&F
66      * has changed.
67      *
68      * @see SComponent#updateCG
69      */

70     public void updateCG() {
71         setCG((LayoutCG) SessionManager.getSession().getCGManager().getCG(this));
72     }
73
74     public void write(Device d)
75             throws IOException JavaDoc {
76         cg.write(d, this);
77     }
78
79     public void setContainer(SContainer c) {
80         container = c;
81     }
82
83     public SContainer getContainer() {
84         return container;
85     }
86
87     /**
88      * Set the preferred size of the receiving {@link SLayoutManager} in pixel.
89      * It is not guaranteed that the {@link SLayoutManager} accepts this property because of
90      * missing implementations in the {@link SLayoutManager } cg or html properties.
91      * If <i>width</i> or <i>height</i> is zero, it is ignored and the browser
92      * defines the size.
93      *
94      * @see #getPreferredSize
95      */

96     public final void setPreferredSize(SDimension preferredSize) {
97         this.preferredSize = preferredSize;
98     }
99
100     /**
101      * Get the preferred size of this {@link SLayoutManager }.
102      *
103      * @see #setPreferredSize
104      */

105     public final SDimension getPreferredSize() {
106         return this.preferredSize;
107     }
108 }
109
110
111
Popular Tags