public void draw(Graphics g,Shape s){
  if (decorations.isEmpty())   return;
  PathIterator pi=s.getPathIterator(null,FLATNESS);
  int segType;
  double[] segCoords=new double[6];
  LinkedList<Point2D> points=new LinkedList<Point2D>();
  Point2D firstPoint=null;
  Point2D point;
  do {
    segType=pi.currentSegment(segCoords);
    point=new Point2D.Double(segCoords[0],segCoords[1]);
switch (segType) {
case PathIterator.SEG_MOVETO:
      if (firstPoint == null)       firstPoint=point;
    if (!points.isEmpty()) {
      draw(g,points);
    }
  points.clear();
points.add(point);
break;
case PathIterator.SEG_LINETO:
points.add(point);
break;
case PathIterator.SEG_CLOSE:
points.add(firstPoint);
break;
}
pi.next();
}
 while (!pi.isDone());
if (!points.isEmpty()) {
draw(g,points);
}
}

public void draw ( Graphics g , Shape s ) { if ( decorations . isEmpty ( ) ) return ; PathIterator pi = s . getPathIterator ( null , FLATNESS ) ; int segType ; double [ ] segCoords = new double [ 6 ] ; LinkedList < Point2D > points = new LinkedList < Point2D > ( ) ; Point2D firstPoint = null ; Point2D point ; do { segType = pi . currentSegment ( segCoords ) ; point = new Point2D . Double ( segCoords [ 0 ] , segCoords [ 1 ] ) ; switch ( segType ) { case PathIterator . SEG_MOVETO : if ( firstPoint == null ) firstPoint = point ; if ( ! points . isEmpty ( ) ) { draw ( g , points ) ; } points . clear ( ) ; points . add ( point ) ; break ; case PathIterator . SEG_LINETO : points . add ( point ) ; break ; case PathIterator . SEG_CLOSE : points . add ( firstPoint ) ; break ; } pi . next ( ) ; } while ( ! pi . isDone ( ) ) ; if ( ! points . isEmpty ( ) ) { draw ( g , points ) ; } }
draws a decorated shape
