Class TriangularBinaryLattice

java.lang.Object
org.opensourcephysics.display2d.TriangularBinaryLattice
All Implemented Interfaces:
Drawable, Measurable

public class TriangularBinaryLattice extends Object implements Measurable
A TriangularBinaryLattice is an array where each array element has a value of 0 or 1.
Version:
1.0
Author:
Joshua Gould, Wolfgang Christian
  • Constructor Summary

    Constructors
    Constructor
    Description
    TriangularBinaryLattice(int _nrow, int _ncol)
    Constructs a binary lattice with the given size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Draws the lattice.
    byte
    getCell(int _row, int _col)
    Gets a lattice cell value.
    double
    Gets the maximum x needed to draw this object.
    double
    Gets the minimum x needed to draw this object.
    double
    Gets the maximum y needed to draw this object.
    double
    Gets the minimum y needed to draw this object.
    boolean
    Determines if information is available to set min/max values.
    void
    Randomizes the lattice values.
    void
    randomize(double probability)
    Randomizes the lattice values with the specified probability.
    void
    resizeLattice(int _nrow, int _ncol)
    Resize the lattice.
    void
    setBlock(int row_offset, int col_offset, byte[][] val)
    Sets a block of cells to new values.
    void
    setBlock(int row_offset, int col_offset, int[][] val)
    Sets a block of cells to new values.
    void
    setCell(int _row, int _col, int val)
    Sets a lattice cell to a new value.
    void
    setCol(int row_offset, int col, byte[] val)
    Sets a column of cells to new values.
    void
    setCol(int row_offset, int col, int[] val)
    Sets a column of cells to new values.
    void
    Sets the color palette.
    void
    setIndexedColor(int i, Color color)
    Sets the color for a single index.
    void
    setMinMax(double xmin, double xmax, double ymin, double ymax)
    Scales this lattice to the given values in world units.
    void
    setRow(int row, int col_offset, byte[] val)
    Sets a row of cells to new values starting at the given column.
    void
    setRow(int row, int col_offset, int[] val)
    Sets a row of cells to new values starting at the given column.
    void
    setVisible(boolean _vis)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.opensourcephysics.display.Drawable

    isInteractive
  • Constructor Details

    • TriangularBinaryLattice

      public TriangularBinaryLattice(int _nrow, int _ncol)
      Constructs a binary lattice with the given size.
      Parameters:
      _nrow - the number of rows
      _ncol - the number of columns
  • Method Details

    • resizeLattice

      public void resizeLattice(int _nrow, int _ncol)
      Resize the lattice.
      Parameters:
      _nx - number of x sites
      _ny - number of y sites
    • setVisible

      public void setVisible(boolean _vis)
    • isMeasured

      public boolean isMeasured()
      Description copied from interface: Measurable
      Determines if information is available to set min/max values. Objects that store data should return false if data is null.
      Specified by:
      isMeasured in interface Measurable
      Returns:
      true if min/max values are valid
    • getXMin

      public double getXMin()
      Description copied from interface: Measurable
      Gets the minimum x needed to draw this object.
      Specified by:
      getXMin in interface Measurable
      Returns:
      minimum
    • getYMin

      public double getYMin()
      Description copied from interface: Measurable
      Gets the minimum y needed to draw this object.
      Specified by:
      getYMin in interface Measurable
      Returns:
      minimum
    • getXMax

      public double getXMax()
      Description copied from interface: Measurable
      Gets the maximum x needed to draw this object.
      Specified by:
      getXMax in interface Measurable
      Returns:
      maximum
    • getYMax

      public double getYMax()
      Description copied from interface: Measurable
      Gets the maximum y needed to draw this object.
      Specified by:
      getYMax in interface Measurable
      Returns:
      minimum
    • randomize

      public void randomize()
      Randomizes the lattice values.
    • randomize

      public void randomize(double probability)
      Randomizes the lattice values with the specified probability. A probability of 1 indicates that all cells will be occupied.
      Parameters:
      probability - the probability of a site being occupied, between 0.0 and 1.0.
    • draw

      public void draw(DrawingPanel panel, Graphics g)
      Draws the lattice.
      Specified by:
      draw in interface Drawable
      Parameters:
      panel -
      g -
    • setMinMax

      public void setMinMax(double xmin, double xmax, double ymin, double ymax)
      Scales this lattice to the given values in world units.
      Parameters:
      xmin -
      xmax -
      ymin -
      ymax -
    • setBlock

      public void setBlock(int row_offset, int col_offset, int[][] val)
      Sets a block of cells to new values. A cell is set to 1 if the value is >0; the cell is set to zero otherwise
      Parameters:
      row_offset -
      col_offset -
      val - the array of values
    • setBlock

      public void setBlock(int row_offset, int col_offset, byte[][] val)
      Sets a block of cells to new values. A cell is set to 1 if the value is >0; the cell is set to zero otherwise
      Parameters:
      row_offset -
      col_offset -
      val - the array of values
    • setCol

      public void setCol(int row_offset, int col, int[] val)
      Sets a column of cells to new values. A cell is set to 1 if the value is > 0; the cell is set to zero otherwise
      Parameters:
      row_offset -
      col -
      val - the array of values
    • setCol

      public void setCol(int row_offset, int col, byte[] val)
      Sets a column of cells to new values. A cell is set to 1 if the value is > 0; the cell is set to zero otherwise
      Parameters:
      row_offset -
      col -
      val - the array of values
    • setRow

      public void setRow(int row, int col_offset, int[] val)
      Sets a row of cells to new values starting at the given column. A cell is set to 1 if the value is >0; the cell is set to zero otherwise
      Parameters:
      row -
      col_offset - the colum offset
      val - the value
    • setRow

      public void setRow(int row, int col_offset, byte[] val)
      Sets a row of cells to new values starting at the given column. A cell is set to 1 if the value is >0; the cell is set to zero otherwise
      Parameters:
      row -
      col_offset - the colum offset
      val - the value
    • setCell

      public void setCell(int _row, int _col, int val)
      Sets a lattice cell to a new value. A cell should take on a value of 0 or 1.
      Parameters:
      _row -
      _col -
      val -
    • getCell

      public byte getCell(int _row, int _col)
      Gets a lattice cell value. Cell values are zero or one.
      Parameters:
      _row -
      _col -
      Returns:
      the cell value.
    • setColorPalette

      public void setColorPalette(Color[] colors)
      Sets the color palette. The color at the 0th index of the array is set to the zero color.
      Parameters:
      colors -
    • setIndexedColor

      public void setIndexedColor(int i, Color color)
      Sets the color for a single index.
      Parameters:
      i - the value to set the color for.
      color -
    • toString

      public String toString()
      Overrides:
      toString in class Object