org.graphstream.ui.j2dviewer

Camera

class Camera extends swingViewer.util.Camera

Define a view of the graph or a part of the graph.

The camera can be seen as an element in charge of projecting the graph elements in graph units (GU) into rendering space units, often in pixels. It defines the transformation, an affine matrix, to pass from the first to the second (in fact its the back-end that does it).

It also contains the graph metrics. This is a set of values that give the overall dimensions of the graph in graph units, as well as the view port, the area on the screen (or any rendering surface) that will receive the results in pixels (or any rendering units). The two mains methods for this operation are Camera.pushView(Graphics2D,GraphicGraph) and Camera.popView().

The user of the camera must set both the view port and the graph bounds in order for the camera to correctly project the graph view (the Renderer does that before using the Camera, at each frame). The camera model is as follows: the camera defines a center at which it always points. It can zoom on the graph (as if the camera angle of view was changing), pan in any direction by moving its center of view and rotate along the axe going from the center to the camera position (camera can rotate around two axes in 3D, but this is a 2D camera).

There are two modes: - an "auto-fit" mode where the camera always show the whole graph even if it changes in size, by automatically changing the center and zoom values, - and a "user" mode where the camera center (looked-at point), zoom and panning are specified and will not be modified in the bounds of the graph change.

The camera is also able to answer questions like: "what element is visible actually?", or "on what element is the mouse cursor actually?".

The camera is also able to compute sprite positions according to their attachment, as well as maintaining a list of all elements out of the view, so that it is not needed to render them.

Linear Supertypes
swingViewer.util.Camera, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Camera
  2. Camera
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Camera(graph: GraphicGraph)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def allNodesOrSpritesIn(graph: GraphicGraph, x1: Double, y1: Double, x2: Double, y2: Double): ArrayList[GraphicElement]

    Search for all the nodes and sprites contained inside the rectangle (x1,y1)-(x2,y2).

    Search for all the nodes and sprites contained inside the rectangle (x1,y1)-(x2,y2).

    graph

    The graph to search for.

    x1

    The rectangle lowest point abscissa.

    y1

    The rectangle lowest point ordinate.

    x2

    The rectangle highest point abscissa.

    y2

    The rectangle highest point ordinate.

    returns

    The set of sprites and nodes in the given rectangle.

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. var autoFit: Boolean

    Automatic centering of the view.

    Automatic centering of the view.

    Attributes
    protected
  9. def autoFitView(): Unit

    Compute a transformation matrix that pass from graph units (user space) to pixel units (device space) so that the whole graph is visible.

    Compute a transformation matrix that pass from graph units (user space) to pixel units (device space) so that the whole graph is visible.

    returns

    The transformation modified.

    Attributes
    protected
  10. var bck: Backend

    The rendering back-end.

    The rendering back-end.

    Attributes
    protected
  11. val center: Point3

    The camera center of view.

    The camera center of view.

    Attributes
    protected
  12. def checkVisibility(graph: GraphicGraph): Unit

    Process each node to check if it is in the actual view port, and mark invisible nodes.

    Process each node to check if it is in the actual view port, and mark invisible nodes. This method allows for fast node, sprite and edge visibility checking when drawing. This must be called before each rendering (if the view port changed). Called in pushView. A node is not visible if it is out of the view port, if it is deliberately hidden (its hidden flag is set) or if it has not yet been positioned (has not yet received a (x,y,z) position). If the auto fitting feature is activate the whole graph is always visible.

    Attributes
    protected
  13. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  17. def findNodeOrSpriteAt(graph: GraphicGraph, x: Double, y: Double): GraphicElement

    Search for the first node or sprite (in that order) that contains the point at coordinates (x, y).

    Search for the first node or sprite (in that order) that contains the point at coordinates (x, y).

    graph

    The graph to search for.

    x

    The point abscissa.

    y

    The point ordinate.

    returns

    The first node or sprite at the given coordinates or null if nothing found.

  18. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  19. def getGraphDimension(): Double

    Definition Classes
    Camera → Camera
  20. def getMetrics(): GraphMetrics

    Definition Classes
    Camera → Camera
  21. def getNodeOrSpritePositionGU(elt: GraphicElement, pos: Point3): Point3

  22. def getNodeOrSpriteSize(elt: GraphicElement): Values

    Attributes
    protected
  23. def getSpritePosition(sprite: GraphicSprite, pos: Point3, units: Units): Point3

    Compute the real position of a sprite according to its eventual attachment in graph units.

    Compute the real position of a sprite according to its eventual attachment in graph units.

    sprite

    The sprite.

    pos

    Receiver for the sprite 2D position, can be null.

    units

    The units in which the position must be computed (the sprite already contains units).

    returns

    The same instance as the one given by parameter pos or a new one if pos was null, containing the computed position in the given units.

  24. def getSpritePositionEdge(sprite: GraphicSprite, position: Point3, units: Units): Point3

    Compute the position of a sprite if attached to an edge.

    Compute the position of a sprite if attached to an edge.

    sprite

    The sprite.

    units

    The units the computed position must be given into.

    returns

    The same instance as pos, or a new one if pos was null.

    Attributes
    protected
  25. def getSpritePositionFree(sprite: GraphicSprite, position: Point3, units: Units): Point3

    Compute the position of a sprite if it is not attached.

    Compute the position of a sprite if it is not attached.

    sprite

    The sprite.

    position

    Where to stored the computed position, if null, the position is created.

    units

    The units the computed position must be given into.

    returns

    The same instance as pos, or a new one if pos was null.

    Attributes
    protected
  26. def getSpritePositionNode(sprite: GraphicSprite, position: Point3, units: Units): Point3

    Compute the position of a sprite if attached to a node.

    Compute the position of a sprite if attached to a node.

    sprite

    The sprite.

    units

    The units the computed position must be given into.

    returns

    The same instance as pos, or a new one if pos was null.

    Attributes
    protected
  27. def getViewCenter(): Point3

    Definition Classes
    Camera → Camera
  28. def getViewPercent(): Double

    Definition Classes
    Camera → Camera
  29. def getViewRotation(): Double

    Definition Classes
    Camera → Camera
  30. val graph: GraphicGraph

    Attributes
    protected
  31. def graphViewport: Array[Double]

  32. var gviewport: Array[Double]

    The graph view port, if any.

    The graph view port, if any. The graph view port is a view inside the graph space. It allows to compute the view according to a specified area of the graph space instead of the graph dimensions.

    Attributes
    protected
  33. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  34. def isEdgeVisible(edge: GraphicEdge): Boolean

    Check if an edge is visible in the current view port.

    Check if an edge is visible in the current view port.

    edge

    The edge to check.

    returns

    True if visible.

    Attributes
    protected
  35. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  36. def isNodeIn(node: GraphicNode, X1: Double, Y1: Double, X2: Double, Y2: Double): Boolean

    Is the given node visible in the given area.

    Is the given node visible in the given area.

    node

    The node to check.

    X1

    The min abscissa of the area.

    Y1

    The min ordinate of the area.

    X2

    The max abscissa of the area.

    Y2

    The max ordinate of the area.

    returns

    True if the node lies in the given area.

    Attributes
    protected
  37. def isSpriteIn(sprite: GraphicSprite, X1: Double, Y1: Double, X2: Double, Y2: Double): Boolean

    Is the given sprite visible in the given area.

    Is the given sprite visible in the given area.

    sprite

    The sprite to check.

    X1

    The min abscissa of the area.

    Y1

    The min ordinate of the area.

    X2

    The max abscissa of the area.

    Y2

    The max ordinate of the area.

    returns

    True if the node lies in the given area.

    Attributes
    protected
  38. def isSpriteVisible(sprite: GraphicSprite): Boolean

    Check if a sprite is visible in the current view port.

    Check if a sprite is visible in the current view port.

    sprite

    The sprite to check.

    returns

    True if visible.

    Attributes
    protected
  39. def isTextVisible(element: GraphicElement): Boolean

  40. def isVisible(element: GraphicElement): Boolean

    True if the element is be visible by the camera view (not out of view).

    True if the element is be visible by the camera view (not out of view). The method used is to transform the center of the element (which is always in graph units) using the camera actual transformation to put it in pixel units. Then to look in the style sheet the size of the element and to test if its enclosing rectangle intersects the view port. For edges, its two nodes are used. If auto fitting is on, all elements are necessarily visible, this method takes this in consideration.

    element

    The element to test.

    returns

    True if the element is visible and therefore must be rendered.

    Definition Classes
    Camera → Camera
  41. val metrics: GraphMetrics

    Information on the graph overall dimension and position.

  42. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  43. def nodeContains(elt: GraphicElement, x: Double, y: Double): Boolean

    Check if a node contains the given point (x,y).

    Check if a node contains the given point (x,y).

    elt

    The node.

    x

    The point abscissa.

    y

    The point ordinate.

    returns

    True if (x,y) is in the given element.

    Attributes
    protected
  44. val nodeInvisible: HashSet[String]

    Which node is visible.

    Which node is visible. This allows to mark invisible nodes to fasten visibility tests for nodes, attached sprites and edges. The visibility test is heavy, and we often need to test for nodes visibility. This allows to do it only once per rendering step. Hence the storage of the invisible nodes here.

    Attributes
    protected
  45. final def notify(): Unit

    Definition Classes
    AnyRef
  46. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  47. var padding: Values

    Padding around the graph.

    Padding around the graph.

    Attributes
    protected
  48. def paddingXgu: Double

    Attributes
    protected
  49. def paddingXpx: Double

    Attributes
    protected
  50. def paddingYgu: Double

    Attributes
    protected
  51. def paddingYpx: Double

    Attributes
    protected
  52. def popView(): Unit

    Restore the transform that was used before #pushView(Graphics2D) is used.

  53. def pushView(graph: GraphicGraph): Unit

    Set the camera view in the given graphics and backup the previous transform of the graphics.

    Set the camera view in the given graphics and backup the previous transform of the graphics. Call #popView(Graphics2D) to restore the saved transform. You can only push one time the view.

    graph

    The graphic graph (used to check element visibility).

  54. def removeGraphViewport(): Unit

    Definition Classes
    Camera → Camera
  55. def resetView(): Unit

    Definition Classes
    Camera → Camera
  56. var rotation: Double

    The rotation angle (along an axis perpendicular to the view).

    The rotation angle (along an axis perpendicular to the view).

    Attributes
    protected
  57. def setAutoFitView(on: Boolean): Unit

    Enable or disable automatic adjustment of the view to see the entire graph.

    Enable or disable automatic adjustment of the view to see the entire graph.

    on

    If true, automatic adjustment is enabled.

    Definition Classes
    Camera → Camera
  58. def setBackend(backend: Backend): Unit

  59. def setBounds(graph: GraphicGraph): Unit

    Set the graphic graph bounds from the graphic graph.

  60. def setBounds(minx: Double, miny: Double, minz: Double, maxx: Double, maxy: Double, maxz: Double): Unit

    Set the graphic graph bounds (the lowest and highest points).

    Set the graphic graph bounds (the lowest and highest points).

    minx

    Lowest abscissa.

    miny

    Lowest ordinate.

    minz

    Lowest depth.

    maxx

    Highest abscissa.

    maxy

    Highest ordinate.

    maxz

    Highest depth.

    Definition Classes
    Camera → Camera
  61. def setGraphViewport(minx: Double, miny: Double, maxx: Double, maxy: Double): Unit

    Definition Classes
    Camera → Camera
  62. def setPadding(graph: GraphicGraph): Unit

    Set the graph padding.

    Set the graph padding. Called in pushView.

    graph

    The graphic graph.

    Attributes
    protected
  63. def setViewCenter(x: Double, y: Double, z: Double): Unit

    Set the center of the view (the looked at point).

    Set the center of the view (the looked at point). As the viewer is only 2D, the z value is not required.

    x

    The new position abscissa.

    y

    The new position ordinate.

    Definition Classes
    Camera → Camera
  64. def setViewPercent(z: Double): Unit

    Definition Classes
    Camera → Camera
  65. def setViewRotation(angle: Double): Unit

    Definition Classes
    Camera → Camera
  66. def setViewport(x: Double, y: Double, viewportWidth: Double, viewportHeight: Double): Unit

    Set the output view port size in pixels.

    Set the output view port size in pixels.

    viewportWidth

    The width in pixels of the view port.

    viewportHeight

    The width in pixels of the view port.

  67. def spriteContains(elt: GraphicElement, x: Double, y: Double): Boolean

    Check if a sprite contains the given point (x,y).

    Check if a sprite contains the given point (x,y).

    elt

    The sprite.

    x

    The point abscissa.

    y

    The point ordinate.

    returns

    True if (x,y) is in the given element.

    Attributes
    protected
  68. def spritePositionPx(sprite: GraphicSprite): Point3

    Attributes
    protected
  69. def styleVisible(element: GraphicElement): Boolean

    Attributes
    protected
  70. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  71. def toString(): String

    Definition Classes
    Camera → AnyRef → Any
  72. def transformGuToPx(x: Double, y: Double, z: Double): Point3

    Transform a point in graph units into pixels.

    Transform a point in graph units into pixels.

    returns

    The transformed point.

    Definition Classes
    Camera → Camera
  73. def transformPxToGu(x: Double, y: Double): Point3

    Return the given point in pixels converted in graph units (GU) using the inverse transformation of the current projection matrix.

    Return the given point in pixels converted in graph units (GU) using the inverse transformation of the current projection matrix. The inverse matrix is computed only once each time a new projection matrix is created.

    x

    The source point abscissa in pixels.

    y

    The source point ordinate in pixels.

    returns

    The resulting points in graph units.

    Definition Classes
    Camera → Camera
  74. def userView(): Unit

    Compute a transformation that pass from graph units (user space) to a pixel units (device space) so that the view (zoom and center) requested by the user is produced.

    Compute a transformation that pass from graph units (user space) to a pixel units (device space) so that the view (zoom and center) requested by the user is produced.

    returns

    The transformation modified.

    Attributes
    protected
  75. def viewCenter: Point3

    The view center (a point in graph units).

  76. def viewPercent: Double

    The visible portion of the graph.

    The visible portion of the graph.

    returns

    A real for which value 1 means the graph is fully visible and uses the whole view port.

  77. def viewPercent_=(z: Double): Unit

    Set the zoom (or percent of the graph visible), 1 means the graph is fully visible.

    Set the zoom (or percent of the graph visible), 1 means the graph is fully visible.

    z

    The zoom.

  78. def viewRotation: Double

    The rotation angle in degrees.

    The rotation angle in degrees.

    returns

    The rotation angle in degrees.

  79. def viewRotation_=(angle: Double): Unit

    Set the rotation angle around the center.

    Set the rotation angle around the center.

    angle

    The rotation angle in degrees.

  80. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  81. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  82. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  83. var zoom: Double

    The camera zoom.

    The camera zoom.

    Attributes
    protected

Inherited from swingViewer.util.Camera

Inherited from AnyRef

Inherited from Any

Ungrouped