From 415c8cce7eb5b774fed60acd5e214ba90704b6b4 Mon Sep 17 00:00:00 2001 From: draxdyn Date: Wed, 1 Jun 2016 16:44:35 +0200 Subject: [PATCH] Don't call setText() on the popup text component until it is shown Performance improvement, impacts profiles. --- .../plugins/adapters/MageActionCallback.java | 1 + Mage.Common/src/mage/cards/TextPopup.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index 682924c3e15..8a0bee23665 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -155,6 +155,7 @@ public class MageActionCallback implements ActionCallback { } data.locationOnScreen = data.component.getLocationOnScreen(); } + data.popupText.updateText(); tooltipPopup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40); tooltipPopup.show(); // hack to get popup to resize to fit text diff --git a/Mage.Common/src/mage/cards/TextPopup.java b/Mage.Common/src/mage/cards/TextPopup.java index e2f1517a59d..e02e9b124c6 100644 --- a/Mage.Common/src/mage/cards/TextPopup.java +++ b/Mage.Common/src/mage/cards/TextPopup.java @@ -39,6 +39,8 @@ package mage.cards; * @author BetaSteward_at_googlemail.com */ public class TextPopup extends javax.swing.JPanel { + private String text; + private boolean needsUpdate; /** Creates new form TextPopup */ public TextPopup() { @@ -46,7 +48,17 @@ public class TextPopup extends javax.swing.JPanel { } public void setText(String text) { - popupText.setText(text); + if(!text.equals(this.text)) { + this.text = text; + this.needsUpdate = true; + } + } + + public void updateText() { + if(this.needsUpdate) { + popupText.setText(this.text); + this.needsUpdate = false; + } } /** This method is called from within the constructor to