Package dialog

Class ColorDialog

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class ColorDialog extends JDialog
Class for a dialog to choose colors for attribute values.
Since:
2007.02.18
See Also:
  • Constructor Details

    • ColorDialog

      public ColorDialog()
      Create a color selection dialog.
      Since:
      2007.02.18 (Christian Borgelt)
    • ColorDialog

      public ColorDialog(Frame owner)
      Create a color selection dialog.
      Parameters:
      owner - the component that is to own the dialog box
      Since:
      2007.02.18 (Christian Borgelt)
    • ColorDialog

      public ColorDialog(Frame owner, String title)
      Create a color selection dialog.
      Parameters:
      owner - the component that is to own the dialog box
      title - the title of the dialog box
      Since:
      2023.05.17 (Christian Borgelt)
    • ColorDialog

      public ColorDialog(Frame owner, String title, boolean apply)
      Create a color selection dialog.
      Parameters:
      owner - the component that is to own the dialog box
      title - the title of the dialog box
      apply - whether to add an "Apply" button
      Since:
      2023.05.17 (Christian Borgelt)
  • Method Details

    • addActionListener

      public void addActionListener(ActionListener al)
      Add a listener for finalizing a selection.
      Parameters:
      al - the listener to add
      Since:
      2007.02.20 (Christian Borgelt)
    • getColor

      public Color getColor()
      Get currently selected color.
      Returns:
      the curently selected color
      Since:
      2007.02.20 (Christian Borgelt)
    • setColor

      public void setColor(Color color)
      Set the current color.
      Parameters:
      color - the color to set
      Since:
      2007.02.20 (Christian Borgelt)
    • setTable

      public boolean setTable(table.Table tab)
      Set the table for which to select colors.
      Parameters:
      tab - the table for which to select colors
      Returns:
      whether a selection is possible (at least one value)
      Since:
      2007.02.20 (Christian Borgelt)
    • setTable

      public boolean setTable(table.Table tab, boolean marked)
      Set the table for which to select colors.
      Parameters:
      tab - the table for which to select colors
      marked - whether to consider only marked columns
      Returns:
      whether a selection is possible (at least one value)
      Since:
      2007.07.17 (Christian Borgelt)
    • setTable

      public boolean setTable(table.Table tab, int show)
      Set the table for which to select colors.
      Parameters:
      tab - the table for which to select colors
      show - which selectors to show
      Returns:
      whether a selection is possible (at least one value)
      Since:
      2007.07.17 (Christian Borgelt)
    • setTable

      public boolean setTable(table.Table tab, boolean marked, int show)
      Set the table for which to select colors.
      Parameters:
      tab - the table for which to select colors
      marked - whether to consider only marked columns
      show - which selectors to show
      Returns:
      whether a selection is possible (at least one value)
      Since:
      2007.02.20 (Christian Borgelt)
    • getTable

      public table.Table getTable()
      Get the table for which to select colors.
      Returns:
      the table for which to select colors
      Since:
      2007.02.24 (Christian Borgelt)
    • setSelectedAtt

      public void setSelectedAtt(String name)
      Set the attribute for whose values to set colors.
      Parameters:
      name - the name of the attribute to set
      Since:
      2007.02.23 (Christian Borgelt)
    • setSelectedValue

      public void setSelectedValue(String name)
      Set the value for which to set colors.
      Parameters:
      name - the name of the value to set
      Since:
      2007.02.23 (Christian Borgelt)
    • showSelectors

      public void showSelectors(int cnt)
      Show or hide the attribute and attribute value selectors.

      Either both attribute selector attribute value selector can be shown (cnt ≥ 2), or only the attribute value selector can be shown (cnt == 1), or only the color chooser itself can be shown (cnt == 0).

      Parameters:
      cnt - the number of selectors to show
      Since:
      2007.07.17 (Christian Borgelt)
    • loadColorsFromTable

      public void loadColorsFromTable()
      Load colors from the table.

      If a color does not exist, a default color is generated and stored in the table.

      Since:
      2007.02.20 (Christian Borgelt)
    • saveColorsInTable

      public void saveColorsInTable()
      Save colors in the table.

      If a listener has been registered with the dialog, it is notified that the colors have changed.

      Since:
      2007.02.20 (Christian Borgelt)
    • main

      public static void main(String[] args)
      Main function for testing basic functionality.
      Parameters:
      args - the command line arguments
      Since:
      2007.07.18 (Christian Borgelt)