| 1 | /* This file is part of the project "Hilbert II" - http://www.qedeq.org |
| 2 | * |
| 3 | * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>. |
| 4 | * |
| 5 | * "Hilbert II" is free software; you can redistribute |
| 6 | * it and/or modify it under the terms of the GNU General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | package org.qedeq.kernel.bo.service.unicode; |
| 17 | |
| 18 | |
| 19 | /** |
| 20 | * Contains printing data for a formal proof line. |
| 21 | * |
| 22 | * @author Michael Meyling |
| 23 | */ |
| 24 | public class ProofLineData { |
| 25 | |
| 26 | /** Current Label of formal proof line. */ |
| 27 | private String lineLabel; |
| 28 | |
| 29 | /** String representation of formal proof line formula. */ |
| 30 | private String[] formula; |
| 31 | |
| 32 | /** String representation of formal proof line reason. */ |
| 33 | private String[] reason; |
| 34 | |
| 35 | /** |
| 36 | * Constructs empty container. |
| 37 | */ |
| 38 | public ProofLineData() { |
| 39 | init(); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Construct new proof line data. |
| 44 | * |
| 45 | * @param lineLabel Proof line label. |
| 46 | * @param formula Formula strings. |
| 47 | * @param reason Reason strings. |
| 48 | */ |
| 49 | public ProofLineData(final String lineLabel, final String[] formula, final String[] reason) { |
| 50 | this.lineLabel = lineLabel; |
| 51 | this.formula = formula; |
| 52 | this.reason = reason; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Copy constructor. |
| 57 | * |
| 58 | * @param lineData Existing object. |
| 59 | */ |
| 60 | public ProofLineData(final ProofLineData lineData) { |
| 61 | this.lineLabel = lineData.lineLabel; |
| 62 | this.formula = new String[lineData.formula.length]; |
| 63 | System.arraycopy(lineData.formula, 0, this.formula, 0, lineData.formula.length); |
| 64 | this.reason = new String[lineData.reason.length]; |
| 65 | System.arraycopy(lineData.reason, 0, this.reason, 0, lineData.reason.length); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Empty data. |
| 70 | */ |
| 71 | public void init() { |
| 72 | this.lineLabel = ""; |
| 73 | this.formula = new String[0]; |
| 74 | this.reason = new String[0]; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Exists formula data or reason data? |
| 79 | * |
| 80 | * @return Is there any reason or formula data? |
| 81 | */ |
| 82 | public boolean containsData() { |
| 83 | return (0 != lines()); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * How many lines do we have? This is maximum of formula lines and reason lines. |
| 88 | * |
| 89 | * @return Number of lines. |
| 90 | */ |
| 91 | public int lines() { |
| 92 | return Math.max(getFormula().length, getReason().length); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Get label for proof line. |
| 97 | * |
| 98 | * @return Proof line label. |
| 99 | */ |
| 100 | public String getLineLabel() { |
| 101 | return lineLabel; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Set label for proof line. |
| 106 | * |
| 107 | * @param lineLabel Proof line label. |
| 108 | */ |
| 109 | public void setLineLabel(final String lineLabel) { |
| 110 | this.lineLabel = lineLabel; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Get proof line formula. |
| 115 | * |
| 116 | * @return Proof line formula. |
| 117 | */ |
| 118 | public String[] getFormula() { |
| 119 | return formula; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Set proof line formula. |
| 124 | * |
| 125 | * @param formula Proof line formula. |
| 126 | */ |
| 127 | public void setFormula(final String[] formula) { |
| 128 | this.formula = formula; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Get derive reason for proof line. Already formatted in several lines. |
| 133 | * |
| 134 | * @return Reason for getting this proof line. |
| 135 | */ |
| 136 | public String[] getReason() { |
| 137 | return reason; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Set derive reason for proof line. |
| 142 | * |
| 143 | * @param reason Reason for getting this proof line. Must be already formatted in serveral |
| 144 | * lines. |
| 145 | */ |
| 146 | public void setReason(final String[] reason) { |
| 147 | this.reason = reason; |
| 148 | } |
| 149 | |
| 150 | } |