Package 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 ofViewerWidgetwhich 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
-
-
Field Summary
-
Fields inherited from class org.faceless.pdf2.viewer2.ViewerWidget
propertyChangeSupport
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedToggleViewerWidget(String name, String groupname)Create a new ToggleViewerWidget
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaction(ViewerEvent event)Toggle the active state of this widget by callingsetSelected(boolean)StringgetGroupName()Return the name of the group this widget is part of, ornullif no group was specifiedJComponentgetGroupOwner()Return the "owner" of this Widget's group.ToggleViewerWidgetgetGroupSelection(String groupname)Return the selected item in the specified group, ornullif none of the items in that group are selected or no such group exists.Collection<ToggleViewerWidget>getWidgets(String groupname)Return a Collection of otherToggleViewerWidgetobjects in the specified group.voidinitialize(PDFViewer viewer)Called when the feature is first added to a viewerbooleanisSelected()Return whether this ViewerWidget is selectedvoidsetGroupOwner(JComponent comp)Set the "owner" for this Widget's group.voidsetSelected(boolean selected)Set whether this Widget is selected.voidteardown()Called when the PDFViewer containing this feature is closedprotected voidupdateViewport(DocumentViewport viewport, boolean selected)Called fromsetSelected(boolean), this method is called in each viewport in use by thePDFViewerorDocumentPanelso it can update its status.-
Methods inherited from class org.faceless.pdf2.viewer2.ViewerWidget
addPropertyChangeListener, createActionListener, firePropertyChange, getComponent, getIcon, getViewer, isButtonEnabledByDefault, isDocumentRequired, isMenuEnabledByDefault, removePropertyChangeListener, 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
-
-
-
-
Method Detail
-
initialize
public void initialize(PDFViewer viewer)
Description copied from class:ViewerFeatureCalled when the feature is first added to a viewer- Overrides:
initializein classViewerWidget
-
teardown
public void teardown()
Description copied from class:ViewerFeatureCalled when the PDFViewer containing this feature is closed- Overrides:
teardownin classViewerFeature
-
getGroupName
public final String getGroupName()
Return the name of the group this widget is part of, ornullif no group was specified
-
setGroupOwner
public final void setGroupOwner(JComponent comp)
Set the "owner" for this Widget's group. This is typically thePDFViewerand 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 aDocumentPanel.- 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 callingsetSelected(boolean)- Overrides:
actionin classViewerWidget
-
setSelected
public void setSelected(boolean selected)
Set whether this Widget is selected. If active is true, this method will automatically callsetSelected(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 fromsetSelected(boolean), this method is called in each viewport in use by thePDFViewerorDocumentPanelso 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, ornullif 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 ofgetGroupName()- Parameters:
groupname- the name of the group
-
getWidgets
public Collection<ToggleViewerWidget> getWidgets(String groupname)
Return a Collection of otherToggleViewerWidgetobjects in the specified group. To return the Collection containing objects in this group, pass in the value ofgetGroupName().- Parameters:
groupname- the name of the group
-
-