TOC PREV NEXT INDEX




Customizing the SwingViewBuilder


The com.icesoft.pdf.ri.common.SwingViewBuilder class constructs a set of GUI components which are pre-configured to work with the com.icesoft.pdf.ri.common.SwingController class to manipulate and reflect the status of view of a rendered PDF document.

The SwingViewBuilder methods, buildViewerFrame and buildViewerPanel, provide the high-level entry points for the GUI construction process, with each constructing complete PDF Viewer user interfaces. In addition, numerous other build... methods are available that construct specific components and subcomponents. See the JavaDoc for the SwingViewBuilder class for an overview of the various build... methods.

For example, the buildCompleteMenubar() method will construct and return a complete application menu bar, including File, View, Document, Window, and Help menus. The buildFileMenu() method will construct and return the File menu, including menu items for Open, Close, Save As, Export, Print, etc. You may use the SwingViewBuilder methods at any level that is appropriate for your application to construct the various user interface components that you require.

If you prefer to customize the GUI components that the SwingViewBuilder creates, you will need to adopt one of the following strategies:

  1. Directly modify the SwingViewBuilder source code, or copy the SwingViewBuilder class into a new class of your own and make required changes to the new class. Using this approach will ensure that any changes or enhancements made to the default Viewer user interface in future versions of ICEpdf will not impact your application. You will need to integrate any changes you wish to adopt manually.
  2. Subclass the SwingViewBuilder class and override the build... methods that you need to modify. The advantage of this approach is that your application will automatically incorporate any changes or additions to the Viewer user interface provided in subsequent releases of ICEpdf for those methods that you haven't overridden. For example, if you are satisfied with the default Viewer Component user interface, but need to modify the Help->About menu-item to display a custom About dialog for your application, you would extend the SwingViewBuilder class and override the buildAboutMenuItem() method to return a menu item that displays your custom About dialog. If a future version of ICEpdf includes additional Tools, such as a Text Selection Tool, your user interface will automatically adopt the new toolbar and menu changes to add support for the new Tool without requiring any manual integration of the new code.
Window Management

Window events, such as closing a window, must be handled by your application, not the ICEpdf framework. Your application needs to track windows and viewports from creation to destruction.

The package com.icesoft.pdf.ri.viewer contains reference code for creating window management.

Adding a Custom Utility Tool

The ICEpdf Viewer RI provides a tabbed utility pane component that is used to display a document outline (bookmarks) when available and a document search capability. This utility pane can also be configured to support additional custom utility tab components as required. The SwingViewBuilder method JTabbedPane buildUtilityTabbedPane() is responsible for creating the tabbed utility pane for the outline and search tools. This method can be easily modified to add your own custom utility tool.

The com.icesoft.pdf.ri.common.SearchPanel component provides a reference implementation that demonstrates implementing a basic search tool for finding text within a PDF document.

Building a Custom Page View

By default, the ICEpdf Viewer application can display PDF documents in any of the predefined views specified in the PDF Reference. The viewer application will first see if the document specifies which document view to use. If not specified, then the viewer selects the view that was last used. The source code for all of the view layout types can be found in the package com.icesoft.pdf.views. Each page is represented by a PageViewComponentImpl object which can be easily used to build custom view types.

The page view implementation uses a secondary MVC to manage the multiple views efficiently. All supporting classes can be found in the package com.icesoft.pdf.views.swing. The support view types are as follows:



Copyright 2005-2007. ICEsoft Technologies, Inc.
http://www.icesoft.com

TOC PREV NEXT INDEX