Interface Graph.Graphic

All Known Implementing Classes:
AnimationLayer2D, AnimationObject2D, AnimationPath2D, AnimationShape2D, CartesianGrid2D, ConnectingLine2D, DirectedObject2D, Graphs.CartesianGrid, Graphs.PolarGrid, GraphView, Model3DView, PlacedAnimationObject2D, PolarGrid
Enclosing class:
Graph

public static interface Graph.Graphic
Interface for objects that can be drawn on a graph. These objects are drawn as if they have an origin at (0.0, 0.0) in graph coordinate space.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTo(Graph graph, Graphics2D g2d, Graphics2D g2dGCS)
    Add this object to a graph.
    default Rectangle2D
    Get the bounding box for this Graphic.
  • Method Details

    • addTo

      void addTo(Graph graph, Graphics2D g2d, Graphics2D g2dGCS)
      Add this object to a graph. The drawing operation is assumed to be a complex one that might involve fills, etc.

      Any modifications to g2d or g2dGCS made by an implementation of this method should be undone before this method returns. For classes provided by the org.bzdev.anim2d package, such modifications must be undone before this method returns.

      Two graphics contexts are provided as arguments. g2d will typically be used as the first argument to the graph's draw or fill methods. In this case, the shape of an object is described in graph coordinate space but the widths of strokes drawn by fill operations, gradient paint, etc., have user-space units. The result is that line widths as they appear in an image are not sensitive to the mapping from graph coordinate space to user space. One should use the draw and fill methods specified by Graph, using g2d as their first argument. By contrast, if a line width, etc., should be in graph-coordinate space units, one can use the g2dGCS argument directly. This will rarely be done when plotting a graph but is useful in animations.

      Parameters:
      graph - the graph on which this object should be drawn
      g2d - the user-space Graphics2D to use to draw the Graphic
      g2dGCS - the graph-coordinate space Graphics2D to use to draw the Graphic
    • boundingBox

      default Rectangle2D boundingBox()
      Get the bounding box for this Graphic. Classes implementing this method should override it if a bounding box can be determined efficiently. It is intended for cases where a bounding-box comparison can allow drawing operations to be avoided.

      The value returned must not be modified.

      Returns:
      the bounding box for this Graphic in graph coordinate space; null if a bounding box has not been computed