Example #1
0
  /**
   * Show a dialog for printing the current drawing.
   *
   * @param fff the parent frame which will be used for dialogs and message boxes.
   * @param CCr the CircuitPanel containing the drawing to be exported.
   */
  public void printDrawing(JFrame fff, CircuitPanel CCr) {
    cc = CCr;
    DialogPrint dp = new DialogPrint(fff);
    dp.setMirror(printMirror);
    dp.setFit(printFitToPage);
    dp.setBW(printBlackWhite);
    dp.setLandscape(printLandscape);
    dp.setVisible(true);

    // Get some information about the printing options.
    printMirror = dp.getMirror();
    printFitToPage = dp.getFit();
    printLandscape = dp.getLandscape();
    printBlackWhite = dp.getBW();

    Vector<LayerDesc> ol = cc.dmp.getLayers();
    if (dp.shouldPrint()) {
      if (printBlackWhite) {
        Vector<LayerDesc> v = new Vector<LayerDesc>();

        // Here we create an alternative array of layers in
        // which all colors are pitch black. This may be
        // useful for PCB's.

        for (int i = 0; i < LayerDesc.MAX_LAYERS; ++i)
          v.add(
              new LayerDesc(
                  new ColorSwing(Color.black),
                  ((LayerDesc) ol.get(i)).getVisible(),
                  "B/W",
                  ((LayerDesc) ol.get(i)).getAlpha()));
        cc.dmp.setLayers(v);
      }
      PrinterJob job = PrinterJob.getPrinterJob();
      job.setPrintable(this);
      boolean ok = job.printDialog();
      if (ok) {
        try {
          PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
          // Set the correct printing orientation.
          if (printLandscape) {
            aset.add(OrientationRequested.LANDSCAPE);
          } else {
            aset.add(OrientationRequested.PORTRAIT);
          }
          job.print(aset);
        } catch (PrinterException ex) {
          // The job did not successfully complete
          JOptionPane.showMessageDialog(fff, Globals.messages.getString("Print_uncomplete"));
        }
      }
      cc.dmp.setLayers(ol);
    }
  }
 public void add(PluggableEditor ed, int index) {
   // add(ed.getName(), ed.getDisplayComponent()); // wierd array bounds error thrown here?
   insertTab(ed.getName(), ed.getIcon(), ed.getDisplayComponent(), ed.getToolTip(), index);
   activeEditors.add(index, ed);
 }