Class PersistableSwatchChooserPanel.SwatchPanel

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.wisc.ssec.mcidasv.ui.PersistableSwatchChooserPanel.SwatchPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
PersistableSwatchChooserPanel.MainSwatchPanel, PersistableSwatchChooserPanel.RecentSwatchPanel
Enclosing class:
PersistableSwatchChooserPanel

This the base class for all swatch panels. Swatch panels are panels that hold a set of blocks where colors are displayed.
  • Field Details

    • cellWidth

      protected int cellWidth
      Width of each block.
    • cellHeight

      protected int cellHeight
      Height of each block.
    • gap

      protected int gap
      Gap between blocks.
    • numRows

      protected int numRows
      Number of rows in the swatch panel.
    • numCols

      protected int numCols
      Number of columns in the swatch panel.
    • selRow

      protected int selRow
      Row of the selected color's cell.
    • selCol

      protected int selCol
      Column of the selected color's cell.
  • Constructor Details

    • SwatchPanel

      Creates a new SwatchPanel object.
  • Method Details

    • getPreferredSize

      This method returns the preferred size of the swatch panel based on the number of rows and columns and the size of each cell.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      Preferred size of the swatch panel.
    • getSelectedColor

      Return the "selected" color.
      Returns:
      The color at selRow and selCol.
    • getColorForPosition

      public abstract Color getColorForPosition(int x, int y)
      This method returns the color for the given position.
      Parameters:
      x - X coordinate of the position.
      y - Y coordinate of the position.
      Returns:
      The color at the given position.
    • getColorForCell

      public abstract Color getColorForCell(int row, int column)
      Return the color at a given cell.
      Parameters:
      row - Cell row.
      column - Cell column.
      Returns:
      Color of the cell at row and column.
    • initializeColors

      protected abstract void initializeColors()
      This method initializes the colors for the swatch panel.
    • setSelectedCellFromPosition

      protected abstract void setSelectedCellFromPosition(int x, int y)
      Set the "selected" cell using screen location.
      Parameters:
      x - X coordinate of the position.
      y - Y coordinate of the position.