A utility method to get the {@link Composite} that represents the filter for the given
PorterDuff mode and the alpha. Defaults to {@link Mode#SRC_OVER} for invalid modes.
float alpha1 = alpha255 != 0xFF ? alpha255 / 255.f : 1.f;
switch (mode) {
case CLEAR:
return AlphaComposite.getInstance(AlphaComposite.CLEAR, alpha1);
case SRC:
return AlphaComposite.getInstance(AlphaComposite.SRC, alpha1);
case DST:
return AlphaComposite.getInstance(AlphaComposite.DST, alpha1);
case SRC_OVER:
return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha1);
case DST_OVER:
return AlphaComposite.getInstance(AlphaComposite.DST_OVER, alpha1);
case SRC_IN:
return AlphaComposite.getInstance(AlphaComposite.SRC_IN, alpha1);
case DST_IN:
return AlphaComposite.getInstance(AlphaComposite.DST_IN, alpha1);
case SRC_OUT:
return AlphaComposite.getInstance(AlphaComposite.SRC_OUT, alpha1);
case DST_OUT:
return AlphaComposite.getInstance(AlphaComposite.DST_OUT, alpha1);
case SRC_ATOP:
return AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha1);
case DST_ATOP:
return AlphaComposite.getInstance(AlphaComposite.DST_ATOP, alpha1);
case XOR:
return AlphaComposite.getInstance(AlphaComposite.XOR, alpha1);
case DARKEN:
return BlendComposite.getInstance(BlendingMode.DARKEN, alpha1);
case LIGHTEN:
return BlendComposite.getInstance(BlendingMode.LIGHTEN, alpha1);
case MULTIPLY:
return BlendComposite.getInstance(BlendingMode.MULTIPLY, alpha1);
case SCREEN:
return BlendComposite.getInstance(BlendingMode.SCREEN, alpha1);
case ADD:
return BlendComposite.getInstance(BlendingMode.ADD, alpha1);
case OVERLAY:
return BlendComposite.getInstance(BlendingMode.OVERLAY, alpha1);
default:
Bridge.getLog().fidelityWarning(LayoutLog.TAG_BROKEN,
String.format("Unsupported PorterDuff Mode: %1$s", mode.name()),
null, null /*data*/);
return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha1);
}