org.icepdf.ri.common.utility.layers.LayersPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of icepdf-viewer Show documentation
Show all versions of icepdf-viewer Show documentation
ICEpdf PDF Viewer Reference Implementation (RI)
/*
* Copyright 2006-2017 ICEsoft Technologies Canada Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an "AS
* IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.icepdf.ri.common.utility.layers;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.pobjects.OptionalContent;
import org.icepdf.core.pobjects.OptionalContentGroup;
import org.icepdf.core.util.PropertyConstants;
import org.icepdf.ri.common.SwingController;
import org.icepdf.ri.common.views.AbstractDocumentView;
import org.icepdf.ri.common.views.AbstractPageViewComponent;
import org.icepdf.ri.common.views.DocumentViewController;
import org.icepdf.ri.common.views.DocumentViewModel;
import javax.swing.*;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.ResourceBundle;
/**
* LayersPanel contains a LayersTree for manipulation of the PDF's optional
* content if present. The panel should only be enabled if the the Document's
* catalog contains a OCProperties entry.
*/
@SuppressWarnings("serial")
public class LayersPanel extends JPanel {
protected DocumentViewController documentViewController;
protected Document currentDocument;
private SwingController controller;
protected LayersTreeNode nodes;
protected DocumentViewModel documentViewModel;
// message bundle for internationalization
ResourceBundle messageBundle;
public LayersPanel(SwingController controller) {
super(true);
setFocusable(true);
this.controller = controller;
this.messageBundle = this.controller.getMessageBundle();
}
private void buildUI() {
JTree tree = new LayersTree(nodes);
tree.setShowsRootHandles(true);
tree.setRootVisible(false);
tree.addMouseListener(new NodeSelectionListener(tree));
this.setLayout(new BorderLayout());
JScrollPane scrollPane = new JScrollPane(tree,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.getVerticalScrollBar().setUnitIncrement(20);
scrollPane.getHorizontalScrollBar().setUnitIncrement(20);
this.add(scrollPane,
BorderLayout.CENTER);
}
public void setDocument(Document document) {
this.currentDocument = document;
documentViewController = controller.getDocumentViewController();
documentViewModel = documentViewController.getDocumentViewModel();
if (this.currentDocument != null) {
OptionalContent optionalContent = currentDocument.getCatalog().getOptionalContent();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy