88 lines
1.8 KiB
Java
88 lines
1.8 KiB
Java
package edu.gatech.cs2335.lemmings.gui;
|
|
|
|
import java.awt.Point;
|
|
import java.awt.Rectangle;
|
|
import java.awt.Graphics;
|
|
|
|
/**
|
|
* Class LLeafComponent: This is the opposite of a container. That is,
|
|
* there can be no children for this component.
|
|
*
|
|
* <PRE>
|
|
* Revision History:
|
|
* v1.0 (Mar. 13, 2004) - Created the LLeafComponent class
|
|
* </PRE>
|
|
*
|
|
* @author <A HREF="mailto:gtg308i@mail.gatech.edu">Vladimir Urazov</A>
|
|
* @version Version 1.0, Mar. 13, 2004
|
|
*/
|
|
public abstract class LLeafComponent extends LComponent {
|
|
|
|
/**
|
|
* Creates a new <code>LLeafComponent</code> instance.
|
|
*/
|
|
public LLeafComponent() {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* Moves the component by the offsets specified by the components of
|
|
* the point.
|
|
*
|
|
* @param offset a <code>Point</code> value
|
|
*/
|
|
public final void move(Point offset) {
|
|
Rectangle r = getBounds();
|
|
|
|
r.x += offset.x;
|
|
r.y += offset.y;
|
|
|
|
/*
|
|
Point p = new Point(getBounds().x, getBounds().y);
|
|
|
|
p.x += offset.x;
|
|
p.y += offset.y;
|
|
|
|
this.setPosition(p);
|
|
*/
|
|
}
|
|
|
|
/**
|
|
* Marks the component dirty.
|
|
*/
|
|
public final void makeDirty() {
|
|
setDirty(true);
|
|
}
|
|
|
|
/**
|
|
* Calls paint on self and then all the children in z order.
|
|
*
|
|
* @param g a <code>Graphics</code> value
|
|
* @return a <code>boolean</code> value
|
|
*/
|
|
public final boolean renderAll(Graphics g) {
|
|
if (!isShown()) {
|
|
//I am invisible. No go.
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
if (!this.isComponentDirty()) {
|
|
//Not dirtty. No need to rerender:
|
|
return true;
|
|
}
|
|
*/
|
|
|
|
this.setDirty(false);
|
|
|
|
//Paint self:
|
|
if (!this.paint(g)) {
|
|
//Could not paint self:
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|