This class has been inspired by the java.awt.Point class.
@author Julien Waechter @author Emil Ivov
209210211212213214215216217218219220221
{ String s = "<text id=\"#i\" x=\"#x\" y=\"#y\" " + "fill=\"#fi\" font-family=\"#ff\" font-size=\"#fs\">#t</text>"; s = s.replaceAll ("#i", getID ()); s = s.replaceAll ("#fi", colorToHex (getColor ())); WhiteboardPoint p = getWhiteboardPoint (); s = s.replaceAll ("#x", "" + p.getX ()); s = s.replaceAll ("#y", "" + p.getY ()); s = s.replaceAll ("#ff", getFontName ()); s = s.replaceAll ("#fs", "" + getFontSize ()); s = s.replaceAll ("#t", getText ()); return s; }
222223224225226227228229230231232233234235236237238239
GeneralPath polygon = new GeneralPath ( GeneralPath.WIND_EVEN_ODD, points.size ()); if(points.size ()<=0) return polygon; WhiteboardPoint start = points.get (0); polygon.moveTo ((float) start.getX (), (float) start.getY ()); WhiteboardPoint p; for (int i =0; i<points.size ();i++) { p = points.get (i); polygon.lineTo ((float) p.getX (), (float) p.getY ()); } polygon.closePath (); return polygon; }
267268269270271272273274275276277278279280
* @param deltaX x coord * @param deltaY y coord */ public void translate (double deltaX, double deltaY) { WhiteboardPoint point ; for (int i =0; i<points.size ();i++) { point = points.get (i); points.set (i, new WhiteboardPoint (point.getX () + deltaX, point.getY () + deltaY)); } }
288289290291292293294295296297298299300301302303304305
public void translateSelectedPoint (double deltaX, double deltaY) { if (getModifyPoint() == null) return; WhiteboardPoint point; for (int i = 0; i < points.size (); i++) { point = points.get (i); if(getModifyPoint().equals(point)) { WhiteboardPoint newPoint = new WhiteboardPoint ( point.getX () + deltaX, point.getY () + deltaY); points.set (i, newPoint);
314315316317318319320321322323324325326327328329330
* @param p point * @return nearest selection point */ public WhiteboardPoint getSelectionPoint (Point2D p) { WhiteboardPoint point; for (int i = 0; i< points.size ();i++) { point = points.get (i); if(( new Point2D.Double ( point.getX (), point.getY ())).distance (p) < 18) { return point; } } return null;
78798081828384858687888990919293
{ super (id); ArrayList<WhiteboardPoint> pointsList = new ArrayList<WhiteboardPoint>(); WhiteboardPoint p; for (int i = 0; i<m_points.size ();i++) { p = m_points.get (i); Point2D w = at.transform ( new Point2D.Double (p.getX (), p.getY ()), null); pointsList.add (new WhiteboardPoint (w.getX (), w.getY ())); } this.initShape(thickness, color, pointsList, fill); }
161162163164165166167168169170171172173
* @return list of selected WhiteboardPoints */ public List<WhiteboardPoint> getSelectionPoints () { List<WhiteboardPoint> list = new ArrayList<WhiteboardPoint>(); WhiteboardPoint p; for(int i =0; i< points.size (); i++) { p = points.get (i); list.add (new WhiteboardPoint (p.getX (), p.getY ())); } return list; }
194195196197198199200201202203204205206207208209210211212
{ GeneralPath polyline = new GeneralPath ( GeneralPath.WIND_EVEN_ODD, points.size ()); if(points.size ()<=0) return polyline; WhiteboardPoint start = points.get (0); Point2D w = new Point2D.Double (start.getX (), start.getY ()); Point2D v = w2v.transform (w, null); polyline.moveTo ((int) v.getX (), (int) v.getY ()); WhiteboardPoint p; for (int i =0; i<points.size ();i++) { p = points.get (i); w = new Point2D.Double (p.getX (), p.getY ()); v = w2v.transform (w, null); polyline.lineTo ((int) v.getX (), (int) v.getY ()); } return polyline;
222223224225226227228229230231232233234235236237238
{ GeneralPath polyline = new GeneralPath ( GeneralPath.WIND_EVEN_ODD, points.size ()); if(points.size ()<=0) return polyline; WhiteboardPoint start = points.get (0); polyline.moveTo ((float) start.getX (), (float) start.getY ()); WhiteboardPoint p; for (int i =0; i<points.size ();i++) { p = points.get (i); polyline.lineTo ((float) p.getX (), (float) p.getY ()); } return polyline; }
266267268269270271272273274275276277278279
* @param deltaX x coord * @param deltaY y coord */ public void translate (double deltaX, double deltaY) { WhiteboardPoint point ; for (int i =0; i<points.size ();i++) { point = points.get (i); points.set (i, new WhiteboardPoint(point.getX () + deltaX, point.getY () + deltaY)); } }