Class MetaPanel

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

public class MetaPanel extends JPanel implements Scrollable
Panel for displaying metadata under headings. It is designed to be contained in a scrollpane with vertical scrolling.
Since:
16 Feb 2015
Author:
Mark Taylor
See Also:
  • Constructor Details

    • MetaPanel

      public MetaPanel()
      Constructor.
  • Method Details

    • addLineField

      public JTextComponent addLineField(String heading)
      Adds a field for displaying a single-line item.
      Parameters:
      heading - item heading text
      Returns:
      component whose content can be set
    • addMultiLineField

      public JTextComponent addMultiLineField(String heading)
      Adds a field for displaying a text item with potentially multiple lines.
      Parameters:
      heading - item heading text
      Returns:
      component whose content can be set
    • addHtmlField

      public JTextComponent addHtmlField(String heading)
      Adds a field for displaying a text item formatted as HTML text.
      Parameters:
      heading - item heading text
      Returns:
      component whose content can be set
    • addUrlField

      public JTextComponent addUrlField(String heading, UrlHandler urlHandler)
      Adds a field intended to contain a clickable URL. If a non-null UrlHandler is supplied, its UrlHandler.clickUrl(java.net.URL) method is invoked when the user clicks on this field.
      Parameters:
      heading - item heading text
      urlHandler - handler used when the field is clicked on; may be null
    • setFieldText

      public void setFieldText(JTextComponent field, String text)
      Sets the content of a field. As well as the obvious, it fixes it so that after the text is added it's positioned correctly.
      Parameters:
      field - field
      text - new content
    • setLogo

      public void setLogo(Icon logoIcon)
      Sets an image to be displayed at the top of this panel.
      Parameters:
      logoIcon - image, may be null
    • setLogoUrl

      public void setLogoUrl(URL iconUrl)
      Sets the URL of an image to be displayed at the top of this panel. This will take care not to block the GUI even if the image is slow to load.
      Parameters:
      iconUrl - URL of icon
    • getPreferredScrollableViewportSize

      public Dimension getPreferredScrollableViewportSize()
      Specified by:
      getPreferredScrollableViewportSize in interface Scrollable
    • getScrollableUnitIncrement

      public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
      Specified by:
      getScrollableUnitIncrement in interface Scrollable
    • getScrollableBlockIncrement

      public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
      Specified by:
      getScrollableBlockIncrement in interface Scrollable
    • getScrollableTracksViewportWidth

      public boolean getScrollableTracksViewportWidth()
      Specified by:
      getScrollableTracksViewportWidth in interface Scrollable
    • getScrollableTracksViewportHeight

      public boolean getScrollableTracksViewportHeight()
      Specified by:
      getScrollableTracksViewportHeight in interface Scrollable
    • mapToHtml

      public static String mapToHtml(Map<String,?> map)
      Converts a string-keyed map to an HTML string suitable for display in an HTML text field of a metapanel.
      Parameters:
      map - map containing display items
      Returns:
      renderable HTML representation of map