package gve.calc.formula;

import java.awt.*;

public abstract class UnaryOp extends Operator {
	public Part child;
	public int getDownPri() { return getPri(); }

	public UnaryOp() {}

	public UnaryOp(Part ch) {
		child = ch;
		ch.parent = this;
	}

	abstract public UnaryOp getInstance(Part ch);

	public Object clone() {
		return getInstance((Part)child.clone());
	}

	public abstract boolean simpleRotate(Formula f,FormulaView view);

	public boolean simpleRotate(Formula f) {
		return simpleRotate(f,null);
	}

	
If this Part is badly positioned in the syntax tree, rotate. Else do nothing.
public void rotate(Formula f) { rotate(f,null); } public void rotate(Formula f,FormulaView view) { while (simpleRotate(f,view)) ; } public void replaceChild(Part child,Part byThat) { if (child == this.child) this.child = byThat; this.child.parent = this; } public void write(java.io.Writer w) throws java.io.IOException { super.write(w); child.write(w); } public Part getChild(int count) { return count==0 ? child : null; } public Part getChild() { return child; } }