Java Doc for AbstractPainter.java in  » Swing-Library » swingx » org » jdesktop » swingx » painter » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » swingx » org.jdesktop.swingx.painter 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jdesktop.beans.AbstractBean
      org.jdesktop.swingx.painter.AbstractPainter

All known Subclasses:   org.jdesktop.swingx.painter.gradient.AbstractGradientPainter,  org.jdesktop.swingx.painter.ShapePainter,  org.jdesktop.swingx.painter.BackgroundPainter,  org.jdesktop.swingx.painter.CompoundPainter,  org.jdesktop.swingx.painter.MattePainter,  org.jdesktop.swingx.painter.ImagePainter,  org.jdesktop.swingx.painter.RectanglePainter,  org.jdesktop.swingx.painter.CheckerboardPainter,  org.jdesktop.swingx.painter.PinstripePainter,  org.jdesktop.swingx.painter.TextPainter,  org.jdesktop.swingx.painter.GlossPainter,
AbstractPainter
abstract public class AbstractPainter extends AbstractBean implements Painter<T>(Code)

A convenient base class from which concrete Painter implementations may extend. It extends JavaBean and thus provides property change notification (which is crucial for the Painter implementations to be available in a GUI builder). It also saves off the Graphics2D state in its "saveState" method, and restores that state in the "restoreState" method. Sublasses simply need to extend AbstractPainter and implement the paintBackground method.

For example, here is the paintBackground method of BackgroundPainter:


 public void paintBackground(Graphics2D g, JComponent component) {
 g.setColor(component.getBackground());
 g.fillRect(0, 0, component.getWidth(), component.getHeight());
 }
 

AbstractPainter provides a very useful default implementation of the paint method. It:

  1. Saves off the old state
  2. Sets any specified rendering hints
  3. Sets the Clip if there is one
  4. Sets the Composite if there is one
  5. Delegates to paintBackground
  6. Restores the original Graphics2D state
    1. Specifying rendering hints can greatly improve the visual impact of your applications. For example, by default Swing doesn't do much in the way of antialiasing (except for Fonts, but that's another story). Pinstripes don't look so good without antialiasing. So if I were going to paint pinstripes, I might do it like this:

      
       PinstripePainter p = new PinstripePainter();
       p.setAntialiasing(RenderingHints.VALUE_ANTIALIAS_ON);
       

      You can read more about antialiasing and other rendering hints in the java.awt.RenderingHints documentation. By nature, changing the rendering hints may have an impact on performance. Certain hints require more computation, others require less


      author:
         rbair



Constructor Summary
public  AbstractPainter()
    

Method Summary
public  ObjectgetAlphaInterpolation()
     the technique used for interpolating alpha values.
public  ObjectgetAntialiasing()
    
public  ShapegetClip()
    
public  ObjectgetColorRendering()
    
public  CompositegetComposite()
    
public  ObjectgetDithering()
    
public  Effect[]getEffects()
     effects a defensive copy of the Effects to apply to the resultsof the AbstractPainter's painting operation.
public  ObjectgetFractionalMetrics()
    
public  ObjectgetInterpolation()
     the technique to use for interpolation (used esp.
public  ObjectgetRendering()
     a hint as to techniques to use with regards to rendering quality vs.
public  ObjectgetRenderingHint(RenderingHints.Key key)
     the rendering hint associated with the given key.
public  Map<RenderingHints.Key, Object>getRenderingHints()
     a copy of the map of rendering hints held by this class.
public  ResizegetResizeClip()
     value indication whether/how to resize the clip.
public  ObjectgetStrokeControl()
    
public  ObjectgetTextAntialiasing()
     technique for anti-aliasing text.(TODO this needs to be updated for Mustang.
public  booleanisUseCache()
    
public  voidpaint(Graphics2D g, T component)
    
abstract protected  voidpaintBackground(Graphics2D g, T component)
     Subclasses should implement this method and perform custom painting operations here.
protected  voidrestoreState(Graphics2D g)
     Restores previously saved state.
protected  voidsaveState(Graphics2D g)
     Saves the state in the given Graphics2D object so that it may be restored later.
public  voidsetAlphaInterpolation(Object alphaInterpolation)
     Sets the technique used for interpolating alpha values.
public  voidsetAntialiasing(Object antialiasing)
    
public  voidsetClip(Shape clip)
     Specifies the Shape to use for clipping the painting area.
public  voidsetColorRendering(Object colorRendering)
    
public  voidsetComposite(Composite c)
     Sets the Composite to use.
public  voidsetDithering(Object dithering)
    
public  voidsetEffects(Effect... effects)
    

Sets the effects to apply to the results of the AbstractPainter's painting operation.

public  voidsetEffects(BufferedImageOp... filters)
    

A convenience method for specifying the effects to use based on BufferedImageOps.

public  voidsetFractionalMetrics(Object fractionalMetrics)
    
public  voidsetInterpolation(Object interpolation)
     Sets the technique to use for interpolation (used esp.
public  voidsetRendering(Object rendering)
     Specifies a hint as to techniques to use with regards to rendering quality vs.
public  voidsetRenderingHint(RenderingHints.Key key, Object hint)
     Set the given hint for the given key.
public  voidsetRenderingHints(Map<RenderingHints.Key, Object> renderingHints)
     Sets the rendering hints to use.
public  voidsetResizeClip(Resize r)
     Specifies the resize behavior of the clip.
public  voidsetStrokeControl(Object strokeControl)
    
public  voidsetTextAntialiasing(Object textAntialiasing)
     Sets the technique for anti-aliasing text. (TODO this needs to be updated for Mustang.
public  voidsetUseCache(boolean b)
    

Sets whether to cache the painted image with a SoftReference in a BufferedImage between calls.



Constructor Detail
AbstractPainter
public AbstractPainter()(Code)
Creates a new instance of AbstractPainter




Method Detail
getAlphaInterpolation
public Object getAlphaInterpolation()(Code)
the technique used for interpolating alpha values. May be oneof:
  • RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED
  • RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY
  • RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT



getAntialiasing
public Object getAntialiasing()(Code)
whether or not to antialiasMay be one of:
  • RenderingHints.VALUE_ANTIALIAS_DEFAULT
  • RenderingHints.VALUE_ANTIALIAS_OFF
  • RenderingHints.VALUE_ANTIALIAS_ON



getClip
public Shape getClip()(Code)
the clipping shape



getColorRendering
public Object getColorRendering()(Code)
the technique to use for rendering colorsMay be one of:
  • RenderingHints.VALUE_COLOR_RENDER_DEFAULT
  • RenderingHints.VALUE_RENDER_QUALITY
  • RenderingHints.VALUE_RENDER_SPEED



getComposite
public Composite getComposite()(Code)
the composite



getDithering
public Object getDithering()(Code)
whether or not to ditherMay be one of:
  • RenderingHints.VALUE_DITHER_DEFAULT
  • RenderingHints.VALUE_DITHER_ENABLE
  • RenderingHints.VALUE_DITHER_DISABLE



getEffects
public Effect[] getEffects()(Code)
effects a defensive copy of the Effects to apply to the resultsof the AbstractPainter's painting operation. Will never null



getFractionalMetrics
public Object getFractionalMetrics()(Code)
whether or not to use fractional metricsMay be one of:
  • RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT
  • RenderingHints.VALUE_FRACTIONALMETRICS_OFF
  • RenderingHints.VALUE_FRACTIONALMETRICS_ON



getInterpolation
public Object getInterpolation()(Code)
the technique to use for interpolation (used esp. when scaling)May be one of:
  • RenderingHints.VALUE_INTERPOLATION_BICUBIC
  • RenderingHints.VALUE_INTERPOLATION_BILINEAR
  • RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR



getRendering
public Object getRendering()(Code)
a hint as to techniques to use with regards to rendering quality vs. speedMay be one of:
  • RenderingHints.VALUE_RENDER_QUALITY
  • RenderingHints.VALUE_RENDER_SPEED
  • RenderingHints.VALUE_RENDER_DEFAULT



getRenderingHint
public Object getRenderingHint(RenderingHints.Key key)(Code)
the rendering hint associated with the given key. May return null



getRenderingHints
public Map<RenderingHints.Key, Object> getRenderingHints()(Code)
a copy of the map of rendering hints held by this class. Thisreturned value will never be null



getResizeClip
public Resize getResizeClip()(Code)
value indication whether/how to resize the clip. Will never be null



getStrokeControl
public Object getStrokeControl()(Code)
technique for rendering strokesMay be one of:
  • RenderingHints.VALUE_STROKE_DEFAULT
  • RenderingHints.VALUE_STROKE_NORMALIZE
  • RenderingHints.VALUE_STROKE_PURE



getTextAntialiasing
public Object getTextAntialiasing()(Code)
technique for anti-aliasing text.(TODO this needs to be updated for Mustang. You may use thenew Mustang values, and everything will work, but support inthe GUI builder and documentation need to be added once webranch for Mustang)
May be one of:
  • RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT
  • RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
  • RenderingHints.VALUE_TEXT_ANTIALIAS_ON



isUseCache
public boolean isUseCache()(Code)
whether or not the cache should be used



paint
public void paint(Graphics2D g, T component)(Code)



paintBackground
abstract protected void paintBackground(Graphics2D g, T component)(Code)
Subclasses should implement this method and perform custom painting operations here. Common behavior, such as setting the clip and composite, saving and restoring state, is performed in the "paint" method automatically, and then delegated here.
Parameters:
  g - The Graphics2D object in which to paint
Parameters:
  component - The JComponent that the Painter is delegate for.



restoreState
protected void restoreState(Graphics2D g)(Code)
Restores previously saved state. A call to saveState must have occured prior to calling restoreState, or an IllegalStateException will be thrown.
Parameters:
  g - the Graphics2D object to restore previously saved state to



saveState
protected void saveState(Graphics2D g)(Code)
Saves the state in the given Graphics2D object so that it may be restored later.
Parameters:
  g - the Graphics2D object who's state will be saved



setAlphaInterpolation
public void setAlphaInterpolation(Object alphaInterpolation)(Code)
Sets the technique used for interpolating alpha values.
Parameters:
  alphaInterpolation - May be one of:
  • RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED
  • RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY
  • RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT



setAntialiasing
public void setAntialiasing(Object antialiasing)(Code)
Sets whether or not to antialias
Parameters:
  antialiasing - May be one of:
  • RenderingHints.VALUE_ANTIALIAS_DEFAULT
  • RenderingHints.VALUE_ANTIALIAS_OFF
  • RenderingHints.VALUE_ANTIALIAS_ON



setClip
public void setClip(Shape clip)(Code)
Specifies the Shape to use for clipping the painting area. This may be null
Parameters:
  clip - the Shape to use to clip the area. Whatever is inside thisshape will be kept, everything else "clipped". May be null. Ifnull, the clipping is not set on the graphics object



setColorRendering
public void setColorRendering(Object colorRendering)(Code)
Sets the technique to use for rendering colors
Parameters:
  colorRendering - May be one of:
  • RenderingHints.VALUE_COLOR_RENDER_DEFAULT
  • RenderingHints.VALUE_RENDER_QUALITY
  • RenderingHints.VALUE_RENDER_SPEED



setComposite
public void setComposite(Composite c)(Code)
Sets the Composite to use. For example, you may specify a specific AlphaComposite so that when this Painter paints, any content in the drawing area is handled properly
Parameters:
  c - The composite to use. If null, then no composite will bespecified on the graphics object



setDithering
public void setDithering(Object dithering)(Code)
Sets whether or not to dither
Parameters:
  dithering - May be one of:
  • RenderingHints.VALUE_DITHER_DEFAULT
  • RenderingHints.VALUE_DITHER_ENABLE
  • RenderingHints.VALUE_DITHER_DISABLE



setEffects
public void setEffects(Effect... effects)(Code)

Sets the effects to apply to the results of the AbstractPainter's painting operation. Some common effects include blurs, shadows, embossing, and so forth. If the given effects is a null array, no effects will be used


Parameters:
  effects - the Effects to apply to the results of the AbstractPainter'spainting operation



setEffects
public void setEffects(BufferedImageOp... filters)(Code)

A convenience method for specifying the effects to use based on BufferedImageOps. These will each be individually wrapped by an ImageEffect and then setEffects(Effect... effects) will be called with the resulting array


Parameters:
  filters - the BufferedImageOps to wrap as effects



setFractionalMetrics
public void setFractionalMetrics(Object fractionalMetrics)(Code)
Sets whether or not to use fractional metrics
Parameters:
  fractionalMetrics - May be one of:
  • RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT
  • RenderingHints.VALUE_FRACTIONALMETRICS_OFF
  • RenderingHints.VALUE_FRACTIONALMETRICS_ON



setInterpolation
public void setInterpolation(Object interpolation)(Code)
Sets the technique to use for interpolation (used esp. when scaling)
Parameters:
  interpolation - May be one of:
  • RenderingHints.VALUE_INTERPOLATION_BICUBIC
  • RenderingHints.VALUE_INTERPOLATION_BILINEAR
  • RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR



setRendering
public void setRendering(Object rendering)(Code)
Specifies a hint as to techniques to use with regards to rendering quality vs. speed
Parameters:
  rendering - May be one of:
  • RenderingHints.VALUE_RENDER_QUALITY
  • RenderingHints.VALUE_RENDER_SPEED
  • RenderingHints.VALUE_RENDER_DEFAULT



setRenderingHint
public void setRenderingHint(RenderingHints.Key key, Object hint)(Code)
Set the given hint for the given key. This will end up firing the appropriate property change event if the key is recognized. For example, if the key is RenderingHints.KEY_ANTIALIASING, then the setAntialiasing method will be called firing an "antialiasing" property change event if necessary. If the key is not recognized, no event will be fired but the key will be saved. The key must not be null
Parameters:
  key - cannot be null
Parameters:
  hint - must be a hint compatible with the given key



setRenderingHints
public void setRenderingHints(Map<RenderingHints.Key, Object> renderingHints)(Code)
Sets the rendering hints to use. This will replace the rendering hints entirely, clearing any hints that were previously set.
Parameters:
  renderingHints - map of hints. May be null. I null, a new Map ofrendering hints will be created



setResizeClip
public void setResizeClip(Resize r)(Code)
Specifies the resize behavior of the clip. As with all other properties that rely on Resize, the value of the width/height of the shape will represent a percentage of the width/height of the component, as a value between 0 and 1
Parameters:
  r - value indication whether/how to resize the clip. If null,Resize.NONE will be used



setStrokeControl
public void setStrokeControl(Object strokeControl)(Code)
Specifies a technique for rendering strokes
Parameters:
  strokeControl - May be one of:
  • RenderingHints.VALUE_STROKE_DEFAULT
  • RenderingHints.VALUE_STROKE_NORMALIZE
  • RenderingHints.VALUE_STROKE_PURE



setTextAntialiasing
public void setTextAntialiasing(Object textAntialiasing)(Code)
Sets the technique for anti-aliasing text. (TODO this needs to be updated for Mustang. You may use the new Mustang values, and everything will work, but support in the GUI builder and documentation need to be added once we branch for Mustang)

Parameters:
  textAntialiasing - May be one of:
  • RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT
  • RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
  • RenderingHints.VALUE_TEXT_ANTIALIAS_ON



setUseCache
public void setUseCache(boolean b)(Code)

Sets whether to cache the painted image with a SoftReference in a BufferedImage between calls. If true, and if the size of the component hasn't changed, then the cached image will be used rather than causing a painting operation.

This should be considered a hint, rather than absolute. Several factors may force repainting, including low memory, different component sizes, or possibly new rendering hint settings, etc.


Parameters:
  b - whether or not to use the cache



Methods inherited from org.jdesktop.beans.AbstractBean
final public void addPropertyChangeListener(PropertyChangeListener listener)(Code)(Java Doc)
final public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)(Java Doc)
final public void addVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc)
final public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener)(Code)(Java Doc)
public Object clone() throws CloneNotSupportedException(Code)(Java Doc)
final protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)(Code)(Java Doc)
final protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)(Code)(Java Doc)
final protected void firePropertyChange(PropertyChangeEvent evt)(Code)(Java Doc)
final protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException(Code)(Java Doc)
final protected void fireVetoableChange(PropertyChangeEvent evt) throws PropertyVetoException(Code)(Java Doc)
final public PropertyChangeListener[] getPropertyChangeListeners()(Code)(Java Doc)
final public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)(Code)(Java Doc)
final public VetoableChangeListener[] getVetoableChangeListeners()(Code)(Java Doc)
final public VetoableChangeListener[] getVetoableChangeListeners(String propertyName)(Code)(Java Doc)
final protected boolean hasPropertyChangeListeners(String propertyName)(Code)(Java Doc)
final protected boolean hasVetoableChangeListeners(String propertyName)(Code)(Java Doc)
final public void removePropertyChangeListener(PropertyChangeListener listener)(Code)(Java Doc)
final public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)(Java Doc)
final public void removeVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc)
final public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.