Class JDGroup


public class JDGroup extends JDRectangular
JDraw Group graphic object. A group can contains all JDObject including group. If the group is scaled, all object within this group will also be scaled.
  • Constructor Details

    • JDGroup

      public JDGroup(String objectName, Vector o)
      Construct a group.
      Parameters:
      objectName - Group name.
      o - Vector of JDObject to be grouped.
  • Method Details

    • 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, 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
    • isInsideObject

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

      public void restoreTransform()
      Description copied from class: JDObject
      Restore original shape previously backuped by saveTransform
      Overrides:
      restoreTransform in class JDObject
      See Also:
    • saveTransform

      public void saveTransform()
      Description copied from class: JDObject
      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().
      Overrides:
      saveTransform in class JDObject
      See Also:
    • rotate90

      public void rotate90(double x, double y)
      Description copied from class: JDObject
      Rotate the object by 90deg. A call to refresh() is needed after transformation.
      Overrides:
      rotate90 in class JDRectangular
      Parameters:
      x - Rotation center horizontal pos
      y - Rotation center vertical pos
      See Also:
    • moveSummit

      public void moveSummit(int id, double x, double y)
      Description copied from class: JDObject
      Moves the specifed summit to the specified position. When using moveSummit() to animate objects, A call to refresh() of this object may be needed.
      Overrides:
      moveSummit in class JDRectangular
      Parameters:
      id - Summit index
      x - Absolute X position
      y - Absolute Y position
      See Also:
    • setBackground

      public void setBackground(Color c)
      Sets the background of this group, Apply it on all children.
      Overrides:
      setBackground in class JDObject
      Parameters:
      c - Background color.
      See Also:
    • setForeground

      public void setForeground(Color c)
      Sets the foreground of this group, Apply it on all children.
      Overrides:
      setForeground in class JDObject
      Parameters:
      c - Foreground color.
      See Also:
    • setFillStyle

      public void setFillStyle(int s)
      Sets the fill style of this group, Apply it on all children.
      Overrides:
      setFillStyle in class JDObject
      Parameters:
      s - Fill style.
      See Also:
    • setLineStyle

      public void setLineStyle(int s)
      Sets the line style of this group, Apply it on all children.
      Overrides:
      setLineStyle in class JDObject
      Parameters:
      s - Line style.
      See Also:
    • setAntiAlias

      public void setAntiAlias(boolean alias)
      Sets the anti aliasing for all objects of this group
      Overrides:
      setAntiAlias in class JDObject
      Parameters:
      alias - Anti alias
      See Also:
    • setLineWidth

      public void setLineWidth(int w)
      Sets the line width of this group, Apply it on all children.
      Overrides:
      setLineWidth in class JDObject
      Parameters:
      w - Line width.
      See Also:
    • setShadow

      public void setShadow(boolean b)
      Sets the shadow of this group, Apply it on all children.
      Overrides:
      setShadow in class JDObject
      Parameters:
      b - Shadow flag.
      See Also:
    • setVisible

      public void setVisible(boolean b)
      Shows or hides this object, Apply it on all children.
      Overrides:
      setVisible in class JDObject
      Parameters:
      b - True to show, false otherwise.
    • setInverseShadow

      public void setInverseShadow(boolean b)
      Sets the inverse shadow of this group, Apply it on all children.
      Overrides:
      setInverseShadow in class JDObject
      Parameters:
      b - Invert shadow flag.
      See Also:
    • setShadowWidth

      public void setShadowWidth(int w)
      Sets the shadow width of this group, Apply it on all children.
      Overrides:
      setShadowWidth in class JDObject
      Parameters:
      w - Shadow width.
      See Also:
    • setMinValue

      public void setMinValue(int v)
      Description copied from class: JDObject
      Sets the minimum value of this object.
      Overrides:
      setMinValue in class JDObject
      Parameters:
      v - Min value
      See Also:
    • setMaxValue

      public void setMaxValue(int v)
      Description copied from class: JDObject
      Sets the max value of this object.
      Overrides:
      setMaxValue in class JDObject
      Parameters:
      v - Max value
      See Also:
    • setInitValue

      public void setInitValue(int v)
      Description copied from class: JDObject
      Sets the init value of this object.
      Overrides:
      setInitValue in class JDObject
      Parameters:
      v - Initial value object.
      See Also:
    • getObjectsByName

      public void getObjectsByName(Vector result, String name, boolean recurseGroup)
      Description copied from class: JDObject
      Return all objects having the given name.
      Overrides:
      getObjectsByName in class JDObject
      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:
    • isProgrammed

      public boolean isProgrammed()
      Overrides:
      isProgrammed in class JDObject
      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:
    • getChildAt

      public JDObject getChildAt(int idx)
      Parameters:
      idx - Child index
      Returns:
      the child at the specifed position.
    • getChildrenNumber

      public int getChildrenNumber()
      Returns:
      the number of child of this group.
    • setChildrenList

      public void setChildrenList(Vector o)
      Sets the children of this group.
      Parameters:
      o - Vector of JDObject to be grouped.
    • getChildren

      public Vector getChildren()
      Returns:
      a Vector containing all children of this group.
    • generateJavaClass

      public void generateJavaClass(FileWriter f) throws IOException
      Generates a Java class capable to paint this object using only java awt functions. It supports only Line and Polyline (or shape that can be converted to polyline) and not all functionality of the JDObject are suppported. Nevertheless, the code keeps the vectorial sizing behavior. Note: All objects named 'body' will have their background color overrided by the color passed to the generated paint() function.
      Parameters:
      f - file to be saved
      Throws:
      IOException - In case of failure