Ejemplo n.º 1
0
 void drawScribbles(Graphics g) {
   if ((scribbles == null) || (scribbles.size() == 0)) {
     return;
   }
   DrawObject L = (DrawObject) scribbles.get(0);
   int scribbleCounter = L.scribbleNum;
   g.setColor(scribbleColor);
   ((Graphics2D) g).setStroke(new BasicStroke(2f));
   int prevX = L.scribbleX;
   int prevY = L.scribbleY;
   for (int i = 1; i < scribbles.size(); i++) {
     L = (DrawObject) scribbles.get(i);
     if (L.scribbleNum == scribbleCounter) {
       // Keep drawing.
       g.drawLine(prevX, prevY, L.scribbleX, L.scribbleY);
       prevX = L.scribbleX;
       prevY = L.scribbleY;
     } else {
       scribbleCounter = L.scribbleNum;
       prevX = L.scribbleX;
       prevY = L.scribbleY;
     }
   }
 }
Ejemplo n.º 2
0
  /**
   * parses the segment string and initializes this segment properties
   *
   * @param segmentString the string representation of a segment
   */
  protected void parseString(String segmentString) {

    segmentString = segmentString.trim();

    // whether the command is a relative one
    boolean isRelative = isRelativeCommand(segmentString);

    // getting the list of the points corresponding to the segment string
    java.util.List<Point2D> pointsList =
        getPoints(segmentString.substring(1, segmentString.length()));

    if (pointsList.size() > 0) {

      point = pointsList.get(0);

      // if the segment is relative, it is transformed into an absolute one
      if (isRelative && previousSegment != null) {

        point = computeAbsolute(point, previousSegment.getEndPoint());
      }
    }
  }