diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-03-02 22:59:51 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-03-02 22:59:51 +0000 |
commit | 01b4f2019e77eace52e1d434aa8d45bf68207220 (patch) | |
tree | 26fa27da51c249c4526b0c3e699b5fe122b1273f /src/net/java/sip | |
parent | 2f9376278522c9334bf44d977c227341e9c797fa (diff) | |
download | jitsi-01b4f2019e77eace52e1d434aa8d45bf68207220.zip jitsi-01b4f2019e77eace52e1d434aa8d45bf68207220.tar.gz jitsi-01b4f2019e77eace52e1d434aa8d45bf68207220.tar.bz2 |
Removes unnecessary calls to Math.ceil() and Math.round() because the division of integers produces an integer anyway. Eliminates a case of duplication.
Diffstat (limited to 'src/net/java/sip')
3 files changed, 33 insertions, 18 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/BoxPopupMenu.java b/src/net/java/sip/communicator/impl/gui/customcontrols/BoxPopupMenu.java index 08840e2..ad79e8b 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/BoxPopupMenu.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/BoxPopupMenu.java @@ -47,11 +47,17 @@ public class BoxPopupMenu extends JPopupMenu { /** * In order to have a popup which is at the form closest to sqware. */ - private void calculateGridDimensions() { - + private void calculateGridDimensions() + { this.gridRowCount = (int) Math.round(Math.sqrt(this.itemsCount)); - this.gridColCount = (int) Math.round(this.itemsCount / gridRowCount); + /* + * FIXME The original code was "(int)Math.round(itemsCount/gridRowCount)". + * But it was unnecessary because both itemsCount and gridRowCount are + * integers and, consequently, itemsCount/gridRowCount gives an integer. + * Was the intention to have the division produce a real number? + */ + this.gridColCount = itemsCount / gridRowCount; } /** @@ -104,4 +110,4 @@ public class BoxPopupMenu extends JPopupMenu { public int getItemsCount() { return itemsCount; } -}
\ No newline at end of file +} diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommMsgTextArea.java b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommMsgTextArea.java index a9ec436..4df0b58 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommMsgTextArea.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/SIPCommMsgTextArea.java @@ -20,17 +20,9 @@ public class SIPCommMsgTextArea { private static final long serialVersionUID = 0L; - public SIPCommMsgTextArea() + public SIPCommMsgTextArea() { - this.setEditable(false); - this.setLineWrap(true); - this.setWrapStyleWord(true); - this.setOpaque(false); - - int col = 40; - this.setColumns(col); - int docLen = this.getDocument().getLength(); - this.setRows((int)Math.ceil(docLen/col)); + init(); } /** @@ -40,7 +32,12 @@ public class SIPCommMsgTextArea */ public SIPCommMsgTextArea(String text){ super(text); - + + init(); + } + + private void init() + { this.setEditable(false); this.setLineWrap(true); this.setWrapStyleWord(true); @@ -49,6 +46,13 @@ public class SIPCommMsgTextArea int col = 40; this.setColumns(col); int docLen = this.getDocument().getLength(); - this.setRows((int)Math.ceil(docLen/col)); + + /* + * FIXME The original code was "(int)Math.ceil(docLen/col)". But it was + * unnecessary because both docLen and col are integers and, + * consequently, docLen/col gives an integer. Was the intention to have + * the division produce a real number? + */ + this.setRows(docLen/col); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/SmiliesSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/SmiliesSelectorBox.java index bd9cb98..94a1d86 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/SmiliesSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/SmiliesSelectorBox.java @@ -96,10 +96,15 @@ public class SmiliesSelectorBox */ private void calculateGridDimensions(int itemsCount) { - this.gridRowCount = (int) Math.round(Math.sqrt(itemsCount)); - this.gridColCount = (int) Math.ceil(itemsCount / gridRowCount); + /* + * FIXME The original code was "(int)Math.ceil(itemsCount/gridRowCount)". + * But it was unnecessary because both itemsCount and gridRowCount are + * integers and, consequently, itemsCount/gridRowCount gives an integer. + * Was the intention to have the division produce a real number? + */ + this.gridColCount = itemsCount / gridRowCount; } /** |