Lines 32-39
Link Here
|
32 |
*/ |
32 |
*/ |
33 |
public final class AlignWithResizeStrategyProvider extends AlignWithSupport implements ResizeStrategy, ResizeProvider { |
33 |
public final class AlignWithResizeStrategyProvider extends AlignWithSupport implements ResizeStrategy, ResizeProvider { |
34 |
|
34 |
|
35 |
public AlignWithResizeStrategyProvider (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator) { |
35 |
private boolean outerBounds; |
|
|
36 |
|
37 |
public AlignWithResizeStrategyProvider (AlignWithWidgetCollector collector, LayerWidget interractionLayer, AlignWithMoveDecorator decorator, boolean outerBounds) { |
36 |
super (collector, interractionLayer, decorator); |
38 |
super (collector, interractionLayer, decorator); |
|
|
39 |
this.outerBounds = outerBounds; |
37 |
} |
40 |
} |
38 |
|
41 |
|
39 |
public Rectangle boundsSuggested (Widget widget, Rectangle originalBounds, Rectangle suggestedBounds, ControlPoint controlPoint) { |
42 |
public Rectangle boundsSuggested (Widget widget, Rectangle originalBounds, Rectangle suggestedBounds, ControlPoint controlPoint) { |
Lines 49-64
Link Here
|
49 |
switch (controlPoint) { |
52 |
switch (controlPoint) { |
50 |
case BOTTOM_CENTER: |
53 |
case BOTTOM_CENTER: |
51 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y + suggestedBounds.height); |
54 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y + suggestedBounds.height); |
|
|
55 |
if (! outerBounds) |
56 |
suggestedLocation.y -= insets.bottom; |
52 |
|
57 |
|
53 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false); |
58 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false); |
54 |
|
59 |
|
|
|
60 |
if (! outerBounds) |
61 |
point.y += insets.bottom; |
62 |
|
55 |
suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y); |
63 |
suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y); |
56 |
break; |
64 |
break; |
57 |
case BOTTOM_LEFT: |
65 |
case BOTTOM_LEFT: |
58 |
suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height); |
66 |
suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height); |
|
|
67 |
if (! outerBounds) { |
68 |
suggestedLocation.y -= insets.bottom; |
69 |
suggestedLocation.x += insets.left; |
70 |
} |
59 |
|
71 |
|
60 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
72 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
61 |
|
73 |
|
|
|
74 |
if (! outerBounds) { |
75 |
point.y += insets.bottom; |
76 |
point.x -= insets.left; |
77 |
} |
78 |
|
62 |
suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y); |
79 |
suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y); |
63 |
|
80 |
|
64 |
tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx); |
81 |
tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx); |
Lines 67-109
Link Here
|
67 |
break; |
84 |
break; |
68 |
case BOTTOM_RIGHT: |
85 |
case BOTTOM_RIGHT: |
69 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height); |
86 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height); |
|
|
87 |
if (! outerBounds) { |
88 |
suggestedLocation.y -= insets.bottom; |
89 |
suggestedLocation.x -= insets.right; |
90 |
} |
70 |
|
91 |
|
71 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
92 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
72 |
|
93 |
|
|
|
94 |
if (! outerBounds) { |
95 |
point.y += insets.bottom; |
96 |
point.x += insets.right; |
97 |
} |
98 |
|
73 |
suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y); |
99 |
suggestedBounds.height = Math.max (miny, point.y - suggestedBounds.y); |
74 |
|
100 |
|
75 |
suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x); |
101 |
suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x); |
76 |
break; |
102 |
break; |
77 |
case CENTER_LEFT: |
103 |
case CENTER_LEFT: |
78 |
suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height / 2); |
104 |
suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y + suggestedBounds.height / 2); |
|
|
105 |
if (! outerBounds) |
106 |
suggestedLocation.x += insets.left; |
79 |
|
107 |
|
80 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false); |
108 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false); |
81 |
|
109 |
|
|
|
110 |
if (! outerBounds) |
111 |
point.x -= insets.left; |
112 |
|
82 |
tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx); |
113 |
tempx = Math.min (point.x, suggestedBounds.x + suggestedBounds.width - minx); |
83 |
suggestedBounds.width = suggestedBounds.x + suggestedBounds.width - tempx; |
114 |
suggestedBounds.width = suggestedBounds.x + suggestedBounds.width - tempx; |
84 |
suggestedBounds.x = tempx; |
115 |
suggestedBounds.x = tempx; |
85 |
break; |
116 |
break; |
86 |
case CENTER_RIGHT: |
117 |
case CENTER_RIGHT: |
87 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height / 2); |
118 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y + suggestedBounds.height / 2); |
|
|
119 |
if (! outerBounds) |
120 |
suggestedLocation.x -= insets.right; |
88 |
|
121 |
|
89 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false); |
122 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, false, false, false); |
90 |
|
123 |
|
|
|
124 |
if (! outerBounds) |
125 |
point.x += insets.right; |
126 |
|
91 |
suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x); |
127 |
suggestedBounds.width = Math.max (minx, point.x - suggestedBounds.x); |
92 |
break; |
128 |
break; |
93 |
case TOP_CENTER: |
129 |
case TOP_CENTER: |
94 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y); |
130 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width / 2, suggestedBounds.y); |
|
|
131 |
if (! outerBounds) |
132 |
suggestedLocation.y += insets.top; |
95 |
|
133 |
|
96 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false); |
134 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, false, true, false, false); |
97 |
|
135 |
|
|
|
136 |
if (! outerBounds) |
137 |
point.y -= insets.top; |
138 |
|
98 |
tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny); |
139 |
tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny); |
99 |
suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy; |
140 |
suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy; |
100 |
suggestedBounds.y = tempy; |
141 |
suggestedBounds.y = tempy; |
101 |
break; |
142 |
break; |
102 |
case TOP_LEFT: |
143 |
case TOP_LEFT: |
103 |
suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y); |
144 |
suggestedLocation = new Point (suggestedBounds.x, suggestedBounds.y); |
|
|
145 |
if (! outerBounds) { |
146 |
suggestedLocation.y += insets.top; |
147 |
suggestedLocation.x += insets.left; |
148 |
} |
104 |
|
149 |
|
105 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
150 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
106 |
|
151 |
|
|
|
152 |
if (! outerBounds) { |
153 |
point.y -= insets.top; |
154 |
point.x -= insets.left; |
155 |
} |
156 |
|
107 |
tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny); |
157 |
tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny); |
108 |
suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy; |
158 |
suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy; |
109 |
suggestedBounds.y = tempy; |
159 |
suggestedBounds.y = tempy; |
Lines 114-121
Link Here
|
114 |
break; |
164 |
break; |
115 |
case TOP_RIGHT: |
165 |
case TOP_RIGHT: |
116 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y); |
166 |
suggestedLocation = new Point (suggestedBounds.x + suggestedBounds.width, suggestedBounds.y); |
|
|
167 |
if (! outerBounds) { |
168 |
suggestedLocation.y += insets.top; |
169 |
suggestedLocation.x -= insets.right; |
170 |
} |
117 |
|
171 |
|
118 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
172 |
point = super.locationSuggested (widget, new Rectangle (suggestedLocation), suggestedLocation, true, true, false, false); |
|
|
173 |
|
174 |
if (! outerBounds) { |
175 |
point.y -= insets.top; |
176 |
point.x += insets.right; |
177 |
} |
119 |
|
178 |
|
120 |
tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny); |
179 |
tempy = Math.min (point.y, suggestedBounds.y + suggestedBounds.height - miny); |
121 |
suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy; |
180 |
suggestedBounds.height = suggestedBounds.y + suggestedBounds.height - tempy; |