etomica.graphics
Class DisplayBox

java.lang.Object
  extended by etomica.graphics.Display
      extended by etomica.graphics.DisplayBox
All Implemented Interfaces:
GraphicalElement

public class DisplayBox
extends Display

Displays a picture of a box, with configurations of molecules, boundaries, and other objects as appropriate, assuming 2-dimensional system. Instantiates a ConfigurationCanvas (an inner class of this one) for most of the work. DisplayBox is an input event (mouse and key) listener of the canvas. It receives these events and uses information from them to form and fire a DisplayBoxEvent to registered listeners.


Field Summary
 int[] align
           
protected  AtomFilter atomFilter
           
static int BOTTOM
           
 DisplayCanvas canvas
           
static int CENTER
           
protected  int[] centralOrigin
          Coordinate origin for central image Explicit to 2D because drawing is done to 2D image
protected  ColorScheme colorScheme
           
protected  Controller controller
           
protected  boolean displayBoundary
           
protected  int[] drawSize
          Size of drawing region of central image, in pixels
static int LEFT
           
static int RIGHT
           
protected  double scale
          Factor used to scale the size of the image.
static int TOP
           
 
Fields inherited from class etomica.graphics.Display
label, support
 
Constructor Summary
DisplayBox(ISimulation sim, IBox box, ISpace space, Controller controller)
          Warning: after instantiation, clients using G3DSys may need to toggle display.canvas.setVisible false and then true to fix the 'sometimes gray' bug.
 
Method Summary
 void addDrawable(Drawable obj)
           
 void addDrawable(Object obj)
           
 void computeImageParameters()
           
 void computeImageParameters2(int w, int h)
           
 int getAlign(int i)
           
 AtomFilter getAtomFilter()
          Accessor method for the atom filter that determines which atoms are displayed.
 IBox getBox()
           
 ColorScheme getColorScheme()
          Accessor method for the color scheme used for this display
 LinkedList getDrawables()
           
 int getDrawingHeight()
          return int : height of the drawing area (only relevant for 1D)
 boolean getDrawOverflow()
           
 int[] getDrawSize()
           
static EtomicaInfo getEtomicaInfo()
          Returns a very brief description of Etomica.
 int getImageShells()
           
 int[] getOrigin()
           
 double getPaddingSigma()
          Returns the amount of padding added around the edge of the drawing area.
 Pixel getPixelUnit()
           
 boolean getResizeOnNewBox()
          Get the flag indicating whether the graphic should resize from its currently displayed size when a new box is set.
 double getScale()
           
 boolean getShowBoundary()
          Get the flag indicating if the boundary should be drawn.
 Dimension getSize()
          Gets the size of the box graphic.
 double getToPixels()
           
 Component graphic(Object obj)
          Simulation.GraphicalElement interface method.
 void removeDrawable(Drawable obj)
           
 void removeDrawable(Object obj)
           
 void repaint()
          Repaint the graphic associated with the display box.
 void setAlign(int i, int value)
           
 void setAtomFilter(AtomFilter filter)
          Mutator method for the atom filter that determines which atoms are displayed.
 void setBox(IBox p)
          Specifies the box for this display.
 void setBoxCanvas(DisplayCanvas boxCanvas)
           
 void setColorScheme(ColorScheme colorScheme)
          Accessor method for the color scheme used for this display
 void setDrawingHeight(int newDrawingHeight)
          Set the height of the drawing area (only relevant for 1D)
 void setDrawOverflow(boolean b)
           
 void setImageShells(int n)
          Changes the value of image shells, and increases/decreases scale accordingly.
 void setOriginShift(int dimension, int shift)
          Amount (in pixels) of a simple shift (translation) applied in determing origin.
 void setPaddingSigma(double sigma)
          Sets the amount of padding added around the edge of the drawing area.
 void setPixelUnit(Pixel pixel)
          Sets unit for conversion between simulation units and display pixels.
 void setResizeOnNewBox(boolean b)
          Set the flag indicating whether the graphic should resize from its currently displayed size when a new box is set.
 void setScale(double s)
           
 void setShowBoundary(boolean b)
          Set the flag indicating if the boundary should be drawn.
 
Methods inherited from class etomica.graphics.Display
addPropertyChangeListener, getLabel, graphic, removePropertyChangeListener, setLabel, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
See Also:
Constant Field Values

CENTER

public static final int CENTER
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

TOP

public static final int TOP
See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
See Also:
Constant Field Values

colorScheme

protected ColorScheme colorScheme

atomFilter

protected AtomFilter atomFilter

displayBoundary

protected boolean displayBoundary

canvas

public DisplayCanvas canvas

align

public final int[] align

drawSize

protected final int[] drawSize
Size of drawing region of central image, in pixels

See Also:
#computeDrawSize

scale

protected double scale
Factor used to scale the size of the image. May be used to scale up or down the image within one box without affecting those in other displays. Default value is 1.0.


centralOrigin

protected final int[] centralOrigin
Coordinate origin for central image Explicit to 2D because drawing is done to 2D image


controller

protected final Controller controller
Constructor Detail

DisplayBox

public DisplayBox(ISimulation sim,
                  IBox box,
                  ISpace space,
                  Controller controller)
Warning: after instantiation, clients using G3DSys may need to toggle display.canvas.setVisible false and then true to fix the 'sometimes gray' bug. i.e.; = new ColorSchemeByType() if(display.canvas instanceof JComponent) { ((JComponent)display.canvas).setVisible(false); ((JComponent)display.canvas).setVisible(true); }

Parameters:
box -
Method Detail

getEtomicaInfo

public static EtomicaInfo getEtomicaInfo()
Returns a very brief description of Etomica.

Returns:
static EtomicaInfo

getSize

public Dimension getSize()
Gets the size of the box graphic.

Returns:
java.awt.Dimension : Dimension object containing box graphic size

setOriginShift

public void setOriginShift(int dimension,
                           int shift)
Amount (in pixels) of a simple shift (translation) applied in determing origin. Usually zero, but can be set to any value by passing in dimension and the number of pixels to shift in the specified dimension.

Dimension : 0 => X direction 1 => Y direction 2 => Z direction (not used)


getOrigin

public int[] getOrigin()
Returns:
int[] :

getDrawSize

public int[] getDrawSize()
Returns:
int[] :

setAlign

public void setAlign(int i,
                     int value)

getAlign

public int getAlign(int i)
Returns:
int :

getDrawOverflow

public final boolean getDrawOverflow()
Returns:
final boolean :

setDrawOverflow

public final void setDrawOverflow(boolean b)

getToPixels

public double getToPixels()
Returns:
double

setScale

public void setScale(double s)

getScale

public double getScale()
Returns:
double

addDrawable

public void addDrawable(Drawable obj)

removeDrawable

public void removeDrawable(Drawable obj)

addDrawable

public void addDrawable(Object obj)

removeDrawable

public void removeDrawable(Object obj)

getBox

public final IBox getBox()
Returns:
Box : the box associated with this display

getPaddingSigma

public double getPaddingSigma()
Returns the amount of padding added around the edge of the drawing area. This allows atoms at the edge of the boundary to be fully drawn. The padding is given in terms of simulations length units (Angstroms) and should (in general) be equal to the diameter of atoms in the box.


setPaddingSigma

public void setPaddingSigma(double sigma)
Sets the amount of padding added around the edge of the drawing area. This allows atoms at the edge of the boundary to be fully drawn. The padding is given in terms of simulations length units (Angstroms) and should (in general) be equal to the diameter of atoms in the box. DisplayBoxCanvas2D is currently the only thing that pays attention to this.


setBox

public void setBox(IBox p)
Specifies the box for this display. Updates atomIterator appropriately.


setBoxCanvas

public void setBoxCanvas(DisplayCanvas boxCanvas)

setColorScheme

public void setColorScheme(ColorScheme colorScheme)
Accessor method for the color scheme used for this display


getColorScheme

public ColorScheme getColorScheme()
Accessor method for the color scheme used for this display

Returns:
ColorScheme

setAtomFilter

public void setAtomFilter(AtomFilter filter)
Mutator method for the atom filter that determines which atoms are displayed. Atoms for which the filter returns false are not displayed. Default is null, meaning all atoms are displayed.


getAtomFilter

public AtomFilter getAtomFilter()
Accessor method for the atom filter that determines which atoms are displayed. Atoms for which the filter returns false are not displayed. Default is null, meaning all atoms are displayed.

Returns:
Atomfilter

getDrawables

public LinkedList getDrawables()
Returns:
LinkedList

graphic

public Component graphic(Object obj)
Simulation.GraphicalElement interface method. Overrides Display method to return the DisplayBox.Canvas as the display object.

Specified by:
graphic in interface GraphicalElement
Overrides:
graphic in class Display
Parameters:
obj - ignored by this method.
Returns:
Component
See Also:
Device, Display

getImageShells

public int getImageShells()
Returns:
int : the current value of imageShells.

setImageShells

public void setImageShells(int n)
Changes the value of image shells, and increases/decreases scale accordingly.

Parameters:
n - the new value of imageShells

computeImageParameters

public void computeImageParameters()

computeImageParameters2

public void computeImageParameters2(int w,
                                    int h)
Parameters:
int - w :
int - h :

repaint

public void repaint()
Repaint the graphic associated with the display box.

Overrides:
repaint in class Display

getPixelUnit

public Pixel getPixelUnit()
Returns:
Pixel : unit for conversion between simulation units and display pixels.

setPixelUnit

public void setPixelUnit(Pixel pixel)
Sets unit for conversion between simulation units and display pixels.

Parameters:
Pixel - :

setDrawingHeight

public void setDrawingHeight(int newDrawingHeight)
Set the height of the drawing area (only relevant for 1D)

Parameters:
int - newDrawingHeight :

getDrawingHeight

public int getDrawingHeight()
return int : height of the drawing area (only relevant for 1D)


setShowBoundary

public void setShowBoundary(boolean b)
Set the flag indicating if the boundary should be drawn.

Parameters:
boolean - b : draw boundary flag

getShowBoundary

public boolean getShowBoundary()
Get the flag indicating if the boundary should be drawn.

Returns:
boolean

setResizeOnNewBox

public void setResizeOnNewBox(boolean b)
Set the flag indicating whether the graphic should resize from its currently displayed size when a new box is set.

Parameters:
boolean - b

getResizeOnNewBox

public boolean getResizeOnNewBox()
Get the flag indicating whether the graphic should resize from its currently displayed size when a new box is set.

Returns:
boolean