Class VertexStylePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ListCellRenderer

public class VertexStylePanel extends JPanel implements ListCellRenderer
A JPanel for styling a vertex. The stylings you can apply to the VertexStylesFactory.
Author:
Matthias Scholz <ms@jammerhund.de>
See Also:
  • Field Details

    • DEFAULT_VERTEX_COLOR

      public static final Color DEFAULT_VERTEX_COLOR
      Default vertex Color is yellow.
    • DEFAULT_VERTEX_FORM

      public static final String DEFAULT_VERTEX_FORM
      Default vertex form is a square.
      See Also:
    • DEFAULT_VERTEX_SIZE

      public static final Integer DEFAULT_VERTEX_SIZE
      Default vertex size is 5 points.
  • Constructor Details

    • VertexStylePanel

      public VertexStylePanel()
      Creates a new panel.
    • VertexStylePanel

      public VertexStylePanel(boolean displayRestoreDefaultsButton)
      Creates a new panel.
      Parameters:
      displayRestoreDefaultsButton - - should the restore defaults button be displayed?
  • Method Details

    • getVertexColor

      public Color getVertexColor()
      Gets the vertex color.
      Returns:
      the vertex color
    • getVertexForm

      public String getVertexForm()
      Gets the vertex form as a Sting.
      Returns:
      the vertex form.
    • getVertexSize

      public int getVertexSize()
      Gets the vertex size.
      Returns:
      the vertex size.
    • setVertexColor

      public void setVertexColor(Color color)
      Sets the vertex color.
    • setVertexForm

      public void setVertexForm(String form)
      Sets the vertex form. For possible forms please see VertexStylesFactory constants.
    • setVertexSize

      public void setVertexSize(int size)
      Sets the vertex Size.
    • getListCellRendererComponent

      public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
      This is the ListCellRenderer for the vertexStyleComboBox, because the items are String arrays. So we need an own renderer, that displays the first index of the array.
      Specified by:
      getListCellRendererComponent in interface ListCellRenderer
      Parameters:
      list - a list of component showing vertex styles
      value - values as a String array
      index -
      isSelected - whether the component is selected or not
      cellHasFocus - whether the component has focus or not
      Returns:
      the label representing the first vertex style of the list