Class JaxoGraph

java.lang.Object
net.sf.jaxodraw.graph.JaxoGraph

public class JaxoGraph extends Object
A JaxoGraph is an extended version of a JaxoSaveGraph. In addition to the list of JaxoObjects, the latex packages and the description of the graph, it contains some information about how the graph is presented on the screen. Note that the information in JaxoGraph is not restored when saving and opening graphs. Only JaxoSaveGraph is serializable.
Since:
2.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new JaxoGraph with empty list of objects, empty description and empty saveFileName.
    Creates a new JaxoGraph with the given list of objects, empty description and empty saveFileName.
    JaxoGraph(JaxoList<JaxoObject> list, String describe)
    Creates a new JaxoGraph with the given list of objects and description and empty saveFileName.
    JaxoGraph(JaxoList<JaxoObject> list, String describe, String saveFile)
    Creates a new JaxoGraph with the given list of objects, description and saveFileName.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    addObject(int index, JaxoObject object)
    Inserts a JaxoObject into the list of objects at a specified position and flags the JaxoGraph as not saved (if it has been modified).
    final void
    Adds the specified JaxoObject to the list of objects by appending it and flags the JaxoGraph as not saved (if it has been modified).
    final void
    Puts the specified JaxoObject into the background, i.e., to the first position in the object list.
    final void
    Breaks all the groups in this graph.
    final void
    Removes all JaxoObjects from the list of objects.
    final void
    Removes all JaxoObjects from the list of objects and sets the saveFileName to a string of size zero.
    final boolean
    Checks if there are Group objects present in this graph.
    final boolean
    Checks if there are instances if the given Class present in this graph.
    final boolean
    Checks if there are LatexText objects present in this current graph.
    final boolean
    Checks if there are marked Group objects present in the current selection.
    final boolean
    Checks if there are marked objects present in this graph.
    final boolean
    Checks if there are PSText objects present in this current graph.
    static final JaxoList<JaxoObject>
    Returns a copy of the specified JaxoList.
    final JaxoGraph
    Returns an exact copy of this JaxoGraph.
    final void
    Removes the specified JaxoObject from the list of objects and flags the JaxoGraph as not saved (if it has been modified).
    final void
    Removes the specified JaxoObjects from the list of objects and flags the JaxoGraph as not saved (if it has been modified).
    final void
    Removes all marked JaxoObjects from the list of objects and flags the JaxoGraph as not saved (if it has been modified).
    final void
    Puts the specified JaxoObject into the foreground, i.e., to the last position in the object list.
    final Rectangle
    Returns the smallest bounding box that contains all the JaxoObjects of this JaxoGraph.
    final Rectangle
    Intersection of bounding box with given Rectangle.
    final Rectangle
    Returns the smallest bounding box that contains all the JaxoObjects of this JaxoGraph except the ones given in 'except'.
    Copies of the marked objects of the graph, in the order of the graph.
    final String
    Returns the description text of this JaxoGraph.
    All marked objects of the graph, in the order of the graph.
    getNearestObject(int x, int y)
    Returns the JaxoObject in this graph that is closest to the given coordinates (ie which has the nearest handle).
    Returns the list of JaxoObjects.
    final List<String>
    Returns the list of Latex packages.
    final String
    Returns the current default save file name.
    Returns the JaxoSaveGraph (i.e., the current list of objects and the current description) of the current JaxoGraph.
    boolean
    Groups the currently marked objects.
    boolean
    Determines if at least a certain number of objects are marked (containsMarkedObjects() == hasMoreMarkedObjectsThan(0)).
    final boolean
    Indicates whether the current JaxoGraph contains unsaved changes.
    Returns the JaxoObject at position i of the object list.
    final int
    Returns the size of the current object list, i.e., the number of objects it contains.
    final void
    move(int index, int newIndex)
    Move the object at 'index' to 'newIndex', leaving all other elements in order.
    final void
    Puts all the objects in the current selection in the background.
    final void
    Puts all the objects in the current selection in the foreground.
    void
    Paint all objects to 'g'.
    void
    Paint all objects to 'g' if they intersect the clip bounds.
    final void
    paintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)
    Paints handles on all objects in this graph.
    final void
    Replace 'old' by 'o'.
    final void
    setAsMarked(boolean marked)
    Marks all objects in this graph.
    final void
    Sets the description text of this JaxoGraph and flags the JaxoGraph as not saved.
    final void
    Sets the list of objects of this JaxoGraph to list and flags the JaxoGraph as not saved.
    final void
    Sets the list of Latex packages of this JaxoGraph to list and flags the JaxoGraph as not saved.
    final void
    setSaved(boolean isSaved)
    Declares the current JaxoGraph as saved or unsaved, according to the boolean variable isSaved.
    final void
    Sets the default file name for save operations.
    final void
    Sets the JaxoSaveGraph (i.e., the current list of objects and the current description) of the current JaxoGraph.
    boolean
    If the given object is a group and contained in this graph, ungroup it.
    boolean
    Ungroup (one level) all marked objects.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JaxoGraph

      public JaxoGraph()
      Creates a new JaxoGraph with empty list of objects, empty description and empty saveFileName.
    • JaxoGraph

      public JaxoGraph(JaxoList<JaxoObject> list)
      Creates a new JaxoGraph with the given list of objects, empty description and empty saveFileName.
      Parameters:
      list - The new list of objects. Not null.
    • JaxoGraph

      public JaxoGraph(JaxoList<JaxoObject> list, String describe)
      Creates a new JaxoGraph with the given list of objects and description and empty saveFileName.
      Parameters:
      list - The new list of objects. Not null.
      describe - String which decsribes this JaxoGraph. May be null.
    • JaxoGraph

      public JaxoGraph(JaxoList<JaxoObject> list, String describe, String saveFile)
      Creates a new JaxoGraph with the given list of objects, description and saveFileName.
      Parameters:
      list - The new list of objects. Not null.
      describe - String which describes this JaxoGraph. May be null.
      saveFile - String holding the file name for saving. Not null.
  • Method Details

    • getSaveGraph

      public final JaxoSaveGraph getSaveGraph()
      Returns the JaxoSaveGraph (i.e., the current list of objects and the current description) of the current JaxoGraph.
      Returns:
      The JaxoSaveGraph of the current JaxoGraph. Not null.
    • setSaveGraph

      public final void setSaveGraph(JaxoSaveGraph newSaveGraph)
      Sets the JaxoSaveGraph (i.e., the current list of objects and the current description) of the current JaxoGraph.
      Parameters:
      newSaveGraph - The new JaxoSaveGraph. Not null.
    • getObjectList

      public final JaxoList<JaxoObject> getObjectList()
      Returns the list of JaxoObjects.
      Returns:
      The list of JaxoObjects. Not null.
    • setObjectList

      public final void setObjectList(JaxoList<JaxoObject> list)
      Sets the list of objects of this JaxoGraph to list and flags the JaxoGraph as not saved.
      Parameters:
      list - The list of JaxoObjects. Not null.
    • getPackageList

      public final List<String> getPackageList()
      Returns the list of Latex packages.
      Returns:
      The list of Latex packages.
    • setPackageList

      public final void setPackageList(List<String> list)
      Sets the list of Latex packages of this JaxoGraph to list and flags the JaxoGraph as not saved.
      Parameters:
      list - The list of Latex packages. Not null.
    • setDescription

      public final void setDescription(String describe)
      Sets the description text of this JaxoGraph and flags the JaxoGraph as not saved.
      Parameters:
      describe - The description of this JaxoGraph. May be null.
    • getDescription

      public final String getDescription()
      Returns the description text of this JaxoGraph.
      Returns:
      The decription of this JaxoGraph. May be null.
    • isSaved

      public final boolean isSaved()
      Indicates whether the current JaxoGraph contains unsaved changes.
      Returns:
      True if the Current JaxoGraph is saved.
    • setSaved

      public final void setSaved(boolean isSaved)
      Declares the current JaxoGraph as saved or unsaved, according to the boolean variable isSaved.
      Parameters:
      isSaved - Boolean variable to indicate whether the current JaxoGraph is saved or not.
    • setSaveFileName

      public final void setSaveFileName(String fileName)
      Sets the default file name for save operations.
      Parameters:
      fileName - The file name to be used for saving. Not null.
    • getSaveFileName

      public final String getSaveFileName()
      Returns the current default save file name. This never returns null, at most an empty string.
      Returns:
      The current default save file name.
    • listElementAt

      public final JaxoObject listElementAt(int i)
      Returns the JaxoObject at position i of the object list.
      Parameters:
      i - The index of the JaxoObject to be returned.
      Returns:
      The JaxoObject at position i of the object list.
    • listSize

      public final int listSize()
      Returns the size of the current object list, i.e., the number of objects it contains.
      Returns:
      The number of objects currently in the object list.
    • foreground

      public final void foreground(JaxoObject object)
      Puts the specified JaxoObject into the foreground, i.e., to the last position in the object list. If the JaxoGraph was modified by this operation, flags it as not saved.
      Parameters:
      object - The JaxoObject to be put into the foreground.
    • move

      public final void move(int index, int newIndex)
      Move the object at 'index' to 'newIndex', leaving all other elements in order.
      Parameters:
      index - The index of the object to move.
      newIndex - The new index of the object.
    • replace

      public final void replace(JaxoObject old, JaxoObject o)
      Replace 'old' by 'o'.
      Parameters:
      old - The object to replace. If this is not contained in this graph, the graph is not modified.
      o - The new object. Must not be null.
    • background

      public final void background(JaxoObject object)
      Puts the specified JaxoObject into the background, i.e., to the first position in the object list. If the JaxoGraph was modified by this operation, flags it as not saved.
      Parameters:
      object - The JaxoObject to be put into the background.
    • delete

      public final void delete(JaxoObject object)
      Removes the specified JaxoObject from the list of objects and flags the JaxoGraph as not saved (if it has been modified).
      Parameters:
      object - The JaxoObject to be removed from the list.
    • deleteMarkedObjects

      public final void deleteMarkedObjects()
      Removes all marked JaxoObjects from the list of objects and flags the JaxoGraph as not saved (if it has been modified).
    • deleteAll

      public final void deleteAll(Collection<JaxoObject> objects)
      Removes the specified JaxoObjects from the list of objects and flags the JaxoGraph as not saved (if it has been modified).
      Parameters:
      objects - Collection of JaxoObjects to be removed from the list.
    • addObject

      public final void addObject(JaxoObject object)
      Adds the specified JaxoObject to the list of objects by appending it and flags the JaxoGraph as not saved (if it has been modified).
      Parameters:
      object - The JaxoObject to be added to the list.
    • addObject

      public final void addObject(int index, JaxoObject object)
      Inserts a JaxoObject into the list of objects at a specified position and flags the JaxoGraph as not saved (if it has been modified).
      Parameters:
      index - The position where the object has to be appended
      object - The JaxoObject to be added to the list.
    • clear

      public final void clear()
      Removes all JaxoObjects from the list of objects. If the JaxoGraph was modified by this operation, flags it as not saved.
    • clearAll

      public final void clearAll()
      Removes all JaxoObjects from the list of objects and sets the saveFileName to a string of size zero. If the JaxoGraph was modified by this operation, flags it as not saved.
    • getBounds

      public final Rectangle getBounds()
      Returns the smallest bounding box that contains all the JaxoObjects of this JaxoGraph.
      Returns:
      A Rectangle holding the bounds of the current JaxoGraph, or null if the graph is empty (ie contains no objects).
    • getBoundsExcept

      public final Rectangle getBoundsExcept(Collection<JaxoObject> except)
      Returns the smallest bounding box that contains all the JaxoObjects of this JaxoGraph except the ones given in 'except'.
      Parameters:
      except - objects to exclude.
      Returns:
      A Rectangle holding the bounds of the current JaxoGraph, or null if the graph is (effectively empty (ie contains no objects).
    • getBounds

      public final Rectangle getBounds(Rectangle inside)
      Intersection of bounding box with given Rectangle. This returns null if either any of the two rectangles are null, or if they do not intersect.
      Parameters:
      inside - The Rectangle to intersect with.
      Returns:
      The intersection.
      See Also:
    • copyFrom

      public static final JaxoList<JaxoObject> copyFrom(JaxoList<JaxoObject> v)
      Returns a copy of the specified JaxoList.
      Parameters:
      v - A JaxoList to be duplicated.
      Returns:
      A copy of v.
    • containsPSText

      public final boolean containsPSText()
      Checks if there are PSText objects present in this current graph.
      Returns:
      True, if there are PSTexts, false otherwise.
    • containsLatexText

      public final boolean containsLatexText()
      Checks if there are LatexText objects present in this current graph.
      Returns:
      True, if there are LatexTexts, false otherwise.
    • containsInstanceOf

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

      public final boolean containsMarkedGroups()
      Checks if there are marked Group objects present in the current selection.
      Returns:
      True, if there are marked groups, false otherwise.
    • containsGroups

      public final boolean containsGroups()
      Checks if there are Group objects present in this graph.
      Returns:
      True, if there are groups, false otherwise.
    • containsMarkedObjects

      public final boolean containsMarkedObjects()
      Checks if there are marked objects present in this graph.
      Returns:
      True, if there is at least one marked object in this graph, false otherwise.
    • getMarkedObjects

      public JaxoList<JaxoObject> getMarkedObjects()
      All marked objects of the graph, in the order of the graph. The result is mutable and free.
      Returns:
      A JaxoList of all marked objects.
    • getCopyOfMarkedObjects

      public JaxoList<JaxoObject> getCopyOfMarkedObjects()
      Copies of the marked objects of the graph, in the order of the graph. The result is mutable and free.
      Returns:
      A JaxoList of all marked objects.
    • hasMoreMarkedObjectsThan

      public boolean hasMoreMarkedObjectsThan(int less)
      Determines if at least a certain number of objects are marked (containsMarkedObjects() == hasMoreMarkedObjectsThan(0)).
      Parameters:
      less - The lower bound to test.
      Returns:
      True if at least 'less + 1' (less >= 0) objects of the graph are 'marked'.
    • paint

      public void paint(JaxoGraphics2D g)
      Paint all objects to 'g'.
      Parameters:
      g - The graphics context to paint to.
    • paintClipped

      public void paintClipped(JaxoGraphics2D g)
      Paint all objects to 'g' if they intersect the clip bounds.
      Parameters:
      g - The graphics contect to paint to.
    • paintHandles

      public final void paintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)
      Paints handles on all objects in this graph.
      Parameters:
      g2 - The graphics context to paint the handles to.
      h - The handle to paint.
      editMode - The edit mode that the handles are being painted in.
    • setAsMarked

      public final void setAsMarked(boolean marked)
      Marks all objects in this graph.
      Parameters:
      marked - A boolean that indicates whether to mark or not.
    • copyOf

      public final JaxoGraph copyOf()
      Returns an exact copy of this JaxoGraph.
      Returns:
      A copy of this JaxoGraph.
    • breakAllGroups

      public final void breakAllGroups()
      Breaks all the groups in this graph.
    • objectsToForeground

      public final void objectsToForeground()
      Puts all the objects in the current selection in the foreground.
    • objectsToBackground

      public final void objectsToBackground()
      Puts all the objects in the current selection in the background.
    • getNearestObject

      public final JaxoObject getNearestObject(int x, int y)
      Returns the JaxoObject in this graph that is closest to the given coordinates (ie which has the nearest handle).
      Parameters:
      x - The x coordinate.
      y - The y coordinate.
      Returns:
      The nearest JaxoObject or null if the graph is empty.
    • ungroupMarkedObjects

      public boolean ungroupMarkedObjects()
      Ungroup (one level) all marked objects.
      Returns:
      true if there were marked groups in this graph, ie the graph has been modified.
    • groupMarkedObjects

      public boolean groupMarkedObjects()
      Groups the currently marked objects.
      Returns:
      true if there were marked objects in this graph, ie the graph has been modified.
    • ungroup

      public boolean ungroup(JaxoObject ob)
      If the given object is a group and contained in this graph, ungroup it. In this case, the constituents of the group are appended to the graph, and the group is removed.
      Parameters:
      ob - the object to ungroup.
      Returns:
      true if the object was a group and contained in this graph, and therefore the graph has been modified.