org.graphstream.ui.swingViewer.util
Interface Camera

All Known Implementing Classes:
DefaultCamera

public interface Camera


Method Summary
 double getGraphDimension()
          A number in GU that gives the approximate graph size (often the diagonal of the graph).
 GraphMetrics getMetrics()
          Get the GraphMetrics object linked to this Camera.
 Point3 getViewCenter()
          The view centre (a point in graph units).
 double getViewPercent()
          The portion of the graph visible.
 double getViewRotation()
          The current rotation angle.
 boolean isVisible(GraphicElement element)
          True if the element would be visible on screen.
 void removeGraphViewport()
          Remove the specified graph view port.
 void resetView()
          Reset the view to the automatic mode.
 void setAutoFitView(boolean on)
          Enable or disable automatic adjustment of the view to see the entire graph.
 void setBounds(double minx, double miny, double minz, double maxx, double maxy, double maxz)
          Set the bounds of the graphic graph in GU.
 void setGraphViewport(double minx, double miny, double maxx, double maxy)
          Specify exactly the minimum and maximum points in GU that are visible (more points may be visible due to aspect-ratio constraints).
 void setViewCenter(double x, double y, double z)
          Change the view centre.
 void setViewPercent(double percent)
          Zoom the view.
 void setViewRotation(double theta)
          Rotate the view around its centre point by a given theta angles (in degrees).
 Point3 transformGuToPx(double x, double y, double z)
          Transform a point in graph units into pixels.
 Point3 transformPxToGu(double x, double y)
          Return the given point in pixels converted in graph units (GU) using the inverse transformation of the current projection matrix.
 

Method Detail

getViewCenter

Point3 getViewCenter()
The view centre (a point in graph units).

Returns:
The view centre.

setViewCenter

void setViewCenter(double x,
                   double y,
                   double z)
Change the view centre.

Parameters:
x - The new abscissa.
y - The new ordinate.
z - The new depth.

getViewPercent

double getViewPercent()
The portion of the graph visible.

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

setViewPercent

void setViewPercent(double percent)
Zoom the view.

Parameters:
percent - Percent of the graph visible.

getViewRotation

double getViewRotation()
The current rotation angle.

Returns:
The rotation angle in degrees.

setViewRotation

void setViewRotation(double theta)
Rotate the view around its centre point by a given theta angles (in degrees).

Parameters:
theta - The rotation angle in degrees.

getGraphDimension

double getGraphDimension()
A number in GU that gives the approximate graph size (often the diagonal of the graph). This allows to compute displacements in the graph as percent of its overall size. For example this can be used to move the view centre.

Returns:
The graph estimated size in graph units.

removeGraphViewport

void removeGraphViewport()
Remove the specified graph view port.

See Also:
setGraphViewport(double, double, double, double)

setGraphViewport

void setGraphViewport(double minx,
                      double miny,
                      double maxx,
                      double maxy)
Specify exactly the minimum and maximum points in GU that are visible (more points may be visible due to aspect-ratio constraints).

Parameters:
minx - The minimum abscissa visible.
miny - The minimum ordinate visible.
maxx - The maximum abscissa visible.
maxy - The maximum abscissa visible.
See Also:
removeGraphViewport()

resetView

void resetView()
Reset the view to the automatic mode.


setBounds

void setBounds(double minx,
               double miny,
               double minz,
               double maxx,
               double maxy,
               double maxz)
Set the bounds of the graphic graph in GU. Called by the Viewer.

Parameters:
minx - Lowest abscissa.
miny - Lowest ordinate.
minz - Lowest depth.
maxx - Highest abscissa.
maxy - Highest ordinate.
maxz - Highest depth.

getMetrics

GraphMetrics getMetrics()
Get the GraphMetrics object linked to this Camera. It can be used to convert pixels to graphic units and vice versa.

Returns:
a GraphMetrics instance

setAutoFitView

void setAutoFitView(boolean on)
Enable or disable automatic adjustment of the view to see the entire graph.

Parameters:
on - If true, automatic adjustment is enabled.

transformGuToPx

Point3 transformGuToPx(double x,
                       double y,
                       double z)
Transform a point in graph units into pixels.

Returns:
The transformed point.

transformPxToGu

Point3 transformPxToGu(double x,
                       double y)
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.

Parameters:
x - The source point abscissa in pixels.
y - The source point ordinate in pixels.
Returns:
The resulting points in graph units.

isVisible

boolean isVisible(GraphicElement element)
True if the element would be visible on screen. 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.

Parameters:
element - The element to test.
Returns:
True if the element is visible and therefore must be rendered.


Copyright © 2012. All Rights Reserved.