001 /* 002 * BackgroundPainterBeanInfo.java 003 * 004 * Created on March 21, 2006, 12:10 PM 005 * 006 * To change this template, choose Tools | Template Manager 007 * and open the template in the editor. 008 */ 009 010 package org.jdesktop.swingx.painter; 011 012 import java.awt.AlphaComposite; 013 import java.awt.RenderingHints; 014 import org.jdesktop.swingx.BeanInfoSupport; 015 import org.jdesktop.swingx.EnumerationValue; 016 import org.jdesktop.swingx.editors.EnumerationValuePropertyEditor; 017 import org.jdesktop.swingx.util.Resize; 018 019 /** 020 * 021 * @author Richard 022 */ 023 public class AbstractPainterBeanInfo extends BeanInfoSupport { 024 025 /** Creates a new instance of BackgroundPainterBeanInfo */ 026 public AbstractPainterBeanInfo() { 027 super(AbstractPainter.class); 028 } 029 030 protected void initialize() { 031 setHidden(true, "class", "propertyChangeListeners", "renderingHints"); 032 033 //set editor for the clip shape 034 //set editor for the effects (not sure how to do this one) 035 //TODO 036 037 //set editor for resizeClip 038 setPropertyEditor(ResizeClipPropertyEditor.class, "resizeClip"); 039 //set editor for composite (incl. Alpha composites by default) 040 setPropertyEditor(CompositePropertyEditor.class, "composite"); 041 //set editors for the various rendering hints 042 setPropertyEditor(AlphaInterpolationPropertyEditor.class, "alphaInterpolation"); 043 setPropertyEditor(AntialiasingPropertyEditor.class, "antialiasing"); 044 setPropertyEditor(ColorRenderingPropertyEditor.class, "colorRendering"); 045 setPropertyEditor(DitheringPropertyEditor.class, "dithering"); 046 setPropertyEditor(FractionalMetricsPropertyEditor.class, "fractionalMetrics"); 047 setPropertyEditor(InterpolationPropertyEditor.class, "interpolation"); 048 setPropertyEditor(RenderingPropertyEditor.class, "rendering"); 049 setPropertyEditor(StrokeControlPropertyEditor.class, "strokeControl"); 050 setPropertyEditor(TextAntialiasingPropertyEditor.class, "textAntialiasing"); 051 052 //move some items into "Appearance" and some into "Behavior" 053 setCategory("Rendering Hints", "alphaInterpolation", "antialiasing", 054 "colorRendering", "dithering", "fractionalMetrics", "interpolation", 055 "rendering", "strokeControl", "textAntialiasing"); 056 setCategory("Appearance", "clip", "composite", "effects"); 057 setCategory("Behavior", "resizeClip", "useCache"); 058 } 059 060 public static final class ResizeClipPropertyEditor extends EnumerationValuePropertyEditor { 061 public ResizeClipPropertyEditor() { 062 super(null, new EnumerationValue[] { 063 new EnumerationValue("None", Resize.NONE, "Resize.NONE"), 064 new EnumerationValue("Horizontal", Resize.HORIZONTAL, "Resize.HORIZONTAL"), 065 new EnumerationValue("Vertical", Resize.VERTICAL, "Resize.VERTICAL"), 066 new EnumerationValue("Both", Resize.BOTH, "Resize.BOTH") 067 }); 068 } 069 } 070 public static final class CompositePropertyEditor extends EnumerationValuePropertyEditor { 071 public CompositePropertyEditor() { 072 super(null, new EnumerationValue[] { 073 new EnumerationValue("", null, "null"), 074 new EnumerationValue("Clear", AlphaComposite.Clear, "AlphaComposite.Clear"), 075 new EnumerationValue("Destination", AlphaComposite.Dst, "AlphaComposite.Dst"), 076 new EnumerationValue("Destination Atop", AlphaComposite.DstAtop, "AlphaComposite.DstAtop"), 077 new EnumerationValue("Destination In", AlphaComposite.DstIn, "AlphaComposite.DstIn"), 078 new EnumerationValue("Destination Out", AlphaComposite.DstOut, "AlphaComposite.DstOut"), 079 new EnumerationValue("Destination Over", AlphaComposite.DstOver, "AlphaComposite.DstOver"), 080 new EnumerationValue("Source", AlphaComposite.Src, "AlphaComposite.Src"), 081 new EnumerationValue("Source Atop", AlphaComposite.SrcAtop, "AlphaComposite.SrcAtop"), 082 new EnumerationValue("Source In", AlphaComposite.SrcIn, "AlphaComposite.SrcIn"), 083 new EnumerationValue("Source Out", AlphaComposite.SrcOut, "AlphaComposite.SrcOut"), 084 new EnumerationValue("Source Over", AlphaComposite.SrcOver, "AlphaComposite.SrcOver"), 085 new EnumerationValue("Xor", AlphaComposite.Xor, "AlphaComposite.Xor") 086 }); 087 } 088 } 089 public static final class AlphaInterpolationPropertyEditor extends EnumerationValuePropertyEditor { 090 public AlphaInterpolationPropertyEditor() { 091 super(null, new EnumerationValue[] { 092 new EnumerationValue("", null, "null"), 093 new EnumerationValue("Default", RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT, "RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT"), 094 new EnumerationValue("Quality", RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY, "RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY"), 095 new EnumerationValue("Speed", RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED, "RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED") 096 }); 097 } 098 } 099 public static final class AntialiasingPropertyEditor extends EnumerationValuePropertyEditor { 100 public AntialiasingPropertyEditor() { 101 super(null, new EnumerationValue[] { 102 new EnumerationValue("", null, "null"), 103 new EnumerationValue("Default", RenderingHints.VALUE_ANTIALIAS_DEFAULT, "RenderingHints.VALUE_ANTIALIAS_DEFAULT"), 104 new EnumerationValue("On", RenderingHints.VALUE_ANTIALIAS_ON, "RenderingHints.VALUE_ANTIALIAS_ON"), 105 new EnumerationValue("Off", RenderingHints.VALUE_ANTIALIAS_OFF, "RenderingHints.VALUE_ANTIALIAS_OFF") 106 }); 107 } 108 } 109 public static final class ColorRenderingPropertyEditor extends EnumerationValuePropertyEditor { 110 public ColorRenderingPropertyEditor() { 111 super(null, new EnumerationValue[] { 112 new EnumerationValue("", null, "null"), 113 new EnumerationValue("Default", RenderingHints.VALUE_COLOR_RENDER_DEFAULT, "RenderingHints.VALUE_COLOR_RENDER_DEFAULT"), 114 new EnumerationValue("Quality", RenderingHints.VALUE_COLOR_RENDER_QUALITY, "RenderingHints.VALUE_COLOR_RENDER_QUALITY"), 115 new EnumerationValue("Speed", RenderingHints.VALUE_COLOR_RENDER_SPEED, "RenderingHints.VALUE_COLOR_RENDER_SPEED") 116 }); 117 } 118 } 119 public static final class DitheringPropertyEditor extends EnumerationValuePropertyEditor { 120 public DitheringPropertyEditor() { 121 super(null, new EnumerationValue[] { 122 new EnumerationValue("", null, "null"), 123 new EnumerationValue("Default", RenderingHints.VALUE_DITHER_DEFAULT, "RenderingHints.VALUE_DITHER_DEFAULT"), 124 new EnumerationValue("Enable", RenderingHints.VALUE_DITHER_ENABLE, "RenderingHints.VALUE_DITHER_ENABLE"), 125 new EnumerationValue("Disable", RenderingHints.VALUE_DITHER_DISABLE, "RenderingHints.VALUE_DITHER_DISABLE") 126 }); 127 } 128 } 129 public static final class FractionalMetricsPropertyEditor extends EnumerationValuePropertyEditor { 130 public FractionalMetricsPropertyEditor() { 131 super(null, new EnumerationValue[] { 132 new EnumerationValue("", null, "null"), 133 new EnumerationValue("Default", RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT, "RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT"), 134 new EnumerationValue("On", RenderingHints.VALUE_FRACTIONALMETRICS_ON, "RenderingHints.VALUE_FRACTIONALMETRICS_ON"), 135 new EnumerationValue("Off", RenderingHints.VALUE_FRACTIONALMETRICS_OFF, "RenderingHints.VALUE_FRACTIONALMETRICS_OFF") 136 }); 137 } 138 } 139 public static final class InterpolationPropertyEditor extends EnumerationValuePropertyEditor { 140 public InterpolationPropertyEditor() { 141 super(null, new EnumerationValue[] { 142 new EnumerationValue("", null, "null"), 143 new EnumerationValue("Bicubic", RenderingHints.VALUE_INTERPOLATION_BICUBIC, "RenderingHints.VALUE_INTERPOLATION_BICUBIC"), 144 new EnumerationValue("Bilinear", RenderingHints.VALUE_INTERPOLATION_BILINEAR, "RenderingHints.VALUE_INTERPOLATION_BILINEAR"), 145 new EnumerationValue("Nearest Neighbor", RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, "RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR") 146 }); 147 } 148 } 149 public static final class RenderingPropertyEditor extends EnumerationValuePropertyEditor { 150 public RenderingPropertyEditor() { 151 super(null, new EnumerationValue[] { 152 new EnumerationValue("", null, "null"), 153 new EnumerationValue("Default", RenderingHints.VALUE_RENDER_DEFAULT, "RenderingHints.VALUE_RENDER_DEFAULT"), 154 new EnumerationValue("Quality", RenderingHints.VALUE_RENDER_QUALITY, "RenderingHints.VALUE_RENDER_QUALITY"), 155 new EnumerationValue("Speed", RenderingHints.VALUE_RENDER_SPEED, "RenderingHints.VALUE_RENDER_SPEED") 156 }); 157 } 158 } 159 public static final class StrokeControlPropertyEditor extends EnumerationValuePropertyEditor { 160 public StrokeControlPropertyEditor() { 161 super(null, new EnumerationValue[] { 162 new EnumerationValue("", null, "null"), 163 new EnumerationValue("Default", RenderingHints.VALUE_STROKE_DEFAULT, "RenderingHints.VALUE_STROKE_DEFAULT"), 164 new EnumerationValue("Normalize", RenderingHints.VALUE_STROKE_NORMALIZE, "RenderingHints.VALUE_STROKE_NORMALIZE"), 165 new EnumerationValue("Pure", RenderingHints.VALUE_STROKE_PURE, "RenderingHints.VALUE_STROKE_PURE") 166 }); 167 } 168 } 169 public static final class TextAntialiasingPropertyEditor extends EnumerationValuePropertyEditor { 170 public TextAntialiasingPropertyEditor() { 171 super(null, new EnumerationValue[] { 172 new EnumerationValue("", null, "null"), 173 new EnumerationValue("Default", RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT, "RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT"), 174 new EnumerationValue("On", RenderingHints.VALUE_TEXT_ANTIALIAS_ON, "RenderingHints.VALUE_TEXT_ANTIALIAS_ON"), 175 new EnumerationValue("Off", RenderingHints.VALUE_TEXT_ANTIALIAS_OFF, "RenderingHints.VALUE_TEXT_ANTIALIAS_OFF") 176 }); 177 } 178 } 179 }