gui
Class DrawPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by gui.DrawPanel
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class DrawPanel
extends java.awt.Panel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener

Responsible for drawing the 3D-view. Draws the 3D-view and enables mouse dragging of the objects. Please note: The code of this class originates from http://www.dgp.toronto.edu/~mjmcguff/learn/java/11-3d/ but has been modified.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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
(package private)  LabeledEdge[] axedges
          List of Axes (that means 3)
(package private)  int azimuth
          coordinates of the viewpoint
(package private)  java.awt.Image backbuffer
           
(package private)  java.awt.Graphics2D backg
           
(package private)  int elevation
          coordinates of the viewpoint
(package private)  int halfsize
          Half the size of the 3D-area base length
(package private)  LabeledEdge[] ledges
          List of all edges that should be drawn
(package private)  LabeledPoint[] lvertices
          List of all points to draw
(package private)  int mx
          The most recently recorded mouse coordinates
(package private)  int my
          The most recently recorded mouse coordinates
(package private)  Parameter param
           
private static long serialVersionUID
           
 
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
DrawPanel(int drawboardsize, java.awt.Image backbuffer, java.awt.Graphics2D backg, Parameter param)
          Initializes the DrawPanel.
 
Method Summary
 void drawAgain(AbstractCrystal crystal)
          For drawing a new lattice.
 void drawWireframe(java.awt.Graphics2D g)
          Drawing the 3D-view.
 int getAzimuth()
          gets the recent value of the azimuth coordinate
 int getElevation()
          gets the recent value of the elevation coordinate
 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 mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void paint(java.awt.Graphics g)
           
 void setAzimuth(int newazimuth)
          set the wireframe azimuth
 void setElevation(int newelevation)
          set the wireframe elevation
 void update(java.awt.Graphics g)
           
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

halfsize

int halfsize
Half the size of the 3D-area base length


mx

int mx
The most recently recorded mouse coordinates


my

int my
The most recently recorded mouse coordinates


backbuffer

java.awt.Image backbuffer

backg

java.awt.Graphics2D backg

azimuth

int azimuth
coordinates of the viewpoint


elevation

int elevation
coordinates of the viewpoint


lvertices

LabeledPoint[] lvertices
List of all points to draw


axedges

LabeledEdge[] axedges
List of Axes (that means 3)


ledges

LabeledEdge[] ledges
List of all edges that should be drawn


param

Parameter param
Constructor Detail

DrawPanel

public DrawPanel(int drawboardsize,
                 java.awt.Image backbuffer,
                 java.awt.Graphics2D backg,
                 Parameter param)
Initializes the DrawPanel. Defines the drawing area, and constructs Points for later drawing the axes.

Parameters:
drawboardsize -
backbuffer - Representing the graphical image, or here, a area to draw in.
backg - Class for rendering 2D-shapes.
param - Contains all necessary parameters.
Method Detail

drawAgain

public void drawAgain(AbstractCrystal crystal)
For drawing a new lattice. This should be evoked, whenever the lattice changes. Then it starts a calculation of all lattice points.

Parameters:
crystal - The class representing the recent lattice.

drawWireframe

public void drawWireframe(java.awt.Graphics2D g)
Drawing the 3D-view. This function is responsible for calculating the coordinates, in dependence of azimuth and elevation, and drawing points and edges. It is therefore evoked, whenever the selected crystal is changed and whenever the mouse is used for dragging the picture.

Parameters:
g - Responsible for 2D-Drawings.

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

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

mouseReleased

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

mouseMoved

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

mouseDragged

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

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Container

getAzimuth

public int getAzimuth()
gets the recent value of the azimuth coordinate


getElevation

public int getElevation()
gets the recent value of the elevation coordinate


mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

setAzimuth

public void setAzimuth(int newazimuth)
set the wireframe azimuth

Parameters:
newazimuth -
author Poms

setElevation

public void setElevation(int newelevation)
set the wireframe elevation

Parameters:
newelevation -
author Poms