org.graphstream.ui.j2dviewer

Camera

class Camera extends AnyRef

Define how the graph is viewed.

The camera is in charge of projecting the graph elements in graph units (GU) into user spaces (often in pixels). It defines the transformation (an affine matrix) to pass from the first to the second. It also contains the graph metrics, 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 rendering units). The two mains methods for this operation are #pushView(Graphics2D,GraphicGraph) and #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 camera also defines a centre at which it always points. It can zoom on the graph, pan in any direction and rotate along two axes.

There are two modes : an "auto-fit" mode where the camera always show the whole graph even if it changes in size, and a "user" mode where the camera centre (looked-at point), zoom and panning are specified.

Knowing the transformation also allows to provide services like "what element is visible ?" (in the camera view) 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
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Camera
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Camera ()

Value Members

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

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

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

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

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

    Attributes
    final
    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. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  8. var autoFit : Boolean

    Automatic centring of the view.

    Automatic centring 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 centre of view.

    The camera centre 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.

    Attributes
    protected
  13. def clone (): AnyRef

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

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

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

    Attributes
    protected[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. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  19. def getNodeOrSpritePositionGU (elt: GraphicElement, pos: Point3): Point3

  20. def getNodeOrSpriteSize (elt: GraphicElement): Values

    Attributes
    protected
  21. 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.

  22. 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
  23. 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
  24. 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
  25. def graphViewport : Array[Double]

  26. 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
  27. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  28. def inverseTransform (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.

  29. 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
  30. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  31. 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
  32. 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
  33. 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
  34. def isTextVisible (element: GraphicElement): Boolean

  35. def isVisible (element: GraphicElement): Boolean

    True if the element would be visible on screen.

    True if the element would be visible on screen. The method used is to transform the centre 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.

    element

    The element to test.

    returns

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

  36. val metrics : GraphMetrics

    Information on the graph overall dimension and position.

  37. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  38. 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
  39. 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
  40. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  41. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  42. var padding : Values

    Padding around the graph.

    Padding around the graph.

    Attributes
    protected
  43. def paddingXgu : Double

    Attributes
    protected
  44. def paddingXpx : Double

    Attributes
    protected
  45. def paddingYgu : Double

    Attributes
    protected
  46. def paddingYpx : Double

    Attributes
    protected
  47. def popView (): Unit

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

  48. 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).

  49. def removeGraphViewport (): Unit

  50. var rotation : Double

    The rotation angle.

    The rotation angle.

    Attributes
    protected
  51. 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.

  52. def setBackend (backend: Backend): Unit

  53. def setBounds (graph: GraphicGraph): Unit

    Set the graphic graph bounds from the graphic graph.

  54. 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.

  55. def setGraphViewport (minx: Double, miny: Double, maxx: Double, maxy: Double): Unit

  56. def setPadding (graph: GraphicGraph): Unit

    Set the graph padding.

    Set the graph padding. Called in pushView.

    graph

    The graphic graph.

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

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

    Set the centre 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.

  58. def setViewport (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.

  59. 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
  60. def spritePositionPx (sprite: GraphicSprite): Point3

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

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

    Attributes
    final
    Definition Classes
    AnyRef
  63. def toString (): String

    Definition Classes
    Camera → AnyRef → Any
  64. def transform (x: Double, y: Double): Point3

    Transform a point in graph units into pixels.

    Transform a point in graph units into pixels.

    returns

    The transformed point.

  65. 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 centre) 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 centre) requested by the user is produced.

    returns

    The transformation modified.

    Attributes
    protected
  66. def viewCenter : Point3

    The view centre (a point in graph units).

    The view centre (a point in graph units).

    returns

    The view centre.

  67. 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.

  68. 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.

  69. def viewRotation : Double

    The rotation angle in degrees.

    The rotation angle in degrees.

    returns

    The rotation angle in degrees.

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

    Set the rotation angle around the centre.

    Set the rotation angle around the centre.

    angle

    The rotation angle in degrees.

  71. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  74. var zoom : Double

    The camera zoom.

    The camera zoom.

    Attributes
    protected

Inherited from AnyRef

Inherited from Any