1 19 20 package org.netbeans.modules.form.layoutdesign; 21 22 import java.awt.Dimension ; 23 import java.awt.Rectangle ; 24 import java.util.HashMap ; 25 import org.netbeans.modules.form.FormModel; 26 27 31 32 public class FakeLayoutMapper implements VisualMapper, LayoutConstants { 33 34 private FormModel fm = null; 35 private HashMap contInterior = null; 36 private HashMap baselinePosition = null; 37 private HashMap prefPaddingInParent = null; 38 private HashMap prefPadding = null; 39 private HashMap compBounds = null; 40 private HashMap compMinSize = null; 41 private HashMap compPrefSize = null; 42 private HashMap hasExplicitPrefSize = null; 43 44 public FakeLayoutMapper(FormModel fm, 45 HashMap contInterior, 46 HashMap baselinePosition, 47 HashMap prefPaddingInParent, 48 HashMap compBounds, 49 HashMap compMinSize, 50 HashMap compPrefSize, 51 HashMap hasExplicitPrefSize, 52 HashMap prefPadding) { 53 this.fm = fm; 54 this.contInterior = contInterior; 55 this.baselinePosition = baselinePosition; 56 this.prefPaddingInParent = prefPaddingInParent; 57 this.compBounds = compBounds; 58 this.compMinSize = compMinSize; 59 this.compPrefSize = compPrefSize; 60 this.hasExplicitPrefSize = hasExplicitPrefSize; 61 this.prefPadding = prefPadding; 62 } 63 64 66 public Rectangle getComponentBounds(String componentId) { 67 return (Rectangle ) compBounds.get(componentId); 68 } 69 70 public Rectangle getContainerInterior(String componentId) { 71 return (Rectangle ) contInterior.get(componentId); 72 } 73 74 public Dimension getComponentMinimumSize(String componentId) { 75 return (Dimension ) compMinSize.get(componentId); 76 } 77 78 public Dimension getComponentPreferredSize(String componentId) { 79 return (Dimension ) compPrefSize.get(componentId); 80 } 81 82 public boolean hasExplicitPreferredSize(String componentId) { 83 return ((Boolean ) hasExplicitPrefSize.get(componentId)).booleanValue(); 84 } 85 86 public int getBaselinePosition(String componentId, int width, int height) { 87 String id = componentId + "-" + width + "-" + height; return ((Integer ) baselinePosition.get(id)).intValue(); 89 } 90 91 public int getPreferredPadding(String comp1Id, 92 String comp2Id, 93 int dimension, 94 int comp2Alignment, 95 int paddingType) 96 { 97 String id = comp1Id + "-" + comp2Id + "-" + dimension + "-" + comp2Alignment + "-" + paddingType; Integer pad = (Integer ) prefPadding.get(id); 99 return pad != null ? pad.intValue() : 6; 100 } 101 102 public int getPreferredPaddingInParent(String parentId, 103 String compId, 104 int dimension, 105 int compAlignment) 106 { 107 String id = parentId + "-" + compId + "-" + dimension + "-" + compAlignment; Integer pad = (Integer ) prefPaddingInParent.get(id); 109 return pad != null ? pad.intValue() : 10; 110 } 111 112 public boolean[] getComponentResizability(String compId, boolean[] resizability) { 113 resizability[0] = resizability[1] = true; 114 return resizability; 115 } 116 117 public void rebuildLayout(String contId) { 118 } 119 120 } 121 | Popular Tags |