public class RMTool<T extends RMShape> extends SwingOwner
Modifier and Type | Class and Description |
---|---|
static class |
RMTool.RMShapeHandle
An inner class describing a shape and a handle.
|
Modifier and Type | Field and Description |
---|---|
static byte |
HandleE |
static byte |
HandleN |
static byte |
HandleNE |
static byte |
HandleNW |
static byte |
HandleS |
static byte |
HandleSE |
static byte |
HandleSW |
static byte |
HandleW |
static byte |
HandleWidth |
static java.lang.String |
SPLIT_RESET |
DragDrop, DragEnter, DragEvents, DragExit, DragOver, KeyEvents, KeyFinished, KeyPressed, KeyReleased, KeyTyped, MouseClicked, MouseDragged, MouseEntered, MouseEvents, MouseExited, MouseFinished, MouseMoved, MousePressed, MouseReleased
Constructor and Description |
---|
RMTool() |
RMTool(com.google.common.eventbus.EventBus ebus) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptsDrag(T aShape,
java.awt.dnd.DropTargetDragEvent anEvent)
Implemented by shapes that can handle drag & drop.
|
void |
activateTool()
Called when a tool is selected.
|
void |
attachEventBus(com.google.common.eventbus.EventBus bus) |
protected javax.swing.JComponent |
createUI()
Create UI.
|
void |
deactivateTool()
Called when a tool is deselected (when another tool is selected).
|
void |
didBecomeSuperSelectedShapeInEditor(RMShape aShape,
RMEditor anEditor)
Editor method - called when an instance of this tool's shape is super selected.
|
void |
dragEnter(RMShape aShape,
java.awt.dnd.DropTargetDragEvent anEvent)
Notifies tool that a something was dragged into of one of its shapes with drag and drop.
|
void |
dragExit(RMShape aShape,
java.awt.dnd.DropTargetDragEvent anEvent)
Notifies tool that a something was dragged out of one of its shapes with drag and drop.
|
void |
dragOver(RMShape aShape,
java.awt.dnd.DropTargetDragEvent anEvent)
Notifies tool that something was dragged over one of its shapes with drag and drop.
|
void |
drop(T aShape,
java.awt.dnd.DropTargetDropEvent anEvent)
Notifies tool that something was dropped on one of its shapes with drag and drop.
|
void |
dropClass(T aShape,
java.awt.dnd.DropTargetDropEvent anEvent) |
void |
dropColor(RMShape aShape,
java.awt.dnd.DropTargetDropEvent anEvent)
Called to handle dropping a color.
|
void |
dropDragKey(T aShape,
java.awt.dnd.DropTargetDropEvent anEvent) |
void |
dropFiles(RMShape aShape,
java.awt.dnd.DropTargetDropEvent anEvent)
Called to handle dropping a file.
|
void |
dropString(T aShape,
java.awt.dnd.DropTargetDropEvent anEvent)
Called to handle dropping a string.
|
static java.awt.datatransfer.DataFlavor |
flavorForClass(java.lang.Class clazz) |
void |
flushChanges(RMEditor anEditor,
RMShape aShape)
Called when a tool is deselected to give an opportunity to finalize changes in progress.
|
boolean |
getAcceptsChildren(RMShape aShape)
Returns whether a given shape accepts children.
|
RMRect |
getBoundsSuperSelected(RMShape aShape)
Returns the bounds of the shape in parent coords when super selected (same as getBoundsMarkedDeep by default).
|
Entity |
getDatasetEntity(RMShape aShape)
Returns the given shape's dataset entity.
|
RMRect |
getDragDisplayBounds(RMShape aShape,
java.awt.dnd.DropTargetDragEvent anEvent)
Returns the bounds to be highlighted for a drag over a given shape.
|
RMEditor |
getEditor()
Returns the currently active editor.
|
RMEditorPane |
getEditorPane()
Returns the currently active editor pane.
|
RMFont |
getFont(RMEditor anEditor,
RMShape shape)
Returns the font for the given shape.
|
RMFont |
getFontDeep(RMEditor anEditor,
RMShape aShape)
Returns the font for the given shape.
|
RMShape |
getGalleryClone(T aShape)
Returns a clone of a gallery shape (hook to allow extra configuration for subclasses).
|
int |
getHandleAtPoint(T aShape,
java.awt.geom.Point2D aPoint,
boolean isSuperSelected)
Returns the handle hit by the given editor coord point.
|
int |
getHandleCount(T aShape)
Returns the number of handles for this shape.
|
java.awt.Cursor |
getHandleCursor(T aShape,
int aHandle)
Returns the cursor for given handle.
|
int |
getHandleOpposing(int handle)
Returns the handle index that is across from given handle index.
|
RMPoint |
getHandlePoint(T aShape,
int aHandle,
boolean isSuperSelected)
Returns the point for the handle of the given shape at the given handle index in the given shape's coords.
|
RMRect |
getHandleRect(T aShape,
int aHandle,
boolean isSuperSelected)
Returns the rect for the handle at the given index in editor coords.
|
javax.swing.Icon |
getIcon()
Returns the icon used to represent shapes that this tool represents.
|
static javax.swing.Icon |
getIcon(java.lang.Class aClass)
Returns the icon for the given shape class.
|
double |
getPointsFromUnits(double aValue)
Converts from tool units to shape units.
|
T |
getSelectedShape()
Returns the current selected shape for the current editor.
|
java.util.List<? extends RMShape> |
getSelectedShapes()
Returns the current selected shapes for the current editor.
|
static RMSelectTool |
getSelectTool()
Returns the SelectTool.
|
java.lang.Class<T> |
getShapeClass()
Returns the shape class that this tool handles.
|
SwingOwner |
getShapeFillInspector()
Returns the fill inspector for this tool's shape class.
|
RMTool.RMShapeHandle |
getShapeHandleAtPoint(java.awt.geom.Point2D aPoint)
Returns the shape handle for the given editor point.
|
static RMTool |
getTool(java.util.List aList)
Returns the specific tool for a list of shapes (if they have the same tool).
|
static RMTool |
getTool(java.lang.Object anObj)
Returns the specific tool for a given shape.
|
java.lang.String |
getToolTipText(T aShape,
java.awt.event.MouseEvent anEvent)
Returns a tool tip string for given shape and event.
|
double |
getUnitsFromPoints(double aValue)
Converts from shape units to tool units.
|
java.lang.String |
getWindowTitle()
Returns the string to be used for the inspector window title.
|
boolean |
isSelected(RMShape aShape)
Returns whether a given shape is selected in the editor.
|
boolean |
isSuperSelectable(RMShape aShape)
Returns whether a given shape is super-selectable.
|
boolean |
isSuperSelected(RMShape aShape)
Returns whether a given shape is superselected in the editor.
|
boolean |
isUngroupable(RMShape aShape)
Returns whether a given shape can be ungrouped.
|
void |
mouseDragged(java.awt.event.MouseEvent anEvent)
Event handling for shape creation.
|
void |
mouseDragged(T aShape,
java.awt.event.MouseEvent anEvent)
Event handling from select tool for super selected shapes.
|
void |
mouseMoved(java.awt.event.MouseEvent anEvent)
Event handling - called on mouse move when this tool is active.
|
void |
mouseMoved(T aShape,
java.awt.event.MouseEvent anEvent)
Event handling from select tool - called on mouse move when tool shape is super selected.
|
void |
mousePressed(java.awt.event.MouseEvent anEvent)
Event handling for shape creation.
|
void |
mousePressed(T aShape,
java.awt.event.MouseEvent anEvent)
Event handling from select tool for super selected shapes.
|
boolean |
mousePressedSelection(java.awt.event.MouseEvent anEvent)
Event hook during selection.
|
void |
mouseReleased(java.awt.event.MouseEvent anEvent)
Event handling for shape creation.
|
void |
mouseReleased(T aShape,
java.awt.event.MouseEvent anEvent)
Event handling from select tool for super selected shapes.
|
void |
moveShapeHandle(T aShape,
int aHandle,
RMPoint toPoint)
Moves the handle at the given index to the given point.
|
protected T |
newInstance()
Returns a new instance of the shape class that this tool is responsible for.
|
void |
paintShapeHandles(T aShape,
java.awt.Graphics2D g,
boolean isSuperSelected)
Handles painting shape handles (or any indication that a shape is selected/super-selected).
|
void |
paintTool(java.awt.Graphics2D g)
Paints when tool is active for things like SelectTool's handles & selection rect or polygon's in-progress path.
|
void |
processKeyEvent(T aShape,
java.awt.event.KeyEvent anEvent)
Editor method.
|
void |
reactivateTool()
Called when a tool is selected even when it's already the current tool.
|
void |
setFont(RMEditor anEditor,
RMShape aShape,
RMFont aFont)
Sets the font for the given shape.
|
void |
setFontBold(RMEditor anEditor,
RMShape aShape,
boolean aFlag)
Sets the font to bold or not bold for given shape.
|
void |
setFontBoldDeep(RMEditor anEditor,
RMShape aShape,
boolean aFlag)
Sets the font to bold or not bold for given shape and its children.
|
void |
setFontFamily(RMEditor anEditor,
RMShape aShape,
RMFont aFont)
Sets the font family for given shape.
|
void |
setFontFamilyDeep(RMEditor anEditor,
RMShape aShape,
RMFont aFont)
Sets the font family for given shape.
|
void |
setFontItalic(RMEditor anEditor,
RMShape aShape,
boolean aFlag)
Sets the font to italic or not italic for given shape.
|
void |
setFontItalicDeep(RMEditor anEditor,
RMShape aShape,
boolean aFlag)
Sets the font to italic or not italic for given shape and its children.
|
void |
setFontName(RMEditor anEditor,
RMShape aShape,
RMFont aFont)
Sets the font name for given shape.
|
void |
setFontNameDeep(RMEditor anEditor,
RMShape aShape,
RMFont aFont)
Sets the font name for given shape.
|
void |
setFontSize(RMEditor anEditor,
RMShape aShape,
double aSize,
boolean isRelative)
Sets the font size for given shape.
|
void |
setFontSizeDeep(RMEditor anEditor,
RMShape aShape,
double aSize,
boolean isRelative)
Sets the font size for given shape.
|
void |
willLoseSuperSelectionInEditor(RMShape aShape,
RMEditor anEditor)
Editor method - called when an instance of this tool's shape in de-super-selected.
|
addKeyActionEvent, createTimer, createUI, createWindow, getNode, getNode, getNodeHelper, getTimer, getTimer, getUI, getWindow, isEventThread, isWindowVisible, requestFocus, requestFocusImpl, runLater, sendEvent, setWindowVisible
addNodeBinding, disableEvents, enableEvents, getBindingModelValue, getBindingNodeValue, getConversionMap, getConversionMapKey, getConversionMaps, getConversionMapValue, getFirstFocus, getModelValue, getNode, getNodeAction, getNodeBoolValue, getNodeFloatValue, getNodeIntValue, getNodeItemDisplayKey, getNodeItems, getNodeSelectedIndex, getNodeSelectedItem, getNodeStringValue, getNodeText, getNodeValue, getUI, getUIHpr, initUI, initUI, isNodeEnabled, isNodeValueAdjusting, isSendEventDisabled, isUISet, processResetUI, processRespondUI, resetLater, resetNodeBindings, resetUI, respondUI, runLaterDelayed, runLaterOnce, sendEvent, sendNodeAction, setBindingModelValue, setBindingNodeValue, setFirstFocus, setModelValue, setNodeAction, setNodeEnabled, setNodeItemDisplayKey, setNodeItems, setNodeItems, setNodeSelectedIndex, setNodeSelectedItem, setNodeText, setNodeValue, setSendEventDisabled
public static final java.lang.String SPLIT_RESET
public static final byte HandleWidth
public static final byte HandleNW
public static final byte HandleNE
public static final byte HandleSW
public static final byte HandleSE
public static final byte HandleW
public static final byte HandleE
public static final byte HandleN
public static final byte HandleS
public RMTool()
public RMTool(com.google.common.eventbus.EventBus ebus)
public java.lang.Class<T> getShapeClass()
public void attachEventBus(com.google.common.eventbus.EventBus bus)
protected T newInstance()
public java.lang.String getWindowTitle()
protected javax.swing.JComponent createUI()
createUI
in class SwingOwner
@Nullable public Entity getDatasetEntity(RMShape aShape)
public RMEditor getEditor()
public RMEditorPane getEditorPane()
public T getSelectedShape()
public java.util.List<? extends RMShape> getSelectedShapes()
public void activateTool()
public void deactivateTool()
public void reactivateTool()
public void flushChanges(RMEditor anEditor, RMShape aShape)
public boolean isSelected(RMShape aShape)
public boolean isSuperSelected(RMShape aShape)
public boolean isSuperSelectable(RMShape aShape)
public boolean getAcceptsChildren(RMShape aShape)
public boolean isUngroupable(RMShape aShape)
public void didBecomeSuperSelectedShapeInEditor(RMShape aShape, RMEditor anEditor)
public void willLoseSuperSelectionInEditor(RMShape aShape, RMEditor anEditor)
public RMRect getBoundsSuperSelected(RMShape aShape)
public double getUnitsFromPoints(double aValue)
public double getPointsFromUnits(double aValue)
public RMFont getFont(RMEditor anEditor, RMShape shape)
public void setFont(RMEditor anEditor, RMShape aShape, RMFont aFont)
public RMFont getFontDeep(RMEditor anEditor, RMShape aShape)
public void setFontFamily(RMEditor anEditor, RMShape aShape, RMFont aFont)
public void setFontFamilyDeep(RMEditor anEditor, RMShape aShape, RMFont aFont)
public void setFontName(RMEditor anEditor, RMShape aShape, RMFont aFont)
public void setFontNameDeep(RMEditor anEditor, RMShape aShape, RMFont aFont)
public void setFontSize(RMEditor anEditor, RMShape aShape, double aSize, boolean isRelative)
public void setFontSizeDeep(RMEditor anEditor, RMShape aShape, double aSize, boolean isRelative)
public void setFontBold(RMEditor anEditor, RMShape aShape, boolean aFlag)
public void setFontBoldDeep(RMEditor anEditor, RMShape aShape, boolean aFlag)
public void setFontItalic(RMEditor anEditor, RMShape aShape, boolean aFlag)
public void setFontItalicDeep(RMEditor anEditor, RMShape aShape, boolean aFlag)
public void mouseMoved(java.awt.event.MouseEvent anEvent)
public void mousePressed(java.awt.event.MouseEvent anEvent)
public void mouseDragged(java.awt.event.MouseEvent anEvent)
public void mouseReleased(java.awt.event.MouseEvent anEvent)
public void mouseMoved(T aShape, java.awt.event.MouseEvent anEvent)
public void mousePressed(T aShape, java.awt.event.MouseEvent anEvent)
public void mouseDragged(T aShape, java.awt.event.MouseEvent anEvent)
public void mouseReleased(T aShape, java.awt.event.MouseEvent anEvent)
public boolean mousePressedSelection(java.awt.event.MouseEvent anEvent)
public java.lang.String getToolTipText(T aShape, java.awt.event.MouseEvent anEvent)
public void processKeyEvent(T aShape, java.awt.event.KeyEvent anEvent)
public void paintTool(java.awt.Graphics2D g)
public void paintShapeHandles(T aShape, java.awt.Graphics2D g, boolean isSuperSelected)
public int getHandleCount(T aShape)
public RMPoint getHandlePoint(T aShape, int aHandle, boolean isSuperSelected)
public RMRect getHandleRect(T aShape, int aHandle, boolean isSuperSelected)
public int getHandleAtPoint(T aShape, java.awt.geom.Point2D aPoint, boolean isSuperSelected)
public java.awt.Cursor getHandleCursor(T aShape, int aHandle)
public void moveShapeHandle(T aShape, int aHandle, RMPoint toPoint)
public int getHandleOpposing(int handle)
public SwingOwner getShapeFillInspector()
public RMTool.RMShapeHandle getShapeHandleAtPoint(java.awt.geom.Point2D aPoint)
public boolean acceptsDrag(T aShape, java.awt.dnd.DropTargetDragEvent anEvent)
public void dragEnter(RMShape aShape, java.awt.dnd.DropTargetDragEvent anEvent)
public void dragExit(RMShape aShape, java.awt.dnd.DropTargetDragEvent anEvent)
public void dragOver(RMShape aShape, java.awt.dnd.DropTargetDragEvent anEvent)
public void drop(T aShape, java.awt.dnd.DropTargetDropEvent anEvent)
public void dropDragKey(T aShape, java.awt.dnd.DropTargetDropEvent anEvent)
public void dropClass(T aShape, java.awt.dnd.DropTargetDropEvent anEvent)
public static java.awt.datatransfer.DataFlavor flavorForClass(java.lang.Class clazz)
public RMRect getDragDisplayBounds(RMShape aShape, java.awt.dnd.DropTargetDragEvent anEvent)
public void dropString(T aShape, java.awt.dnd.DropTargetDropEvent anEvent)
public void dropColor(RMShape aShape, java.awt.dnd.DropTargetDropEvent anEvent)
public void dropFiles(RMShape aShape, java.awt.dnd.DropTargetDropEvent anEvent)
public RMShape getGalleryClone(T aShape)
public javax.swing.Icon getIcon()
public static javax.swing.Icon getIcon(java.lang.Class aClass)
public static RMSelectTool getSelectTool()
@Nonnull public static RMTool getTool(java.util.List aList)
@Nonnull public static RMTool getTool(java.lang.Object anObj)