WIP desktop client for Chatto reimplemented in ScalaFX and Sapphire Framework
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.

81 lines
2.5 KiB

4 years ago
  1. package wow.doge.chatto.messagebuble;
  2. import javafx.scene.shape.HLineTo;
  3. import javafx.scene.shape.LineTo;
  4. import javafx.scene.shape.MoveTo;
  5. import javafx.scene.shape.Path;
  6. import javafx.scene.shape.VLineTo;
  7. public class Bubble extends Path {
  8. /*
  9. * Copyright {2015} {Terah Laweh}
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  12. * use this file except in compliance with the License. You may obtain a copy of
  13. * the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  19. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  20. * License for the specific language governing permissions and limitations under
  21. * the License.
  22. */
  23. public Bubble(BubbleSpec bubbleSpec) {
  24. super();
  25. switch (bubbleSpec) {
  26. case FACE_BOTTOM:
  27. break;
  28. case FACE_LEFT_BOTTOM:
  29. drawRectBubbleLeftBaselineIndicator();
  30. break;
  31. case FACE_LEFT_CENTER:
  32. drawRectBubbleLeftCenterIndicator();
  33. break;
  34. case FACE_RIGHT_BOTTOM:
  35. drawRectBubbleRightBaselineIndicator();
  36. break;
  37. case FACE_RIGHT_CENTER:
  38. drawRectBubbleRightCenterIndicator();
  39. break;
  40. case FACE_TOP:
  41. drawRectBubbleToplineIndicator();
  42. break;
  43. default:
  44. break;
  45. }
  46. }
  47. private void drawRectBubbleToplineIndicator() {
  48. getElements().addAll(new MoveTo(1.0f, 1.2f), new HLineTo(2.5f), new LineTo(2.7f, 1.0f), new LineTo(2.9f, 1.2f),
  49. new HLineTo(4.4f), new VLineTo(4f), new HLineTo(1.0f), new VLineTo(1.2f));
  50. }
  51. private void drawRectBubbleRightBaselineIndicator() {
  52. getElements().addAll(new MoveTo(3.0f, 1.0f), new HLineTo(0f), new VLineTo(4f), new HLineTo(3.0f),
  53. new LineTo(2.8f, 3.8f), new VLineTo(1f));
  54. }
  55. private void drawRectBubbleLeftBaselineIndicator() {
  56. getElements().addAll(new MoveTo(1.2f, 1.0f), new HLineTo(3f), new VLineTo(4f), new HLineTo(1.0f),
  57. new LineTo(1.2f, 3.8f), new VLineTo(1f));
  58. }
  59. private void drawRectBubbleRightCenterIndicator() {
  60. getElements().addAll(new MoveTo(3.0f, 2.5f), new LineTo(2.8f, 2.4f), new VLineTo(1f), new HLineTo(0f),
  61. new VLineTo(4f), new HLineTo(2.8f), new VLineTo(2.7f), new LineTo(3.0f, 2.5f));
  62. }
  63. protected double drawRectBubbleIndicatorRule = 0.2;
  64. private void drawRectBubbleLeftCenterIndicator() {
  65. getElements().addAll(new MoveTo(1.0f, 2.5f), new LineTo(1.2f, 2.4f), new VLineTo(1f), new HLineTo(2.9f),
  66. new VLineTo(4f), new HLineTo(1.2f), new VLineTo(2.7f), new LineTo(1.0f, 2.5f));
  67. }
  68. }