/src/gosu/DrawOp.java
http://jgosu.googlecode.com/ · Java · 41 lines · 27 code · 10 blank · 4 comment · 1 complexity · 02ee95618c987c252981f1b142ac94d8 MD5 · raw file
- package gosu;
- public abstract class DrawOp implements Comparable {
- // Gosu assumes that the drawOps will be ordered by the
- // z value first and secondly by the drawing order.
- // Since Java's PriorityQueue throws insertion order to the
- // wind, I have this counter hack to keep track of it.
- private static long counter = 0;
- protected int _clipX;
- protected int _clipY;
- protected int _clipWidth;
- protected int _clipHeight;
- private boolean _clipped;
- private long _id;
- public DrawOp() {
- _id = counter++;
- }
- public abstract double getZ();
- public abstract void execute();
-
- public int compareTo(Object o) {
- int result = Double.valueOf(getZ()).compareTo(((DrawOp) o).getZ());
- return (result != 0) ? result : Long.valueOf(_id).compareTo(((DrawOp) o)._id);
- }
- void clip(int x, int y, int width, int height) {
- _clipped = true;
- _clipX = x;
- _clipY = y;
- _clipWidth = width;
- _clipHeight = height;
- }
- boolean isClipped() { return _clipped; }
- }