1 package net.miginfocom.swing;
6 * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright notice, this list
12 * of conditions and the following disclaimer.
13 * Redistributions in binary form must reproduce the above copyright notice, this
14 * list of conditions and the following disclaimer in the documentation and/or other
15 * materials provided with the distribution.
16 * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
17 * used to endorse or promote products derived from this software without specific
18 * prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 * @author Mikael Grev, MiG InfoCom AB
36 import net.miginfocom.layout.ComponentWrapper;
37 import net.miginfocom.layout.ContainerWrapper;
39 import java.awt.BasicStroke;
40 import java.awt.Color;
41 import java.awt.Component;
42 import java.awt.Container;
43 import java.awt.Graphics2D;
47 public final class SwingContainerWrapper extends SwingComponentWrapper implements ContainerWrapper
49 /** Debug color for cell outline.
51 private static final Color DB_CELL_OUTLINE = new Color(255, 0, 0);
53 public SwingContainerWrapper(Container c)
59 public ComponentWrapper[] getComponents()
61 Container c = (Container) getComponent();
62 ComponentWrapper[] cws = new ComponentWrapper[c.getComponentCount()];
63 for (int i = 0; i < cws.length; i++)
64 cws[i] = new SwingComponentWrapper(c.getComponent(i));
69 public int getComponentCount()
71 return ((Container) getComponent()).getComponentCount();
75 public Object getLayout()
77 return ((Container) getComponent()).getLayout();
81 public final boolean isLeftToRight()
83 return ((Container) getComponent()).getComponentOrientation().isLeftToRight();
87 public final void paintDebugCell(int x, int y, int width, int height)
89 Component c = (Component) getComponent();
90 if (c.isShowing() == false)
93 Graphics2D g = (Graphics2D) c.getGraphics();
97 g.setStroke(new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10f, new float[] {2f, 3f}, 0));
98 g.setPaint(DB_CELL_OUTLINE);
99 g.drawRect(x, y, width - 1, height - 1);
103 public int getComponentType(boolean disregardScrollPane)
105 return TYPE_CONTAINER;
108 // Removed for 2.3 because the parent.isValid() in MigLayout will catch this instead.
110 public int getLayoutHashCode()
112 long n = System.nanoTime();
113 int h = super.getLayoutHashCode();