-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
6u12
FULL PRODUCT VERSION :
1.6.0_12
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP3 32bit
A DESCRIPTION OF THE PROBLEM :
In a paint function, this code worked in 1.6.0_11 and below (back to 1.5.0_9)
Graphics2D g2 = (Graphics2D) g; //Used to paint the arrow
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
In 1.6.0_12 I have to comment out the second line for it to render at all.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g; //Used to paint the arrow
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
...paint somethinging...
}
I painted this (where xs and ys were coordinates of where the arrows started/ended:
Point end = new Point(xs[xs.length - 1], ys[ys.length - 1]);
Point preEnd = new Point(xs[xs.length - 2], ys[ys.length - 2]);
/* Arrowhead is a right triangle: side lengths = A^2 + B^2 = C^2
* The points defining the triangle boundaries are a, b, & c.
* a B B a
* |\ b___c c___b /| where the line intersects C
* A| \C C\ |A A| /C C/ |A and ends where A and B meet
* |__\ \| |/ /__|
* c B b a a b B c */
int xDist = end.x - preEnd.x; //use last 2 points to determine
int yDist = end.y - preEnd.y; //arrowHead direction.
Point center = new Point((int) Math.floor(Math.sqrt(
25 / (1 + Math.pow((double) yDist / (double) xDist, 2)))),
(int) Math.floor(Math.sqrt(
25 / (1 + Math.pow((double) xDist / (double) yDist, 2)))));
//add or subtract dependant on direction of arrowHead
center.x = (xDist < 0) ? center.x : (-center.x);
center.y = (yDist < 0) ? center.y : (-center.y);
//the base points of the arrow head
Point a = new Point(end.x + center.x + center.y, (end.y + center.y) - center.x);
Point b = new Point((end.x + center.x) - center.y, end.y + center.y + center.x);
Polygon arrowHead = new Polygon();
arrowHead.addPoint(end.x, end.y); //tip of arrow head
arrowHead.addPoint(a.x, a.y); //arrow head base 1
arrowHead.addPoint(b.x, b.y); //arrow head base 2
g2.setColor(getArrowColor());
g2.drawPolyline(xs, ys, xs.length);
g2.fill(arrowHead);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
To display something
ACTUAL -
Displayed nothing (until I commented out the line about antialiasing- then it displayed properly [though not anti-aliased obviously])
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error was logged
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Included in "steps to reproduce"
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not anti-alias
Release Regression From : 6u11
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
1.6.0_12
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP3 32bit
A DESCRIPTION OF THE PROBLEM :
In a paint function, this code worked in 1.6.0_11 and below (back to 1.5.0_9)
Graphics2D g2 = (Graphics2D) g; //Used to paint the arrow
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
In 1.6.0_12 I have to comment out the second line for it to render at all.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g; //Used to paint the arrow
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
...paint somethinging...
}
I painted this (where xs and ys were coordinates of where the arrows started/ended:
Point end = new Point(xs[xs.length - 1], ys[ys.length - 1]);
Point preEnd = new Point(xs[xs.length - 2], ys[ys.length - 2]);
/* Arrowhead is a right triangle: side lengths = A^2 + B^2 = C^2
* The points defining the triangle boundaries are a, b, & c.
* a B B a
* |\ b___c c___b /| where the line intersects C
* A| \C C\ |A A| /C C/ |A and ends where A and B meet
* |__\ \| |/ /__|
* c B b a a b B c */
int xDist = end.x - preEnd.x; //use last 2 points to determine
int yDist = end.y - preEnd.y; //arrowHead direction.
Point center = new Point((int) Math.floor(Math.sqrt(
25 / (1 + Math.pow((double) yDist / (double) xDist, 2)))),
(int) Math.floor(Math.sqrt(
25 / (1 + Math.pow((double) xDist / (double) yDist, 2)))));
//add or subtract dependant on direction of arrowHead
center.x = (xDist < 0) ? center.x : (-center.x);
center.y = (yDist < 0) ? center.y : (-center.y);
//the base points of the arrow head
Point a = new Point(end.x + center.x + center.y, (end.y + center.y) - center.x);
Point b = new Point((end.x + center.x) - center.y, end.y + center.y + center.x);
Polygon arrowHead = new Polygon();
arrowHead.addPoint(end.x, end.y); //tip of arrow head
arrowHead.addPoint(a.x, a.y); //arrow head base 1
arrowHead.addPoint(b.x, b.y); //arrow head base 2
g2.setColor(getArrowColor());
g2.drawPolyline(xs, ys, xs.length);
g2.fill(arrowHead);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
To display something
ACTUAL -
Displayed nothing (until I commented out the line about antialiasing- then it displayed properly [though not anti-aliased obviously])
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error was logged
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Included in "steps to reproduce"
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not anti-alias
Release Regression From : 6u11
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.