Class ViewOperationChooser

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

public class ViewOperationChooser extends JToolBar

The ViewOperationChooser class is a JToolBar that allows the user to select view transform operations using a set of toolbar buttons. There are seven view transform operations in total: Magnify, Shrink, 1:1, Zoom, Pan, Recenter, and Reset, and Fit. The Magnify, Shrink, 1:1, Reset, and Fit operations are designed to be non-interactive, single-click modes. The user would click these buttons once, then the view should change according to the operation. The Zoom, Pan, and Recenter operations are interactive in the sense that once selected, additional input must be obtained from the user in order the change the view transform.

The operation chooser signals a change in the selected operation by firing a PropertyChangeEvent whose property name is ViewOperationChooser.OPERATION_PROPERTY, and new value contains an operation name from the constants in this class.

A static instance of this class is available via getInstance() so that a single chooser may be used from multiple classes, even though it is only included in one layout manager.

Since:
3.1.7
Author:
Peter Hollemans
See Also:
  • Field Details

  • Constructor Details

    • ViewOperationChooser

      public ViewOperationChooser()
      Creates a new horizontal operation chooser with text and icons. By default, the chooser is set to be not floatable.
    • ViewOperationChooser

      public ViewOperationChooser(int orientation, boolean showText)
      Creates a new operation chooser. By default, the chooser is set to be not floatable.
      Parameters:
      orientation - the toolbar orientation, either HORIZONTAL or VERTICAL.
      showText - the show text flag. If true, text is shown below the icon in each button. If false, no text is shown, but a tool tip is set for the button.
  • Method Details

    • deactivate

      public void deactivate()
      Deactivates the view chooser so that no operation is selected.
    • setEnabled

      public void setEnabled(boolean flag)
      Sets the enabled status of the chooser buttons.
      Overrides:
      setEnabled in class JComponent
    • setShowText

      public void setShowText(boolean flag)
      Sets the visibility of the toolbar text labels.
      Parameters:
      flag - the new text visibility flag value.
      Since:
      3.8.1
    • getOperation

      public String getOperation()
      Gets the selected operation, or null if no operation is selected.
    • getInstance

      public static ViewOperationChooser getInstance()
      Creates a static instance of this class using the default constructor.
    • getFullScreenChooser

      public FullScreenToolBar getFullScreenChooser()
      Creates a full screen version of the chooser with a subset of the view operations, and an additional exit button.
      Returns:
      the full screen mode chooser.
    • performOperation

      public void performOperation(String operation)
      Performs an operation programatically, rather than having to wait for the user to click a button on the chooser.
      Parameters:
      operation - the operation to perform.
      See Also: