Package org.graphstream.ui.view.util
Class GraphMetrics
java.lang.Object
org.graphstream.ui.view.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
Fields Modifier and Type Field Description doublediagonalThe graph diagonal.Point3hiGraph higher position (top,right,back).Point3hiVisibleThe highest visible point.Point3loGraph lower position (bottom,left,front).Point3loVisibleThe lowest visible point.doublepx1The length for one pixel, according to the current transformation.doubleratioPx2GuThe scaling factor to pass from graph units to pixels.org.miv.pherd.geom.Vector3sizeGraph dimension.double[]viewportThe view port size. -
Constructor Summary
Constructors Constructor Description GraphMetrics()New canvas metrics with default values. -
Method Summary
Modifier and Type Method Description doublegetDiagonal()The graph diagonal (the overall width).Point3getHighPoint()The graph highest (top,right,back) point.Point3getLowPoint()The graph lowest (bottom,left,front) point.org.miv.pherd.geom.Vector3getSize()The graph bounds.doublegraphDepthGU()doublegraphHeightGU()doublegraphWidthGU()doublelengthToGu(double value, StyleConstants.Units units)Convert a value in given units to graph units.doublelengthToGu(Value value)Convert a value in a given units to graph units.doublelengthToGu(Values values, int index)Convert one of the given values in a given units to graph units.doublelengthToPx(double value, StyleConstants.Units units)Convert a value in a given units to pixels.doublelengthToPx(Value value)Convert a value in a given units to pixels.doublelengthToPx(Values values, int index)Convert one of the given values in a given units pixels.doublepositionPixelToGu(int pixels, int index)voidsetBounds(double minx, double miny, double minz, double maxx, double maxy, double maxz)Set the graphic graph bounds (the lowest and highest points).voidsetRatioPx2Gu(double ratio)The ratio to pass by multiplication from pixels to graph units.voidsetViewport(double viewportX, double viewportY, double viewportWidth, double viewportHeight)Set the output view port size in pixels.StringtoString()
-
Field Details
-
lo
Graph lower position (bottom,left,front). -
hi
Graph higher position (top,right,back). -
loVisible
The lowest visible point. -
hiVisible
The highest visible point. -
size
public org.miv.pherd.geom.Vector3 sizeGraph dimension. -
diagonal
public double diagonalThe graph diagonal. -
viewport
public double[] viewportThe view port size. -
ratioPx2Gu
public double ratioPx2GuThe scaling factor to pass from graph units to pixels. -
px1
public double px1The length for one pixel, according to the current transformation.
-
-
Constructor Details
-
GraphMetrics
public GraphMetrics()New canvas metrics with default values.
-
-
Method Details
-
getDiagonal
public double getDiagonal()The graph diagonal (the overall width).- Returns:
- The diagonal.
-
getSize
public org.miv.pherd.geom.Vector3 getSize()The graph bounds.- Returns:
- The size.
-
getLowPoint
The graph lowest (bottom,left,front) point.- Returns:
- The lowest point.
-
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
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
Convert a value in a given units to graph units.- Parameters:
value- The value to convert (it contains its own units).
-
lengthToGu
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
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
Convert a value in a given units to pixels.- Parameters:
value- The value to convert (it contains its own units).
-
lengthToPx
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
-
setViewport
public void setViewport(double viewportX, double viewportY, 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.
-