org.faceless.pdf2.viewer2

## Class ToggleViewerWidget

- java.lang.Object
- - org.faceless.pdf2.viewer2.ViewerFeature
  - - org.faceless.pdf2.viewer2.ViewerWidget
    - - org.faceless.pdf2.viewer2.ToggleViewerWidget

- Direct Known Subclasses:
    AbstractRegionSelector, ContinuousPageView, DragScroll, DualPageView, SinglePageView, TextTool, ZoomFit, ZoomFitHeight, ZoomFitWidth

      public abstract class ToggleViewerWidget
      extends ViewerWidget

  An subclass of `ViewerWidget` which causes the widget to be toggled on or off, rather than simply pushed. ToggleViewerWidget objects may be part of a "group", in which case when this object is selected, all objects in the same group are deselected.

  This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

  Since:
    2.10

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ToggleViewerWidget(String name, String groupname)` Create a new ToggleViewerWidget

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `action(ViewerEvent event)` Toggle the active state of this widget by calling `setSelected(boolean)`
    `String` | `getGroupName()` Return the name of the group this widget is part of, or `null` if no group was specified
    `JComponent` | `getGroupOwner()` Return the "owner" of this Widget's group.
    `ToggleViewerWidget` | `getGroupSelection(String groupname)` Return the selected item in the specified group, or `null` if none of the items in that group are selected or no such group exists.
    `Collection<ToggleViewerWidget>` | `getWidgets(String groupname)` Return a Collection of other `ToggleViewerWidget` objects in the specified group.
    `void` | `initialize(PDFViewer viewer)` Called when the feature is first added to a viewer
    `boolean` | `isSelected()` Return whether this ViewerWidget is selected
    `void` | `setGroupOwner(JComponent comp)` Set the "owner" for this Widget's group.
    `void` | `setSelected(boolean selected)` Set whether this Widget is selected.
    `protected void` | `updateViewport(DocumentViewport viewport, boolean selected)` Called from `setSelected(boolean)`, this method is called in each viewport in use by the `PDFViewer` or `DocumentPanel` so it can update its status.

    - ### Methods inherited from class org.faceless.pdf2.viewer2.ViewerWidget

      `createActionListener, getComponent, getIcon, getViewer, isButtonEnabledByDefault, isDocumentRequired, isMenuEnabledByDefault, setButton, setComponent, setDocumentRequired, setMenu, setMenu, setToolBarEnabled, setToolBarEnabledAlways, setToolBarFloatable, setToolBarFloating, toString`

    - ### Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature

      `getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ToggleViewerWidget

          protected ToggleViewerWidget(String name,
                                       String groupname)

      Create a new ToggleViewerWidget
      Parameters:
        `name` - the name of the Widget
        `groupname` - the group this widget is part of, or `null` for no group

  - ### Method Detail

    - #### initialize

          public void initialize(PDFViewer viewer)

      Description copied from class: `ViewerFeature`
      Called when the feature is first added to a viewer
      Overrides:
        `initialize` in class `ViewerWidget`

    - #### getGroupName

          public final String getGroupName()

      Return the name of the group this widget is part of, or `null` if no group was specified

    - #### setGroupOwner

          public final void setGroupOwner(JComponent comp)

      Set the "owner" for this Widget's group. This is typically the `PDFViewer` and set automatically - the only time this method needs to be called manually is when no PDFViewer is in use and these widgets are being applied directly to a `DocumentPanel`.
      Parameters:
        `comp` - the JComponent that owns the group this widget is part of

    - #### getGroupOwner

          public final JComponent getGroupOwner()

      Return the "owner" of this Widget's group.

    - #### action

          public void action(ViewerEvent event)

      Toggle the active state of this widget by calling `setSelected(boolean)`
      Overrides:
        `action` in class `ViewerWidget`

    - #### setSelected

          public void setSelected(boolean selected)

      Set whether this Widget is selected. If active is true, this method will automatically call `setSelected(false)` on all the other widgets in this group. Subclasses should override this method to do whatever they need to do when their active status is changed.
      Parameters:
        `selected` - whether this Widget is active or not

    - #### updateViewport

          protected void updateViewport(DocumentViewport viewport,
                                        boolean selected)

      Called from `setSelected(boolean)`, this method is called in each viewport in use by the `PDFViewer` or `DocumentPanel` so it can update its status. By default it is a no-op.
      Since:
        2.10.3

    - #### isSelected

          public boolean isSelected()

      Return whether this ViewerWidget is selected

    - #### getGroupSelection

          public ToggleViewerWidget getGroupSelection(String groupname)

      Return the selected item in the specified group, or `null` if none of the items in that group are selected or no such group exists. To get the selected item in this item's group, pass in the value of `getGroupName()`
      Parameters:
        `groupname` - the name of the group

    - #### getWidgets

          public Collection<ToggleViewerWidget> getWidgets(String groupname)

      Return a Collection of other `ToggleViewerWidget` objects in the specified group. To return the Collection containing objects in this group, pass in the value of `getGroupName()`.
      Parameters:
        `groupname` - the name of the group

Copyright © 2001-2015 Big Faceless Organization