package ckelling.baukasten;


// Versionsgeschichte
// 0.9.0, 26.07.97
// 0.9.1, 01.08.97
/**
 * Wrapper für RechnerKomponente und RechnerKomponentePanel.
 * Jede Instanz von Editor_Source beherbergt in ihrem Inneren
 * eine Instanz von RK oder RKP und reicht Methodenaufrufe an diese
 * weiter.
 *
 * @author   Carsten Kelling
 * @version  0.9.1, 01.08.97
 */
public class Editor_Source
{
	private RechnerKomponente		rk;
	private RechnerKomponentePanel	rkp;


	public Editor_Source(Editor_Source source)
	{
		this.rk = source.getRK();
		this.rkp = source.getRKP();
	}

	public Editor_Source(RechnerKomponente rk)
	{
		if (rk != null)
		{
			this.rk = rk;
			rkp = null;
		}
		else
		{
			Rechner.out("FEHLER in Editor_Source: RechnerKomponente ist null.");
		}
	}

	public Editor_Source(RechnerKomponentePanel rkp)
	{
		if (rkp != null)
		{
			rk = null;
			this.rkp = rkp;
		}
		else
		{
			Rechner.out("FEHLER in Editor_Source: RechnerKomponentePanel ist null.");
		}
	}


	public RechnerKomponente getRK()
	{
		return rk;
	}

	public RechnerKomponentePanel getRKP()
	{
		return rkp;
	}

	public synchronized void paint(java.awt.Graphics onScreenGC)
	{
		if (rk == null)
			rkp.paint(onScreenGC);
		else
			rk.paint(onScreenGC);
	}

	public synchronized void paintActivated(java.awt.Graphics onScreenGC)
	{
		if (rk == null)
			rkp.paintActivated(onScreenGC);
		else
			rk.paintActivated(onScreenGC);
	}


	public java.awt.Point getCoordinates(String qualifier)
	{
		if (rk == null)
			return rkp.getCoordinates(qualifier);
		else
			return rk.getCoordinates(qualifier);
	}


	public boolean equals(RechnerKomponente toBeCompared)
	{
		if (rk == null)
			return false;
		else
			return rk.equals(toBeCompared);
	}
	public boolean equals(RechnerKomponentePanel toBeCompared)
	{
		if (rkp == null)
			return false;
		else
			return rkp.equals(toBeCompared);
	}
	public boolean equals(Editor_Source toBeCompared)
	{
		if (rk == null)
			return rkp.equals(toBeCompared.getRKP());
		else
			return rk.equals(toBeCompared.getRK());
	}


	public void reshape(int x, int y, int width, int height)
	{
		if (rk == null)
			rkp.reshape(x, y, width, height);
		else
			rk.reshape(x, y, width, height);
	}

	public void reshape(int x, int y, int width, int height, String grabMode)
	{
		if (rk == null)
			rkp.reshape(x, y, width, height, grabMode);
		else
			rk.reshape(x, y, width, height, grabMode);
	}


	public String[] getPossibleQualifiers()
	{
		if (rk == null)
			return rkp.getPossibleQualifiers();
		else
			return rk.getPossibleQualifiers();
	}


	public String[] getLabel()
	{
		if (rk == null)
		{
			String[] strArray = {rkp.getLabel()};
			return strArray;
		}
		else
			return rk.getLabel();
	}

	public void setLabel(String[] newLabel)
	{
		if (rk == null)
			rkp.setLabel(newLabel[0]);
		else
			rk.setLabel(newLabel);
	}

	public void setLabel(String newLabel)
	{
		if (rk == null)
			rkp.setLabel(newLabel);
		else
			rk.setLabel(newLabel);
	}


	public void setCoordinates(int x, int y, String grabMode)
	{
		if (rk == null)
			rkp.setCoordinates(x, y, grabMode);
		else
			rk.setCoordinates(x, y, grabMode);
	}

	public boolean intersectsWith(java.awt.Point p)
	{
		if (rk == null)
			return rkp.intersectsWith(p);
		else
			return rk.intersectsWith(p);
	}

	public String getInfoTipText(java.awt.Point p)
	{
		if (rk == null)
			return rkp.getInfoTipText(p);
		else
			return rk.getInfoTipText(p);
	}


	public void setValue(int newValue)
	{
		if (rk == null)
			rkp.setValue(newValue);
		else
			rk.setValue(newValue);
	}

	public int getValue()
	{
		if (rk == null)
			return rkp.getValue();
		else
			return rk.getValue();
	}

	public long getMaxValue()
	{
		if (rk == null)
			return rkp.getMaxValue();
		else
			return rk.getMaxValue();
	}

	public synchronized void activate()
	{
		if (rk == null)
			rkp.activate();
		else
			rk.activate();
	}

	public synchronized void deactivate()
	{
		if (rk == null)
			rkp.deactivate();
		else
			rk.deactivate();
	}

	public boolean isActivated()
	{
		if (rk == null)
			return rkp.isActivated();
		else
			return rk.isActivated();
	}

	public void lock()
	{
		if (rk == null)
			rkp.lock();
		else
			rk.lock();
	}

	public void unlock()
	{
		if (rk == null)
			rkp.unlock();
		else
			rk.unlock();
	}

}
