Package org.jzy3d.plot3d.rendering.view
Class View2DProcessing
- java.lang.Object
-
- org.jzy3d.plot3d.rendering.view.View2DProcessing
-
public class View2DProcessing extends Object
Process and store the layout of a 2D view having margins and axis labels defined by theView2DLayout
settings. Storing the results is handy for classes needing to reuse intermediate processing of this margins :View.computeCamera2D_RenderingSquare(Camera, ViewportConfiguration, BoundingBox3d)
AxisLabelProcessor.axisLabelPosition_2D(int, org.jzy3d.maths.Coord3d)
AxisTickProcessor.getTickLength3D_OrComputeTickLength2D(org.jzy3d.painters.IPainter, int)
getModelToScreenRatio(Area, Area, Area)
which has an extended documentation providing mathematical demonstration.- Author:
- Martin Pernollet
-
-
Field Summary
Fields Modifier and Type Field Description protected float
axisTextHorizontal
protected float
axisTextVertical
protected Area
margin
protected float
marginBottomModel
protected float
marginBottomPx
protected float
marginLeftModel
protected float
marginLeftPx
protected float
marginRightModel
protected float
marginRightPx
protected float
marginTopModel
protected float
marginTopPx
protected Coord2d
modelToScreen
protected float
tickTextHorizontal
protected float
tickTextVertical
protected View
view
-
Constructor Summary
Constructors Constructor Description View2DProcessing(View view)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(ViewportConfiguration viewport, BoundingBox3d bounds)
Apply current view'sView2DLayout
and process all margins in 3D.float
getAxisTextHorizontal()
Return the axis label width in pixel that was processed at the latest call to#apply()
according to the axis and view layout settingsfloat
getAxisTextVertical()
Return the axis label height in pixel that was processed at the latest call to#apply()
according to the axis and view layout settingsArea
getMargin()
Return the overall margin that was processed at the latest call to#apply()
according to the axis and view layout settingsCoord2d
getModelToScreen()
Return the model-to-screen ratio that that was processed at the latest call to#apply()
Coord2d
getModelToScreenRatio(Area space, Area canvas, Area margins)
A helper for processing 2D margins.Coord2d
getModelToScreenRatio(BoundingBox3d bounds, ViewportConfiguration viewport, Area margin)
float
getTickTextHorizontal()
Return the tick label width in pixel that was processed at the latest call to#apply()
according to the axis and view layout settingsfloat
getTickTextVertical()
Return the tick label height in pixel that was processed at the latest call to#apply()
according to the axis and view layout settings
-
-
-
Field Detail
-
view
protected View view
-
tickTextHorizontal
protected float tickTextHorizontal
-
tickTextVertical
protected float tickTextVertical
-
axisTextHorizontal
protected float axisTextHorizontal
-
axisTextVertical
protected float axisTextVertical
-
marginLeftPx
protected float marginLeftPx
-
marginRightPx
protected float marginRightPx
-
marginTopPx
protected float marginTopPx
-
marginBottomPx
protected float marginBottomPx
-
marginLeftModel
protected float marginLeftModel
-
marginRightModel
protected float marginRightModel
-
marginTopModel
protected float marginTopModel
-
marginBottomModel
protected float marginBottomModel
-
margin
protected Area margin
-
modelToScreen
protected Coord2d modelToScreen
-
-
Constructor Detail
-
View2DProcessing
public View2DProcessing(View view)
-
-
Method Detail
-
apply
public void apply(ViewportConfiguration viewport, BoundingBox3d bounds)
Apply current view'sView2DLayout
and process all margins in 3D.
-
getModelToScreenRatio
public Coord2d getModelToScreenRatio(Area space, Area canvas, Area margins)
A helper for processing 2D margins. This method process a model-to-screen ratio able to indicate which range of real world coordinates will be mapped to a single pixel, both on the width and height of the viewport. It is used to evaluate the camera settings to apply to a 2D projection to allow keeping a white space for drawing 2D margins. The intuition lead to consider that this ratio R should be :R.x = scene.bounds.xrange() / viewport.width R.y = scene.bounds.yrange() / viewport.height
100px 800px 100px |-----+------------------+-----| | | | |------------------| | | | | | | | xrange=20 | | | |------------------| | | x=-10 x=10 | |-----+------------------+-----|
R.x = scene.xrange() / viewport.width = 20/1000 = 2/100
margin3D.x = margin2D.x * R.x = 200 * 2/100 = 4
scene.xrange() / sceneWithMargin.xrange() = screen.xrange() / screenWithMargin.xrange() in our example : 20 / 24 = 800 / 1000
scene.xrange screen.xrange - margin2D.x ------------------------------- = -------------------------- R.x * margin2D.x + scene.xrange screen.xrange
screen.xrange * scene.xrange ( ---------------------------- - scene.xrange ) * (1/margin2D.x) screen.xrange - margin2D.x
- Parameters:
space
-canvas
-margins
-- Returns:
-
getModelToScreenRatio
public Coord2d getModelToScreenRatio(BoundingBox3d bounds, ViewportConfiguration viewport, Area margin)
-
getMargin
public Area getMargin()
Return the overall margin that was processed at the latest call to#apply()
according to the axis and view layout settings
-
getTickTextHorizontal
public float getTickTextHorizontal()
Return the tick label width in pixel that was processed at the latest call to#apply()
according to the axis and view layout settings
-
getTickTextVertical
public float getTickTextVertical()
Return the tick label height in pixel that was processed at the latest call to#apply()
according to the axis and view layout settings
-
getAxisTextHorizontal
public float getAxisTextHorizontal()
Return the axis label width in pixel that was processed at the latest call to#apply()
according to the axis and view layout settings
-
getAxisTextVertical
public float getAxisTextVertical()
Return the axis label height in pixel that was processed at the latest call to#apply()
according to the axis and view layout settings
-
getModelToScreen
public Coord2d getModelToScreen()
Return the model-to-screen ratio that that was processed at the latest call to#apply()
-
-