refactor: removed some outdated GUI components and code

This commit is contained in:
Oleg Agafonov 2023-11-27 00:20:11 +04:00
parent d016e4c4c3
commit 550e97e1e3
4 changed files with 29 additions and 182 deletions

View file

@ -225,79 +225,6 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
action.actionPerformed(null);
}
public static class ImageRenderer2 extends JEditorPane implements ListCellRenderer {
public final Map<String, String> cache = new HashMap<>();
@Override
public Component getListCellRendererComponent(
javax.swing.JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus
) {
setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 6));
UI.setHTMLEditorKit(this);
setOpaque(false);
setBackground(new Color(0, 0, 0, 0));
String text = value.toString();
if (cache.containsKey(text)) {
text = cache.get(text);
} else {
StringBuilder buffer = getHtmlForText(isSelected, text);
String rendered = buffer.toString();
cache.put(text, rendered);
text = rendered;
}
final String finalText = text;
// System.out.println(finalText);
ImageRenderer2.super.setText(finalText);
setCaretPosition(0);
return this;
}
private StringBuilder getHtmlForText(boolean isSelected, String text) {
int fontSize = 16;
String fontFamily = "arial";
final StringBuilder buffer = new StringBuilder(512);
buffer.append("<html><body style='font-family:");
buffer.append(fontFamily);
buffer.append(";font-size:");
buffer.append(fontSize);
buffer.append("pt;margin:3px 3px 3px 3px;");
if (isSelected) {
buffer.append("color: #4093D0'>");
} else {
buffer.append("color: #FFFFFF'>");
}
buffer.append("<b>");
text = text.replaceAll("#([^#]+)#", "<i>$1</i>");
text = text.replaceAll("\\s*//\\s*", "<hr width='50%'>");
text = text.replace("\r\n", "<div style='font-size:5pt'></div>");
//text += "<br>";
if (!text.isEmpty()) {
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.DIALOG));
}
buffer.append("</b></body></html>");
return buffer;
}
}
class ImageRenderer extends DefaultListCellRenderer {
@Override

View file

@ -1,29 +0,0 @@
package mage.client.components.ext;
import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
/**
* @author noxx
*/
public class MageFloatPane extends JEditorPane {
public MageFloatPane() {
UI.setHTMLEditorKit(this);
setEditable(false);
setBackground(Color.white);
JButton jb = new JButton("Done");
jb.setLocation(50, 50);
jb.setSize(100, 50);
add(jb);
}
public void setCard(final String text) {
SwingUtilities.invokeLater(() -> {
setText(text);
setCaretPosition(0);
});
}
}

View file

@ -1,36 +0,0 @@
package mage.client.components.ext;
import mage.client.components.MageRoundPane;
import javax.swing.*;
/**
* @author ayratn
*/
public final class TestMageFloatPane {
public static void main(String... args) {
JFrame f = new JFrame();
f.setSize(600, 400);
f.setVisible(true);
MageFloatPane fp = new MageFloatPane();
fp.setCard("Card");
MageRoundPane popupContainer = new MageRoundPane();
popupContainer.setLayout(null);
popupContainer.add(fp);
//popupContainer.setVisible(false);
popupContainer.setBounds(0, 0, 320 + 80, 201 + 80);
JDialog floatOnParent = new JDialog(f, false);
floatOnParent.setUndecorated(true);
floatOnParent.getContentPane().add(popupContainer);
floatOnParent.setBounds(300, 100, 300, 200);
floatOnParent.setVisible(true);
}
}