* Allow to addd hint texts to stack abilities. Swicthed to html text format for text box of stack abilites.

This commit is contained in:
LevelX2 2020-07-02 00:53:46 +02:00
parent f409f56c05
commit 84370ee5ab
11 changed files with 64 additions and 46 deletions

View file

@ -8,6 +8,7 @@
package mage.client.cards;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
@ -15,9 +16,10 @@ import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.util.List;
import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.text.BadLocationException;
import javax.swing.text.StyledDocument;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import static mage.client.constants.Constants.CONTENT_MAX_XOFFSET;
import static mage.client.constants.Constants.FRAME_MAX_HEIGHT;
import static mage.client.constants.Constants.FRAME_MAX_WIDTH;
@ -29,6 +31,7 @@ import mage.client.util.ImageHelper;
import mage.constants.EnlargeMode;
import org.jdesktop.swingx.JXPanel;
import mage.client.util.TransformedImageCache;
import org.mage.card.arcane.UI;
/**
* Class for displaying big image of the card
@ -62,6 +65,9 @@ public class BigCard extends JComponent {
setOpaque(true);
this.scrollPane.setOpaque(true);
this.scrollPane.setVisible(false);
UI.setHTMLEditorKit(text);
text.setEditable(false);
}
private void initBounds(boolean rotated) {
@ -69,8 +75,8 @@ public class BigCard extends JComponent {
if (rotated) {
scrollPane.setBounds(50, 50, 100, 100);
} else {
scrollPane.setBounds(this.getWidth()*1000/17777,this.getWidth()*1000/1100,
this.getWidth()*1000/1142,this.getWidth()*1000/2539);
scrollPane.setBounds(this.getWidth()*1000/17777,this.getWidth()*1000/1150,
this.getWidth()*1000/1130,this.getWidth()*1000/2100);
}
}
@ -95,8 +101,14 @@ public class BigCard extends JComponent {
synchronized (this) {
source = null;
hue = 0.000f;
}
drawText(strings);
}
StringBuilder displayedText = new StringBuilder();
for (String textLine: strings) {
if (textLine != null && !textLine.replace(".", "").trim().isEmpty()) {
displayedText.append("<p style='margin: 2px'>").append(textLine).append("</p>");
}
}
this.text.setText(displayedText.toString());
repaint();
}
}
@ -109,19 +121,6 @@ public class BigCard extends JComponent {
this.cardId = null;
}
private void drawText(java.util.List<String> strings) {
text.setText("");
StyledDocument doc = text.getStyledDocument();
try {
for (String line : strings) {
doc.insertString(doc.getLength(), line + '\n', doc.getStyle("regular"));
}
} catch (BadLocationException ble) {
}
text.setCaretPosition(0);
}
@Override
public void paintComponent(Graphics graphics) {
if (bigImage != null) {
@ -169,21 +168,19 @@ public class BigCard extends JComponent {
setFocusable(false);
setMinimumSize(new Dimension(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT));
setName("bigCardPanel"); // NOI18N
setOpaque(false);
setPreferredSize(getMinimumSize());
setLayout(null);
scrollPane.setBackground(new java.awt.Color(220, 220, 220));
scrollPane.setBorder(null);
scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setOpaque(false);
scrollPane.setViewportBorder(javax.swing.BorderFactory.createEtchedBorder());
text.setEditable(false);
text.setFocusable(false);
text.setOpaque(false);
scrollPane.setViewportView(text);
add(scrollPane);
scrollPane.setBounds(20, 230, 210, 120);
scrollPane.setBounds(20, 220, 210, 130);
scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT));
}// </editor-fold>//GEN-END:initComponents