LineTo.java 867 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.mxgraph.io.vsdx.geometry;
  2. import com.mxgraph.io.vsdx.Shape;
  3. import com.mxgraph.io.vsdx.mxVsdxUtils;
  4. import com.mxgraph.util.mxPoint;
  5. public class LineTo extends Row
  6. {
  7. public LineTo(int index, Double x, Double y)
  8. {
  9. super(index, x, y);
  10. }
  11. @Override
  12. public String handle(mxPoint p, Shape shape)
  13. {
  14. double x = p.getX(), y = p.getY();
  15. double h = shape.getHeight();
  16. double w = shape.getWidth();
  17. if (this.x != null && this.y != null)
  18. {
  19. x = this.x * mxVsdxUtils.conversionFactor;
  20. y = this.y * mxVsdxUtils.conversionFactor;
  21. }
  22. x = x * 100.0 / w;
  23. y = y * 100.0 / h;
  24. y = 100 - y;
  25. x = Math.round(x * 100.0) / 100.0;
  26. y = Math.round(y * 100.0) / 100.0;
  27. p.setX(x);
  28. p.setY(y);
  29. shape.setLastX(x);
  30. shape.setLastY(y);
  31. return "<" + "line" + " x=\"" + String.valueOf(x) + "\" y=\"" + String.valueOf(y) + "\"/>";
  32. }
  33. }