Package net.sf.jaxodraw.object.group
Class JaxoGroup
- java.lang.Object
-
- net.sf.jaxodraw.object.JaxoObject
-
- net.sf.jaxodraw.object.JaxoExtendedObject
-
- net.sf.jaxodraw.object.group.JaxoGroup
-
- All Implemented Interfaces:
java.awt.Shape,java.beans.PropertyChangeListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener
public class JaxoGroup extends JaxoExtendedObject
Groups together a number of JaxoObjects.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class net.sf.jaxodraw.object.JaxoExtendedObject
SELECT_DX, SELECT_DY, SELECT_P2
-
Fields inherited from class net.sf.jaxodraw.object.JaxoObject
D_FORMAT, GRAY_SCALE_FORMAT, SELECT_NONE, SELECT_P1
-
-
Constructor Summary
Constructors Constructor Description JaxoGroup()Constructor: creates a new empty vector and sets the dimensions to a default value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanBeSelected(int handle, int mode)Determines if the object can be selected (moved, edited, etc) from the given point in a given edit mode.voidclearGroup()Removes all JaxoObjects from the Group.booleancontainsInstanceOf(java.lang.Class<?> clazz)Determines whether there are instances of the given Class in this group.JaxoObjectcopy()Returns an exact copy of this JaxoGroup.voidcopyFrom(JaxoGroup temp)Sets all parameters from the given object to the current one.intgetAmp()Returns the groupAmp property of this group object.java.awt.RectanglegetBounds()Returns the bounding box of this object.java.awt.FontgetFont()Returns the groupTextFont property of this text object.intgetGrabbedHandle(int clickX, int clickY, JaxoHandle h)Determines which handle the user has selected to move/resize/edit an object.intgetLatexTextSize()Returns the groupTeXSize property of this group object.JaxoList<JaxoObject>getObjectList()Returns the JaxoObjects in this group.booleanisCopy(JaxoObject comp)Determines if this JaxoObject is a copy of the specified one.java.lang.StringlatexCommand(float scale, java.awt.Dimension canvasDim)The latex command of this group (obsolete because every JaxoObject has its own latex command).java.lang.StringlatexWidth()The latex command setting the width of this group (obsolete because every JaxoObject has its own latexWidth).voidmoveBy(int deltaX, int deltaY)Displaces the group.voidpaint(JaxoGraphics2D g2)The method that paints the JaxoObject.voidpaintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)Paints the handles of this JaxoObject that allow to move/resize/edit it.voidpaintVisualAid(JaxoGraphics2D g2)Paints a visual aid for the user during dragging (moving or resizing) of this JaxoObject.voidprepareEditPanel(JaxoObjectEditPanel editPanel)Initializes the given editPanel to edit properties of this JaxoObject.voidrescaleObject(int orx, int ory, float scale)Rescale this JaxoObject by the scale factor scale, keeping the point (orx, ory) fixed.voidsetAmp(int amp)Sets the groupAmp property of this group object.voidsetColor(java.awt.Color newColor)Sets the color for all objects in this group.If newColor !voidsetFont(java.awt.Font textFont)Sets the groupTextFont property of this group.voidsetFontName(java.lang.String name)Sets the font name of this group.voidsetFontSize(int size)Sets the font size of this group.voidsetFontStyle(int style)Sets the font style of this group.voidsetLatexTextSize(int teXSize)Sets the groupTeXSize property of this group object.voidsetNewScale(float scale)Rescales the group with the given scale factor, leaving the first point fixed.voidsetObjectList(JaxoList<JaxoObject> obList)Sets the JaxoObjects of this group.voidsetState(JaxoObject o)Restore state to the values of 'o'.voidsetStrokeWidth(float newStroke)Sets the strokeWidth property of this group object.intsize()Returns the number of JaxoObjects in this group.floatsmallestDistanceTo(int px, int py)Determines the smallest distance of any of the handles of this JaxoObject from the given point.-
Methods inherited from class net.sf.jaxodraw.object.JaxoExtendedObject
copyFrom, getHeight, getPointCount, getRadius, getRelh, getRelSize, getRelw, getSize, getStroke, getStrokeWidth, getWidth, getX, getX2, getY, getY2, resetStroke, setLocation, setPreferences, setRadius, setRelativeHeight, setRelativeWidth, setRelWAndH, setStroke, setX, setX2, setY, setY2, strokeIs
-
Methods inherited from class net.sf.jaxodraw.object.JaxoObject
addPropertyChangeListener, contains, contains, contains, contains, copyFrom, firePropertyChange, getBounds2D, getBoundsWithHandles, getColor, getGeneralPath, getLaTexLocation, getName, getPathIterator, getPathIterator, getPoints, getX, getY, intersects, intersects, isAround, isMarked, propertyChange, removePropertyChangeListener, setAsMarked, setLocation, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setPointCount, setPoints, setTransient, setX, setXPosition, setY, setYPosition
-
-
-
-
Method Detail
-
copy
public final JaxoObject copy()
Returns an exact copy of this JaxoGroup.- Overrides:
copyin classJaxoObject- 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:
isCopyin classJaxoExtendedObject- 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 byJaxoObject.copy().- Overrides:
setStatein classJaxoExtendedObject- 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:
getGrabbedHandlein classJaxoExtendedObject- 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:
canBeSelectedin classJaxoExtendedObject- 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:
paintHandlesin classJaxoExtendedObject- 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:
smallestDistanceToin classJaxoExtendedObject- 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:
paintVisualAidin classJaxoObject- 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:
paintin classJaxoObject- 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:
moveByin classJaxoExtendedObject- Parameters:
deltaX- The displacement in x directiondeltaY- The displacement in y direction
-
latexCommand
public final java.lang.String latexCommand(float scale, java.awt.Dimension canvasDim)The latex command of this group (obsolete because every JaxoObject has its own latex command).- Specified by:
latexCommandin classJaxoObject- 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 java.lang.String latexWidth()
The latex command setting the width of this group (obsolete because every JaxoObject has its own latexWidth).- Overrides:
latexWidthin classJaxoExtendedObject- Returns:
- The string "%".
-
getBounds
public java.awt.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:
rescaleObjectin classJaxoObject- 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:
setStrokeWidthin classJaxoExtendedObject- 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 java.awt.Font getFont()
Returns the groupTextFont property of this text object.- Returns:
- The groupTextFont property of this text object.
-
setFont
public final void setFont(java.awt.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(java.lang.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(java.awt.Color newColor)
Sets the color for all objects in this group.If newColor != null, applies the value to all objects in the group.- Overrides:
setColorin classJaxoObject- Parameters:
newColor- The color to be set.
-
containsInstanceOf
public final boolean containsInstanceOf(java.lang.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:
prepareEditPanelin classJaxoObject- Parameters:
editPanel- the panel to prepare.
-
-