From 572897736060bdff03a146ff18a5f7692bf9b424 Mon Sep 17 00:00:00 2001 From: heeyoung Date: Tue, 8 Jul 2014 10:48:55 +0900 Subject: [PATCH] Combo Widget : add a null check Change-Id: I5ab289a758aa2f8712e2b2430539413e6429fda6 Signed-off-by: heeyoung --- .../widgets/combo/DACustomComboRenderer.java | 46 +++++++++++----------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboRenderer.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboRenderer.java index f95bb8b..4cd0f78 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboRenderer.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/combo/DACustomComboRenderer.java @@ -113,29 +113,31 @@ public class DACustomComboRenderer implements IDACustomButtonRenderer { protected void drawButtonImage(GC gc, Rectangle rect, DACustomButtonAttribute attr, int state) { - Image img = attr.getButtonImage(state); - if (attr != null && img != null) { - Point p = null; - Rectangle imgRect = img.getBounds(); - - int x = 0, y = 0; - if (null == (p = attr.getButtonImagePoint())) { - int width = rect.width - imgRect.width; - int height = rect.height - imgRect.height; - if (width > 0) { - x = width / 2; - } - - if (height > 0) { - y = height / 2; + if (attr != null) { + Image img = attr.getButtonImage(state); + if (img != null) { + Point p = null; + Rectangle imgRect = img.getBounds(); + + int x = 0, y = 0; + if (null == (p = attr.getButtonImagePoint())) { + int width = rect.width - imgRect.width; + int height = rect.height - imgRect.height; + if (width > 0) { + x = width / 2; + } // else : the image is drawn without the left and right margins. + + if (height > 0) { + y = height / 2; + } // else : the image is drawn without the top and bottom margin. + } else { + x = p.x; + y = p.y; } - } else { - x = p.x; - y = p.y; - } - - gc.drawImage(img, x, y); - } // else : attr or imag is null + + gc.drawImage(img, x, y); + } // else : imag is null + } // else : attr is null } protected void drawButtonText(GC gc, Rectangle rect, -- 2.7.4