You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LineInfo.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (c) 2006-2014 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.addons.ui_swing.textpane;
  23. /**
  24. * Information about a position in a line.
  25. */
  26. public final class LineInfo {
  27. /** Line number. */
  28. private int line;
  29. /** What part of a line. */
  30. private int part;
  31. /** Character index? */
  32. private int index;
  33. /**
  34. * Creates a new instance of LineInfo.
  35. *
  36. * @param line Line number
  37. * @param part line wrap number
  38. */
  39. public LineInfo(final int line, final int part) {
  40. this(line, part, -1);
  41. }
  42. /**
  43. * Creates a new instance of LineInfo.
  44. *
  45. * @param line Line number
  46. * @param part line wrap number
  47. * @param index Position index
  48. */
  49. public LineInfo(final int line, final int part, final int index) {
  50. this.line = line;
  51. this.part = part;
  52. this.index = index;
  53. }
  54. /**
  55. * Returns the line number of this object.
  56. *
  57. * @return Line number
  58. */
  59. public int getLine() {
  60. return line;
  61. }
  62. /**
  63. * Returns the part for this line.
  64. *
  65. * @return Part number
  66. */
  67. public int getPart() {
  68. return part;
  69. }
  70. /**
  71. * Returns the index for this line.
  72. *
  73. * @return Index for the line of -1
  74. */
  75. public int getIndex() {
  76. return index;
  77. }
  78. /**
  79. * Sets the index for this line.
  80. *
  81. * @param index New index
  82. */
  83. public void setIndex(final int index) {
  84. this.index = index;
  85. }
  86. /**
  87. * Sets the line for this line.
  88. *
  89. * @param line New line
  90. */
  91. public void setLine(final int line) {
  92. this.line = line;
  93. }
  94. /**
  95. * Sets the line part for this line.
  96. *
  97. * @param part New part
  98. */
  99. public void setPart(final int part) {
  100. this.part = part;
  101. }
  102. /* {@inheritDoc} */
  103. @Override
  104. public String toString() {
  105. return "LineInfo[line=" + line + ", part=" + part + ", index="
  106. + index + "]";
  107. }
  108. }