Package com.intellij.openapi.graph.builder.actions.printing

Source Code of com.intellij.openapi.graph.builder.actions.printing.Graph2DPrintPreviewPanel

/*
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
*/

package com.intellij.openapi.graph.builder.actions.printing;

import com.intellij.openapi.graph.GraphManager;
import com.intellij.openapi.graph.option.OptionHandler;
import com.intellij.openapi.graph.view.Graph2DPrinter;
import com.intellij.openapi.graph.view.PrintPreviewPanel;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;

/**
* User: Sergey.Vasiliev
*/
public class Graph2DPrintPreviewPanel {
  private Graph2DPrintPreviewPanel() {
  }

  public static PrintPreviewPanel createPanel(PrinterJob printJob, final Graph2DPrinter gp, PageFormat pf) {
    final PrintPreviewPanel panel = GraphManager.getGraphManager()
      .createPrintPreviewPanel(printJob, gp, gp.getPosterColumns(), gp.getPosterColumns() * gp.getPosterRows(), pf);

    final OptionHandler options = PrintUtil.createPrintOptions();

    //show custom print dialog and adopt values
    Action optionAction = new AbstractAction(PrintUtil.OPTIONS_BUTTON) {
      public void actionPerformed(ActionEvent ev) {
        if (!options.showEditor()) return;

        PrintUtil.initGraph2DPrinter(gp, options);

        panel.setPages(0, gp.getPosterColumns(), gp.getPosterColumns() * gp.getPosterRows());
      }
    };
    panel.addControlComponent(new JButton(optionAction));

    return panel;
  }

}
TOP

Related Classes of com.intellij.openapi.graph.builder.actions.printing.Graph2DPrintPreviewPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.