@@ -0,0 +1,2766 @@
+package com.vzome.core.editor;%0A%0A/**%0A *%0A * @author David Hall%0A */%0Apublic class ToolBehavior %7B%0A%09// These masks are copied from ActionEvent, so ActionEvent.getModifiers() can be directly passed to the c'tor.%0A%09// This allows a compile-time dependency on ActionEvent to be avoided.%0A%09public static final int SHIFT_MASK = 1;%0A%09public static final int CTRL_MASK = 2;%0A%09public static final int META_MASK = 4;%0A%09public static final int ALT_MASK = 8;%0A%0A%09// Assign standard generic meanings to given masks%0A%09// Input behaviors%0A%09public static final int selectInputs_MASK = SHIFT_MASK;%0A    public static final int hideInputs_MASK = CTRL_MASK;%0A%09// Output behaviors%0A    public static final int deselectOutputs_MASK = ALT_MASK;%0A    public static final int justSelectExistingOutputs_MASK = META_MASK;%0A%0A%09// Derived classes could add new behavior suggestions based on additional bitwise masks.%0A%09// The masks could potentially even be unrelated to ActionEvent. %0A%09// Maybe use checkboxes or other UI features to control additional mask bits.%0A%09%0A%09private final int modifierFlags;%0A%09%0A%09// This c'tor is just to used as an initializer for a ToolBehavior variable so it won't be null.%0A%09// There is intentionally no method to change the modifiers after the c'tor. %0A%09// If this is needed, then replace the whole ToolBehavior object. (they're cheap)%0A%09public ToolBehavior()%0A    %7B%0A%09%09this(0);%0A%09%7D%0A%09%0A%09public ToolBehavior( int modifiers  )%0A    %7B%0A%09%09modifierFlags = modifiers;%0A%09%7D%0A%09%0A%09protected final boolean hasAllMaskBitsSet(int mask) %7B%0A%09%09// be sure this works on multi-bit flage%0A%09%09return ( modifierFlags & mask ) == mask; %0A%09%7D%0A%09%09%0A%09protected final boolean hasAnyMaskBitsSet(int mask) %7B%0A%09%09return ( modifierFlags & mask ) != 0; %0A%09%7D%0A%09%09%0A%09// These methods provide a common generic meaning to each of the associated keyboard modifier keys.%0A%09// They are based on the meanings of each mask as implemented in ApplyTool before this class was implemented.%0A%09// The meanings are only suggestions. Actual behavior is implementation dependent.%0A%09public boolean selectInputs()%09%09%7B return hasAllMaskBitsSet( selectInputs_MASK ); %7D%0A    public boolean hideInputs()%09%09%09%7B return hasAllMaskBitsSet( hideInputs_MASK ); %7D%0A    public boolean deselectOutputs()%09%7B return hasAllMaskBitsSet( deselectOutputs_MASK ); %7D%0A    public boolean justSelectExisting()%09%7B return hasAllMaskBitsSet(justSelectExistingOutputs_MASK ); %7D%0A%09%0A%09// convenience methods%0A%09public boolean hasAnyModifiers()%09%09%7B return ( modifierFlags != 0 ); %7D%0A%09public boolean hasAnyInputModifiers()%09%7B return hasAnyMaskBitsSet( selectInputs_MASK %7C hideInputs_MASK ); %7D%0A%09public boolean hasAnyOutputModifiers()%09%7B return hasAnyMaskBitsSet( deselectOutputs_MASK %7C justSelectExistingOutputs_MASK ); %7D%0A%0A%09// allows serialization%0A%09public Integer getModifiers() %7B %0A%09%09return modifierFlags; %0A%09%7D%0A%09%0A%7D%0A

Add new ToolBehavior class.