-
Bug
-
Resolution: Fixed
-
P3
-
fx2.0
When you use a shape with Region such as a Arc that is used in PieChart implementation then specify that the background insets are not 0; You expect to make bigger and smaller version of the shape. This is much the same as stroking. NGRegion & SGRegion have simple implementations that just scale the shape. They should at least scale the shape around its center. At the moment they scale around the origin, this will never look right. Below is example fix for one of the code paths to make it scale around the center. Ideally region would use the same calculations as when we calculate a stroke.
/**
* Create a bigger or smaller version of shape. If not resizeShape then the shape is just centered rather
* than resized. Proportions are not maintained when resizing.
*/
private Shape createShape(Shape shape, float topOffset, float leftOffset,
float bottomOffset, float rightOffset) {
......
} else if (topOffset!=0 || rightOffset!=0 || bottomOffset!=0 || leftOffset!=0) {
// we have to resize as well because of offsets
float newW = (float)bounds.getWidth() - leftOffset - rightOffset;
float newH = (float)bounds.getHeight() - topOffset - bottomOffset;
double middleX = bounds.getMinX() + (bounds.getWidth()/2);
double middleY = bounds.getMinY() + (bounds.getHeight()/2);
transform.translate(middleX,middleY);
transform.scale(newW / bounds.getWidth(), newH / bounds.getHeight());
transform.translate(-middleX, -middleY);
}
return transform.isIdentity() ? shape : transform.createTransformedShape(shape);
}
/**
* Create a bigger or smaller version of shape. If not resizeShape then the shape is just centered rather
* than resized. Proportions are not maintained when resizing.
*/
private Shape createShape(Shape shape, float topOffset, float leftOffset,
float bottomOffset, float rightOffset) {
......
} else if (topOffset!=0 || rightOffset!=0 || bottomOffset!=0 || leftOffset!=0) {
// we have to resize as well because of offsets
float newW = (float)bounds.getWidth() - leftOffset - rightOffset;
float newH = (float)bounds.getHeight() - topOffset - bottomOffset;
double middleX = bounds.getMinX() + (bounds.getWidth()/2);
double middleY = bounds.getMinY() + (bounds.getHeight()/2);
transform.translate(middleX,middleY);
transform.scale(newW / bounds.getWidth(), newH / bounds.getHeight());
transform.translate(-middleX, -middleY);
}
return transform.isIdentity() ? shape : transform.createTransformedShape(shape);
}