1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.jguiraffe.gui.layout;
17
18 import java.awt.Rectangle;
19
20 /**
21 * <p>
22 * Definition of an interface that encapsulates platform (library) specific
23 * access to GUI components that are managed by a percent layout manager.
24 * </p>
25 * <p>
26 * The family of percent layout managers is intended to work together with
27 * different GUI libraries. To achieve this the classes cannot directly access
28 * the managed components. They rather implement only the layouting algorithms
29 * and delegate to a platform specific adapter when it comes to manipulating
30 * components.
31 * </p>
32 * <p>
33 * This interface defines how such an adapter looks like. It contains methods
34 * that can roughly be devided into two different groups: One group allows
35 * access to the components currently associated with this layout manager and
36 * their layout constraints. The other group supports manipulating of components
37 * and accessing their properties.
38 * </p>
39 * <p>
40 * For each specific GUI library to be supported by percent layouts an adapter
41 * class has to be created. This single adapter class will then play together
42 * with all different percent layout implementations.
43 * </p>
44 *
45 * @author Oliver Heger
46 * @version $Id: PercentLayoutPlatformAdapter.java 205 2012-01-29 18:29:57Z oheger $
47 */
48 public interface PercentLayoutPlatformAdapter
49 {
50 /**
51 * Returns the number of components that belong to this layout manager.
52 *
53 * @return the number of managed components
54 */
55 int getComponentCount();
56
57 /**
58 * Returns the component with the given index.
59 *
60 * @param index the index of a component (0-based)
61 * @return the component with this index
62 */
63 Object getComponent(int index);
64
65 /**
66 * Returns the constraints object for the component with the given index.
67 *
68 * @param index the index of a component (0-based)
69 * @return the constraints object for this component
70 */
71 Object getConstraints(int index);
72
73 /**
74 * Returns the platform specific <code>{@link UnitSizeHandler}</code>
75 * implementation.
76 *
77 * @return the <code>SizeHandler</code> for this platform
78 */
79 UnitSizeHandler getSizeHandler();
80
81 /**
82 * Returns the minimum component size of the specified component for the
83 * given axis.
84 *
85 * @param component the component
86 * @param vert the direction flag (<code>true</code> for the y axis,
87 * <b>false</b> for the x axis)
88 * @return the minimum component size
89 */
90 int getMinimumComponentSize(Object component, boolean vert);
91
92 /**
93 * Returns the preferred component size of the specified component for the
94 * given axis.
95 *
96 * @param component the component
97 * @param vert the direction flag (<code>true</code> for the y axis,
98 * <b>false</b> for the x axis)
99 * @return the preferred component size
100 */
101 int getPreferredComponentSize(Object component, boolean vert);
102
103 /**
104 * Sets the bounds of a component. This method will be invoked after the
105 * layout manager has calculated the final bounds of a component.
106 *
107 * @param component the affected component
108 * @param bounds the bounds for this component
109 */
110 void setComponentBounds(Object component, Rectangle bounds);
111 }