public class RenderableBlock extends javax.swing.JComponent implements SearchableElement, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, ISupportMemento, CommentSource
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
RenderableBlock(Workspace workspace,
WorkspaceWidget parent,
java.lang.Long blockID)
Constructs a new RenderableBlock instance with the specified parent
WorkspaceWidget and Long blockID of its associated Block
|
| Modifier and Type | Method and Description |
|---|---|
int |
accomodateImagesHeight()
Returns the total height of all the images to draw on this block
|
int |
accomodateImagesWidth()
Returns the total width of all the images to draw on this block
|
int |
accomodateLabelsWidth()
Determine the width necessary to accommodate for placed labels.
|
int |
accomodatePageLabelHeight()
Returns the width of the page label on this block; if page label is not
enabled and does not exist, returns 0.
|
void |
addComment()
If this does NOT have comment, then add a new comment to this parent
Container at a point (10,-20) away from upper-right hand corner.
|
void |
blockConnected(BlockConnector connectedSocket,
long connectedBlockID)
Notifies this renderable block that ITS socket connectedSocket was
connected to ANOTHER block with ID connectedBlockID.
|
void |
blockDisconnected(BlockConnector disconnectedSocket)
Notifies this renderable block that its socket connectedSocket had a
block disconnected from it.
|
int |
calculateUnzoomedX(int x)
calculates the x when the zoom is 1.0
|
int |
calculateUnzoomedY(int y)
calculates the y when the zoom is 1.0
|
void |
clearBufferedImage()
Clears the BufferedImage of this
|
void |
cloneMe() |
boolean |
contains(int x,
int y)
Overriding JComponent.contains(int x, int y) so that this component's
boundaries are defined by the actual area occupied by the Renderable
Block shape.
|
void |
createRefer() |
javax.swing.JToolTip |
createToolTip() |
static void |
extractBoxSizeInfo(org.w3c.dom.Node boxSizeNode,
java.awt.Dimension boxSize)
Changes Point boxSize (x,y) to the (width,height) of boxSizeNode That is
x = width and y = height
|
static void |
extractLocationInfo(org.w3c.dom.Node location,
java.awt.Point loc)
Read Location Node change loc to location in Node
|
Block |
getBlock()
Shortcut to get block with current BlockID of this renderable block.
|
java.awt.geom.Area |
getBlockArea()
returns the Area of the block
|
java.awt.Color |
getBLockColor() |
int |
getBlockHeight()
Returns the height of the block shape of this
|
java.lang.Long |
getBlockID()
Returns the Long id of this
|
BlockShape |
getBlockShape()
Returns the BlockShape instance representing this
|
java.awt.Dimension |
getBlockSize()
Returns the dimensions of the block shape of this
|
java.awt.Dimension |
getBlockWidgetDimension() |
int |
getBlockWidth()
Returns the width of the block shape of this
|
int |
getCollapseLabelWidth()
Returns the width of the collapseLabel for this block if there is one, 0
otherwise
|
Comment |
getComment() |
java.awt.Point |
getCommentLocation()
returns where the CommentArrow should draw from
|
JComponentDragHandler |
getDragHandler() |
java.lang.String |
getGenus() |
int |
getHighlightStrokeWidth()
Returns the width of the stroke used to draw the highlight.
|
BlockImageIcon |
getImageIconAt(BlockImageIcon.ImageLocation location)
Returns the BlockImageIcon instance at the specified location; null if no
BlockImageIcon exists at that location
|
java.lang.String |
getKeyword()
Returns the keyword representation of the element, which is used to determine whether it belongs
to a particular query.
|
int |
getMaxSocketShapeWidth()
Returns the maximum width between all the socket connectors of this or 0
if this does not have any sockets
|
int |
getMaxWidthOfSockets(java.lang.Long blockID)
Helper method for updateSocketSpace and calcStackDim.
|
BlockLink |
getNearbyLink()
Looks for links between this RenderableBlock and others.
|
WorkspaceWidget |
getParentWidget()
Returns the parent WorkspaceWidget containing this
|
org.w3c.dom.Node |
getSaveNode(org.w3c.dom.Document document)
Returns the node of this
|
java.awt.Point |
getSocketAbstractPoint(BlockConnector socket)
Returns a new Point object that represents the abstract location of this
socket's center.
|
java.awt.Point |
getSocketPixelPoint(BlockConnector socket)
Returns a new Point object that represents the pixel location of this
socket's center.
|
java.awt.Dimension |
getSocketSpaceDimension(BlockConnector socket)
Returns the dimension associated with a socket.
|
java.awt.Rectangle |
getStackBounds()
Returns the bounds of the block stack of this, where this block is at the
top of its stack (in other words, it does not take the bounds of the
blocks above it into account).
|
java.lang.Object |
getState() |
double |
getUnzoomedX()
observer for the initial value of x
|
double |
getUnzoomedY()
observer for the initial value of y
|
Workspace |
getWorkspace()
Returns the workspace in which this block is living in
|
double |
getZoom()
the current zoom for this RenderableBlock
|
boolean |
hasComment() |
void |
ignoreDefaultArguments()
Modifies this RenderableBlock such that default arguments are ignored.
|
boolean |
isCollapsed()
Returns the collapsed state if the block has a collapseLabel otherwise
false.
|
boolean |
isLoading()
Returns whether or not this is still loading data.
|
boolean |
isSearchResult() |
boolean |
isVisible()
Overridden from JComponent.
|
void |
linkDefArgs()
Links the default arguments of this block if it has any and if this block
has not already linked its default args in this session.
|
static RenderableBlock |
loadBlockNode(Workspace workspace,
org.w3c.dom.Node blockNode,
WorkspaceWidget parent,
java.util.HashMap<java.lang.Long,java.lang.Long> idMapping)
Loads a RenderableBlock and its related Block instance from the specified
blockNode; returns null if no RenderableBlock was loaded.
|
void |
loadState(java.lang.Object memento) |
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
moveConnectedBlocks()
Aligns all RenderableBlocks plugged into this one with the current
location of this RenderableBlock.
|
void |
paintComponent(java.awt.Graphics g)
Swing paint method for J-Component Checks to see if the buffer has been
cleared (or yet to be created), if so then it redraws the buffer and then
draws the image on the graphics2d or else it uses the previous buffer.
|
void |
processKeyPressed(java.awt.event.KeyEvent e) |
void |
processMouseEvent(java.awt.event.MouseEvent e)
Makes public the protected processMouseEvent() method from Component so
that the children within this block may pass mouse events to this
|
void |
redrawFromTop()
Redraws this RenderableBlock along with the RenderableBlocks after it,
which include after and socket blocks.
|
void |
removeComment()
remove this comment from this parent Container and modify such that
this.hasComment returns false.
|
void |
repaintBlock()
Clears the BufferedImage of this and repaint this entirely
|
void |
resetHighlight()
Hides highlighting for this block.
|
void |
setBlockHighlightColor(java.awt.Color color)
Sets the highlight color of this block.
|
void |
setBlockLabelUneditable()
Sets all the labels of this block as uneditable block labels.
|
void |
setBlockToolTip(java.lang.String text) |
void |
setBlockWidget(javax.swing.JComponent blockWidget) |
void |
setCollapsed(boolean collapse)
If this block can be collapsed its collapse state will be set
|
void |
setComment(Comment comment)
Sets this RenderableBlock's comment
|
void |
setHighlightParent(RBParent parent)
Tells this RenderableBlock to move its highlight handler to a new parent
(should be called after this RB is moved to a new parent)
|
void |
setLocation(int x,
int y)
Moves this component to a new location.
|
void |
setLocation(java.awt.Point p)
Moves this component to a new location.
|
void |
setParentWidget(WorkspaceWidget widget)
Sets the parent WorkspaceWidget containing this
|
void |
setUnzoomedX(double unzoomedX)
mutator for the initial value of x
|
void |
setUnzoomedY(double unzoomedY)
mutator for the initial value of y
|
void |
setZoomLevel(double newZoom) |
static void |
stopDragging(RenderableBlock renderable,
WorkspaceWidget widget)
This method is called when this RenderableBlock is plugged into another
RenderableBlock that has finished dragging.
|
void |
switchToLabelEditingMode(boolean highlighted)
sets the label to belonging to this renderable block to editing state ==
true (editing mode)
|
java.lang.String |
toString() |
void |
updateCollapse()
Sets the visibility of blocks connected to this block according to the
current collapse state.
|
void |
updateConnectors()
Updates the renderable block with the underlying block's before, after,
and plug connectors.
|
void |
updateInSearchResults(boolean inSearchResults)
Called by the search bar to update the SearchableElement of whether it currently belongs to
the search bar's results.
|
void |
updateSocketPoint(BlockConnector socket,
java.awt.geom.Point2D point)
Updates the center point location of this socket
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycleequals, getClass, hashCode, notify, notifyAll, wait, wait, waitadd, getParentpublic RenderableBlock(Workspace workspace, WorkspaceWidget parent, java.lang.Long blockID)
workspace - The workspace in useparent - the WorkspaceWidget containing thisblockID - Long Block id of associated with thispublic Workspace getWorkspace()
public java.lang.Long getBlockID()
getBlockID in interface CommentSourcepublic int getBlockHeight()
public java.awt.Dimension getBlockSize()
public int getBlockWidth()
public BlockShape getBlockShape()
public void setLocation(int x,
int y)
x and y parameters
in the coordinate space of this component's parent.setLocation in class java.awt.Componentx - the x-coordinate of the new location's top-left corner
in the parent's coordinate spacey - the y-coordinate of the new location's top-left corner
in the parent's coordinate spacepublic void setLocation(java.awt.Point p)
p. Point p is
given in the parent's coordinate space.setLocation in class java.awt.Componentp - the point defining the top-left corner of the new location,
given in the coordinate space of this component's parentpublic int getHighlightStrokeWidth()
public java.awt.Rectangle getStackBounds()
public void switchToLabelEditingMode(boolean highlighted)
public java.awt.Dimension getBlockWidgetDimension()
public void setBlockWidget(javax.swing.JComponent blockWidget)
blockWidget - public JComponentDragHandler getDragHandler()
public BlockImageIcon getImageIconAt(BlockImageIcon.ImageLocation location)
location - the ImageLocation of the desired BlockImageIconpublic int accomodateLabelsWidth()
public int accomodatePageLabelHeight()
public void setBlockLabelUneditable()
public int accomodateImagesHeight()
public int accomodateImagesWidth()
public BlockLink getNearbyLink()
public int getMaxSocketShapeWidth()
public java.awt.Point getSocketPixelPoint(BlockConnector socket)
socket - - the socket whose point we want. socket MAY NOT BE NULL.public java.awt.Point getSocketAbstractPoint(BlockConnector socket)
socket - - the socket whose point we want. socket MAY NOT BE NULL.public void updateSocketPoint(BlockConnector socket, java.awt.geom.Point2D point)
socket - - the socket whose point we will update. Socket MAY NOT BE
NULLpoint - - the ABSTRACT location of socket's center. ABSTRACT
LOCATION!!!public void updateConnectors()
public WorkspaceWidget getParentWidget()
getParentWidget in interface CommentSourcepublic void setParentWidget(WorkspaceWidget widget)
widget - the desired WorkspaceWidgetpublic boolean contains(int x,
int y)
contains in class javax.swing.JComponentpublic Block getBlock()
public java.awt.Color getBLockColor()
public void linkDefArgs()
public void ignoreDefaultArguments()
public java.awt.Dimension getSocketSpaceDimension(BlockConnector socket)
public void redrawFromTop()
public int getMaxWidthOfSockets(java.lang.Long blockID)
blockID - the Long blockID of the desired blockpublic void blockConnected(BlockConnector connectedSocket, long connectedBlockID)
public void blockDisconnected(BlockConnector disconnectedSocket)
public void clearBufferedImage()
public void repaintBlock()
public void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentpublic java.awt.geom.Area getBlockArea()
public void setBlockHighlightColor(java.awt.Color color)
color - the desired highlight Colorpublic void resetHighlight()
public void setHighlightParent(RBParent parent)
parent - the RBParent that is the RB's new parentpublic boolean isVisible()
isVisible in class java.awt.Componentpublic boolean hasComment()
public Comment getComment()
public void setComment(Comment comment)
comment - public void addComment()
public void removeComment()
public java.awt.Point getCommentLocation()
getCommentLocation in interface CommentSourcepublic void createRefer()
public void cloneMe()
public void moveConnectedBlocks()
public static void stopDragging(RenderableBlock renderable, WorkspaceWidget widget)
widget - the WorkspaceWidget where this RenderableBlock is being
dropped.public void processMouseEvent(java.awt.event.MouseEvent e)
processMouseEvent in class javax.swing.JComponentpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenerpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic java.lang.String getKeyword()
SearchableElementgetKeyword in interface SearchableElementpublic java.lang.String getGenus()
public void updateInSearchResults(boolean inSearchResults)
SearchableElementupdateInSearchResults in interface SearchableElementinSearchResults - true when the SearchableElement is part of the current results.public boolean isSearchResult()
public org.w3c.dom.Node getSaveNode(org.w3c.dom.Document document)
public boolean isLoading()
public static RenderableBlock loadBlockNode(Workspace workspace, org.w3c.dom.Node blockNode, WorkspaceWidget parent, java.util.HashMap<java.lang.Long,java.lang.Long> idMapping)
workspace - The workspace to useblockNode - Node containing information to load into a RenderableBlock
instanceparent - WorkspaceWidget to contain the block to loadpublic static void extractLocationInfo(org.w3c.dom.Node location,
java.awt.Point loc)
location - loc - public static void extractBoxSizeInfo(org.w3c.dom.Node boxSizeNode,
java.awt.Dimension boxSize)
boxSizeNode - boxSize - public java.lang.String toString()
toString in class java.awt.Componentpublic java.lang.Object getState()
getState in interface ISupportMementopublic void loadState(java.lang.Object memento)
loadState in interface ISupportMementopublic void setZoomLevel(double newZoom)
public double getZoom()
public int calculateUnzoomedX(int x)
x - of the current positionpublic int calculateUnzoomedY(int y)
y - of the current positionpublic void setUnzoomedX(double unzoomedX)
unzoomedX - public void setUnzoomedY(double unzoomedY)
unzoomedY - public double getUnzoomedX()
public double getUnzoomedY()
public void processKeyPressed(java.awt.event.KeyEvent e)
public javax.swing.JToolTip createToolTip()
createToolTip in class javax.swing.JComponentpublic void setBlockToolTip(java.lang.String text)
public boolean isCollapsed()
public void setCollapsed(boolean collapse)
collapse - public void updateCollapse()
public int getCollapseLabelWidth()