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 ofViewerWidget
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
-
-
Field Summary
-
Fields inherited from class org.faceless.pdf2.viewer2.ViewerWidget
propertyChangeSupport
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ToggleViewerWidget(String name, String groupname)
Create a new ToggleViewerWidget
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
action(ViewerEvent event)
Toggle the active state of this widget by callingsetSelected(boolean)
String
getGroupName()
Return the name of the group this widget is part of, ornull
if no group was specifiedJComponent
getGroupOwner()
Return the "owner" of this Widget's group.ToggleViewerWidget
getGroupSelection(String groupname)
Return the selected item in the specified group, ornull
if none of the items in that group are selected or no such group exists.Collection<ToggleViewerWidget>
getWidgets(String groupname)
Return a Collection of otherToggleViewerWidget
objects in the specified group.void
initialize(PDFViewer viewer)
Called when the feature is first added to a viewerboolean
isSelected()
Return whether this ViewerWidget is selectedvoid
setGroupOwner(JComponent comp)
Set the "owner" for this Widget's group.void
setSelected(boolean selected)
Set whether this Widget is selected.void
teardown()
Called when the PDFViewer containing this feature is closedprotected void
updateViewport(DocumentViewport viewport, boolean selected)
Called fromsetSelected(boolean)
, this method is called in each viewport in use by thePDFViewer
orDocumentPanel
so 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:ViewerFeature
Called when the feature is first added to a viewer- Overrides:
initialize
in classViewerWidget
-
teardown
public void teardown()
Description copied from class:ViewerFeature
Called when the PDFViewer containing this feature is closed- Overrides:
teardown
in classViewerFeature
-
getGroupName
public final String getGroupName()
Return the name of the group this widget is part of, ornull
if no group was specified
-
setGroupOwner
public final void setGroupOwner(JComponent comp)
Set the "owner" for this Widget's group. This is typically thePDFViewer
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 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:
action
in 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 thePDFViewer
orDocumentPanel
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, ornull
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 ofgetGroupName()
- Parameters:
groupname
- the name of the group
-
getWidgets
public Collection<ToggleViewerWidget> getWidgets(String groupname)
Return a Collection of otherToggleViewerWidget
objects 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
-
-