Class singleLink

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--singleLink

public class singleLink
extends javax.swing.JPanel

Represents a link between two operators. Displayed on the screen as a JPanel added to the panel on the scrollpane, filling it entirely but transparent so other compoents (other links and operatorBoxes can be seen beneath it. A link exists between a specific output (1 or 2) of an operator and a specific input (1 or 2) of another operator. Only one single link can link to a specific input. Several links can link from an output.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 javax.swing.JLabel connectionFrom
          The specific output (1 or 2) that the link originates from.
 javax.swing.JLabel connectionTo
          The specific input (1 or 2) that the link terminates at.
 operator linkFrom
          The operator that outputs through the link.
 operator linkTo
           
 
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
 
Constructor Summary
singleLink()
          Default no argument constructor.
singleLink(operator fromOp, javax.swing.JLabel fromCon)
          Constructor taking an operator and an output (belonging to that operator) where the new link originates.
singleLink(operator fromOp, java.lang.String fromCon, operator toOp, java.lang.String toCon)
           
 
Method Summary
 void connectLinkTo(operator toOp, javax.swing.JLabel toCon)
          Connects the link to an operator and a connection, both graphically and internally (for propagating data through the operators).
 void dragLinkTo(java.awt.Point point)
          Called when the terminating end of a link is being dragged to a new point.
 java.awt.Point getBottomRightBound()
          Gets the bottom-right corner of a rectangle that will completely enclose this link.
 java.awt.Point getTopLeftBound()
          Gets the top-left corner of a rectangle that will completely enclose this link.
 double getXCoord(javax.swing.JLabel connection)
           
 double getYCoord(javax.swing.JLabel connection)
           
 void paint(java.awt.Graphics graphics)
          Overrides the paint method for JPanel, so that the curvy line is painted on the screen.
 java.lang.String saveLink()
          Returns a String representing the link, with the names of the operators it links to and from and the names of the connections within these operators.
 void translatePointFrom(int x, int y)
          Translates the originating point of this link by the specified vertical and horizontal values.
 void translatePointTo(int x, int y)
          Translates the terminating point of this link by the specified vertical and horizontal values.
 void updateLink()
          Updates the link by calculating the area completely containing the curve and repainting it.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

linkFrom

public operator linkFrom
The operator that outputs through the link.

linkTo

public operator linkTo

connectionFrom

public javax.swing.JLabel connectionFrom
The specific output (1 or 2) that the link originates from.

connectionTo

public javax.swing.JLabel connectionTo
The specific input (1 or 2) that the link terminates at.
Constructor Detail

singleLink

public singleLink()
Default no argument constructor.

singleLink

public singleLink(operator fromOp,
                  java.lang.String fromCon,
                  operator toOp,
                  java.lang.String toCon)

singleLink

public singleLink(operator fromOp,
                  javax.swing.JLabel fromCon)
Constructor taking an operator and an output (belonging to that operator) where the new link originates.
Parameters:
fromOp - the operator that the link originates from
fromCon - the connection/output that the link originates from
Method Detail

getXCoord

public double getXCoord(javax.swing.JLabel connection)

getYCoord

public double getYCoord(javax.swing.JLabel connection)

saveLink

public java.lang.String saveLink()
Returns a String representing the link, with the names of the operators it links to and from and the names of the connections within these operators. String representing the link

dragLinkTo

public void dragLinkTo(java.awt.Point point)
Called when the terminating end of a link is being dragged to a new point.
Parameters:
point - the new terminating point (relative to the panel on the scrollpane) for the link

updateLink

public void updateLink()
Updates the link by calculating the area completely containing the curve and repainting it.

connectLinkTo

public void connectLinkTo(operator toOp,
                          javax.swing.JLabel toCon)
Connects the link to an operator and a connection, both graphically and internally (for propagating data through the operators).
Parameters:
toOp - the operator the link is to be linked to
toCon - the connection (IN1 or IN2) that the link is to link to

translatePointTo

public void translatePointTo(int x,
                             int y)
Translates the terminating point of this link by the specified vertical and horizontal values.
Parameters:
x - the horizontal translation amount (positive - to the left)
y - the vertical translation amount (positive - down)

translatePointFrom

public void translatePointFrom(int x,
                               int y)
Translates the originating point of this link by the specified vertical and horizontal values.
Parameters:
x - the horizontal translation amount (positive - to the left)
y - the vertical translation amount (positive - down)

getTopLeftBound

public java.awt.Point getTopLeftBound()
Gets the top-left corner of a rectangle that will completely enclose this link.
Returns:
the top-left corner of the bounding rectangle

getBottomRightBound

public java.awt.Point getBottomRightBound()
Gets the bottom-right corner of a rectangle that will completely enclose this link.
Returns:
the bottom-right corner of the bounding rectangle

paint

public void paint(java.awt.Graphics graphics)
Overrides the paint method for JPanel, so that the curvy line is painted on the screen.
Parameters:
graphics - the graphics context to be painted on
Overrides:
paint in class javax.swing.JComponent