org.jdesktop.swingx.editors
Class Paint2PropertyEditor

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.jdesktop.swingx.editors.Paint2PropertyEditor
All Implemented Interfaces:
PropertyEditor

public class Paint2PropertyEditor
extends PropertyEditorSupport


Constructor Summary
Paint2PropertyEditor()
          Creates a new instance of Paint2PropertyEditor
 
Method Summary
 String getAsText()
          Gets the property value as a string suitable for presentation to a human to edit.
 Component getCustomEditor()
          A PropertyEditor may chose to make available a full custom Component that edits its property value.
 String getJavaInitializationString()
          This method is intended for use when generating Java code to set the value of the property.
 Paint getValue()
          Gets the value of the property.
 boolean isPaintable()
          Determines whether the class will honor the paintValue method.
 void paintValue(Graphics g, Rectangle box)
          Paint a representation of the value into a given area of screen real estate.
 void setAsText(String text)
          Sets the property value by parsing a given String.
 void setValue(Object object)
          Set (or change) the object that is to be edited.
 boolean supportsCustomEditor()
          Determines whether the propertyEditor can provide a custom editor.
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getSource, getTags, removePropertyChangeListener, setSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Paint2PropertyEditor

public Paint2PropertyEditor()
Creates a new instance of Paint2PropertyEditor

Method Detail

getValue

public Paint getValue()
Description copied from class: java.beans.PropertyEditorSupport
Gets the value of the property.

Specified by:
getValue in interface PropertyEditor
Overrides:
getValue in class PropertyEditorSupport
Returns:
The value of the property.

setValue

public void setValue(Object object)
Description copied from class: java.beans.PropertyEditorSupport
Set (or change) the object that is to be edited.

Specified by:
setValue in interface PropertyEditor
Overrides:
setValue in class PropertyEditorSupport
Parameters:
object - The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.

getJavaInitializationString

public String getJavaInitializationString()
Description copied from class: java.beans.PropertyEditorSupport
This method is intended for use when generating Java code to set the value of the property. It should return a fragment of Java code that can be used to initialize a variable with the current property value.

Example results are "2", "new Color(127,127,34)", "Color.orange", etc.

Specified by:
getJavaInitializationString in interface PropertyEditor
Overrides:
getJavaInitializationString in class PropertyEditorSupport
Returns:
A fragment of Java code representing an initializer for the current value.

setAsText

public void setAsText(String text)
               throws IllegalArgumentException
Description copied from class: java.beans.PropertyEditorSupport
Sets the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.

Specified by:
setAsText in interface PropertyEditor
Overrides:
setAsText in class PropertyEditorSupport
Parameters:
text - The string to be parsed.
Throws:
IllegalArgumentException

getAsText

public String getAsText()
Description copied from class: java.beans.PropertyEditorSupport
Gets the property value as a string suitable for presentation to a human to edit.

Specified by:
getAsText in interface PropertyEditor
Overrides:
getAsText in class PropertyEditorSupport
Returns:
The property value as a string suitable for presentation to a human to edit.

Returns "null" is the value can't be expressed as a string.

If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().


paintValue

public void paintValue(Graphics g,
                       Rectangle box)
Description copied from class: java.beans.PropertyEditorSupport
Paint a representation of the value into a given area of screen real estate. Note that the propertyEditor is responsible for doing its own clipping so that it fits into the given rectangle.

If the PropertyEditor doesn't honor paint requests (see isPaintable) this method should be a silent noop.

Specified by:
paintValue in interface PropertyEditor
Overrides:
paintValue in class PropertyEditorSupport
Parameters:
g - Graphics object to paint into.
box - Rectangle within graphics object into which we should paint.

isPaintable

public boolean isPaintable()
Description copied from class: java.beans.PropertyEditorSupport
Determines whether the class will honor the paintValue method.

Specified by:
isPaintable in interface PropertyEditor
Overrides:
isPaintable in class PropertyEditorSupport
Returns:
True if the class will honor the paintValue method.

supportsCustomEditor

public boolean supportsCustomEditor()
Description copied from class: java.beans.PropertyEditorSupport
Determines whether the propertyEditor can provide a custom editor.

Specified by:
supportsCustomEditor in interface PropertyEditor
Overrides:
supportsCustomEditor in class PropertyEditorSupport
Returns:
True if the propertyEditor can provide a custom editor.

getCustomEditor

public Component getCustomEditor()
Description copied from class: java.beans.PropertyEditorSupport
A PropertyEditor may chose to make available a full custom Component that edits its property value. It is the responsibility of the PropertyEditor to hook itself up to its editor Component itself and to report property value changes by firing a PropertyChange event.

The higher-level code that calls getCustomEditor may either embed the Component in some larger property sheet, or it may put it in its own individual dialog, or ...

Specified by:
getCustomEditor in interface PropertyEditor
Overrides:
getCustomEditor in class PropertyEditorSupport
Returns:
A java.awt.Component that will allow a human to directly edit the current property value. May be null if this is not supported.