Newer
Older
AnchorGarden_M / src / main / java / jaist / css / covis / PPPath.java
@Motoki Miura Motoki Miura on 21 Jun 2022 2 KB reset path
package jaist.css.covis;

import java.awt.Shape;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Stroke;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Ellipse2D;

import org.piccolo2d.nodes.PPath;

/**
 * 以前のPiccolo PPathとの互換性をとるためのクラス
 */
public class PPPath extends PPath.Double {
    private static final Rectangle2D.Float TEMP_RECTANGLE = new Rectangle2D.Float();
    private static final Ellipse2D.Float TEMP_ELLIPSE = new Ellipse2D.Float();
    private static final BasicStroke DEFAULT_STROKE = new BasicStroke(1.0f);
	private static final Color DEFAULT_STROKE_PAINT = Color.black;
    private transient Stroke stroke;
    public PPPath(){
        super(new Path2D.Float());
        // setStrokePaint(DEFAULT_STROKE_PAINT);
        // setStroke(DEFAULT_STROKE);
        setPaint(null);
    }
    public PPPath(Shape aShape) {
		this(aShape, DEFAULT_STROKE);
	}
    public PPPath(Shape aShape, Stroke aStroke) {
		this();
		stroke = aStroke;
		if (aShape != null) append(aShape, false);
	}
    public void setPathTo(final Shape aShape) {
        this.getPathReference().reset();
        append(aShape, false);
    }
    public void setPathToRectangle(float x, float y, float width, float height){
        TEMP_RECTANGLE.setFrame(x, y, width, height);
		setPathTo(TEMP_RECTANGLE);
    }
    public void setPathToEllipse(float x, float y, float width, float height) {
		TEMP_ELLIPSE.setFrame(x, y, width, height);
		setPathTo(TEMP_ELLIPSE);
	}
    /**
	 * Return a reference to the list used to manage this node's
	 * children. This list should not be modified.
	 * 
	 * @return reference to the children list
	 */
	// public List<PNode> getChildrenReference() {
	// 	if (children == null) {
	// 		children = new ArrayList<PNode>();
	// 	}
	// 	return children;
	// }
    // public PInterpolatingActivity animateToStrokeColor(final Color destColor, final long duration) {
    //     return super.animateToColor(destColor, duration);
        
    // }
}