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

Java2D: BasicStroke in XOR mode does not work properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs
    • 2d
    • x86
    • windows_nt



      Name: gsC80088 Date: 01/26/99


      // BasicStroke class works bad in XOR mode.
      // To reproduce the problem just start this program.
      // It draws a line in the frame, BUT if you turn on
      // the XOR mode, by
      // g2D.setXORMode( Color.red );
      // you will see nothing on the screen.
      //
      // NOTE: It is not a problem of zero width! I use width 0.
      // only for example. Actualy I have this problem with
      // not zero-width lines (and not 1x1 scales), but it
      // is more difficult case for reproduce, becouse I get
      // XOR lines, but widths are differen for XOR and PAINT
      // modes.
      //
      import java.awt.*;
      import java.awt.geom.*;
      import javax.swing.*;


      class TestComponent extends JComponent
      {
      public void paint( Graphics g )
      {
      Graphics2D g2D = ( Graphics2D ) g;

      g2D.setColor( Color.white );
      g2D.fill( new Rectangle2D.Double( 0., 0., 500., 500. ) );

      g2D.setColor( Color.red );
      //------------
      // If you comment the next line, you will see the line.
      // BUT in XOR mode you will see nothing !?.
      g2D.setXORMode( Color.red );

      g2D.setStroke( new BasicStroke( 0.f ) );
      g2D.draw( new Line2D.Double( 0., 0., 300., 300. ) );
      }
      }


      public class test
      {
      static public void main( String [] args )
      {
      JFrame frame = new JFrame();
      frame.setContentPane( new TestComponent() );

      frame.setSize( 500, 500 );
      frame.show();
      }
      }
      (Review ID: 52393)
      ======================================================================

            tnguyensunw Thanh Nguyen (Inactive)
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: