Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4341755

When I print out using transparency effecs, the printed image is shifted

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.3.0
    • client-libs
    • 2d
    • x86
    • windows_nt



      Name: cl74495 Date: 05/27/2000


      This is the resubmission of Review ID: 105167 (below).
      I report again, because this problen is very important.

      Please print out by two methods, one is by transparent effecs,
      the other is by non-taransparent effects.
      Then you will have two pieces of paper printed out image.
      Please put one paper upon another paper exactry right,
      and hold on them(=two pieces of paper) to the light.
      You will be aware of the different positions of the image
      printed out on paper.


      The following is the contents of Review ID: 105167.

      When I print out using transparency effecs (java.awt.AlphaComposite),
      the position of the printed image is about one centimeter off in
      comparison with the position printed without transparency effects.

      Please try to test with the following program.
      At the first, please compile and execute the program as it is.
      (When you press the "print" button on the Java's Frame, automaticlly
       the image will be printed out.)
      Next, after you change line A and B to comment line (//) , please compile
      and execute the program.
      Then please compare the first printed image with the second printed
      image.

      We expect that this problem has been fixed by this August.


        Program:
      --------------<TwoRects.java>-----------------------------------
      import javax.swing.*;
      import java.awt.event.*;
      import java.awt.*;
      import java.awt.print.*;

      class TwoRects extends JFrame
      {

      public static void main(String[] args)
      {
      JFrame frame = new JFrame("TwoRects");
      Container pane = frame.getContentPane();
      TwoRectsCanvas trc = new TwoRectsCanvas(pane);

      pane.add(trc,BorderLayout.CENTER);


      /*
      //Panel Size
      Dimension size = new Dimension(450,250);
      panel.setMaximumSize(size);
      panel.setMinimumSize(size);
      */


      frame.setSize(500,300);
      frame.setVisible(true);
      }


      }

      class TwoRectsCanvas extends Canvas implements Printable
      {
              Container pane;
              TwoRectsCanvas(Container con) {
                      pane = con;


      JButton btn1 = new JButton("Print");

      pane.add(btn1,BorderLayout.SOUTH);


      btn1.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
      PrinterJob pj = PrinterJob.getPrinterJob();
      pj.setPrintable((Printable)TwoRectsCanvas.this);

      if(pj.printDialog()){
      try{
      pj.print();
      }catch(PrinterException pe){
      System.out.println(pe);
      }
      }
      }
      });

              }
      public void paint(Graphics g)
      {
      g.setColor(Color.blue);
      g.fillRect(100,100,100,100);
      g.setColor(Color.red);
      g.fillRect(150,50,100,100);
      g.setColor(Color.black);
                      g.drawString("AlphaComposite Test (SRC_OVER)", 130, 120);

      }

      /**
      *
      * Overload the print Method of Printable Interface print
      */
      public int print(Graphics g,PageFormat pf,int pageIndex)
      {
      if(pageIndex != 0){
      return NO_SUCH_PAGE;
      }

      //Graphics2D Cast
      Graphics2D g2 = (Graphics2D)g;

                      AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f); // A
                      g2.setComposite(ac); // B

      //public abstract void translate(int x,int y)

      g2.translate(pf.getImageableX(),pf.getImageableY());

      //g2 paint
      paint(g2);
      return PAGE_EXISTS;
      }
      }
      ------------------------------------------------------------------
      (Review ID: 105215)
      ======================================================================

            prr Philip Race
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: