Class JaxoGroup

All Implemented Interfaces:
Shape, PropertyChangeListener, Serializable, Cloneable, EventListener

public class JaxoGroup extends JaxoExtendedObject
Groups together a number of JaxoObjects.
Since:
2.0
See Also:
  • Constructor Details

    • JaxoGroup

      public JaxoGroup()
      Constructor: creates a new empty vector and sets the dimensions to a default value.
  • Method Details

    • copy

      public final JaxoObject copy()
      Returns an exact copy of this JaxoGroup.
      Overrides:
      copy in class JaxoObject
      Returns:
      A copy of this JaxoGroup.
    • isCopy

      public final boolean isCopy(JaxoObject comp)
      Determines if this JaxoObject is a copy of the specified one.
      Overrides:
      isCopy in class JaxoExtendedObject
      Parameters:
      comp - The JaxoObject to compare against.
      Returns:
      True if the JaxoObjects are identical.
    • copyFrom

      public void copyFrom(JaxoGroup temp)
      Sets all parameters from the given object to the current one.
      Parameters:
      temp - The object to copy from.
    • setState

      public void setState(JaxoObject o)
      Restore state to the values of 'o'. The object 'o' must be an object of the same "type" obtained by JaxoObject.copy().
      Overrides:
      setState in class JaxoExtendedObject
      Parameters:
      o - the object to copy from.
    • getGrabbedHandle

      public final int getGrabbedHandle(int clickX, int clickY, JaxoHandle h)
      Determines which handle the user has selected to move/resize/edit an object.
      Overrides:
      getGrabbedHandle in class JaxoExtendedObject
      Parameters:
      clickX - The x coordinate where the mouse click has ocurred.
      clickY - The y coordinate where the mouse click has ocurred.
      h - A handle object.
      Returns:
      One of the static variables SELECT_* defined for this JaxoObject that specifies the handle which the user has clicked.
    • canBeSelected

      public boolean canBeSelected(int handle, int mode)
      Determines if the object can be selected (moved, edited, etc) from the given point in a given edit mode.
      Overrides:
      canBeSelected in class JaxoExtendedObject
      Parameters:
      handle - One of the static variables SELECT_* defined for this JaxoObject.
      mode - The current edit mode.
      Returns:
      True if the object may be selected from the given point, false otherwise.
    • paintHandles

      public final void paintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)
      Paints the handles of this JaxoObject that allow to move/resize/edit it.
      Overrides:
      paintHandles in class JaxoExtendedObject
      Parameters:
      g2 - The corresponding graphics context.
      h - A handle object to be used for painting.
      editMode - The edit mode that the handles are being painted in.
    • smallestDistanceTo

      public final float smallestDistanceTo(int px, int py)
      Determines the smallest distance of any of the handles of this JaxoObject from the given point.
      Overrides:
      smallestDistanceTo in class JaxoExtendedObject
      Parameters:
      px - The x coordinate of the test point.
      py - The y coordinate of the test point.
      Returns:
      The smallest distance.
    • paintVisualAid

      public final void paintVisualAid(JaxoGraphics2D g2)
      Paints a visual aid for the user during dragging (moving or resizing) of this JaxoObject.
      Overrides:
      paintVisualAid in class JaxoObject
      Parameters:
      g2 - The graphics context to paint the visual aid.
    • paint

      public final void paint(JaxoGraphics2D g2)
      The method that paints the JaxoObject.
      Specified by:
      paint in class JaxoObject
      Parameters:
      g2 - The graphics context where the object has to be painted.
    • moveBy

      public final void moveBy(int deltaX, int deltaY)
      Displaces the group.
      Overrides:
      moveBy in class JaxoExtendedObject
      Parameters:
      deltaX - The displacement in x direction
      deltaY - The displacement in y direction
    • latexCommand

      public final String latexCommand(float scale, Dimension canvasDim)
      The latex command of this group (obsolete because every JaxoObject has its own latex command).
      Specified by:
      latexCommand in class JaxoObject
      Parameters:
      scale - A scale factor to translate Java coordinates to LaTeX coordinates.
      canvasDim - The current dimension of the canvas.
      Returns:
      The string "%"
    • latexWidth

      public final String latexWidth()
      The latex command setting the width of this group (obsolete because every JaxoObject has its own latexWidth).
      Overrides:
      latexWidth in class JaxoExtendedObject
      Returns:
      The string "%".
    • getBounds

      public Rectangle getBounds()
      Returns the bounding box of this object. Note that this returns null if the group is empty.
      Returns:
      the bounding box of this object.
    • clearGroup

      public final void clearGroup()
      Removes all JaxoObjects from the Group.
    • getObjectList

      public final JaxoList<JaxoObject> getObjectList()
      Returns the JaxoObjects in this group.
      Returns:
      A list containing all the JaxoObjects of this group
    • setObjectList

      public final void setObjectList(JaxoList<JaxoObject> obList)
      Sets the JaxoObjects of this group.
      Parameters:
      obList - A list containing all the JaxoObjects to be set for this group
    • size

      public final int size()
      Returns the number of JaxoObjects in this group.
      Returns:
      The size of the list of JaxoObjects in this group
    • rescaleObject

      public final void rescaleObject(int orx, int ory, float scale)
      Rescale this JaxoObject by the scale factor scale, keeping the point (orx, ory) fixed.
      Specified by:
      rescaleObject in class JaxoObject
      Parameters:
      orx - The x-coordinate of the fixed point.
      ory - The y-coordinate of the fixed point.
      scale - The scale parameter.
    • setNewScale

      public final void setNewScale(float scale)
      Rescales the group with the given scale factor, leaving the first point fixed.
      Parameters:
      scale - the scale factor.
    • setStrokeWidth

      public final void setStrokeWidth(float newStroke)
      Sets the strokeWidth property of this group object.
      Overrides:
      setStrokeWidth in class JaxoExtendedObject
      Parameters:
      newStroke - The strokeWidth property of this group object.
    • getAmp

      public final int getAmp()
      Returns the groupAmp property of this group object.
      Returns:
      The groupAmp property of this group object.
    • setAmp

      public final void setAmp(int amp)
      Sets the groupAmp property of this group object. If amp != 0, applies the value to all WiggleObjects in the group.
      Parameters:
      amp - The groupAmp property of this group object.
    • getLatexTextSize

      public final int getLatexTextSize()
      Returns the groupTeXSize property of this group object.
      Returns:
      The groupTeXSize property of this group object.
    • setLatexTextSize

      public final void setLatexTextSize(int teXSize)
      Sets the groupTeXSize property of this group object. If teXSize != 0, applies the value to all LatexText objects in the group.
      Parameters:
      teXSize - The groupTeXSize property of this group object.
    • getFont

      public final Font getFont()
      Returns the groupTextFont property of this text object.
      Returns:
      The groupTextFont property of this text object.
    • setFont

      public final void setFont(Font textFont)
      Sets the groupTextFont property of this group. If textFont != null, applies the value to all PSText objects in the group.
      Parameters:
      textFont - The groupTextFont property of this group object.
    • setFontName

      public final void setFontName(String name)
      Sets the font name of this group. If the current font is null, the style and size of the font are taken from the preferences.
      Parameters:
      name - the font name to set.
    • setFontStyle

      public final void setFontStyle(int style)
      Sets the font style of this group. If the current font is null, the name and size of the font are taken from the preferences.
      Parameters:
      style - the font style to set.
    • setFontSize

      public final void setFontSize(int size)
      Sets the font size of this group. If the current font is null, the style and name of the font are taken from the preferences.
      Parameters:
      size - the font size to set.
    • setColor

      public final void setColor(Color newColor)
      Sets the color for all objects in this group.If newColor != null, applies the value to all objects in the group.
      Overrides:
      setColor in class JaxoObject
      Parameters:
      newColor - The color to be set.
    • containsInstanceOf

      public final boolean containsInstanceOf(Class<?> clazz)
      Determines whether there are instances of the given Class in this group.
      Parameters:
      clazz - a Class to look for.
      Returns:
      True if the group contains any Object ob for which clazz.isInstance(ob) returns true.
    • prepareEditPanel

      public void prepareEditPanel(JaxoObjectEditPanel editPanel)
      Initializes the given editPanel to edit properties of this JaxoObject.
      Specified by:
      prepareEditPanel in class JaxoObject
      Parameters:
      editPanel - the panel to prepare.