Class JDObject

java.lang.Object
fr.esrf.tangoatk.widget.util.jdraw.JDObject
Direct Known Subclasses:
JDLine, JDPolyline, JDRectangular

public abstract class JDObject extends Object
An abstract class for the JDraw graphics objects. This class handle all common properties of JDObject.
  • Field Details

    • LINE_STYLE_SOLID

      public static final int LINE_STYLE_SOLID
      Solid line style
      See Also:
    • LINE_STYLE_DOT

      public static final int LINE_STYLE_DOT
      Dot line style
      See Also:
    • LINE_STYLE_DASH

      public static final int LINE_STYLE_DASH
      Dash line style
      See Also:
    • LINE_STYLE_LONG_DASH

      public static final int LINE_STYLE_LONG_DASH
      Long Dash line style
      See Also:
    • LINE_STYLE_DASH_DOT

      public static final int LINE_STYLE_DASH_DOT
      Dash + Dot line style
      See Also:
    • FILL_STYLE_NONE

      public static final int FILL_STYLE_NONE
      No filling
      See Also:
    • FILL_STYLE_SOLID

      public static final int FILL_STYLE_SOLID
      Solid fill style
      See Also:
    • FILL_STYLE_LARGE_RIGHT_HATCH

      public static final int FILL_STYLE_LARGE_RIGHT_HATCH
      Hatch fill style
      See Also:
    • FILL_STYLE_LARGE_LEFT_HATCH

      public static final int FILL_STYLE_LARGE_LEFT_HATCH
      Hatch fill style
      See Also:
    • FILL_STYLE_LARGE_CROSS_HATCH

      public static final int FILL_STYLE_LARGE_CROSS_HATCH
      Hatch fill style
      See Also:
    • FILL_STYLE_SMALL_RIGHT_HATCH

      public static final int FILL_STYLE_SMALL_RIGHT_HATCH
      Hatch fill style
      See Also:
    • FILL_STYLE_SMALL_LEFT_HATCH

      public static final int FILL_STYLE_SMALL_LEFT_HATCH
      Hatch fill style
      See Also:
    • FILL_STYLE_SMALL_CROSS_HATCH

      public static final int FILL_STYLE_SMALL_CROSS_HATCH
      Hatch fill style
      See Also:
    • FILL_STYLE_DOT_PATTERN_1

      public static final int FILL_STYLE_DOT_PATTERN_1
      Hatch fill style
      See Also:
    • FILL_STYLE_DOT_PATTERN_2

      public static final int FILL_STYLE_DOT_PATTERN_2
      Hatch fill style
      See Also:
    • FILL_STYLE_DOT_PATTERN_3

      public static final int FILL_STYLE_DOT_PATTERN_3
      Hatch fill style
      See Also:
    • FILL_STYLE_GRADIENT

      public static final int FILL_STYLE_GRADIENT
      Gradient fill style
      See Also:
    • VALUE_INC_ON_CLICK

      public static final int VALUE_INC_ON_CLICK
      the object value is incremented (+1) on click
      See Also:
    • VALUE_INC_ON_PRESSRELEASE

      public static final int VALUE_INC_ON_PRESSRELEASE
      the object value is incremented (+1) on mousePressed or mouseReleased
      See Also:
    • VALUE_CHANGE_ON_XDRAG_LEFT

      public static final int VALUE_CHANGE_ON_XDRAG_LEFT
      the object value receive the x mouse coordinates when dragged (relative to left of object)
      See Also:
    • VALUE_CHANGE_ON_XDRAG_RIGHT

      public static final int VALUE_CHANGE_ON_XDRAG_RIGHT
      the object value receive the x mouse coordinates when dragged (relative to right of object)
      See Also:
    • VALUE_CHANGE_ON_YDRAG_TOP

      public static final int VALUE_CHANGE_ON_YDRAG_TOP
      the object value receive the y mouse coordinates when dragged (relative to top of object)
      See Also:
    • VALUE_CHANGE_ON_YDRAG_BOTTOM

      public static final int VALUE_CHANGE_ON_YDRAG_BOTTOM
      the object value receive the y mouse coordinates when dragged (relative to bottom of object)
      See Also:
  • Constructor Details

    • JDObject

      public JDObject()
  • Method Details

    • getValue

      public int getValue()
      Returns:
      the value of this object.
      See Also:
    • setValue

      public void setValue(int v)
      Sets the value of this object and execute the dynamic object program if enabled. If this object is a JDGroup, the specified value is spread all over children of this group.
      Parameters:
      v - New value
    • addValueListener

      public void addValueListener(JDValueListener l)
      Adds the specified value listener to this object.
      Parameters:
      l - Value listener
    • addMouseListener

      public void addMouseListener(JDMouseListener l)
      Adds the specified mouse listener to this object.
      Parameters:
      l - JDMouseListener
    • removeValueListener

      public void removeValueListener(JDValueListener l)
      Remove the specified value listener from this object.
      Parameters:
      l - Listener to be removed.
    • removeMouseListener

      public void removeMouseListener(JDMouseListener l)
      Remove the specified mouse listener from this object.
      Parameters:
      l - Listener to be removed.
    • clearValueListener

      public void clearValueListener()
      Remove all value listener belonging to this object.
    • clearMouseListener

      public void clearMouseListener()
      Remove all mouse listener belonging to this object.
    • paint

      public abstract void paint(JDrawEditor parent, Graphics g)
      Paints this object.
      Parameters:
      parent - JdrawEditor parent (Can be null except for JDSwingObject)
      g - the specified Graphics window
    • getObjectsByName

      public void getObjectsByName(Vector result, String name, boolean recurseGroup)
      Return all objects having the given name.
      Parameters:
      result - Result vector (must be constructed by the caller)
      name - JDObject name (Case sensitive)
      recurseGroup - true to perform a deep search whithin group, false otherwise.
      See Also:
    • getBoundRect

      public Rectangle getBoundRect()
      Returns:
      the bounding rectangle of this object.
    • isInsideObject

      public boolean isInsideObject(int x, int y)
      Parameters:
      x - X coordinate (pixel)
      y - Y coordinate (pixel)
      Returns:
      whether the specified point is inside this object.
    • getSummitNumber

      public int getSummitNumber()
      Returns:
      the summit number of this object.
    • getSummit

      public Point2D.Double getSummit(int id)
      Parameters:
      id - Summit index
      Returns:
      the summit at the specified position. Do not use this to change summit coordinates, Use moveSummit() instead.
      See Also:
    • moveSummit

      public abstract void moveSummit(int id, double x, double y)
      Moves the specifed summit to the specified position. When using moveSummit() to animate objects, A call to refresh() of this object may be needed.
      Parameters:
      id - Summit index
      x - Absolute X position
      y - Absolute Y position
      See Also:
    • moveSummitH

      public void moveSummitH(int id, double x)
      Moves horizontaly the specifed summit to the specified position. When using moveSummit() to animate objects, A call to refresh() of this object may be needed.
      Parameters:
      id - Summit index
      x - Absolute X position
      See Also:
    • moveSummitV

      public void moveSummitV(int id, double y)
      Moves verticaly the specifed summit to the specified position. When using moveSummit() to animate objects, A call to refresh() of this object may be needed.
      Parameters:
      id - Summit index
      y - Absolute Y position
      See Also:
    • copy

      public abstract JDObject copy(int x, int y)
      Returns a copy of this object at the specified location.
      Parameters:
      x - Horizontal position of the copied object (pixel)
      y - Vertical Position of the copied object (pixel)
      Returns:
      The copy of this object.
    • translate

      public void translate(double x, double y)
      Translate this object. A call to refresh() is needed after translation.
      Parameters:
      x - H translation
      y - V translation
      See Also:
    • scaleTranslate

      public void scaleTranslate(double scaleX, double scaleY, double ratioX, double ratioY, double transX, double transY)
      Scale, then translate this object. A call to refresh() is needed after transformation.
      Parameters:
      scaleX - Scaling origin
      scaleY - Scaling origin
      ratioX - H scaling ratio
      ratioY - V scaling ration
      transX - H translation
      transY - V translation
      See Also:
    • scale

      public void scale(double x, double y, double rx, double ry)
      Scale this object. A call to refresh() is needed after transformation.
      Parameters:
      x - Scaling origin
      y - Scaling origin
      rx - H scaling ratio
      ry - V scaling ration
      See Also:
    • rotate90

      public void rotate90(double x, double y)
      Rotate the object by 90deg. A call to refresh() is needed after transformation.
      Parameters:
      x - Rotation center horizontal pos
      y - Rotation center vertical pos
      See Also:
    • restoreTransform

      public void restoreTransform()
      Restore original shape previously backuped by saveTransform
      See Also:
    • saveTransform

      public void saveTransform()
      Backup the shape. This can be usefull when making scaling animation, after multiple scale the rounding may result in deformed shape. To avoid this you can use saveTransform() and restoreTransform(). Note: This is done once when JDrawEditor.loadFile() is called().
      See Also:
    • setVisible

      public void setVisible(boolean b)
      Shows or hides this object.
      Parameters:
      b - True to show, false otherwise.
    • isVisible

      public boolean isVisible()
      Returns:
      whether this object is visible.
    • setName

      public void setName(String s)
      Sets the name of this object.
      Parameters:
      s - Object name
    • getName

      public String getName()
      Returns:
      the current name of this object.
    • setBackground

      public void setBackground(Color c)
      Sets the background color (usualy fill color) of this object.
      Parameters:
      c - Background color
    • getBackground

      public Color getBackground()
      Returns:
      the current background color of this object.
      See Also:
    • setForeground

      public void setForeground(Color c)
      Sets the foreground color (usualy line color) of this object. This color is also used for base shadow color.
      Parameters:
      c - Foreground color
    • getForeground

      public Color getForeground()
      Returns:
      the current foreground color of this object.
      See Also:
    • setOrigin

      public void setOrigin(Point2D.Double p)
      Sets the origin of this object.
      Parameters:
      p - Origin point.
    • centerOrigin

      public void centerOrigin()
      Center the origin.
    • getOrigin

      public Point2D.Double getOrigin()
      Returns:
      the current origin.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setFillStyle

      public void setFillStyle(int style)
      Sets the fill style of this object.
      Parameters:
      style - Fill style
      See Also:
    • getFillStyle

      public int getFillStyle()
      Returns:
      the current fill style of this object.
      See Also:
    • setLineStyle

      public void setLineStyle(int style)
      Sets the line style.
      Parameters:
      style - Line style
      See Also:
    • getLineStyle

      public int getLineStyle()
      Returns:
      the current line style of this object.
      See Also:
    • setAntiAlias

      public void setAntiAlias(boolean aliasing)
      Enables or disables the anti aliasing for this object.
      Parameters:
      aliasing - True to enable antialiasing, false otherwise
    • isAntiAliased

      public boolean isAntiAliased()
      Returns:
      wheter this object is anti aliased.
    • setLineWidth

      public void setLineWidth(int width)
      Sets the line width of this object.
      Parameters:
      width - Line width (pixel)
    • getLineWidth

      public int getLineWidth()
      Returns:
      the current line width of this object.
    • hasShadow

      public boolean hasShadow()
      Returns:
      true only if this object is shadowed.
    • setShadow

      public void setShadow(boolean b)
      Enables or disabled shadow for this object. By default shadow represents a lowered bevel border. To change the shadow orientation, you can call setInverseShadow().
      Parameters:
      b - Shadow flag.
      See Also:
    • setShadowWidth

      public void setShadowWidth(int w)
      Sets the shadow thickness of this object.
      Parameters:
      w - Shadow thickness.
    • getShadowWidth

      public int getShadowWidth()
      Returns:
      the current shadow thickness.
      See Also:
    • hasInverseShadow

      public boolean hasInverseShadow()
      Returns:
      whether this object has inverse shadow.
      See Also:
    • setInverseShadow

      public void setInverseShadow(boolean b)
      Sets inverse shadow for this object.
      Parameters:
      b - Inverse shadow flag.
      See Also:
    • setMinValue

      public void setMinValue(int min)
      Sets the minimum value of this object.
      Parameters:
      min - Min value
      See Also:
    • getMinValue

      public int getMinValue()
      Returns:
      the minimum value of this object.
      See Also:
    • setMaxValue

      public void setMaxValue(int max)
      Sets the max value of this object.
      Parameters:
      max - Max value
      See Also:
    • getMaxValue

      public int getMaxValue()
      Returns:
      the maximum value of this object.
      See Also:
    • setInitValue

      public void setInitValue(int i)
      Sets the init value of this object.
      Parameters:
      i - Initial value object.
      See Also:
    • getInitValue

      public int getInitValue()
      Returns:
      the init value of this object.
      See Also:
    • isInteractive

      public boolean isInteractive()
      Returns:
      whether this object is interactive.
      See Also:
    • setInteractive

      public void setInteractive(boolean b)
      Enables or disabled the interactivity. When enabled the object value change with user interaction.
      Parameters:
      b - Interactive flag.
      See Also:
    • getValueChangeMode

      public int getValueChangeMode()
      Returns:
      the value change mode of this object for user interaction.
      See Also:
    • setValueChangeMode

      public void setValueChangeMode(int m)
      Sets the value change mode of this object for user interaction.
      Parameters:
      m - Interaction mode
      See Also:
    • hasBackgroundMapper

      public boolean hasBackgroundMapper()
      Returns:
      whether this object has a value program for background color.
      See Also:
    • setBackgroundMapper

      public void setBackgroundMapper(JDValueProgram m)
      Sets the value program for background color of this object.
      Parameters:
      m - Value program.
      See Also:
    • getBackgroundMapper

      public JDValueProgram getBackgroundMapper()
      Returns:
      the current value program for background color of this object.
    • hasForegroundMapper

      public boolean hasForegroundMapper()
      Returns:
      whether this object has a value program for foreground color.
      See Also:
    • setForegroundMapper

      public void setForegroundMapper(JDValueProgram m)
      Sets the value program for foreground color of this object.
      Parameters:
      m - Value program.
      See Also:
    • getForegroundMapper

      public JDValueProgram getForegroundMapper()
      Returns:
      the current value program for foreground color of this object.
    • hasVisibilityMapper

      public boolean hasVisibilityMapper()
      Returns:
      whether this object has a value program for visibility.
      See Also:
    • setVisibilityMapper

      public void setVisibilityMapper(JDValueProgram m)
      Sets the value program for visibility of this object.
      Parameters:
      m - Value program.
      See Also:
    • getVisibilityMapper

      public JDValueProgram getVisibilityMapper()
      Returns:
      the current value program for visibility of this object.
    • hasInvertShadowMapper

      public boolean hasInvertShadowMapper()
      Returns:
      whether this object has a value program for invert shadow.
      See Also:
    • setInvertShadowMapper

      public void setInvertShadowMapper(JDValueProgram m)
      Sets the value program for invert shadow of this object.
      Parameters:
      m - Value program.
      See Also:
    • getInvertShadowMapper

      public JDValueProgram getInvertShadowMapper()
      Returns:
      the current value program for invert shadow of this object.
    • hasHTranslationMapper

      public boolean hasHTranslationMapper()
      Returns:
      whether this object has a value program for horizontal translation.
      See Also:
    • setHTranslationMapper

      public void setHTranslationMapper(JDValueProgram m)
      Sets the value program for horizontal translation of this object.
      Parameters:
      m - Value program.
      See Also:
    • getHTranslationMapper

      public JDValueProgram getHTranslationMapper()
      Returns:
      the current value program for horizontal translation of this object.
    • hasVTranslationMapper

      public boolean hasVTranslationMapper()
      Returns:
      whether this object has a value program for vertical translation.
      See Also:
    • setVTranslationMapper

      public void setVTranslationMapper(JDValueProgram m)
      Sets the value program for vertical translation of this object.
      Parameters:
      m - Value program.
      See Also:
    • getVTranslationMapper

      public JDValueProgram getVTranslationMapper()
      Returns:
      the current value program for vertical translation of this object.
    • setGradientFillParam

      public void setGradientFillParam(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic)
      Sets the gradient of this object. Has effects only if fill style is FILL_STYLE_GRADIENT.
      Parameters:
      x1 - x coordinate of the first specified Point in user space
      y1 - y coordinate of the first specified Point in user space
      color1 - Color at the first specified Point
      x2 - x coordinate of the second specified Point in user space
      y2 - y coordinate of the second specified Point in user space
      color2 - Color at the second specified Point
      cyclic - true if the gradient pattern should cycle repeatedly between the two colors; false otherwise
      See Also:
    • isProgrammed

      public boolean isProgrammed()
      Returns:
      whether this object has a programmed behavior. If this object is a JDGroup, the function return true if at least one of grouped JDObject is programmed.
      See Also:
    • refresh

      public void refresh()
      Refresh the JDObject on the screen by repainting its bounding rectangle. This method shoud be called after a property change.
      See Also:
    • preRefresh

      public void preRefresh()
      Prepare this object to be repainted. Certain modifications of the object may need to be repainted outside the new bounding rectangle. So before applying modifcations to the object , a call to preRefresh() will memorize the current repaint region then a call to refresh() after mofications will repaint the union of the 2 rectangles.
      See Also:
    • setExtensionList

      public void setExtensionList(String[] names)
      Sets the list of extended parameter name for this object. Note: All value are reseted.
      Parameters:
      names - List of names
    • addExtension

      public void addExtension(String name)
      Add an extension to this object.
      Parameters:
      name - Name of the extension.
      See Also:
    • setExtendedParam

      public void setExtendedParam(String name, String value)
      Sets the extended param value.
      Parameters:
      name - Param name
      value - Param value
      See Also:
    • removeExtension

      public void removeExtension(int extIdx)
      Remove the extended param at the specified index.
      Parameters:
      extIdx - Index of the extension.
    • setExtendedParam

      public void setExtendedParam(int extIdx, String value)
      Sets the extended param value.
      Parameters:
      extIdx - Index of the extensions.
      value - param value
      See Also:
    • getExtendedParam

      public String getExtendedParam(String name)
      Returns the value of the specified extended param, an empty string if not found.
      Parameters:
      name - Extension name
      Returns:
      param value
      See Also:
    • getExtendedParam

      public String getExtendedParam(int extIdx)
      Returns the value of the specified extended param, an empty string if not found.
      Parameters:
      extIdx - Index of the extension.
      Returns:
      param value
      See Also:
    • getExtendedParamName

      public String getExtendedParamName(int extIdx)
      Returns the name of the extended param at the specified index.
      Parameters:
      extIdx - Index of the extension.
      Returns:
      param name
      See Also:
    • getExtendedParamDesc

      public String getExtendedParamDesc(String extName)
      Parameters:
      extName - Extension name
      Returns:
      the description of the specified extension.
    • getExtendedParamNumber

      public int getExtendedParamNumber()
      Returns:
      the number of extensions
    • getExtendedParamIndex

      public int getExtendedParamIndex(String name)
      Parameters:
      name - Param name
      Returns:
      the index of the specified extended param , -1 when not found
    • hasExtendedParam

      public boolean hasExtendedParam(String name)
      Parameters:
      name - Param name
      Returns:
      true if the specified extended param exists , false otherwise
    • isFixedExtendedParam

      public boolean isFixedExtendedParam(String name)
      Parameters:
      name - Param name
      Returns:
      true if this parameters is fixed and cannot be removed.
    • isDisabled

      public boolean isDisabled()
    • setDisabled

      public void setDisabled(boolean disabled)