renderable
Class RenderableBlock

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by renderable.RenderableBlock
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, CommentSource, ISupportMemento, SearchableElement
Direct Known Subclasses:
FactoryRenderableBlock

public class RenderableBlock
extends javax.swing.JComponent
implements SearchableElement, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, ISupportMemento, CommentSource

RenderableBlock is responsible for all graphical rendering of a code Block. This class is also responsible for consuming all mouse and key events on itself. Each RenderableBlock object is coupled with its associated Block object, and uses information maintained in Block to render the graphical block accordingly.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RenderableBlock(WorkspaceWidget parent, java.lang.Long blockID)
          Constructs a new RenderableBlock instance with the specified parent WorkspaceWidget and Long blockID of its associated Block
 
Method Summary
 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
 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.
 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
(package private)  java.awt.geom.Area getAbstractBlockArea()
           
 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
(package private)  javax.swing.JComponent getBlockWidget()
          returns the blockWidget for this RenderableBlock
 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
(package private)  int getControlLabelsWidth()
          returns the larger width of the CollapseLabel or CommentLabel if they exist for this RenderableBlock
 JComponentDragHandler getDragHandler()
           
 java.lang.String getGenus()
           
(package private)  RBHighlightHandler getHighlightHandler()
          returns the RBHighlightHandler for this RenderableBlock
 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
static RenderableBlock getRenderableBlock(java.lang.Long blockID)
          Returns the Renderable specified by blockID; null if RenderableBlock does not exist
 java.lang.String getSaveString()
          Returns the save string 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
 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(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.
protected  boolean processKeyBinding(javax.swing.KeyStroke ks, java.awt.event.KeyEvent e, int condition, boolean pressed)
           
 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
(package private)  int rescale(double x)
          returns a new double x position based on the current zoom
(package private)  int rescale(int x)
          returns a new int x based on the current zoom
static void reset()
          Clears all renderable block instances and all block instances
 void resetHighlight()
          Hides highlighting for this block.
(package private)  void setAbstractBlockArea(java.awt.geom.Area abstractBlockArea)
           
 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
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, hide, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface renderable.CommentSource
add, getParent
 

Constructor Detail

RenderableBlock

public RenderableBlock(WorkspaceWidget parent,
                       java.lang.Long blockID)
Constructs a new RenderableBlock instance with the specified parent WorkspaceWidget and Long blockID of its associated Block

Parameters:
parent - the WorkspaceWidget containing this
blockID - Long Block id of associated with this
Method Detail

getBlockID

public java.lang.Long getBlockID()
Returns the Long id of this

Specified by:
getBlockID in interface CommentSource
Returns:
the Long id of this

getBlockHeight

public int getBlockHeight()
Returns the height of the block shape of this

Returns:
the height of the block shape of this

getBlockSize

public java.awt.Dimension getBlockSize()
Returns the dimensions of the block shape of this

Returns:
the dimensions of the block shape of this

getBlockWidth

public int getBlockWidth()
Returns the width of the block shape of this

Returns:
the width of the block shape of this

getBlockShape

public BlockShape getBlockShape()
Returns the BlockShape instance representing this

Returns:
the BlockShape instance representing this

getAbstractBlockArea

java.awt.geom.Area getAbstractBlockArea()
Returns:
the abstractBlockArea

setAbstractBlockArea

void setAbstractBlockArea(java.awt.geom.Area abstractBlockArea)
Parameters:
abstractBlockArea - the abstractBlockArea to set

setLocation

public void setLocation(int x,
                        int y)
Moves this component to a new location. The top-left corner of the new location is specified by the x and y parameters in the coordinate space of this component's parent.

Overrides:
setLocation in class java.awt.Component
Parameters:
x - the x-coordinate of the new location's top-left corner in the parent's coordinate space
y - the y-coordinate of the new location's top-left corner in the parent's coordinate space

setLocation

public void setLocation(java.awt.Point p)
Moves this component to a new location. The top-left corner of the new location is specified by point p. Point p is given in the parent's coordinate space.

Overrides:
setLocation in class java.awt.Component
Parameters:
p - the point defining the top-left corner of the new location, given in the coordinate space of this component's parent

getHighlightStrokeWidth

public int getHighlightStrokeWidth()
Returns the width of the stroke used to draw the highlight. Note that the highlight will only appear half this width, so the overall width of the block + highlight will be blockWidth + highlightStrokeWidth.

Returns:
the width of the stroke used to draw the highlight.

getStackBounds

public 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).

Returns:
the bounds of the block stack of this, where this block is at the top of its stack.

switchToLabelEditingMode

public void switchToLabelEditingMode(boolean highlighted)
sets the label to belonging to this renderable block to editing state == true (editing mode)


getBlockWidget

javax.swing.JComponent getBlockWidget()
returns the blockWidget for this RenderableBlock

Returns:

getBlockWidgetDimension

public java.awt.Dimension getBlockWidgetDimension()
Returns:
the dimension of the sole block widget in this block. May NOT return null.

setBlockWidget

public void setBlockWidget(javax.swing.JComponent blockWidget)
Parameters:
blockWidget -

reset

public static void reset()
Clears all renderable block instances and all block instances


getDragHandler

public JComponentDragHandler getDragHandler()

getImageIconAt

public BlockImageIcon getImageIconAt(BlockImageIcon.ImageLocation location)
Returns the BlockImageIcon instance at the specified location; null if no BlockImageIcon exists at that location

Parameters:
location - the ImageLocation of the desired BlockImageIcon
Returns:
the BlockImageIcon instance at the specified location; null if no BlockImageIcon exists at that location

accomodateLabelsWidth

public int accomodateLabelsWidth()
Determine the width necessary to accommodate for placed labels. Used to determine the minimum width of a block.


accomodatePageLabelHeight

public int accomodatePageLabelHeight()
Returns the width of the page label on this block; if page label is not enabled and does not exist, returns 0.

Returns:
the width of the page label on this block iff page label is enabled and exists; returns 0 otherwise.

setBlockLabelUneditable

public void setBlockLabelUneditable()
Sets all the labels of this block as uneditable block labels. Useful for Factory blocks.


accomodateImagesHeight

public int accomodateImagesHeight()
Returns the total height of all the images to draw on this block

Returns:
the total height of all the images to draw on this block

accomodateImagesWidth

public int accomodateImagesWidth()
Returns the total width of all the images to draw on this block

Returns:
the total width of all the images to draw on this block

getNearbyLink

public BlockLink getNearbyLink()
Looks for links between this RenderableBlock and others.

Returns:
a BlockLink object with information on the closest possible linking between this RenderableBlock and another.

getMaxSocketShapeWidth

public int getMaxSocketShapeWidth()
Returns the maximum width between all the socket connectors of this or 0 if this does not have any sockets

Returns:
the maximum width between all the socket connectors of this or 0 if this does not have any sockets

getSocketPixelPoint

public java.awt.Point getSocketPixelPoint(BlockConnector socket)
Returns a new Point object that represents the pixel location of this socket's center. Mutating the new Point will not affect future calls to getSocketPoint; that is, this method clones a new Point object. The new Point object MAY NOT BE NULL.

Parameters:
socket - - the socket whose point we want. socket MAY NOT BE NULL.
Returns:
a Point representing the socket's center

getSocketAbstractPoint

public java.awt.Point getSocketAbstractPoint(BlockConnector socket)
Returns a new Point object that represents the abstract location of this socket's center. Mutating the new Point will not affect future calls to getSocketPoint; that is, this method clones a new Point object. The new Point object MAY NOT BE NULL.

Parameters:
socket - - the socket whose point we want. socket MAY NOT BE NULL.
Returns:
a Point representing the socket's center

updateSocketPoint

public void updateSocketPoint(BlockConnector socket,
                              java.awt.geom.Point2D point)
Updates the center point location of this socket

Parameters:
socket - - the socket whose point we will update. Socket MAY NOT BE NULL
point - - the ABSTRACT location of socket's center. ABSTRACT LOCATION!!!

updateConnectors

public void updateConnectors()
Updates the renderable block with the underlying block's before, after, and plug connectors.


getParentWidget

public WorkspaceWidget getParentWidget()
Returns the parent WorkspaceWidget containing this

Specified by:
getParentWidget in interface CommentSource
Returns:
the parent WorkspaceWidget containing this

setParentWidget

public void setParentWidget(WorkspaceWidget widget)
Sets the parent WorkspaceWidget containing this

Parameters:
widget - the desired WorkspaceWidget

contains

public 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. Returns true iff the specified coordinates are contained within the area of the BlockShape.

Overrides:
contains in class javax.swing.JComponent
Returns:
true iff the specified coordinates are contained within the Area of the BlockShape

getBlock

public Block getBlock()
Shortcut to get block with current BlockID of this renderable block.


getBLockColor

public java.awt.Color getBLockColor()

linkDefArgs

public 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. Re-linking this block's default args everytime it gets dropped/moved within the block canvas can get annoying.


ignoreDefaultArguments

public void ignoreDefaultArguments()
Modifies this RenderableBlock such that default arguments are ignored. In the future, invoking this.linkDefArgs() will trigger no action.


getRenderableBlock

public static RenderableBlock getRenderableBlock(java.lang.Long blockID)
Returns the Renderable specified by blockID; null if RenderableBlock does not exist

Parameters:
blockID - the block id of the desired RenderableBlock
Returns:
the Renderable specified by blockID; null if RenderableBlock does not exist

getSocketSpaceDimension

public java.awt.Dimension getSocketSpaceDimension(BlockConnector socket)
Returns the dimension associated with a socket. If a socket dimension has not yet been set, this will return null.


redrawFromTop

public void redrawFromTop()
Redraws this RenderableBlock along with the RenderableBlocks after it, which include after and socket blocks. In other words, this method redraws the stack of blocks that begin with this. NOTE: this is inefficient, should only use this if needed NOTE: Must call this after loading of blocks to update the socket dimensions of this and set the isLoading flag to false


getMaxWidthOfSockets

public int getMaxWidthOfSockets(java.lang.Long blockID)
Helper method for updateSocketSpace and calcStackDim. Returns the maximum width of the specified blockID's socket blocks

Parameters:
blockID - the Long blockID of the desired block

blockConnected

public void blockConnected(BlockConnector connectedSocket,
                           long connectedBlockID)
Notifies this renderable block that ITS socket connectedSocket was connected to ANOTHER block with ID connectedBlockID.


blockDisconnected

public void blockDisconnected(BlockConnector disconnectedSocket)
Notifies this renderable block that its socket connectedSocket had a block disconnected from it.


clearBufferedImage

public void clearBufferedImage()
Clears the BufferedImage of this


repaintBlock

public void repaintBlock()
Clears the BufferedImage of this and repaint this entirely


paintComponent

public 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.

Overrides:
paintComponent in class javax.swing.JComponent

getBlockArea

public java.awt.geom.Area getBlockArea()
returns the Area of the block

Returns:

setBlockHighlightColor

public void setBlockHighlightColor(java.awt.Color color)
Sets the highlight color of this block. The specified highlight may be overrided if this block has focus, is a search result, or is "bad". However when those states are no longer active, the color is set back to the specified hlColor, if resetHightlight() was not called in the meantime.

Parameters:
color - the desired highlight Color

resetHighlight

public void resetHighlight()
Hides highlighting for this block.


setHighlightParent

public 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)

Parameters:
parent - the RBParent that is the RB's new parent

isVisible

public boolean isVisible()
Overridden from JComponent. Returns true iff it has a parent, its parent is visible, and itself is visible; false otherwise.

Overrides:
isVisible in class java.awt.Component
Returns:
true iff it has a parent, its parent is visible, and itself is visible; false otherwise.

hasComment

public boolean hasComment()
Returns:
true iff this.comment !=null

getComment

public Comment getComment()
Returns:
this.comment

setComment

public void setComment(Comment comment)
Sets this RenderableBlock's comment

Parameters:
comment -

addComment

public 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. Modify such that this.hasComment will now return true.


removeComment

public void removeComment()
remove this comment from this parent Container and modify such that this.hasComment returns false.


getCommentLocation

public java.awt.Point getCommentLocation()
returns where the CommentArrow should draw from

Specified by:
getCommentLocation in interface CommentSource
Returns:

moveConnectedBlocks

public void moveConnectedBlocks()
Aligns all RenderableBlocks plugged into this one with the current location of this RenderableBlock. These RenderableBlocks to move include blocks connected at sockets and the after connector.


stopDragging

public static void stopDragging(RenderableBlock renderable,
                                WorkspaceWidget widget)
This method is called when this RenderableBlock is plugged into another RenderableBlock that has finished dragging.

Parameters:
widget - the WorkspaceWidget where this RenderableBlock is being dropped.

processMouseEvent

public 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

Overrides:
processMouseEvent in class javax.swing.JComponent

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

getKeyword

public java.lang.String getKeyword()
Description copied from interface: SearchableElement
Returns the keyword representation of the element, which is used to determine whether it belongs to a particular query.

Specified by:
getKeyword in interface SearchableElement
Returns:
the keyword representation of this Searchable.

getGenus

public java.lang.String getGenus()

updateInSearchResults

public void updateInSearchResults(boolean inSearchResults)
Description copied from interface: SearchableElement
Called by the search bar to update the SearchableElement of whether it currently belongs to the search bar's results. Guaranteed to be called on the Swing thread. It is the responsibility of this SearchableElement to update any necessary state and repaint any necessary components as a result of a call to this method.

Specified by:
updateInSearchResults in interface SearchableElement
Parameters:
inSearchResults - true when the SearchableElement is part of the current results.

isSearchResult

public boolean isSearchResult()

getSaveString

public java.lang.String getSaveString()
Returns the save string of this

Returns:
the save string of this

isLoading

public boolean isLoading()
Returns whether or not this is still loading data.

Returns:
whether or not this is still loading data.

loadBlockNode

public static RenderableBlock loadBlockNode(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.

Parameters:
blockNode - Node containing information to load into a RenderableBlock instance
parent - WorkspaceWidget to contain the block to load
Returns:
RenderableBlock instance holding the information in blockNode; null if no RenderableBlock loaded

extractLocationInfo

public static void extractLocationInfo(org.w3c.dom.Node location,
                                       java.awt.Point loc)
Read Location Node change loc to location in Node

Parameters:
location -
loc -

extractBoxSizeInfo

public 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

Parameters:
location -
boxSize -

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

getState

public java.lang.Object getState()
Specified by:
getState in interface ISupportMemento

loadState

public void loadState(java.lang.Object memento)
Specified by:
loadState in interface ISupportMemento

setZoomLevel

public void setZoomLevel(double newZoom)

getZoom

public double getZoom()
the current zoom for this RenderableBlock

Returns:
the zoom

rescale

int rescale(int x)
returns a new int x based on the current zoom

Parameters:
x -
Returns:

rescale

int rescale(double x)
returns a new double x position based on the current zoom

Parameters:
x -
Returns:

calculateUnzoomedX

public int calculateUnzoomedX(int x)
calculates the x when the zoom is 1.0

Parameters:
x - of the current position
Returns:
the x when the zoom is 1.0

calculateUnzoomedY

public int calculateUnzoomedY(int y)
calculates the y when the zoom is 1.0

Parameters:
y - of the current position
Returns:
the y when the zoom is 1.0

setUnzoomedX

public void setUnzoomedX(double unzoomedX)
mutator for the initial value of x

Parameters:
unzoomedX -

setUnzoomedY

public void setUnzoomedY(double unzoomedY)
mutator for the initial value of y

Parameters:
unzoomedY -

getUnzoomedX

public double getUnzoomedX()
observer for the initial value of x

Returns:
initial value of x coordinate

getUnzoomedY

public double getUnzoomedY()
observer for the initial value of y

Returns:
initial value of x coordinate

processKeyPressed

public void processKeyPressed(java.awt.event.KeyEvent e)

createToolTip

public javax.swing.JToolTip createToolTip()
Overrides:
createToolTip in class javax.swing.JComponent

setBlockToolTip

public void setBlockToolTip(java.lang.String text)

processKeyBinding

protected boolean processKeyBinding(javax.swing.KeyStroke ks,
                                    java.awt.event.KeyEvent e,
                                    int condition,
                                    boolean pressed)
Overrides:
processKeyBinding in class javax.swing.JComponent

isCollapsed

public boolean isCollapsed()
Returns the collapsed state if the block has a collapseLabel otherwise false.


setCollapsed

public void setCollapsed(boolean collapse)
If this block can be collapsed its collapse state will be set

Parameters:
collapse -

updateCollapse

public void updateCollapse()
Sets the visibility of blocks connected to this block according to the current collapse state.


getCollapseLabelWidth

public int getCollapseLabelWidth()
Returns the width of the collapseLabel for this block if there is one, 0 otherwise

Returns:

getHighlightHandler

RBHighlightHandler getHighlightHandler()
returns the RBHighlightHandler for this RenderableBlock

Returns:
the highlighter

getControlLabelsWidth

int getControlLabelsWidth()
returns the larger width of the CollapseLabel or CommentLabel if they exist for this RenderableBlock

Returns: