Class JDSwingObject
java.lang.Object
fr.esrf.tangoatk.widget.util.jdraw.JDObject
fr.esrf.tangoatk.widget.util.jdraw.JDRectangular
fr.esrf.tangoatk.widget.util.jdraw.JDSwingObject
- All Implemented Interfaces:
MouseListener,EventListener
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 "";
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intEtched border.static BorderSwing Etched border used by JDSwingObject.static BorderSwing Lowered border used by JDSwingObject.static final intLowered border.static final intNo border.static BorderSwing Raised border used by JDSwingObject.static final intRaised 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
ConstructorsConstructorDescriptionJDSwingObject(String objectName, String className, int x, int y) Contruct a JDSwingObject -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified mouse listener to this object.copy(int x, int y) Returns a copy of this object at the specified location.intgetExtendedParamDesc(String extName) getFont()booleanbooleanisFixedExtendedParam(String name) voidvoidvoidvoidvoidvoidpaint(JDrawEditor parent, Graphics g) Paints this object.voidremoveExtension(int idx) Remove the extended param at the specified index.voidRemove the specified mouse listener from this object.voidSets the background color (usualy fill color) of this object.voidsetBorder(int border) Sets the border of this component.voidsetExtendedParam(String name, String value) Sets the extended param value.voidsetFillStyle(int style) Sets the fill style of this object.voidSets the font of this JDSwingObject.voidSets the font of this JDSwingObject and resize the component if needed.voidSets the foreground color (usualy line color) of this object.voidsetVisible(boolean v) Shows or hides this object.Methods inherited from class fr.esrf.tangoatk.widget.util.jdraw.JDRectangular
getBottom, getHeight, getLeft, getRight, getTop, getWidth, moveSummit, rotate90, setBottom, setHeight, setLeft, setRight, setTop, setWidthMethods inherited from class fr.esrf.tangoatk.widget.util.jdraw.JDObject
addExtension, 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, isDisabled, isInsideObject, isInteractive, isProgrammed, isVisible, moveSummitH, moveSummitV, preRefresh, refresh, removeValueListener, restoreTransform, saveTransform, scale, scaleTranslate, setAntiAlias, setBackgroundMapper, setDisabled, setExtendedParam, setExtensionList, setForegroundMapper, setGradientFillParam, setHTranslationMapper, setInitValue, setInteractive, setInverseShadow, setInvertShadowMapper, setLineStyle, setLineWidth, setMaxValue, setMinValue, setName, setOrigin, setShadow, setShadowWidth, setValue, setValueChangeMode, setVisibilityMapper, setVTranslationMapper, toString, translate
-
Field Details
-
lowerBevelBorder
Swing Lowered border used by JDSwingObject. -
raiseBevelBorder
Swing Raised border used by JDSwingObject. -
etchedBevelBorder
Swing Etched border used by JDSwingObject. -
NO_BORDER
public static final int NO_BORDERNo border.- See Also:
-
LOWERED_BORDER
public static final int LOWERED_BORDERLowered border.- See Also:
-
RAISED_BORDER
public static final int RAISED_BORDERRaised border.- See Also:
-
ETCHED_BORDER
public static final int ETCHED_BORDEREtched border.- See Also:
-
-
Constructor Details
-
JDSwingObject
Contruct a JDSwingObject- Parameters:
objectName- Object nameclassName- Class name of the JDrawable objectx- Up left corner x coordinatey- Up left corner y coordinate
-
-
Method Details
-
copy
Description copied from class:JDObjectReturns a copy of this object at the specified location. -
paint
Description copied from class:JDObjectPaints this object.- Overrides:
paintin classJDRectangular- Parameters:
parent- JdrawEditor parent (Can be null except for JDSwingObject)g- the specified Graphics window
-
isFixedExtendedParam
- Overrides:
isFixedExtendedParamin classJDObject- Parameters:
name- Param name.- Returns:
- true if the specified param is fixed. (coming from JDrawable)
-
addMouseListener
Description copied from class:JDObjectAdds the specified mouse listener to this object.- Overrides:
addMouseListenerin classJDObject- Parameters:
l- JDMouseListener
-
removeMouseListener
Description copied from class:JDObjectRemove the specified mouse listener from this object.- Overrides:
removeMouseListenerin classJDObject- Parameters:
l- Listener to be removed.
-
setExtendedParam
Description copied from class:JDObjectSets the extended param value.- Overrides:
setExtendedParamin classJDObject- Parameters:
name- Param namevalue- Param value- See Also:
-
removeExtension
public void removeExtension(int idx) Description copied from class:JDObjectRemove the extended param at the specified index.- Overrides:
removeExtensionin classJDObject- Parameters:
idx- Index of the extension.
-
getExtendedParamDesc
- Overrides:
getExtendedParamDescin classJDObject- Parameters:
extName- Extension name- Returns:
- the description of the specified extension.
-
setBackground
Description copied from class:JDObjectSets the background color (usualy fill color) of this object.- Overrides:
setBackgroundin classJDObject- Parameters:
b- Background color
-
setForeground
Description copied from class:JDObjectSets the foreground color (usualy line color) of this object. This color is also used for base shadow color.- Overrides:
setForegroundin classJDObject- Parameters:
b- Foreground color
-
setVisible
public void setVisible(boolean v) Description copied from class:JDObjectShows or hides this object.- Overrides:
setVisiblein classJDObject- Parameters:
v- True to show, false otherwise.
-
setFillStyle
public void setFillStyle(int style) Description copied from class:JDObjectSets the fill style of this object.- Overrides:
setFillStylein classJDObject- Parameters:
style- Fill style- See Also:
-
JDObject.FILL_STYLE_NONEJDObject.FILL_STYLE_SOLIDJDObject.FILL_STYLE_LARGE_RIGHT_HATCHJDObject.FILL_STYLE_LARGE_LEFT_HATCHJDObject.FILL_STYLE_LARGE_CROSS_HATCHJDObject.FILL_STYLE_SMALL_RIGHT_HATCHJDObject.FILL_STYLE_SMALL_LEFT_HATCHJDObject.FILL_STYLE_SMALL_CROSS_HATCHJDObject.FILL_STYLE_DOT_PATTERN_1JDObject.FILL_STYLE_DOT_PATTERN_2JDObject.FILL_STYLE_DOT_PATTERN_3JDObject.FILL_STYLE_GRADIENT
-
setFont
Sets the font of this JDSwingObject.- Parameters:
f- Font
-
setFont
Sets the font of this JDSwingObject and resize the component if needed.- Parameters:
f- Fontresize- true to resize the component.
-
setBorder
public void setBorder(int border) Sets the border of this component.- Parameters:
border- Border- See Also:
-
getBorder
public int getBorder()- Returns:
- the current border.
- See Also:
-
getFont
- Returns:
- the current font.
- See Also:
-
hasShadow
public boolean hasShadow() -
getClassName
- Returns:
- class name of the Swing JComponent object.
-
getComponent
- Returns:
- the actual JComponent.
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-