|
|
@@ -0,0 +1,89 @@
|
|
|
+package org.leumasjaffe.charsheet.view.magic;
|
|
|
+
|
|
|
+import javax.swing.JPanel;
|
|
|
+
|
|
|
+import org.leumasjaffe.charsheet.model.magic.DDSpell;
|
|
|
+
|
|
|
+import java.awt.GridBagLayout;
|
|
|
+import javax.swing.JLabel;
|
|
|
+import java.awt.GridBagConstraints;
|
|
|
+import java.awt.Component;
|
|
|
+import javax.swing.Box;
|
|
|
+import java.awt.Insets;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+public class SpellLine extends JPanel {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
+ public SpellLine(final DDSpell spell) {
|
|
|
+ GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
+ gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
+ gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
+ gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
|
+ gridBagLayout.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
|
+ setLayout(gridBagLayout);
|
|
|
+
|
|
|
+ JLabel lblName = new JLabel(spell.getName());
|
|
|
+ GridBagConstraints gbc_lblName = new GridBagConstraints();
|
|
|
+ gbc_lblName.insets = new Insets(0, 0, 0, 5);
|
|
|
+ gbc_lblName.gridx = 0;
|
|
|
+ gbc_lblName.gridy = 0;
|
|
|
+ add(lblName, gbc_lblName);
|
|
|
+
|
|
|
+ Component horizontalStrut = Box.createHorizontalStrut(20);
|
|
|
+ GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
|
|
|
+ gbc_horizontalStrut.insets = new Insets(0, 0, 0, 5);
|
|
|
+ gbc_horizontalStrut.gridx = 1;
|
|
|
+ gbc_horizontalStrut.gridy = 0;
|
|
|
+ add(horizontalStrut, gbc_horizontalStrut);
|
|
|
+
|
|
|
+ JLabel lblSchool = new JLabel(spell.getSchool().toString());
|
|
|
+ String extra = "";
|
|
|
+ if (spell.getSubSchool() != null) {
|
|
|
+ extra = "SubSchool: " + spell.getSubSchool().toString();
|
|
|
+ }
|
|
|
+ if (!spell.getKeywords().isEmpty()) {
|
|
|
+ if (!extra.isEmpty()) extra += "<br>";
|
|
|
+ extra += "Keywords: " + spell.getKeywords().toString();
|
|
|
+ }
|
|
|
+ if (!extra.isEmpty()) {
|
|
|
+ lblSchool.setToolTipText("<html>" + extra + "</html>");
|
|
|
+ }
|
|
|
+ GridBagConstraints gbc_lblSchool = new GridBagConstraints();
|
|
|
+ gbc_lblSchool.insets = new Insets(0, 0, 0, 5);
|
|
|
+ gbc_lblSchool.gridx = 2;
|
|
|
+ gbc_lblSchool.gridy = 0;
|
|
|
+ add(lblSchool, gbc_lblSchool);
|
|
|
+
|
|
|
+ Component horizontalStrut_1 = Box.createHorizontalStrut(20);
|
|
|
+ GridBagConstraints gbc_horizontalStrut_1 = new GridBagConstraints();
|
|
|
+ gbc_horizontalStrut_1.insets = new Insets(0, 0, 0, 5);
|
|
|
+ gbc_horizontalStrut_1.gridx = 3;
|
|
|
+ gbc_horizontalStrut_1.gridy = 0;
|
|
|
+ add(horizontalStrut_1, gbc_horizontalStrut_1);
|
|
|
+
|
|
|
+ JLabel lblComponents = new JLabel(spell.getComponents().stream().map(e -> e.name()).collect(Collectors.toList()).toString());
|
|
|
+ GridBagConstraints gbc_lblComponents = new GridBagConstraints();
|
|
|
+ gbc_lblComponents.insets = new Insets(0, 0, 0, 5);
|
|
|
+ gbc_lblComponents.gridx = 4;
|
|
|
+ gbc_lblComponents.gridy = 0;
|
|
|
+ add(lblComponents, gbc_lblComponents);
|
|
|
+
|
|
|
+ Component horizontalStrut_2 = Box.createHorizontalStrut(20);
|
|
|
+ GridBagConstraints gbc_horizontalStrut_2 = new GridBagConstraints();
|
|
|
+ gbc_horizontalStrut_2.insets = new Insets(0, 0, 0, 5);
|
|
|
+ gbc_horizontalStrut_2.gridx = 5;
|
|
|
+ gbc_horizontalStrut_2.gridy = 0;
|
|
|
+ add(horizontalStrut_2, gbc_horizontalStrut_2);
|
|
|
+
|
|
|
+ JLabel lblAction = new JLabel(spell.getCastingTime().name());
|
|
|
+ GridBagConstraints gbc_lblAction = new GridBagConstraints();
|
|
|
+ gbc_lblAction.gridx = 6;
|
|
|
+ gbc_lblAction.gridy = 0;
|
|
|
+ add(lblAction, gbc_lblAction);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|