Arrow.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * This file is licensed under the MIT License, part of Roughly Enough Items.
  3. * Copyright (c) 2018, 2019, 2020 shedaniel
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. package me.shedaniel.rei.api.widgets;
  24. import me.shedaniel.rei.gui.widget.WidgetWithBounds;
  25. import org.jetbrains.annotations.NotNull;
  26. public abstract class Arrow extends WidgetWithBounds {
  27. /**
  28. * @return the x coordinate for the top left corner of this widget.
  29. */
  30. public final int getX() {
  31. return getBounds().getX();
  32. }
  33. /**
  34. * @return the y coordinate for the top left corner of this widget.
  35. */
  36. public final int getY() {
  37. return getBounds().getY();
  38. }
  39. /**
  40. * Gets the animation duration in milliseconds, -1 if animation is disabled.
  41. */
  42. public abstract double getAnimationDuration();
  43. /**
  44. * Sets the animation duration in milliseconds.
  45. *
  46. * @param animationDurationMS animation duration in milliseconds, animation is disabled when below or equals to 0.
  47. */
  48. public abstract void setAnimationDuration(double animationDurationMS);
  49. /**
  50. * Sets the animation duration in milliseconds.
  51. *
  52. * @param animationDurationMS animation duration in milliseconds, animation is disabled when below or equals to 0.
  53. * @return the arrow itself.
  54. */
  55. @NotNull
  56. public final Arrow animationDurationMS(double animationDurationMS) {
  57. setAnimationDuration(animationDurationMS);
  58. return this;
  59. }
  60. /**
  61. * Sets the animation duration in ticks.
  62. *
  63. * @param animationDurationTicks animation duration in ticks, animation is disabled when below or equals to 0.
  64. * @return the arrow itself.
  65. */
  66. @NotNull
  67. public final Arrow animationDurationTicks(double animationDurationTicks) {
  68. return animationDurationMS(animationDurationTicks * 50);
  69. }
  70. /**
  71. * Disables the animation.
  72. *
  73. * @return the arrow itself.
  74. */
  75. @NotNull
  76. public final Arrow disableAnimation() {
  77. return animationDurationMS(-1);
  78. }
  79. }