X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.editor%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Feditor%2Fhandles%2FHandle.java;h=cbfe2a2aa31d0e9193dd47d53363666dd5144355;hb=148a58630b38b30d4d24a21e3f55c357f5b4d0bc;hp=454f42141db77d120f07b928a23def9d7804d4f1;hpb=a393b0a2a9899707af54c9ee77a01f28ac967bd1;p=Mograsim.git diff --git a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/Handle.java b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/Handle.java index 454f4214..cbfe2a2a 100644 --- a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/Handle.java +++ b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/Handle.java @@ -14,9 +14,11 @@ public abstract class Handle { private final Rectangle bounds; private final Collection redrawListeners, destroyListeners; - - public Handle() + private final int priority; + + public Handle(int priority) { + this.priority = priority; redrawListeners = new ArrayList<>(); destroyListeners = new ArrayList<>(); bounds = new Rectangle(0, 0, 0, 0); @@ -44,7 +46,7 @@ public abstract class Handle bounds.y = y; callRedrawListeners(); } - + public Rectangle getBounds() { return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); @@ -89,26 +91,27 @@ public abstract class Handle { redrawListeners.remove(listener); } - + public boolean contains(double x, double y) { return bounds.contains(x, y); } - + public boolean contains(Point p) { return contains(p.x, p.y); } - + /** * Register a mouse click + * * @param x Coordinate of the click in the world, not the display context * @param y Coordinate of the click in the world, not the display context * @return true if the click was consumed, false otherwise */ public boolean click(double x, double y, int stateMask, EditorState state) { - if(contains(x, y)) + if (contains(x, y)) return state.clickedHandle(new HandleClickInfo(this, stateMask)); return false; } @@ -120,23 +123,28 @@ public abstract class Handle public void onSelect() {} public void onDeselect() {} //@formatter:on - - public abstract HandleType getType(); - - public static enum HandleType - { - COMPONENT, STATIC_PIN, INTERFACE_PIN, WIRE_POINT, WIRE, CORNER; - } - - public static class HandleClickInfo - { - public final int stateMask; - public final Handle clicked; - - HandleClickInfo(Handle clicked, int stateMask) - { - this.clicked = clicked; - this.stateMask = stateMask; - } - } + + public final int getPriority() + { + return priority; + } + + public abstract HandleType getType(); + + public static enum HandleType + { + COMPONENT, STATIC_PIN, INTERFACE_PIN, WIRE_POINT, WIRE, CORNER; + } + + public static class HandleClickInfo + { + public final int stateMask; + public final Handle clicked; + + HandleClickInfo(Handle clicked, int stateMask) + { + this.clicked = clicked; + this.stateMask = stateMask; + } + } }