org.graphstream.ui.swingViewer.util
Class GraphMetrics

java.lang.Object
  extended by org.graphstream.ui.swingViewer.util.GraphMetrics

public class GraphMetrics
extends Object

p Various geometric informations on the graphic graph.

This class extends the GraphMetrics to provide not only metrics on the graphic graph but also on the rendering canvas, and allow to convert from graph metrics to canvas metrics and the reverse.

Here we call the canvas "view port" since this class allows to place a view port inside the graph in order to zoom and pan the view.


Field Summary
 double diagonal
          The graph diagonal.
 Point3 hi
          Graph higher position (top,right,back).
 Point3 hiVisible
          The highest visible point.
 Point3 lo
          Graph lower position (bottom,left,front).
 Point3 loVisible
          The lowest visible point.
 double px1
          The length for one pixel, according to the current transformation.
 double ratioPx2Gu
          The scaling factor to pass from graph units to pixels.
 Vector3 size
          Graph dimension.
 Vector3 viewport
          The view port size.
 
Constructor Summary
GraphMetrics()
          New canvas metrics with default values.
 
Method Summary
 double getDiagonal()
          The graph diagonal (the overall width).
 Point3 getHighPoint()
          The graph highest (top,right,back) point.
 Point3 getLowPoint()
          The graph lowest (bottom,left,front) point.
 Vector3 getSize()
          The graph bounds.
 double graphDepthGU()
           
 double graphHeightGU()
           
 double graphWidthGU()
           
 double lengthToGu(double value, StyleConstants.Units units)
          Convert a value in given units to graph units.
 double lengthToGu(Value value)
          Convert a value in a given units to graph units.
 double lengthToGu(Values values, int index)
          Convert one of the given values in a given units to graph units.
 double lengthToPx(double value, StyleConstants.Units units)
          Convert a value in a given units to pixels.
 double lengthToPx(Value value)
          Convert a value in a given units to pixels.
 double lengthToPx(Values values, int index)
          Convert one of the given values in a given units pixels.
 double positionPixelToGu(int pixels, int index)
           
 void setBounds(double minx, double miny, double minz, double maxx, double maxy, double maxz)
          Set the graphic graph bounds (the lowest and highest points).
 void setRatioPx2Gu(double ratio)
          The ratio to pass by multiplication from pixels to graph units.
 void setViewport(double viewportWidth, double viewportHeight)
          Set the output view port size in pixels.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lo

public Point3 lo
Graph lower position (bottom,left,front).


hi

public Point3 hi
Graph higher position (top,right,back).


loVisible

public Point3 loVisible
The lowest visible point.


hiVisible

public Point3 hiVisible
The highest visible point.


size

public Vector3 size
Graph dimension.


diagonal

public double diagonal
The graph diagonal.


viewport

public Vector3 viewport
The view port size.


ratioPx2Gu

public double ratioPx2Gu
The scaling factor to pass from graph units to pixels.


px1

public double px1
The length for one pixel, according to the current transformation.

Constructor Detail

GraphMetrics

public GraphMetrics()
New canvas metrics with default values.

Method Detail

getDiagonal

public double getDiagonal()
The graph diagonal (the overall width).

Returns:
The diagonal.

getSize

public Vector3 getSize()
The graph bounds.

Returns:
The size.

getLowPoint

public Point3 getLowPoint()
The graph lowest (bottom,left,front) point.

Returns:
The lowest point.

getHighPoint

public Point3 getHighPoint()
The graph highest (top,right,back) point.

Returns:
The highest point.

graphWidthGU

public double graphWidthGU()

graphHeightGU

public double graphHeightGU()

graphDepthGU

public double graphDepthGU()

lengthToGu

public double lengthToGu(double value,
                         StyleConstants.Units units)
Convert a value in given units to graph units.

Parameters:
value - The value to convert.
units - The units the value to convert is expressed in.
Returns:
The value converted to GU.

lengthToGu

public double lengthToGu(Value value)
Convert a value in a given units to graph units.

Parameters:
value - The value to convert (it contains its own units).

lengthToGu

public double lengthToGu(Values values,
                         int index)
Convert one of the given values in a given units to graph units.

Parameters:
values - The values set containing the value to convert (it contains its own units).
index - Index of the value to convert.

lengthToPx

public double lengthToPx(double value,
                         StyleConstants.Units units)
Convert a value in a given units to pixels.

Parameters:
value - The value to convert.
units - The units the value to convert is expressed in.
Returns:
The value converted in pixels.

lengthToPx

public double lengthToPx(Value value)
Convert a value in a given units to pixels.

Parameters:
value - The value to convert (it contains its own units).

lengthToPx

public double lengthToPx(Values values,
                         int index)
Convert one of the given values in a given units pixels.

Parameters:
values - The values set containing the value to convert (it contains its own units).
index - Index of the value to convert.

positionPixelToGu

public double positionPixelToGu(int pixels,
                                int index)

toString

public String toString()
Overrides:
toString in class Object

setViewport

public void setViewport(double viewportWidth,
                        double viewportHeight)
Set the output view port size in pixels.

Parameters:
viewportWidth - The width in pixels of the view port.
viewportHeight - The width in pixels of the view port.

setRatioPx2Gu

public void setRatioPx2Gu(double ratio)
The ratio to pass by multiplication from pixels to graph units. This ratio must be larger than zero, else nothing is changed.

Parameters:
ratio - The ratio.

setBounds

public void setBounds(double minx,
                      double miny,
                      double minz,
                      double maxx,
                      double maxy,
                      double maxz)
Set the graphic graph bounds (the lowest and highest points).

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


Copyright © 2011. All Rights Reserved.