Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.swingx.painter
Class ShapePainter

    java.lang.Object
      org.jdesktop.beans.AbstractBean
          org.jdesktop.swingx.painter.AbstractPainter<T>
              org.jdesktop.swingx.painter.AbstractLayoutPainter<T>
                  org.jdesktop.swingx.painter.AbstractAreaPainter<java.lang.Object>
                      org.jdesktop.swingx.painter.ShapePainter

All Implemented Interfaces:
  Painter<java.lang.Object>

    public class ShapePainter

extends AbstractAreaPainter<java.lang.Object>

A Painter that paints java.awt.Shapes. It uses a stroke and a fillPaint to do so. The shape is painted as is, at a specific location. If no Shape is specified, nothing will be painted. If no stroke is specified, the default for the Graphics2D will be used. If no fillPaint is specified, the component background color will be used. The shape can be positioned using the insets, horizontal, and vertical properties.

Here is an example that draws a rectangle aligned on the center right:

      Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, 50, 50);
      ShapePainter p = new ShapePainter(rect);
     p.setHorizontal(HorizontalAlignment.RIGHT);
     p.setVertical(VerticalAlignment.CENTER);

Author:
  rbair

Nested Class Summary

Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractAreaPainter
`AbstractAreaPainter.Style`

Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractLayoutPainter
`AbstractLayoutPainter.HorizontalAlignment, AbstractLayoutPainter.VerticalAlignment`

Nested classes/interfaces inherited from class org.jdesktop.swingx.painter.AbstractPainter
`AbstractPainter.Interpolation`

Constructor Summary
`ShapePainter()` Create a new ShapePainter
`ShapePainter(java.awt.Shape shape)` Create a new ShapePainter with the specified shape.
`ShapePainter(java.awt.Shape shape, java.awt.Paint paint)` Create a new ShapePainter with the specified shape and fillPaint.
`ShapePainter(java.awt.Shape shape, java.awt.Paint paint, AbstractAreaPainter.Style style)` Create a new ShapePainter with the specified shape and fillPaint.

Method Summary
`protected void` | `doPaint(java.awt.Graphics2D g, java.lang.Object component, int w, int h)` Subclasses must implement this method and perform custom painting operations here.
`java.awt.Shape` | `getShape()` Gets the current shape
`protected java.awt.Shape` | `provideShape(java.awt.Graphics2D g, java.lang.Object comp, int width, int height)` Returns the outline shape of this painter.
`void` | `setShape(java.awt.Shape s)` Sets the shape to fillPaint.

Methods inherited from class org.jdesktop.swingx.painter.AbstractAreaPainter
`getAreaEffects, getBorderPaint, getBorderWidth, getFillPaint, getStyle, isPaintStretched, setAreaEffects, setBorderPaint, setBorderWidth, setFillPaint, setPaintStretched, setStyle`

Methods inherited from class org.jdesktop.swingx.painter.AbstractLayoutPainter
`calculateLayout, getHorizontalAlignment, getInsets, getVerticalAlignment, isFillHorizontal, isFillVertical, setFillHorizontal, setFillVertical, setHorizontalAlignment, setInsets, setVerticalAlignment`

Methods inherited from class org.jdesktop.swingx.painter.AbstractPainter
`clearCache, configureGraphics, getFilters, getInterpolation, isAntialiasing, isCacheable, isDirty, isVisible, paint, setAntialiasing, setCacheable, setDirty, setFilters, setInterpolation, setVisible, shouldUseCache, validate`

Methods inherited from class org.jdesktop.beans.AbstractBean
`addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ShapePainter

    public ShapePainter()

  Create a new ShapePainter

### ShapePainter

    public ShapePainter(java.awt.Shape shape)

  Create a new ShapePainter with the specified shape.

  Parameters:
    `shape` - the shape to fillPaint

### ShapePainter

    public ShapePainter(java.awt.Shape shape,
                        java.awt.Paint paint)

  Create a new ShapePainter with the specified shape and fillPaint.

  Parameters:
    `shape` - the shape to fillPaint
    `paint` - the fillPaint to be used to fillPaint the shape

### ShapePainter

    public ShapePainter(java.awt.Shape shape,
                        java.awt.Paint paint,
                        AbstractAreaPainter.Style style)

  Create a new ShapePainter with the specified shape and fillPaint. The shape can be filled or stroked (only the outline is painted).

  Parameters:
    `shape` - the shape to fillPaint
    `paint` - the fillPaint to be used to fillPaint the shape
    `style` - specifies the ShapePainter.Style to use for painting this shape. If null, then Style.BOTH is used

Method Detail

### setShape

    public void setShape(java.awt.Shape s)

  Sets the shape to fillPaint. This shape is not resized when the component bounds are. To do that, create a custom shape that is bound to the component width/height

  Parameters:
    `s` - the Shape to fillPaint. May be null

### getShape

    public java.awt.Shape getShape()

  Gets the current shape

  Returns:
    the Shape to fillPaint. May be null

### doPaint

    protected void doPaint(java.awt.Graphics2D g,
                           java.lang.Object component,
                           int w,
                           int h)

  Subclasses must implement this method and perform custom painting operations here.

  Specified by:
    `doPaint` in class `AbstractPainter<java.lang.Object>`
  Parameters:
    `g` - The Graphics2D object in which to paint

### provideShape

    protected java.awt.Shape provideShape(java.awt.Graphics2D g,
                                          java.lang.Object comp,
                                          int width,
                                          int height)

  Description copied from class: `AbstractAreaPainter`
  Returns the outline shape of this painter. Subclasses must implement this method. This shape will be used for filling, stroking, and clipping.

  Specified by:
    `provideShape` in class `AbstractAreaPainter<java.lang.Object>`
  Parameters:
    `g` - graphics
    `comp` - The Object this painter will be painted on.
    `width` - the width to paint
    `height` - the height to paint
  Returns:
    the outline shape of this painter

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010. All Rights Reserved.