Skip to content

Commit

Permalink
8346227: Seal Paint and Material
Browse files Browse the repository at this point in the history
Reviewed-by: nlisker, angorya, kcr
  • Loading branch information
Michael Strauß committed Jan 8, 2025
1 parent 5b074c4 commit 3cfd317
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,23 +594,12 @@ private Object getPaint(RadialGradient paint) {
}

public Object getPaint(Paint paint) {
if (paint instanceof Color) {
return createColorPaint((Color) paint);
}

if (paint instanceof LinearGradient) {
return getPaint((LinearGradient) paint);
}

if (paint instanceof RadialGradient) {
return getPaint((RadialGradient) paint);
}

if (paint instanceof ImagePattern) {
return createImagePatternPaint((ImagePattern) paint);
}

return null;
return switch (paint) {
case Color color -> createColorPaint(color);
case LinearGradient gradient -> getPaint(gradient);
case RadialGradient gradient -> getPaint(gradient);
case ImagePattern pattern -> createImagePatternPaint(pattern);
};
}

protected static final double clampStopOffset(double offset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ void acc_removeListener(AbstractNotifyListener platformChangeListener) {
@Override Object acc_getPlatformPaint() {
if (acc_isMutable() || platformPaint == null) {
platformPaint = Toolkit.getToolkit().getPaint(this);
assert platformPaint != null;
}
return platformPaint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* @since JavaFX 8.0
*/
public abstract class Material {
public abstract sealed class Material permits PhongMaterial {

static {
// This is used by classes in different packages to get access to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
*
* @since JavaFX 2.0
*/
public abstract class Paint implements Interpolatable<Paint> {
public abstract sealed class Paint implements Interpolatable<Paint>
permits Color, LinearGradient, RadialGradient, ImagePattern {

static {
Toolkit.setPaintAccessor(new Toolkit.PaintAccessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@
* @see Shape3D
* @since JavaFX 8.0
*/
public class PhongMaterial extends Material {
public non-sealed class PhongMaterial extends Material {

private boolean diffuseColorDirty = true;
private boolean specularColorDirty = true;
Expand Down

1 comment on commit 3cfd317

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.