torsusapplet
Class DrawArea

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--torsusapplet.DrawArea
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class DrawArea
extends javax.swing.JPanel

DrawArea class handles the graphical construction and display of truss structures.

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
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static int DRAW_HEIGHT
          Integer value representing width of the DrawArea.
static int DRAW_WIDTH
          Integer value representing width of the DrawArea.
static int X_ORIGIN_OFFSET
          Integer value representing x offset.
static int Y_ORIGIN_OFFSET
          Integer value representing y offset.
 
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
DrawArea(TorsusView v)
          Constructor takes view as an argument to enable communication in both directions between classes.
 
Method Summary
 void addMember(Node m, Node n)
          Calls the method of the same name on the local TrussStructure.
 void displayNodeMemberNumbers(boolean b)
          If boolean b is true, the numbering scheme of the Nodes and Members is displayed.
 void drawLine(java.awt.Point a, java.awt.Point b)
          Draws a line between Points a and b.
 void drawSnap(Node n, boolean b)
          Depending on value of boolean b, this method will draw a "snap square" around Node n.
 void drawXLoad(Node n, java.awt.Graphics graphics)
          Draws the arrow and force corresponding to the of x-component of the load at Node n.
 void drawYLoad(Node n, java.awt.Graphics graphics)
          Draws the arrow and force corresponding to the of y-component of the load at Node n.
 TrussStructure getTrussStructure()
          Returns most current copy of local TrussStructure.
 void highlightMember(Member m, boolean b)
          Depending on value of boolean b, this method will highlight Member m.
 void highlightModifyNode(Node n, boolean b)
          Depending on value of boolean b, this method will highlight Node n.
 void modifyStructure(Node n, java.awt.Point p)
          Calls the method of the same name on the local TrussStructure.
 void paintComponent(java.awt.Graphics g)
          This method overrides the paintComponent() method of JPanel.
 void paintDisplacedNodes(TrussStructure t)
          Causes DrawArea to display only the displaced structure.
 void paintInternalForces(TrussStructure t)
          Causes DrawArea to display only the internal forces of the structure.
 void paintStructureOnly()
          Causes DrawArea to display only the structure (build mode).
 void refresh()
          Calls repaint() on self.
 void removeMember(Node m, Node n)
          Calls the method of the same name on the local TrussStructure.
 void resetScreen()
          Resets local TrussStructure and reverts to build mode.
 void resetTempLine()
          Erases any remnant of the "sticky" line used in graphical addition Members.
 void setBC(Node n, int mode)
          Calls the method of the same name on the local TrussStructure.
 void setBGBlack()
          Changes the color scheme of the DrawArea to correspond to a black background (~15 different items are assigned colors).
 void setBGWhite()
          Changes the color scheme of the DrawArea to correspond to a white background (~15 different items are assigned colors).
 void setGrid(boolean b, int n)
          If boolean b is true, grid is turned on at a spacing of n pixels.
 void setLoad(Node n, double fx, double fy)
          Calls the method of the same name on the local TrussStructure.
 void setSnapDistance(int n)
          Calls the method of the same name on the local TrussStructure.
 void setTrussStructure(TrussStructure t)
          Sets the current TrussStructure according to argument.
 void undo()
          Reverts local TrussStructure to form before last build operation.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, 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, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, 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, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, 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

DRAW_WIDTH

public static final int DRAW_WIDTH
Integer value representing width of the DrawArea. Set to 570 pixels.

DRAW_HEIGHT

public static final int DRAW_HEIGHT
Integer value representing width of the DrawArea. Set to 450 pixels.

X_ORIGIN_OFFSET

public static final int X_ORIGIN_OFFSET
Integer value representing x offset. Used in determining origin on DrawArea with respect to coordinate (0,0) of DrawArea.

Y_ORIGIN_OFFSET

public static final int Y_ORIGIN_OFFSET
Integer value representing y offset. Used in determining origin on DrawArea with respect to coordinate (0,0) of DrawArea. Note: this is in the standard, coordinate geometry meaning of y, not the Java coordinate system.
Constructor Detail

DrawArea

public DrawArea(TorsusView v)
Constructor takes view as an argument to enable communication in both directions between classes.
Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
This method overrides the paintComponent() method of JPanel. Based on the current settings, it will display the appropriate information in the DrawArea.
Overrides:
paintComponent in class javax.swing.JComponent

getTrussStructure

public TrussStructure getTrussStructure()
Returns most current copy of local TrussStructure.

setTrussStructure

public void setTrussStructure(TrussStructure t)
Sets the current TrussStructure according to argument. Used to load a truss from a file.

refresh

public void refresh()
Calls repaint() on self.

paintStructureOnly

public void paintStructureOnly()
Causes DrawArea to display only the structure (build mode).

paintDisplacedNodes

public void paintDisplacedNodes(TrussStructure t)
Causes DrawArea to display only the displaced structure.

paintInternalForces

public void paintInternalForces(TrussStructure t)
Causes DrawArea to display only the internal forces of the structure.

drawLine

public void drawLine(java.awt.Point a,
                     java.awt.Point b)
Draws a line between Points a and b.

drawSnap

public void drawSnap(Node n,
                     boolean b)
Depending on value of boolean b, this method will draw a "snap square" around Node n. Used in informing user that the mouse cursor is within snap distance of Node n.

highlightMember

public void highlightMember(Member m,
                            boolean b)
Depending on value of boolean b, this method will highlight Member m. Used in informing user that the mouse cursor is over Member m (for graphical removal of Members).

highlightModifyNode

public void highlightModifyNode(Node n,
                                boolean b)
Depending on value of boolean b, this method will highlight Node n. Used in informing user that the mouse cursor is over Node n (for graphical modification of Node position).

modifyStructure

public void modifyStructure(Node n,
                            java.awt.Point p)
Calls the method of the same name on the local TrussStructure. Also updates a different local TrussStructure which is used in undo operation.

addMember

public void addMember(Node m,
                      Node n)
Calls the method of the same name on the local TrussStructure. Also updates a different local TrussStructure which is used in undo operation.

removeMember

public void removeMember(Node m,
                         Node n)
Calls the method of the same name on the local TrussStructure. Also updates a different local TrussStructure which is used in undo operation.

resetScreen

public void resetScreen()
Resets local TrussStructure and reverts to build mode. Also updates a different local TrussStructure which is used in undo operation.

resetTempLine

public void resetTempLine()
Erases any remnant of the "sticky" line used in graphical addition Members.

setBC

public void setBC(Node n,
                  int mode)
Calls the method of the same name on the local TrussStructure. Also updates a different local TrussStructure which is used in undo operation.

setBGBlack

public void setBGBlack()
Changes the color scheme of the DrawArea to correspond to a black background (~15 different items are assigned colors).

setBGWhite

public void setBGWhite()
Changes the color scheme of the DrawArea to correspond to a white background (~15 different items are assigned colors). This is the default configuration.

setGrid

public void setGrid(boolean b,
                    int n)
If boolean b is true, grid is turned on at a spacing of n pixels. If boolean b is false, grid is turned off.

setSnapDistance

public void setSnapDistance(int n)
Calls the method of the same name on the local TrussStructure.

setLoad

public void setLoad(Node n,
                    double fx,
                    double fy)
Calls the method of the same name on the local TrussStructure. Also updates a different local TrussStructure which is used in undo operation.

displayNodeMemberNumbers

public void displayNodeMemberNumbers(boolean b)
If boolean b is true, the numbering scheme of the Nodes and Members is displayed. If boolean b is false, the numbering scheme is not displayed.

drawXLoad

public void drawXLoad(Node n,
                      java.awt.Graphics graphics)
Draws the arrow and force corresponding to the of x-component of the load at Node n.

drawYLoad

public void drawYLoad(Node n,
                      java.awt.Graphics graphics)
Draws the arrow and force corresponding to the of y-component of the load at Node n.

undo

public void undo()
Reverts local TrussStructure to form before last build operation.