Class TriangularByteLattice

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

public class TriangularByteLattice extends Object implements Measurable
A TriangularByteLattice is an array where each array element can assume one of 256 values. Values can be set between -128 and 127. Because byte values larger than 127 overflow to negative, values can also be set between 0 and 255.
Version:
1.0
Author:
Joshua Gould, Wolfgang Christian
  • Constructor Summary

    Constructors
    Constructor
    Description
    TriangularByteLattice(int _row, int _col)
    Constructs a byte lattice with the given size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    Draws the lattice.
    int
    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
    Ranomizes the lattice values.
    void
    resizeLattice(int _row, int _col)
     
    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, byte 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
    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)
     
    void
    setRow(int row, int col_offset, byte[] val)
    Sets a row of cells to new values.
    void
    setVisible(boolean _vis)
     
    void
    Shows the color associated with each value.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.opensourcephysics.display.Drawable

    isInteractive
  • Constructor Details

    • TriangularByteLattice

      public TriangularByteLattice(int _row, int _col)
      Constructs a byte lattice with the given size. Cell values are -128 to 127.
      Parameters:
      _row - the number of rows
      _col - the number of columns
  • Method Details

    • resizeLattice

      public void resizeLattice(int _row, int _col)
    • setVisible

      public void setVisible(boolean _vis)
    • setMinMax

      public void setMinMax(double xmin, double xmax, double ymin, double ymax)
    • draw

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

      public void setBlock(int row_offset, int col_offset, byte[][] val)
      Sets a block of cells to new values.
      Parameters:
      row_offset -
      col_offset -
      val -
    • setBlock

      public void setBlock(int row_offset, int col_offset, int[][] val)
      Sets a block of cells to new values.
      Parameters:
      row_offset -
      col_offset -
      val -
    • setCol

      public void setCol(int row_offset, int col, byte[] val)
      Sets a column of cells to new values.
      Parameters:
      row_offset -
      col -
      val -
    • setRow

      public void setRow(int row, int col_offset, byte[] val)
      Sets a row of cells to new values.
      Parameters:
      row -
      col_offset -
      val -
    • setCell

      public void setCell(int row, int col, byte val)
      Sets a lattice cell to a new value.
      Parameters:
      row -
      col -
      val -
    • getCell

      public int getCell(int row, int col)
      Gets a lattice cell value.
      Parameters:
      row -
      col -
      Returns:
      the cell value.
    • randomize

      public void randomize()
      Ranomizes the lattice values.
    • showLegend

      public void showLegend()
      Shows the color associated with each value.
    • setColorPalette

      public void setColorPalette(Color[] colors)
      Sets the color palette.
      Parameters:
      colors -
    • setIndexedColor

      public void setIndexedColor(int i, Color color)
      Sets the color for a single index.
      Parameters:
      i -
      color -
    • 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
    • createDefaultColors

      public void createDefaultColors()