Package snap.viewx

Class ColorDock

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable

public class ColorDock extends View
A View that handle a whole grid of color swatches, including drag and drop support.
  • Constructor Details

    • ColorDock

      public ColorDock()
      Creates a new color dock.
  • Method Details

    • getColor

      public Color getColor()
      Returns the color of the selected swatch.
    • setColor

      public void setColor(Color aColor)
      Sets the color of the selected swatch.
    • getColor

      public Color getColor(int anIndex)
      Returns the color at the given swatch index.
    • setColor

      public void setColor(Color aColor, int anIndex)
      Sets the color at the given swatch index.
    • setColors

      public void setColors(List<? extends Color> theColors)
      Sets the colors.
    • getColor

      public Color getColor(int aRow, int aCol)
      Returns the color at given row & column.
    • setColor

      public void setColor(int aRow, int aCol, Color aColor)
      Sets the color at the given row & column.
    • isPersistent

      public boolean isPersistent()
      Returns whether this doc writes itself out to preferences.
    • setPersistent

      public void setPersistent(boolean aFlag)
      Sets whether this dock writes itself out to preferences.
    • getSwatch

      public ColorDock.Swatch getSwatch(int anIndex)
      Returns the swatch at given index.
    • getSwatch

      public ColorDock.Swatch getSwatch(int aRow, int aCol)
      Returns the swatch at given row+col.
    • getSwatchAt

      public ColorDock.Swatch getSwatchAt(Point aPoint)
      Returns the swatch at given point.
    • getSwatchAt

      public ColorDock.Swatch getSwatchAt(double aX, double aY)
      Returns the swatch at given point.
    • getRowCount

      public int getRowCount()
      Returns the number of rows in this color dock.
    • getColCount

      public int getColCount()
      Returns the number of columns in this color dock.
    • getSwatchCount

      public int getSwatchCount()
      Returns the total number of visible swatches.
    • getSelSwatch

      public ColorDock.Swatch getSelSwatch()
      Returns the selected swatch.
    • setSelSwatch

      public void setSelSwatch(ColorDock.Swatch aSwatch)
      Sets the selected swatch.
    • getSelIndex

      public int getSelIndex()
      Returns the selected swatch index.
    • resetColors

      public void resetColors()
      Resets the colors in colordock to white.
    • isSelected

      public boolean isSelected()
      Returns whether color dock is selected.
    • setSelected

      public void setSelected(boolean aValue)
      Sets whether color dock is selected.
    • isSelectable

      public boolean isSelectable()
      Returns whether or not the dock can be selected.
    • setSelectable

      public void setSelectable(boolean aValue)
      Sets whether or not the dock can be selected.
    • paintFront

      protected void paintFront(Painter aPntr)
      Paints this color dock component.
      Overrides:
      paintFront in class View
    • processEvent

      protected void processEvent(ViewEvent anEvent)
      Handle events.
      Overrides:
      processEvent in class View
    • colorDropped

      protected void colorDropped(ViewEvent anEvent)
      Called when color is dropped on dock.
    • startColorDrag

      protected void startColorDrag(ViewEvent anEvent)
      Called when color is dropped on dock.
    • colorWellDidFireAction

      protected void colorWellDidFireAction(ViewEvent anEvent)
      Called when color well fires action event.
    • saveToPrefs

      protected void saveToPrefs(String aName, int anIndex)
      Update an individual color at {row,column} in the preferences
    • readFromPrefs

      protected void readFromPrefs(String aName)
      Read color well color from preferences.
    • setShowing

      protected void setShowing(boolean aValue)
      Override to set Selected to false when hidden.
      Overrides:
      setShowing in class View
    • getDefaultBorder

      public Border getDefaultBorder()
      Override to return dock border.
      Overrides:
      getDefaultBorder in class View