/*

  public void printData() {

  getJMenuBar().repaint();

  try {

  PrinterJob prnJob = PrinterJob.getPrinterJob();

  prnJob.setPrintable(m_panel);

  if (!prnJob.printDialog())

  return;

  setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

  prnJob.print();

  setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

  JOptionPane.showMessageDialog(this, "Printing completed successfully", "JPEGEditor2",

  JOptionPane.INFORMATION_MESSAGE);

  }

  catch (PrinterException e) {

  e.printStackTrace();

  System.err.println("Printing error: "+e.toString());

  }

  }

  */
  public void printData(Image im) {

    Printer p = new Printer(im);

    try {

      java.awt.print.PrinterJob prnJob = java.awt.print.PrinterJob.getPrinterJob();

      prnJob.setPrintable(p);

      if (!prnJob.printDialog()) {
        return;
      }

      setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));

      prnJob.print();

      setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));

      javax.swing.JOptionPane.showMessageDialog(
          this,
          "Printing completed successfully",
          "JPEGEditor2",
          javax.swing.JOptionPane.INFORMATION_MESSAGE);

    } catch (java.awt.print.PrinterException e) {

      e.printStackTrace();

      System.err.println("Printing_error:_" + e.toString());
    }
  }
示例#2
0
  public int CalculateValidPortraits() {
    int portraitnum = 0;
    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    File tmpfile = new File(directory);
    if (!tmpfile.exists()) {
      JOptionPane.showMessageDialog(
          null,
          "Fatal Error - No portraits directory. Please create a new portraits directory in your NWN directory.",
          "Error",
          0);
      System.exit(0);
    }

    String filenames[] = (tmpfile.list(new ImageFilter()));
    String sexstr = "";
    int sex = ((Integer) menucreate.MainCharData[0].get(new Integer(0))).intValue();
    int race = Integer.parseInt(menucreate.MainCharDataAux[1][0]);
    int numbif = 0;

    for (int p = 0; p < portraitmap.length; p++) {
      String basepicfilename = portraitmap[p][1];
      if (basepicfilename != null && portraitmap[p][2] != null && portraitmap[p][3] != null) {
        basepicfilename = basepicfilename.toLowerCase();
        if (!basepicfilename.startsWith("plc")
            && !basepicfilename.equalsIgnoreCase("door01_")
            && (Integer.parseInt(portraitmap[p][2]) == sex && sexlock || !sexlock)
            && (Integer.parseInt(portraitmap[p][3]) == race && racelock || !racelock)
            && CheckPortrait(directory, "po_" + basepicfilename)) {
          portraitnum++;
        }
      }
    }

    for (int i = 0; i < filenames.length; ++i) ++portraitnum;

    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    ScreenCount = roundup(portraitnum, 50);

    return portraitnum;
  }
  /**
   * Creates a new instance of Validator.
   *
   * @param comp DOCUMENT ME!
   */
  public Validator(final javax.swing.JComponent comp) {
    this.comp = comp;
    // comp.setBackground(Color.red);
    iconContainer.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    iconContainer.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    iconContainer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    // iconContainer.setText("LALAL");
    comp.setLayout(new java.awt.BorderLayout());
    comp.add(iconContainer, java.awt.BorderLayout.EAST);
    iconContainer.setVisible(true);
    iconContainer.addMouseListener(
        new java.awt.event.MouseAdapter() {

          @Override
          public void mouseClicked(final java.awt.event.MouseEvent evt) {
            iconContainerMouseClicked(evt);
          }
        });
  }
示例#4
0
  public void RedoPortraits(int screen) {
    // PortraitObjects = new LinkedList();
    if (screen == -1) {
      ScreenNum = 0;
      screen = 0;
      TotalPortrait = CalculateValidPortraits();
    }

    int CurrentNum = 0;
    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    PortraitsWindow.removeAll();
    PortraitsWindow.repaint();
    String filenames[] = (new File(directory)).list(new ImageFilter());
    String sexstr = "";
    int sex = ((Integer) menucreate.MainCharData[0].get(new Integer(0))).intValue();
    int race = Integer.parseInt(menucreate.MainCharDataAux[1][0]);
    int numbif = 0;

    for (int p = 0; p < portraitmap.length; p++) {
      String basepicfilename = portraitmap[p][1];
      if (basepicfilename != null && portraitmap[p][2] != null && portraitmap[p][3] != null) {
        basepicfilename = basepicfilename.toLowerCase();
        if (!basepicfilename.startsWith("plc")
            && !basepicfilename.equalsIgnoreCase("door01_")
            && (Integer.parseInt(portraitmap[p][2]) == sex && sexlock || !sexlock)
            && (Integer.parseInt(portraitmap[p][3]) == race && racelock || !racelock)
            && CheckPortrait(directory, "po_" + basepicfilename)) {
          String picFilename = "po_" + basepicfilename + "m.tga";
          CurrentNum++;
          if ((CurrentNum <= (50 * (screen + 1))) && (CurrentNum > (50 * screen))) {
            try {
              File tempImage = RESFAC.TempImageFile(picFilename);
              if (tempImage != null) {
                Portrait port =
                    new Portrait(
                        tempImage.getParent() + FileDelim,
                        tempImage.getName(),
                        true,
                        basepicfilename);
                port.getComponent(0).setSize(64, 100);
                PortraitsWindow.add(port, -1);
                numbif++;
              }
            } catch (IOException err) {
              JOptionPane.showMessageDialog(
                  null,
                  "Error reading " + picFilename + ". Out of Memory. Error: " + err,
                  "Error",
                  0);
              System.exit(0);
            }
          }
        }
      }
    }

    for (int i = 0; i < filenames.length; ++i) {
      ++CurrentNum;
      if ((CurrentNum <= (50 * (screen + 1))) && (CurrentNum > (50 * screen))) {
        Portrait port = new Portrait(directory, filenames[i], false, "");
        port.getComponent(0).setSize(64, 100);
        PortraitsWindow.add(port, -1);
      }
    }

    FirstButton.setEnabled(screen != 0);
    BackButton.setEnabled(screen != 0);
    LastButton.setEnabled(screen < (ScreenCount - 1));
    ForwardButton.setEnabled(screen < (ScreenCount - 1));

    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    Runtime r = Runtime.getRuntime();
    r.gc();
  }