fr.esrf.tangoatk.widget.util.jdraw
Class JDSwingObject

java.lang.Object
  extended by fr.esrf.tangoatk.widget.util.jdraw.JDObject
      extended by fr.esrf.tangoatk.widget.util.jdraw.JDRectangular
          extended by fr.esrf.tangoatk.widget.util.jdraw.JDSwingObject

public class JDSwingObject
extends JDRectangular

JDraw Swing graphic object. JDSwingObject allows a JComponent to be edited (and played) within JDraw as if it is a JDObject. The JComponent must implements the JDrawable interface. Implementing JDrawable for a Component is interresting if you want to make your component available in the JDrawEditor. Adding a component for playing only can be done by using the classic add(Component) method, no need here to be JDrawable ,however the add() method shoud be called after initPlayer() or loadFile() is called. Here is an example of a simple JDrawable JButton:

 public class MyJDButton extends JButton implements JDrawable {

  static String[] extensions = {"text"};

  public void initForEditing() {
    setText("Button");
    setBorder(JDSwingObject.etchedBevelBorder);
  }

  public JComponent getComponent() {
    return this;
  }

  public String[] getExtensionList() {
    return extensions;
  }

  public boolean setExtendedParam(String name,String value,boolean popupAllowed) {
    if(name.equalsIgnoreCase("text")) {
      setText(value);
      return true;
    }
    return false;
  }

  public String getExtendedParam(String name) {
    if(name.equalsIgnoreCase("text")) {
      return getText();
    }
    return "";
  }

  public String getDescription(String extName) {
    if(extName.equalsIgnoreCase("text")) {
      return "JButton label";
    }
    return "";
  }

}
 

See Also:
JDrawable, JDrawableList, JDrawEditorFrame.main(java.lang.String[])

Field Summary
static int ETCHED_BORDER
          Etched border.
static javax.swing.border.Border etchedBevelBorder
          Swing Etched border used by JDSwingObject.
static javax.swing.border.Border lowerBevelBorder
          Swing Lowered border used by JDSwingObject.
static int LOWERED_BORDER
          Lowered border.
static int NO_BORDER
          No border.
static javax.swing.border.Border raiseBevelBorder
          Swing Raised border used by JDSwingObject.
static int RAISED_BORDER
          Raised border.
 
Fields inherited from class fr.esrf.tangoatk.widget.util.jdraw.JDObject
FILL_STYLE_DOT_PATTERN_1, FILL_STYLE_DOT_PATTERN_2, FILL_STYLE_DOT_PATTERN_3, FILL_STYLE_GRADIENT, FILL_STYLE_LARGE_CROSS_HATCH, FILL_STYLE_LARGE_LEFT_HATCH, FILL_STYLE_LARGE_RIGHT_HATCH, FILL_STYLE_NONE, FILL_STYLE_SMALL_CROSS_HATCH, FILL_STYLE_SMALL_LEFT_HATCH, FILL_STYLE_SMALL_RIGHT_HATCH, FILL_STYLE_SOLID, LINE_STYLE_DASH, LINE_STYLE_DASH_DOT, LINE_STYLE_DOT, LINE_STYLE_LONG_DASH, LINE_STYLE_SOLID, VALUE_CHANGE_ON_XDRAG_LEFT, VALUE_CHANGE_ON_XDRAG_RIGHT, VALUE_CHANGE_ON_YDRAG_BOTTOM, VALUE_CHANGE_ON_YDRAG_TOP, VALUE_INC_ON_CLICK, VALUE_INC_ON_PRESSRELEASE
 
Constructor Summary
JDSwingObject(java.lang.String objectName, java.lang.String className, int x, int y)
          Contruct a JDSwingObject
 
Method Summary
 JDObject copy(int x, int y)
          Returns a copy of this object at the specified location.
 int getBorder()
          Returns the current border.
 java.lang.String getClassName()
          Returns class name of the Swing JComponent object.
 javax.swing.JComponent getComponent()
          Returns the actual JComponent.
 java.lang.String getExtendedParamDesc(java.lang.String extName)
          Returns the description of the specified extension.
 java.awt.Font getFont()
          Returns the current font.
 boolean hasShadow()
          Returns true only if this object is shadowed.
 boolean isFixedExtendedParam(java.lang.String name)
          Returns true if the specified param is fixed.
 void paint(JDrawEditor parent, java.awt.Graphics g)
          Paints this object.
 void removeExtension(int idx)
          Remove the extended param at the specified index.
 void setBackground(java.awt.Color b)
          Sets the background color (usualy fill color) of this object.
 void setBorder(int border)
          Sets the border of this component.
 void setExtendedParam(java.lang.String name, java.lang.String value)
          Sets the extended param value.
 void setFillStyle(int style)
          Sets the fill style of this object.
 void setFont(java.awt.Font f)
          Sets the font of this JDSwingObject.
 void setFont(java.awt.Font f, boolean resize)
          Sets the font of this JDSwingObject and resize the component if needed.
 void setForeground(java.awt.Color b)
          Sets the foreground color (usualy line color) of this object.
 void setVisible(boolean v)
          Shows or hides this object.
 
Methods inherited from class fr.esrf.tangoatk.widget.util.jdraw.JDRectangular
moveSummit, rotate90
 
Methods inherited from class fr.esrf.tangoatk.widget.util.jdraw.JDObject
addExtension, addMouseListener, addValueListener, centerOrigin, clearMouseListener, clearValueListener, getBackground, getBackgroundMapper, getBoundRect, getExtendedParam, getExtendedParam, getExtendedParamIndex, getExtendedParamName, getExtendedParamNumber, getFillStyle, getForeground, getForegroundMapper, getHTranslationMapper, getInitValue, getInvertShadowMapper, getLineStyle, getLineWidth, getMaxValue, getMinValue, getName, getObjectsByName, getOrigin, getShadowWidth, getSummit, getSummitNumber, getValue, getValueChangeMode, getVisibilityMapper, getVTranslationMapper, hasBackgroundMapper, hasExtendedParam, hasForegroundMapper, hasHTranslationMapper, hasInverseShadow, hasInvertShadowMapper, hasVisibilityMapper, hasVTranslationMapper, isAntiAliased, isInsideObject, isInteractive, isProgrammed, isVisible, moveSummitH, moveSummitV, preRefresh, refresh, removeMouseListener, removeValueListener, restoreTransform, saveTransform, scale, scaleTranslate, setAntiAlias, setBackgroundMapper, setExtendedParam, setExtensionList, setForegroundMapper, setGradientFillParam, setHTranslationMapper, setInitValue, setInteractive, setInverseShadow, setInvertShadowMapper, setLineStyle, setLineWidth, setMaxValue, setMinValue, setName, setOrigin, setShadow, setShadowWidth, setValue, setValueChangeMode, setVisibilityMapper, setVTranslationMapper, toString, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lowerBevelBorder

public static javax.swing.border.Border lowerBevelBorder
Swing Lowered border used by JDSwingObject.


raiseBevelBorder

public static javax.swing.border.Border raiseBevelBorder
Swing Raised border used by JDSwingObject.


etchedBevelBorder

public static javax.swing.border.Border etchedBevelBorder
Swing Etched border used by JDSwingObject.


NO_BORDER

public static final int NO_BORDER
No border.

See Also:
Constant Field Values

LOWERED_BORDER

public static final int LOWERED_BORDER
Lowered border.

See Also:
Constant Field Values

RAISED_BORDER

public static final int RAISED_BORDER
Raised border.

See Also:
Constant Field Values

ETCHED_BORDER

public static final int ETCHED_BORDER
Etched border.

See Also:
Constant Field Values
Constructor Detail

JDSwingObject

public JDSwingObject(java.lang.String objectName,
                     java.lang.String className,
                     int x,
                     int y)
Contruct a JDSwingObject

Parameters:
objectName - Object name
className - Class name of the JDrawable object
x - Up left corner x coordinate
y - Up left corner y coordinate
Method Detail

copy

public JDObject copy(int x,
                     int y)
Description copied from class: JDObject
Returns a copy of this object at the specified location.

Specified by:
copy in class JDObject
Parameters:
x - Horizontal position of the copied object (pixel)
y - Vertical Position of the copied object (pixel)
Returns:
The copy of this object.

paint

public void paint(JDrawEditor parent,
                  java.awt.Graphics g)
Description copied from class: JDObject
Paints this object.

Overrides:
paint in class JDRectangular
Parameters:
parent - JdrawEditor parent (Can be null except for JDSwingObject)
g - the specified Graphics window

isFixedExtendedParam

public boolean isFixedExtendedParam(java.lang.String name)
Returns true if the specified param is fixed. (coming from JDrawable)

Overrides:
isFixedExtendedParam in class JDObject
Parameters:
name - Param name.

setExtendedParam

public void setExtendedParam(java.lang.String name,
                             java.lang.String value)
Description copied from class: JDObject
Sets the extended param value.

Overrides:
setExtendedParam in class JDObject
Parameters:
name - Param name
value - Param value
See Also:
JDObject.setExtensionList(java.lang.String[])

removeExtension

public void removeExtension(int idx)
Description copied from class: JDObject
Remove the extended param at the specified index.

Overrides:
removeExtension in class JDObject
Parameters:
idx - Index of the extension.

getExtendedParamDesc

public java.lang.String getExtendedParamDesc(java.lang.String extName)
Description copied from class: JDObject
Returns the description of the specified extension.

Overrides:
getExtendedParamDesc in class JDObject
Parameters:
extName - Extension name

setBackground

public void setBackground(java.awt.Color b)
Description copied from class: JDObject
Sets the background color (usualy fill color) of this object.

Overrides:
setBackground in class JDObject
Parameters:
b - Background color

setForeground

public void setForeground(java.awt.Color b)
Description copied from class: JDObject
Sets the foreground color (usualy line color) of this object. This color is also used for base shadow color.

Overrides:
setForeground in class JDObject
Parameters:
b - Foreground color

setVisible

public void setVisible(boolean v)
Description copied from class: JDObject
Shows or hides this object.

Overrides:
setVisible in class JDObject
Parameters:
v - True to show, false otherwise.

setFillStyle

public void setFillStyle(int style)
Description copied from class: JDObject
Sets the fill style of this object.

Overrides:
setFillStyle in class JDObject
Parameters:
style - Fill style
See Also:
JDObject.FILL_STYLE_NONE, JDObject.FILL_STYLE_SOLID, JDObject.FILL_STYLE_LARGE_RIGHT_HATCH, JDObject.FILL_STYLE_LARGE_LEFT_HATCH, JDObject.FILL_STYLE_LARGE_CROSS_HATCH, JDObject.FILL_STYLE_SMALL_RIGHT_HATCH, JDObject.FILL_STYLE_SMALL_LEFT_HATCH, JDObject.FILL_STYLE_SMALL_CROSS_HATCH, JDObject.FILL_STYLE_DOT_PATTERN_1, JDObject.FILL_STYLE_DOT_PATTERN_2, JDObject.FILL_STYLE_DOT_PATTERN_3, JDObject.FILL_STYLE_GRADIENT

setFont

public void setFont(java.awt.Font f)
Sets the font of this JDSwingObject.

Parameters:
f - Font

setFont

public void setFont(java.awt.Font f,
                    boolean resize)
Sets the font of this JDSwingObject and resize the component if needed.

Parameters:
f - Font
resize - true to resize the component.

setBorder

public void setBorder(int border)
Sets the border of this component.

Parameters:
border - Border
See Also:
NO_BORDER, LOWERED_BORDER, RAISED_BORDER, ETCHED_BORDER

getBorder

public int getBorder()
Returns the current border.

See Also:
setBorder(int)

getFont

public java.awt.Font getFont()
Returns the current font.

See Also:
setFont(Font), setFont(Font,boolean)

hasShadow

public boolean hasShadow()
Description copied from class: JDObject
Returns true only if this object is shadowed.

Overrides:
hasShadow in class JDObject

getClassName

public java.lang.String getClassName()
Returns class name of the Swing JComponent object.


getComponent

public javax.swing.JComponent getComponent()
Returns the actual JComponent.