1 19 20 package org.netbeans.modules.form.layoutdesign.support; 21 22 import java.util.*; 23 import org.netbeans.modules.form.layoutdesign.LayoutComponent; 24 25 30 public class SwingLayoutUtils { 31 32 public static final int STATUS_UNKNOWN = -1; 33 34 public static final int STATUS_NON_RESIZABLE = 0; 35 36 public static final int STATUS_RESIZABLE = 1; 37 38 43 private static Set nonResizableComponents = new HashSet(); 44 static { 45 nonResizableComponents.addAll( 46 Arrays.asList(new String [] { 47 "javax.swing.JLabel", "javax.swing.JButton", "javax.swing.JToggleButton", "javax.swing.JCheckBox", "javax.swing.JRadioButton", "javax.swing.JList", }) 54 ); 55 } 56 57 62 private static Set resizableComponents = new HashSet(); 63 static { 64 resizableComponents.addAll( 65 Arrays.asList(new String [] { 66 "javax.swing.JComboBox", "javax.swing.JTextField", "javax.swing.JTextArea", "javax.swing.JTabbedPane", "javax.swing.JScrollPane", "javax.swing.JSplitPane", "javax.swing.JFormattedTextField", "javax.swing.JPasswordField", "javax.swing.JSpinner", "javax.swing.JSeparator", "javax.swing.JTextPane", "javax.swing.JEditorPane", "javax.swing.JInternalFrame", "javax.swing.JLayeredPane", "javax.swing.JDesktopPane" }) 82 ); 83 } 84 85 94 public static int getResizableStatus(Class componentClass) { 95 String className = componentClass.getName(); 96 if (resizableComponents.contains(className)) return STATUS_RESIZABLE; 97 if (nonResizableComponents.contains(className)) return STATUS_NON_RESIZABLE; 98 return STATUS_UNKNOWN; 99 } 100 101 public static Map createLinkSizeGroups(LayoutComponent layoutComponent, int dimension) { 102 103 Map linkSizeGroup = new HashMap(); 104 105 if (layoutComponent.isLayoutContainer()) { 106 Iterator i = layoutComponent.getSubcomponents(); 107 108 while (i.hasNext()) { 109 LayoutComponent lc = (LayoutComponent)i.next(); 110 if (lc != null) { 111 if (lc.isLinkSized(dimension)) { 112 String cid = lc.getId(); 113 Integer id = new Integer (lc.getLinkSizeId(dimension)); 114 List l = (List)linkSizeGroup.get(id); 115 if (l == null) { 116 l = new ArrayList(); 117 l.add(cid); 118 linkSizeGroup.put(id, l); 119 } else { 120 l.add(cid); 121 } 122 } 123 } 124 } 125 } 126 return linkSizeGroup; 127 } 128 129 } 130 | Popular Tags |