|
|
@@ -0,0 +1,342 @@
|
|
|
+package org.leumasjaffe.charsheet.view.magic;
|
|
|
+
|
|
|
+import javax.swing.JPanel;
|
|
|
+import java.awt.GridBagLayout;
|
|
|
+import java.awt.GridBagConstraints;
|
|
|
+import java.awt.Insets;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+import javax.swing.JTextArea;
|
|
|
+
|
|
|
+import org.leumasjaffe.charsheet.model.DDCharacterClass;
|
|
|
+import org.leumasjaffe.charsheet.model.magic.DDSpell;
|
|
|
+import org.leumasjaffe.charsheet.model.magic.DDSpell.Component;
|
|
|
+import org.leumasjaffe.charsheet.model.magic.Source;
|
|
|
+
|
|
|
+import javax.swing.JScrollPane;
|
|
|
+import javax.swing.JLabel;
|
|
|
+import javax.swing.JTextField;
|
|
|
+import java.awt.Font;
|
|
|
+import java.awt.FlowLayout;
|
|
|
+import javax.swing.JCheckBox;
|
|
|
+
|
|
|
+import static org.leumasjaffe.charsheet.model.magic.DDSpell.Component.*;
|
|
|
+
|
|
|
+class SpellInfoPanel extends JPanel {
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
+ public SpellInfoPanel(DDCharacterClass dclass, final DDSpell spell) {
|
|
|
+ GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
+ gridBagLayout.columnWidths = new int[]{0, 0};
|
|
|
+ gridBagLayout.rowHeights = new int[]{0, 0, 0};
|
|
|
+ gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
+ gridBagLayout.rowWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
|
|
|
+ setLayout(gridBagLayout);
|
|
|
+
|
|
|
+ JPanel panel = new JPanel();
|
|
|
+ GridBagConstraints gbc_panel = new GridBagConstraints();
|
|
|
+ gbc_panel.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_panel.fill = GridBagConstraints.BOTH;
|
|
|
+ gbc_panel.gridx = 0;
|
|
|
+ gbc_panel.gridy = 0;
|
|
|
+ add(panel, gbc_panel);
|
|
|
+ GridBagLayout gbl_panel = new GridBagLayout();
|
|
|
+ gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0};
|
|
|
+ gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
+ gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0, Double.MIN_VALUE};
|
|
|
+ gbl_panel.rowWeights = new double[]{0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
|
|
|
+ panel.setLayout(gbl_panel);
|
|
|
+
|
|
|
+ JLabel lblName = new JLabel("Name:");
|
|
|
+ lblName.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblName = new GridBagConstraints();
|
|
|
+ gbc_lblName.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblName.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblName.gridx = 0;
|
|
|
+ gbc_lblName.gridy = 0;
|
|
|
+ panel.add(lblName, gbc_lblName);
|
|
|
+
|
|
|
+ JTextField name = new JTextField(spell.getName());
|
|
|
+ name.setEditable(false);
|
|
|
+ GridBagConstraints gbc_name = new GridBagConstraints();
|
|
|
+ gbc_name.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_name.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_name.gridx = 1;
|
|
|
+ gbc_name.gridy = 0;
|
|
|
+ panel.add(name, gbc_name);
|
|
|
+ name.setColumns(10);
|
|
|
+
|
|
|
+ JLabel lblSpellSchool = new JLabel("Spell School:");
|
|
|
+ lblSpellSchool.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblSpellSchool = new GridBagConstraints();
|
|
|
+ gbc_lblSpellSchool.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblSpellSchool.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblSpellSchool.gridx = 2;
|
|
|
+ gbc_lblSpellSchool.gridy = 0;
|
|
|
+ panel.add(lblSpellSchool, gbc_lblSpellSchool);
|
|
|
+
|
|
|
+ JTextField school = new JTextField(spell.getSpellSchool());
|
|
|
+ school.setEditable(false);
|
|
|
+ school.setColumns(10);
|
|
|
+ GridBagConstraints gbc_school = new GridBagConstraints();
|
|
|
+ gbc_school.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_school.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_school.gridx = 3;
|
|
|
+ gbc_school.gridy = 0;
|
|
|
+ panel.add(school, gbc_school);
|
|
|
+
|
|
|
+ JLabel lblKeywords = new JLabel("Keywords:");
|
|
|
+ lblKeywords.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblKeywords = new GridBagConstraints();
|
|
|
+ gbc_lblKeywords.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblKeywords.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblKeywords.gridx = 0;
|
|
|
+ gbc_lblKeywords.gridy = 1;
|
|
|
+ panel.add(lblKeywords, gbc_lblKeywords);
|
|
|
+
|
|
|
+ JTextField keywords = new JTextField(asString(spell.getKeywords()));
|
|
|
+ keywords.setEditable(false);
|
|
|
+ keywords.setColumns(10);
|
|
|
+ GridBagConstraints gbc_keywords = new GridBagConstraints();
|
|
|
+ gbc_keywords.gridwidth = 3;
|
|
|
+ gbc_keywords.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_keywords.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_keywords.gridx = 1;
|
|
|
+ gbc_keywords.gridy = 1;
|
|
|
+ panel.add(keywords, gbc_keywords);
|
|
|
+
|
|
|
+ JLabel lblComponents = new JLabel("Components:");
|
|
|
+ lblComponents.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblComponents = new GridBagConstraints();
|
|
|
+ gbc_lblComponents.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblComponents.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblComponents.gridx = 0;
|
|
|
+ gbc_lblComponents.gridy = 2;
|
|
|
+ panel.add(lblComponents, gbc_lblComponents);
|
|
|
+
|
|
|
+ JPanel panel_1 = new JPanel();
|
|
|
+ GridBagConstraints gbc_panel_1 = new GridBagConstraints();
|
|
|
+ gbc_panel_1.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_panel_1.gridwidth = 3;
|
|
|
+ gbc_panel_1.fill = GridBagConstraints.BOTH;
|
|
|
+ gbc_panel_1.gridx = 1;
|
|
|
+ gbc_panel_1.gridy = 2;
|
|
|
+ panel.add(panel_1, gbc_panel_1);
|
|
|
+ panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
|
|
+
|
|
|
+ final Set<Component> comps = spell.getComponents();
|
|
|
+ final Source src = dclass.getProto().getSpells().get().getGroup();
|
|
|
+
|
|
|
+ JCheckBox chckbxVerbal = new JCheckBox("Verbal");
|
|
|
+ chckbxVerbal.setEnabled(false);
|
|
|
+ chckbxVerbal.setSelected(comps.contains(V));
|
|
|
+ panel_1.add(chckbxVerbal);
|
|
|
+
|
|
|
+ JCheckBox chckbxSomatic = new JCheckBox("Somatic");
|
|
|
+ chckbxSomatic.setEnabled(false);
|
|
|
+ chckbxSomatic.setSelected(comps.contains(S));
|
|
|
+ panel_1.add(chckbxSomatic);
|
|
|
+
|
|
|
+ JCheckBox chckbxMaterial = new JCheckBox("Material");
|
|
|
+ chckbxMaterial.setEnabled(false);
|
|
|
+ chckbxMaterial.setSelected(comps.contains(M) || (comps.contains(M_DF) && src == Source.ARCANE));
|
|
|
+ panel_1.add(chckbxMaterial);
|
|
|
+
|
|
|
+ JCheckBox chckbxFocus = new JCheckBox("Focus");
|
|
|
+ chckbxFocus.setEnabled(false);
|
|
|
+ chckbxFocus.setSelected(comps.contains(F) || (comps.contains(F_DF) && src == Source.ARCANE));
|
|
|
+ panel_1.add(chckbxFocus);
|
|
|
+
|
|
|
+ JCheckBox chckbxDivineFocus = new JCheckBox("Divine Focus");
|
|
|
+ chckbxDivineFocus.setEnabled(false);
|
|
|
+ chckbxDivineFocus.setSelected(comps.contains(DF) || ((comps.contains(M_DF) || comps.contains(F_DF)) && src == Source.DIVINE));
|
|
|
+ panel_1.add(chckbxDivineFocus);
|
|
|
+
|
|
|
+ JCheckBox chckbxExperience = new JCheckBox("Experience");
|
|
|
+ chckbxExperience.setEnabled(false);
|
|
|
+ chckbxExperience.setSelected(comps.contains(XP));
|
|
|
+ panel_1.add(chckbxExperience);
|
|
|
+
|
|
|
+ JLabel lblCastingTime = new JLabel("Casting Time:");
|
|
|
+ lblCastingTime.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblCastingTime = new GridBagConstraints();
|
|
|
+ gbc_lblCastingTime.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblCastingTime.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblCastingTime.gridx = 0;
|
|
|
+ gbc_lblCastingTime.gridy = 3;
|
|
|
+ panel.add(lblCastingTime, gbc_lblCastingTime);
|
|
|
+
|
|
|
+ JTextField action = new JTextField(spell.getCastingTime().name());
|
|
|
+ action.setEditable(false);
|
|
|
+ action.setColumns(10);
|
|
|
+ GridBagConstraints gbc_action = new GridBagConstraints();
|
|
|
+ gbc_action.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_action.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_action.gridx = 1;
|
|
|
+ gbc_action.gridy = 3;
|
|
|
+ panel.add(action, gbc_action);
|
|
|
+
|
|
|
+ JLabel lblRange = new JLabel("Range:");
|
|
|
+ lblRange.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblRange = new GridBagConstraints();
|
|
|
+ gbc_lblRange.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblRange.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblRange.gridx = 2;
|
|
|
+ gbc_lblRange.gridy = 3;
|
|
|
+ panel.add(lblRange, gbc_lblRange);
|
|
|
+
|
|
|
+ JTextField range = new JTextField(spell.getRange().getResolved(dclass.getLevel()));
|
|
|
+ range.setToolTipText(spell.getRange().toString());
|
|
|
+ range.setEditable(false);
|
|
|
+ range.setColumns(10);
|
|
|
+ GridBagConstraints gbc_range = new GridBagConstraints();
|
|
|
+ gbc_range.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_range.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_range.gridx = 3;
|
|
|
+ gbc_range.gridy = 3;
|
|
|
+ panel.add(range, gbc_range);
|
|
|
+
|
|
|
+ JLabel lblTarget = new JLabel("Target:");
|
|
|
+ lblTarget.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblTarget = new GridBagConstraints();
|
|
|
+ gbc_lblTarget.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblTarget.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblTarget.gridx = 0;
|
|
|
+ gbc_lblTarget.gridy = 4;
|
|
|
+ panel.add(lblTarget, gbc_lblTarget);
|
|
|
+
|
|
|
+ JTextField target = new JTextField(asString(spell.getTarget()));
|
|
|
+ target.setEditable(false);
|
|
|
+ target.setColumns(10);
|
|
|
+ GridBagConstraints gbc_target = new GridBagConstraints();
|
|
|
+ gbc_target.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_target.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_target.gridx = 1;
|
|
|
+ gbc_target.gridy = 4;
|
|
|
+ panel.add(target, gbc_target);
|
|
|
+
|
|
|
+ JLabel lblEffect = new JLabel("Effect:");
|
|
|
+ lblEffect.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblEffect = new GridBagConstraints();
|
|
|
+ gbc_lblEffect.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblEffect.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblEffect.gridx = 2;
|
|
|
+ gbc_lblEffect.gridy = 4;
|
|
|
+ panel.add(lblEffect, gbc_lblEffect);
|
|
|
+
|
|
|
+ JTextField effect = new JTextField(asString(spell.getEffect()));
|
|
|
+ effect.setEditable(false);
|
|
|
+ effect.setColumns(10);
|
|
|
+ GridBagConstraints gbc_effect = new GridBagConstraints();
|
|
|
+ gbc_effect.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_effect.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_effect.gridx = 3;
|
|
|
+ gbc_effect.gridy = 4;
|
|
|
+ panel.add(effect, gbc_effect);
|
|
|
+
|
|
|
+ JLabel lblArea = new JLabel("Area:");
|
|
|
+ lblArea.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblArea = new GridBagConstraints();
|
|
|
+ gbc_lblArea.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblArea.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblArea.gridx = 0;
|
|
|
+ gbc_lblArea.gridy = 5;
|
|
|
+ panel.add(lblArea, gbc_lblArea);
|
|
|
+
|
|
|
+ JTextField area = new JTextField(asString(spell.getArea()));
|
|
|
+ area.setEditable(false);
|
|
|
+ area.setColumns(10);
|
|
|
+ GridBagConstraints gbc_area = new GridBagConstraints();
|
|
|
+ gbc_area.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_area.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_area.gridx = 1;
|
|
|
+ gbc_area.gridy = 5;
|
|
|
+ panel.add(area, gbc_area);
|
|
|
+
|
|
|
+ JLabel lblDuration = new JLabel("Duration:");
|
|
|
+ lblDuration.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblDuration = new GridBagConstraints();
|
|
|
+ gbc_lblDuration.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblDuration.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblDuration.gridx = 2;
|
|
|
+ gbc_lblDuration.gridy = 5;
|
|
|
+ panel.add(lblDuration, gbc_lblDuration);
|
|
|
+
|
|
|
+ JTextField duration = new JTextField(spell.getDuration());
|
|
|
+ duration.setEditable(false);
|
|
|
+ duration.setColumns(10);
|
|
|
+ GridBagConstraints gbc_duration = new GridBagConstraints();
|
|
|
+ gbc_duration.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_duration.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_duration.gridx = 3;
|
|
|
+ gbc_duration.gridy = 5;
|
|
|
+ panel.add(duration, gbc_duration);
|
|
|
+
|
|
|
+ JLabel lblSavingThrow = new JLabel("Saving Throw:");
|
|
|
+ lblSavingThrow.setFont(new Font("Tahoma", Font.BOLD, 14));
|
|
|
+ GridBagConstraints gbc_lblSavingThrow = new GridBagConstraints();
|
|
|
+ gbc_lblSavingThrow.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblSavingThrow.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblSavingThrow.gridx = 0;
|
|
|
+ gbc_lblSavingThrow.gridy = 6;
|
|
|
+ panel.add(lblSavingThrow, gbc_lblSavingThrow);
|
|
|
+
|
|
|
+ JTextField saving = new JTextField(spell.getSavingThrow());
|
|
|
+ saving.setEditable(false);
|
|
|
+ saving.setColumns(10);
|
|
|
+ GridBagConstraints gbc_saving = new GridBagConstraints();
|
|
|
+ gbc_saving.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_saving.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_saving.gridx = 1;
|
|
|
+ gbc_saving.gridy = 6;
|
|
|
+ panel.add(saving, gbc_saving);
|
|
|
+
|
|
|
+ JLabel lblSpellResistance = new JLabel("Spell Resistance:");
|
|
|
+ lblSpellResistance.setFont(new Font("Tahoma", Font.BOLD, 12));
|
|
|
+ GridBagConstraints gbc_lblSpellResistance = new GridBagConstraints();
|
|
|
+ gbc_lblSpellResistance.anchor = GridBagConstraints.EAST;
|
|
|
+ gbc_lblSpellResistance.insets = new Insets(0, 0, 5, 5);
|
|
|
+ gbc_lblSpellResistance.gridx = 2;
|
|
|
+ gbc_lblSpellResistance.gridy = 6;
|
|
|
+ panel.add(lblSpellResistance, gbc_lblSpellResistance);
|
|
|
+
|
|
|
+ JTextField resist = new JTextField(spell.isAllowsSpellResistance() ? "Yes" : "No");
|
|
|
+ resist.setEditable(false);
|
|
|
+ resist.setColumns(10);
|
|
|
+ GridBagConstraints gbc_resist = new GridBagConstraints();
|
|
|
+ gbc_resist.insets = new Insets(0, 0, 5, 0);
|
|
|
+ gbc_resist.fill = GridBagConstraints.HORIZONTAL;
|
|
|
+ gbc_resist.gridx = 3;
|
|
|
+ gbc_resist.gridy = 6;
|
|
|
+ panel.add(resist, gbc_resist);
|
|
|
+
|
|
|
+ JScrollPane scrollPane = new JScrollPane();
|
|
|
+ GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
|
|
+ gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
|
|
+ gbc_scrollPane.gridx = 0;
|
|
|
+ gbc_scrollPane.gridy = 1;
|
|
|
+ add(scrollPane, gbc_scrollPane);
|
|
|
+
|
|
|
+ JTextArea description = new JTextArea(spell.getDescription());
|
|
|
+ description.setEditable(false);
|
|
|
+ description.setWrapStyleWord(true);
|
|
|
+ description.setRows(10);
|
|
|
+ scrollPane.setViewportView(description);
|
|
|
+ description.setColumns(30);
|
|
|
+ description.setLineWrap(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String asString(Object obj) {
|
|
|
+ return obj == null ? "" : obj.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String asString(Set<String> keys) {
|
|
|
+ if (keys.isEmpty()) return "<none>";
|
|
|
+ String str = keys.toString();
|
|
|
+ return str.substring(1, str.length()-1);
|
|
|
+ }
|
|
|
+}
|