2 * Copyright 2000-2009 JetBrains s.r.o.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package com
.intellij
.uiDesigner
.radComponents
;
18 import com
.intellij
.uiDesigner
.shared
.XYLayoutManager
;
24 * @author Anton Katilin
25 * @author Vladimir Kondratyev
27 public final class XYLayoutManagerImpl
extends XYLayoutManager
{
28 private final Dimension myPreferredSize
;
29 private static final Dimension MIN_SIZE
= new Dimension(20,20);
31 public XYLayoutManagerImpl(){
32 myPreferredSize
= new Dimension();
35 public void setPreferredSize(final Dimension size
) {
36 myPreferredSize
.setSize(size
);
39 public Dimension
maximumLayoutSize(final Container container
){
40 return new Dimension(Integer
.MAX_VALUE
, Integer
.MAX_VALUE
);
43 public Dimension
preferredLayoutSize(final Container container
){
44 return myPreferredSize
;
47 public void layoutContainer(final Container parent
){
50 public Dimension
minimumLayoutSize(final Container container
){
51 final Container parent
= container
.getParent();
52 if (!(parent
instanceof JComponent
)) {
55 final RadComponent component
= (RadComponent
)((JComponent
)parent
).getClientProperty(RadComponent
.CLIENT_PROP_RAD_COMPONENT
);
56 if (component
== null) {
60 // the following code prevents XYs placed in Grid from being shrunk
61 final RadComponent radParent
= component
.getParent();
62 if (radParent
instanceof RadContainer
&& (((RadContainer
)radParent
).getLayoutManager().isGrid())) {
64 Math
.max(myPreferredSize
.width
, MIN_SIZE
.width
),
65 Math
.max(myPreferredSize
.height
, MIN_SIZE
.height
)