UnitGraph.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. package ui.view;
  2. import java.awt.BasicStroke;
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.RenderingHints;
  7. import java.awt.event.ComponentEvent;
  8. import java.awt.event.ComponentListener;
  9. import java.awt.event.MouseEvent;
  10. import java.awt.event.MouseListener;
  11. import java.awt.event.MouseMotionListener;
  12. import java.awt.geom.CubicCurve2D;
  13. import java.awt.geom.GeneralPath;
  14. import java.awt.geom.Line2D;
  15. import java.util.LinkedList;
  16. import java.awt.Point;
  17. import javax.swing.JPanel;
  18. import classes.HolonElement;
  19. import ui.controller.Control;
  20. import ui.model.Model;
  21. import classes.HolonSwitch;
  22. import java.awt.Cursor;
  23. class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, ComponentListener {
  24. private static final long serialVersionUID = 1L;
  25. private float MAXIMUM = 0;
  26. private Point recSize = new Point(8, 8); // Point Size
  27. private Graphics2D g2;
  28. private CubicCurve2D c = new CubicCurve2D.Double();
  29. private CubicCurve2D cr = new CubicCurve2D.Double();
  30. private CubicCurve2D cl = new CubicCurve2D.Double();
  31. private LinkedList<Point> pointList;
  32. private double scaleX;
  33. private double scaleY;
  34. private float[] arrayOfFloats = null;
  35. private boolean[] arrayOfBooleans = null;
  36. private double width = -1;
  37. private double height = -1;
  38. private boolean isElement = false;
  39. private boolean isSwitch = false;
  40. private HolonElement tempElement;
  41. private HolonSwitch tempSwitch;
  42. private Model model;
  43. private Control controller;
  44. private Line2D.Double line = null;
  45. GeneralPath graphCurve = new GeneralPath();
  46. private boolean pointDrag = false;
  47. private boolean init = true;
  48. private Point tempP = null;
  49. private double x = 0, y = 0;
  50. private int x1, x2, y1, y2, ctrlx1, ctrly1, ctrlx2, ctrly2;
  51. public UnitGraph(final Model model, Control control) {
  52. setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
  53. this.controller = control;
  54. this.model = model;
  55. this.pointList = new LinkedList<>();
  56. this.setBackground(Color.WHITE);
  57. this.addMouseListener(this);
  58. this.addMouseMotionListener(this);
  59. this.addComponentListener(this);
  60. }
  61. /**
  62. * Paints all Components on the Canvas
  63. *
  64. * @param Graphics
  65. *
  66. */
  67. public void paintComponent(Graphics g) {
  68. super.paintComponent(g);
  69. g2 = (Graphics2D) g;
  70. RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  71. g2.setRenderingHints(rh);
  72. g2.setStroke(new BasicStroke(0));
  73. graphCurve.reset();
  74. // Draw the Vertical Lines
  75. g2.setColor(Color.BLACK);
  76. for (int i = 0; i <= this.getWidth(); i += 10) {
  77. g2.drawLine(i, 0, i, this.getHeight());
  78. }
  79. for (int i = 0; i <= this.getHeight(); i += 5) {
  80. g2.drawLine(0, i, this.getWidth(), i);
  81. }
  82. if (isElement) {
  83. if (arrayOfFloats != null) {
  84. // array fillen
  85. fillArrayofValue();
  86. // Draw the Lines
  87. g2.setStroke(new BasicStroke(2));
  88. g2.setColor(Color.BLACK);
  89. for (int i = 0; i < pointList.size() - 1; i++) {
  90. c = buildCurve(pointList.get(i), pointList.get(i + 1));
  91. graphCurve.append(c, true);
  92. }
  93. g2.draw(graphCurve);
  94. // Draw the Points
  95. g2.setColor(Color.BLUE);
  96. for (int i = 0; i < pointList.size() - 0; i++) {
  97. g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
  98. (int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
  99. (int) recSize.getY());
  100. }
  101. // Iteration Value
  102. if (arrayOfFloats != null) {
  103. g2.drawString("" + arrayOfFloats[model.getCurIteration()],
  104. (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
  105. this.getHeight() - 10);
  106. }
  107. }
  108. /*
  109. * // Actual Iteration Point Visualization g2.setColor(Color.RED);
  110. * if (arrayOfValue != null) { for (int i = 0; i <
  111. * arrayOfValue.length; i++) { g2.fillOval((int) (i * width /
  112. * (model.getIterations() - 1) * scaleX - recSize.getX() / 2), (int)
  113. * (convertToCanvasY((int) arrayOfValue[i]) * scaleY -
  114. * recSize.getY() / 2), (int) recSize.getX(), (int) recSize.getY());
  115. * } }
  116. */
  117. } else if (isSwitch) {
  118. if (arrayOfBooleans != null) {
  119. // array fillen
  120. fillArrayofBooleans();
  121. // Draw the Lines
  122. g2.setStroke(new BasicStroke(2));
  123. g2.setColor(Color.BLACK);
  124. for (int i = 0; i < pointList.size() - 1; i++) {
  125. line = new Line2D.Double(pointList.get(i).getX() * scaleX, pointList.get(i).getY() * scaleY,
  126. pointList.get(i + 1).getX() * scaleX, pointList.get(i + 1).getY() * scaleY);
  127. graphCurve.append(line, true);
  128. }
  129. g2.draw(graphCurve);
  130. /*
  131. * // Draw the Points g2.setColor(Color.BLUE); for (int i = 0; i
  132. * < pointList.size() - 0; i++) { g2.fillOval((int)
  133. * (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
  134. * (int) (pointList.get(i).getY() * scaleY - recSize.getY() /
  135. * 2), (int) recSize.getX(), (int) recSize.getY()); }
  136. */
  137. // Iteration Value
  138. if (arrayOfBooleans != null) {
  139. g2.drawString("" + arrayOfBooleans[model.getCurIteration()],
  140. (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
  141. this.getHeight() - 10);
  142. }
  143. }
  144. }
  145. // Iteration Line
  146. g2.setColor(Color.BLUE);
  147. g2.setStroke(new BasicStroke(1));
  148. g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
  149. (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
  150. }
  151. @Override
  152. public void mouseDragged(MouseEvent e) {
  153. if (isElement) {
  154. elementDragged(e);
  155. } else if (isSwitch) {
  156. switchDragged(e);
  157. }
  158. }
  159. /**
  160. * Wenn ein Punkt bei einem HolonElement gedragged wird
  161. *
  162. * @param e
  163. */
  164. public void elementDragged(MouseEvent e) {
  165. if (pointDrag && tempP != null) {
  166. // Out of Bounds verhindern
  167. int i = pointList.indexOf(tempP);
  168. x = e.getX() / scaleX;
  169. y = e.getY() / scaleY;
  170. // y
  171. if (e.getY() <= 0) {
  172. y = 0 / scaleY;
  173. } else if (this.getHeight() <= e.getY()) {
  174. y = this.getHeight() / scaleY;
  175. }
  176. // x
  177. if (tempP == pointList.getFirst() || tempP == pointList.getLast() || pointList.get(i + 1).getX() <= x
  178. || pointList.get(i - 1).getX() >= x) {
  179. x = tempP.getX();
  180. }
  181. tempP.setLocation(x, y);
  182. repaint();
  183. }
  184. }
  185. /**
  186. * Wenn ein Punkt bei einem CpsSwitch gedragged wird
  187. *
  188. * @param e
  189. */
  190. public void switchDragged(MouseEvent e) {
  191. if (pointDrag && tempP != null && tempP != pointList.getFirst() && tempP != pointList.getLast()) {
  192. int i = pointList.indexOf(tempP);
  193. x = e.getX() / scaleX;
  194. if (pointList.get(i + 1).getY() == tempP.getY()) {
  195. // x
  196. if (pointList.get(i + 1).getX() <= x || pointList.get(i - 2).getX() >= x) {
  197. x = tempP.getX();
  198. }
  199. pointList.get(i - 1).setLocation(x, pointList.get(i - 1).getY());
  200. } else {
  201. // x
  202. if (pointList.get(i + 2).getX() <= x || pointList.get(i - 1).getX() >= x) {
  203. x = tempP.getX();
  204. }
  205. pointList.get(i + 1).setLocation(x, pointList.get(i + 1).getY());
  206. }
  207. tempP.setLocation(x, tempP.getY());
  208. repaint();
  209. }
  210. }
  211. @Override
  212. public void mouseMoved(MouseEvent e) {
  213. }
  214. @Override
  215. public void mouseClicked(MouseEvent e) {
  216. }
  217. @Override
  218. public void mouseEntered(MouseEvent e) {
  219. }
  220. @Override
  221. public void mouseExited(MouseEvent e) {
  222. }
  223. @Override
  224. public void mousePressed(MouseEvent e) {
  225. if (isElement) {
  226. elementPressed(e);
  227. } else if (isSwitch) {
  228. switchPressed(e);
  229. }
  230. }
  231. /**
  232. * Wenn ein Punkt von einem Element gedrück wird
  233. *
  234. * @param e
  235. */
  236. public void elementPressed(MouseEvent e) {
  237. boolean added = false;
  238. boolean deletePoint = false;
  239. double x = e.getX() / scaleX;
  240. double y = e.getY() / scaleY;
  241. // Click on Point
  242. tempP = null;
  243. if (pointList != null) {
  244. // look if a point was clicked
  245. for (Point p : pointList) {
  246. if (x >= p.getX() - recSize.getX() / 2 && y >= p.getY() - recSize.getY() / 2
  247. && x <= p.getX() + recSize.getX() / 2 && y <= p.getY() * scaleY + recSize.getY() / 2) {
  248. if (e.getButton() == MouseEvent.BUTTON3) {
  249. tempP = p;
  250. deletePoint = true;
  251. } else {
  252. pointDrag = true;
  253. tempP = p;
  254. }
  255. }
  256. }
  257. // New Point
  258. if (!pointDrag && e.getButton() != MouseEvent.BUTTON3 && e.getX() != 0
  259. && e.getX() != this.getWidth() / scaleX) {
  260. for (int i = 0; i < pointList.size(); i++) {
  261. if (x < pointList.get(i).getX() && !added) {
  262. if (e.getY() <= 0) {
  263. pointList.add(i, new Point((int) (x), (int) (0 / scaleY)));
  264. } else {
  265. pointList.add(i, new Point((int) (x), (int) y));
  266. }
  267. added = true;
  268. pointDrag = true;
  269. tempP = pointList.get(i);
  270. }
  271. }
  272. }
  273. // Delete a Point
  274. if (deletePoint && tempP.getX() != 0
  275. && (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
  276. pointList.remove(tempP);
  277. }
  278. repaint();
  279. }
  280. }
  281. /**
  282. * Wenn ein Punkt von einem Switch gedrück wird
  283. *
  284. * @param e
  285. */
  286. public void switchPressed(MouseEvent e) {
  287. boolean added = false;
  288. boolean deletePoint = false;
  289. double x = e.getX() / scaleX;
  290. double y = e.getY() / scaleY;
  291. // Halbe Iterations Distanz
  292. double dist = (width / (model.getIterations() - 1)) / 2;
  293. // Click on Point
  294. tempP = null;
  295. if (pointList != null) {
  296. for (Point p : pointList) {
  297. if (x >= p.getX() - dist && x <= p.getX() + dist) {
  298. if (e.getButton() == MouseEvent.BUTTON3) {
  299. tempP = p;
  300. deletePoint = true;
  301. } else {
  302. pointDrag = true;
  303. tempP = p;
  304. }
  305. }
  306. }
  307. // New Point
  308. if (!pointDrag && e.getButton() != MouseEvent.BUTTON3 && x != 0 && x != width) {
  309. for (int i = 0; i < pointList.size() && !added; i++) {
  310. if (x < pointList.get(i).getX() - dist) {
  311. // Punkt hinzufügen, je nachdem ob es oberhalb oder
  312. // unterhalb der hälfte ist
  313. if (y < height / 2 && (pointList.get(i - 1).getY() == height - 1
  314. && pointList.get(i).getY() == height - 1)) {
  315. pointList.add(i, new Point((int) (x + dist), (int) height - 1));
  316. pointList.add(i, new Point((int) (x + dist), 0));
  317. pointList.add(i, new Point((int) (x - dist), 0));
  318. pointList.add(i, new Point((int) (x - dist), (int) height - 1));
  319. added = true;
  320. } else if (y >= height / 2 && (pointList.get(i - 1).getY() != height - 1
  321. || pointList.get(i).getY() != height - 1)) {
  322. pointList.add(i, new Point((int) (x + dist), 0));
  323. pointList.add(i, new Point((int) (x + dist), (int) height - 1));
  324. pointList.add(i, new Point((int) (x - dist), (int) height - 1));
  325. pointList.add(i, new Point((int) (x - dist), 0));
  326. added = true;
  327. }
  328. }
  329. }
  330. }
  331. repaint();
  332. }
  333. // TODO Siwtch pressed zeugs hier hin
  334. }
  335. @Override
  336. public void mouseReleased(MouseEvent e) {
  337. if (pointDrag) {
  338. pointDrag = false;
  339. tempP = null;
  340. }
  341. }
  342. public void componentResized(ComponentEvent e) {
  343. // Wenn ein anderes Element genommen wird
  344. if (init) {
  345. init = false;
  346. // for scale on the first initialisation
  347. if (width == -1 && height == -1) {
  348. width = this.getWidth();
  349. height = this.getHeight();
  350. }
  351. scaleX = this.getWidth() / width;
  352. scaleY = this.getHeight() / height;
  353. }
  354. // Scale
  355. scaleX = this.getWidth() / width;
  356. scaleY = this.getHeight() / height;
  357. repaint();
  358. }
  359. @Override
  360. public void componentHidden(ComponentEvent e) {
  361. }
  362. @Override
  363. public void componentMoved(ComponentEvent e) {
  364. }
  365. @Override
  366. public void componentShown(ComponentEvent e) {
  367. }
  368. /*
  369. * Emptys the Graph
  370. */
  371. public void empty() {
  372. pointList = null;
  373. tempElement = null;
  374. tempSwitch = null;
  375. arrayOfFloats = null;
  376. arrayOfBooleans = null;
  377. isSwitch = false;
  378. isElement = false;
  379. repaint();
  380. }
  381. /*
  382. * Resets the Points for the Element
  383. */
  384. public void reset() {
  385. pointList.removeAll(pointList);
  386. pointList.addFirst(new Point(0, 0));
  387. pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
  388. repaint();
  389. }
  390. /**
  391. * converts the number to fit the canvas
  392. *
  393. * @param double
  394. * d, the number to convert
  395. * @return the converted number
  396. */
  397. public double convertToCanvasY(float d) {
  398. return (height - (d * (height / MAXIMUM)));
  399. }
  400. /**
  401. * converts the number to fit the value
  402. *
  403. * @param double
  404. * d, the number to convert
  405. * @return the converted number
  406. */
  407. public float convertToValueY(double d) {
  408. return (float) Math.round(((height - (height * (d / height))) / (height / MAXIMUM)) * 10) / 10;
  409. }
  410. /**
  411. * Visualize the HolonElement on the Graph
  412. *
  413. * @param HolonElement
  414. * ele, which should be visualized
  415. */
  416. public void repaintWithNewElement(HolonElement ele) {
  417. arrayOfFloats = ele.getEnergyAt();
  418. tempElement = ele;
  419. pointList = ele.getGraphPoints();
  420. isSwitch = false;
  421. isElement = true;
  422. MAXIMUM = tempElement.getEnergy();
  423. // First time clicked on the Element
  424. if (pointList.isEmpty()) {
  425. pointList.addFirst(new Point(0, 0));
  426. pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
  427. }
  428. repaint();
  429. }
  430. /**
  431. * Visualize the HolonElement on the Graph
  432. *
  433. * @param HolonElement
  434. * ele, which should be visualized
  435. */
  436. public void repaintWithNewSwitch(HolonSwitch s) {
  437. arrayOfBooleans = s.getActiveAt();
  438. tempSwitch = s;
  439. pointList = s.getGraphPoints();
  440. isSwitch = true;
  441. isElement = false;
  442. // First time clicked on the Element
  443. if (pointList.isEmpty()) {
  444. pointList.addFirst(new Point(0, 0));
  445. pointList.addLast(new Point((int) (width), 0));
  446. }
  447. repaint();
  448. }
  449. /**
  450. * Build a Curve for the Graph
  451. *
  452. * @param Point,Point
  453. * ,startpoint p1 and endpoint p2
  454. *
  455. * @return CubicCurve2D, c, the CubicCurve2D for the Graph
  456. */
  457. public CubicCurve2D buildCurve(Point p1, Point p2) {
  458. x1 = (int) p1.getX();
  459. y1 = (int) p1.getY();
  460. x2 = (int) p2.getX();
  461. y2 = (int) p2.getY();
  462. // calculate the controllpoints
  463. ctrlx1 = (int) p1.getX() + ((int) p2.getX() - (int) p1.getX()) / 2;
  464. ctrlx2 = (int) p2.getX() - ((int) p2.getX() - (int) p1.getX()) / 2;
  465. if (y1 < y2) {
  466. ctrly1 = (int) p1.getY() + ((int) p2.getY() - (int) p1.getY()) / 10;
  467. ctrly2 = (int) p2.getY() - ((int) p2.getY() - (int) p1.getY()) / 10;
  468. } else {
  469. ctrly1 = (int) p1.getY() - ((int) p1.getY() - (int) p2.getY()) / 10;
  470. ctrly2 = (int) p2.getY() + ((int) p1.getY() - (int) p2.getY()) / 10;
  471. }
  472. // set the curve
  473. c.setCurve(x1 * scaleX, y1 * scaleY, ctrlx1 * scaleX, ctrly1 * scaleY, ctrlx2 * scaleX, ctrly2 * scaleY,
  474. x2 * scaleX, y2 * scaleY);
  475. return c;
  476. }
  477. /**
  478. * Fills the Arrays with booleans
  479. */
  480. public void fillArrayofBooleans() {
  481. for (int i = 0; i < arrayOfBooleans.length; i++) {
  482. int t = (int) getYValueAt_2((int) (i * width / (model.getIterations() - 1)));
  483. if (t == 0) {
  484. arrayOfBooleans[i] = true;
  485. } else {
  486. arrayOfBooleans[i] = false;
  487. }
  488. }
  489. }
  490. /**
  491. * Fills the Arrays of each HolonElement
  492. */
  493. public void fillArrayofValue() {
  494. for (int i = 0; i < arrayOfFloats.length; i++) {
  495. arrayOfFloats[i] = convertToValueY(getYValueAt_2((int) (i * width / (model.getIterations() - 1))));
  496. }
  497. }
  498. /**
  499. *
  500. * @param xVal,
  501. * the x value for the y value
  502. * @return y, the value at x
  503. */
  504. public float getYValueAt(int xVal) {
  505. for (int i = 0; i < pointList.size() - 1; i++) {
  506. // get the Points
  507. if (xVal <= pointList.get(i + 1).getX()) {
  508. // Curve erstellen
  509. Line2D l1 = new Line2D.Double(pointList.get(i).getX(), pointList.get(i).getY(),
  510. pointList.get(i + 1).getX(), pointList.get(i + 1).getY());
  511. Line2D l2 = new Line2D.Double(xVal, 0, xVal, height);
  512. return getIntersectionPoint(l1, l2);
  513. }
  514. }
  515. return 0;
  516. }
  517. /**
  518. *
  519. * @param xVal,
  520. * the x value for the y value
  521. * @return y, the value at x
  522. */
  523. public float getYValueAt_2(int xVal) {
  524. for (int i = 0; i < pointList.size() - 1; i++) {
  525. // get the Points
  526. if (xVal >= pointList.get(i).getX()) {
  527. // Curve erstellen
  528. c = buildCurve(pointList.get(i), pointList.get(i + 1));
  529. c.subdivide(cl, cr);
  530. // Teil der Kurve aussuchen
  531. if (cl.getX1() <= xVal * scaleX && cl.getX2() > xVal * scaleX) {
  532. c = cl;
  533. // Kurve Links von "unten"
  534. if (pointList.get(i).getY() >= pointList.get(i + 1).getY()) {
  535. for (float j = (float) (height - 1); j >= 0; j -= 0.1f) {
  536. if (c.contains(xVal * scaleX, j * scaleY)) {
  537. return (float) (j);
  538. }
  539. }
  540. } else {// Kurve Links von "oben"
  541. for (float j = 0; j < height; j += 0.1f) {
  542. if (c.contains(xVal * scaleX, j * scaleY)) {
  543. return (float) (j);
  544. }
  545. }
  546. }
  547. } else {
  548. c = cr;
  549. // Kurve Links von "unten"
  550. if (pointList.get(i).getY() >= pointList.get(i + 1).getY()) {
  551. for (float j = 0; j < height; j += 0.1f) {
  552. if (c.contains(xVal * scaleX, j * scaleY)) {
  553. return (float) (j);
  554. }
  555. }
  556. } else {// Kurve Links von "oben"
  557. for (float j = (float) (height - 1); j >= 0; j -= 0.1f) {
  558. if (c.contains(xVal * scaleX, j * scaleY)) {
  559. return (float) (j);
  560. }
  561. }
  562. }
  563. }
  564. }
  565. }
  566. return getYValueAt(xVal);
  567. }
  568. /**
  569. *
  570. * @param l1,
  571. * the first Line
  572. * @param l2,
  573. * the second Line
  574. *
  575. * @return The Intersection Point
  576. */
  577. public float getIntersectionPoint(Line2D l1, Line2D l2) {
  578. if (!l1.intersectsLine(l2)) {
  579. return 0;// null;
  580. }
  581. double px = l1.getX1(), py = l1.getY1(), rx = l1.getX2() - px, ry = l1.getY2() - py;
  582. double qx = l2.getX1(), qy = l2.getY1(), sx = l2.getX2() - qx, sy = l2.getY2() - qy;
  583. double det = sx * ry - sy * rx;
  584. if (det == 0) {
  585. return 0;// null;
  586. } else {
  587. double z = (sx * (qy - py) + sy * (px - qx)) / det;
  588. if (z < 0 || z > 1) {
  589. return 0;// new Point(0, 0); // intersection at end point!
  590. }
  591. return (float) (py + z * ry);// new Point((int) (px + z * rx), (int)
  592. // (py + z * ry));
  593. }
  594. } // end intersection line-line
  595. }