MCPcopy Create free account
hub / github.com/Card-Forge/forge / draw

Method draw

forge-gui-mobile/src/forge/Graphics.java:200–236  ·  view source on GitHub ↗
(FDisplayObject displayObj)

Source from the content-addressed store, hash-verified

198 }
199
200 public void draw(FDisplayObject displayObj) {
201 if (displayObj.getWidth() <= 0 || displayObj.getHeight() <= 0) {
202 return;
203 }
204
205 final Rectangle parentBounds = bounds;
206 bounds = new Rectangle(parentBounds.x + displayObj.getLeft(), parentBounds.y + displayObj.getTop(), displayObj.getWidth(), displayObj.getHeight());
207 if (!Dtransforms.isEmpty()) { //transform screen position if needed by applying transform matrix to rectangle
208 updateScreenPosForRotation(displayObj);
209 } else {
210 displayObj.screenPos.set(bounds);
211 }
212
213 Rectangle intersection = Utils.getIntersection(bounds, visibleBounds);
214 if (intersection != null) { //avoid drawing object if it's not within visible region
215 final Rectangle backup = visibleBounds;
216 visibleBounds = intersection;
217
218 if (displayObj.getRotate90()) { //use top-right corner of bounds as pivot point
219 startRotateTransform(displayObj.getWidth(), 0, -90);
220 updateScreenPosForRotation(displayObj);
221 } else if (displayObj.getRotate180()) { //use center of bounds as pivot point
222 startRotateTransform(displayObj.getWidth() / 2, displayObj.getHeight() / 2, 180);
223 //screen position won't change for this object from a 180 degree rotation
224 }
225
226 displayObj.draw(this);
227
228 if (displayObj.getRotate90() || displayObj.getRotate180()) {
229 endTransform();
230 }
231
232 visibleBounds = backup;
233 }
234
235 bounds = parentBounds;
236 }
237
238 private void updateScreenPosForRotation(FDisplayObject displayObj) {
239 tmp.set(bounds.x, regionHeight - bounds.y, 0);

Callers

nothing calls this directly

Calls 13

getIntersectionMethod · 0.95
startRotateTransformMethod · 0.95
endTransformMethod · 0.95
getLeftMethod · 0.80
getRotate90Method · 0.80
getRotate180Method · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
isEmptyMethod · 0.65
drawMethod · 0.65
getTopMethod · 0.45

Tested by

no test coverage detected