Пример #1
0
 /**
  * Transforms the figure.
  *
  * @param tx the transformation.
  */
 public void transform(AffineTransform tx) {
   if (TRANSFORM.get(this) != null
       || tx.getType() != (tx.getType() & AffineTransform.TYPE_TRANSLATION)) {
     if (TRANSFORM.get(this) == null) {
       TRANSFORM.basicSet(this, (AffineTransform) tx.clone());
     } else {
       AffineTransform t = TRANSFORM.getClone(this);
       t.preConcatenate(tx);
       TRANSFORM.basicSet(this, t);
     }
   } else {
     for (int i = 0; i < coordinates.length; i++) {
       tx.transform(coordinates[i], coordinates[i]);
     }
     if (FILL_GRADIENT.get(this) != null && !FILL_GRADIENT.get(this).isRelativeToFigureBounds()) {
       Gradient g = FILL_GRADIENT.getClone(this);
       g.transform(tx);
       FILL_GRADIENT.basicSet(this, g);
     }
     if (STROKE_GRADIENT.get(this) != null
         && !STROKE_GRADIENT.get(this).isRelativeToFigureBounds()) {
       Gradient g = STROKE_GRADIENT.getClone(this);
       g.transform(tx);
       STROKE_GRADIENT.basicSet(this, g);
     }
   }
   invalidate();
 }
Пример #2
0
 public void restoreTransformTo(Object geometry) {
   Object[] restoreData = (Object[]) geometry;
   TRANSFORM.basicSetClone(this, (AffineTransform) restoreData[0]);
   Point2D.Double[] restoredCoordinates = (Point2D.Double[]) restoreData[1];
   for (int i = 0; i < this.coordinates.length; i++) {
     coordinates[i] = (Point2D.Double) restoredCoordinates[i].clone();
   }
   FILL_GRADIENT.basicSetClone(this, (Gradient) restoreData[2]);
   STROKE_GRADIENT.basicSetClone(this, (Gradient) restoreData[3]);
   invalidate();
 }
Пример #3
0
 public Object getTransformRestoreData() {
   Point2D.Double[] restoredCoordinates = (Point2D.Double[]) this.coordinates.clone();
   for (int i = 0; i < this.coordinates.length; i++) {
     restoredCoordinates[i] = (Point2D.Double) this.coordinates[i].clone();
   }
   return new Object[] {
     TRANSFORM.getClone(this),
     restoredCoordinates,
     FILL_GRADIENT.getClone(this),
     STROKE_GRADIENT.getClone(this),
   };
 }