Package org.jzy3d.chart
Class Chart
- java.lang.Object
-
- org.jzy3d.chart.Chart
-
- Direct Known Subclasses:
AWTChart
,GraphChart
,SWTChart
public class Chart extends Object
Chart
is a convenient object that gather all components required to render a 3d scene for plotting.- Author:
- Martin Pernollet
-
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
Chart()
Chart(IChartFactory factory, Quality quality)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(Collection<Serie2d> series)
Chart
add(List<? extends Drawable> drawables)
Add a list of drawables and refresh the view of the scene once they are all added.void
add(Map<String,Serie2d> series)
void
add(Serie2d serie)
Chart
add(Drawable drawable)
Add a drawable and refresh the view of the scene once it is added.Chart
add(Drawable drawable, boolean updateView)
Add a drawable to the scene graph of the chart.Chart
add(Drawable drawable, LODCandidates candidates)
Add a drawable by first evaluating its rendering performance onscreen from worse (LODSetting.Bounds.ON
to most good looking rendering.void
addController(AbstractCameraController controller)
Add aAbstractCameraController
to thisChart
.ICameraKeyController
addKeyboard()
ICameraKeyController
addKeyboardCameraController()
Deprecated.IScreenshotKeyController
addKeyboardScreenshotController()
Light
addLight(Coord3d position)
Add a light at the given position, using theLight.DEFAULT_COLOR
for the three coloring settings.Light
addLight(Coord3d position, Color colorForAll)
Light
addLight(Coord3d position, Color ambiant, Color diffuse, Color specular)
Add a light at the given position.Light
addLight(Coord3d position, Color ambiant, Color diffuse, Color specular, float radius)
Add a light at the given position.Light
addLightOnCamera()
Add a light that is attached to camera, which is moved as soon as the viewpoint changes, using theLight.DEFAULT_COLOR
for the three coloring settings.Light
addLightOnCamera(Color colorForAll)
Light
addLightOnCamera(Color ambiant, Color diffuse, Color specular)
Add a light that is attached to camera, which is moved as soon as the viewpoint changes.Light[]
addLightPairOnCamera()
Light[]
addLightPairOnCamera(Color colorForAll)
Light[]
addLightPairOnCamera(Color ambiant, Color diffuse, Color specular)
Add a light pair syncronized to camera.ICameraMouseController
addMouse()
ICameraMouseController
addMouseCameraController()
Deprecated.IMousePickingController
addMousePickingController(int clickWidth)
Chart
black()
void
clear()
protected void
clearControllerList()
Chart
color(Color background, Color axis)
protected void
configureKeyboardWithAnimator()
Switch between on demand/continuous rendering keep to false if animated to avoid double rendering keep to true otherwise the mouse does not updateprotected void
configureMouseWithAnimator()
Switch between on demand/continuous rendering keep to false if animated to avoid double rendering keep to true otherwise the mouse does not updateIFrame
display(Rectangle rectangle, String title)
void
dispose()
float
flip(float y)
AxisLayout
getAxisLayout()
ICanvas
getCanvas()
List<AbstractCameraController>
getControllers()
IChartFactory
getFactory()
ICameraKeyController
getKeyboard()
ICameraMouseController
getMouse()
IMousePickingController
getMousePicking()
IPainter
getPainter()
Quality
getQuality()
Scale
getScale()
ChartScene
getScene()
IScreenshotKeyController
getScreenshotKey()
Serie2d
getSerie(String name, Serie2d.Type type)
CameraThreadController
getThread()
View
getView()
ViewPositionMode
getViewMode()
Coord3d
getViewPoint()
protected static MouseEvent
mouseEvent(Component sourceCanvas, int x, int y)
View
newView()
IFrame
open()
IFrame
open(int width, int height)
IFrame
open(String title)
IFrame
open(String title, int width, int height)
IFrame
open(String title, Rectangle rect)
Open the frame if it was not opened beforevoid
remove(List<? extends Drawable> drawables)
void
remove(Serie2d serie)
void
remove(Drawable drawable)
void
remove(Drawable drawable, boolean updateViews)
void
removeController(AbstractCameraController controller)
Serie2d
removeSerie(String name, Serie2d.Type type)
void
render()
Trigger a chart rendering.Object
screenshot()
void
screenshot(File file)
Compute screenshot and save to filevoid
setAnimated(boolean status)
void
setAxeDisplayed(boolean status)
void
setQuality(Quality quality)
void
setScale(Scale scale)
void
setScale(Scale scale, boolean notify)
void
setViewMode(ViewPositionMode mode)
void
setViewPoint(Coord3d viewPoint)
IFrame
show(Rectangle rectangle, String title)
Alias fordisplay()
void
sleep(int mili)
A one liner to wait a bit, mainly for test purpose, when needing to have a frame opened and a chart initializedvoid
startAnimation()
void
stopAllThreads()
void
stopAnimation()
protected void
updateAnimationThreadWithQualitySettings()
protected void
updateLightOnCameraPosition()
protected void
updateLightPairOnCameraPosition()
protected void
updateLightsOnCameraPositions()
void
updateProjectionsAndRender()
View
view()
Chart
view2d()
Toggle the chart for 2D rendering.Chart
view3d()
Chart
white()
-
-
-
Field Detail
-
logger
protected static org.apache.logging.log4j.Logger logger
-
DEFAULT_QUALITY
public static final Quality DEFAULT_QUALITY
-
LOD_BOUNDS_ONLY_RENDER_TIME_MS
protected static final int LOD_BOUNDS_ONLY_RENDER_TIME_MS
- See Also:
- Constant Field Values
-
LOD_EVAL_TRIALS
protected static final int LOD_EVAL_TRIALS
- See Also:
- Constant Field Values
-
LOD_EVAL_MAX_EVAL_DURATION_MS
protected static final int LOD_EVAL_MAX_EVAL_DURATION_MS
- See Also:
- Constant Field Values
-
factory
protected IChartFactory factory
-
quality
protected Quality quality
-
scene
protected ChartScene scene
-
view
protected View view
-
canvas
protected ICanvas canvas
-
previousViewPointFree
protected Coord3d previousViewPointFree
-
previousViewPointTop
protected Coord3d previousViewPointTop
-
previousViewPointProfile
protected Coord3d previousViewPointProfile
-
controllers
protected ArrayList<AbstractCameraController> controllers
-
mouse
protected ICameraMouseController mouse
-
mousePicking
protected IMousePickingController mousePicking
-
keyboard
protected ICameraKeyController keyboard
-
screenshotKey
protected IScreenshotKeyController screenshotKey
-
lightOnCamera
protected Light lightOnCamera
-
lightPairOnCamera
protected Light[] lightPairOnCamera
-
axisYLabelOrientation
protected LabelOrientation axisYLabelOrientation
-
axisZLabelDisplayed
protected boolean axisZLabelDisplayed
-
axisZTickLabelDisplayed
protected boolean axisZTickLabelDisplayed
-
isTickLineDisplayed
protected boolean isTickLineDisplayed
-
isSquaredViewActive
protected boolean isSquaredViewActive
-
viewPositionMode
protected ViewPositionMode viewPositionMode
-
viewportMode
protected ViewportMode viewportMode
-
viewpoint
protected Coord3d viewpoint
-
-
Constructor Detail
-
Chart
public Chart(IChartFactory factory, Quality quality)
-
Chart
protected Chart()
-
-
Method Detail
-
black
public Chart black()
-
white
public Chart white()
-
view2d
public Chart view2d()
Toggle the chart for 2D rendering. Warning : when using 2D rendering, one should not try to set a squared view to avoid messing a tick and axis labels.
-
view3d
public Chart view3d()
-
clear
public void clear()
-
dispose
public void dispose()
-
render
public void render()
Trigger a chart rendering. Only usefull if chart Quality.is
-
setAnimated
public void setAnimated(boolean status)
-
updateAnimationThreadWithQualitySettings
protected void updateAnimationThreadWithQualitySettings()
-
startAnimation
public void startAnimation()
-
stopAnimation
public void stopAnimation()
-
stopAllThreads
public void stopAllThreads()
-
screenshot
public void screenshot(File file) throws IOException
Compute screenshot and save to file- Throws:
IOException
-
screenshot
public Object screenshot() throws IOException
- Throws:
IOException
-
updateProjectionsAndRender
public void updateProjectionsAndRender()
-
newView
public View newView()
-
addMouseCameraController
@Deprecated public ICameraMouseController addMouseCameraController()
Deprecated.useaddMouse()
instead.
-
addMouse
public ICameraMouseController addMouse()
-
configureMouseWithAnimator
protected void configureMouseWithAnimator()
Switch between on demand/continuous rendering keep to false if animated to avoid double rendering keep to true otherwise the mouse does not update
-
addMousePickingController
public IMousePickingController addMousePickingController(int clickWidth)
-
addKeyboardCameraController
@Deprecated public ICameraKeyController addKeyboardCameraController()
Deprecated.useaddKeyboard()
instead.
-
addKeyboard
public ICameraKeyController addKeyboard()
-
configureKeyboardWithAnimator
protected void configureKeyboardWithAnimator()
Switch between on demand/continuous rendering keep to false if animated to avoid double rendering keep to true otherwise the mouse does not update
-
addKeyboardScreenshotController
public IScreenshotKeyController addKeyboardScreenshotController()
-
getMouse
public ICameraMouseController getMouse()
-
getThread
public CameraThreadController getThread()
-
getMousePicking
public IMousePickingController getMousePicking()
-
getKeyboard
public ICameraKeyController getKeyboard()
-
getScreenshotKey
public IScreenshotKeyController getScreenshotKey()
-
addController
public void addController(AbstractCameraController controller)
Add aAbstractCameraController
to thisChart
. Warning: theChart
is not the owner of the controller. Disposing the chart thus just unregisters the controllers, but does not handle stopping and disposing controllers.
-
removeController
public void removeController(AbstractCameraController controller)
-
clearControllerList
protected void clearControllerList()
-
open
public IFrame open()
-
open
public IFrame open(int width, int height)
-
sleep
public void sleep(int mili)
A one liner to wait a bit, mainly for test purpose, when needing to have a frame opened and a chart initialized
-
open
public IFrame open(String title, Rectangle rect)
Open the frame if it was not opened before- Parameters:
title
-rect
-- Returns:
-
add
public Chart add(List<? extends Drawable> drawables)
Add a list of drawables and refresh the view of the scene once they are all added.- Parameters:
drawables
-- Returns:
-
add
public Chart add(Drawable drawable)
Add a drawable and refresh the view of the scene once it is added.- Parameters:
drawable
-- Returns:
-
add
public Chart add(Drawable drawable, boolean updateView)
Add a drawable to the scene graph of the chart. If the view holds aSpaceTransformer
, then it will be applied to the drawable. This can be reset by later calling {@link Drawable#setSpaceTransformer(null)}- Parameters:
drawable
-updateView
- states if the view should be updated immediately. Should be false if adding multiple drawable at the same time. The effect of not updating view is that view bounds won't be updated as well- Returns:
-
add
public Chart add(Drawable drawable, LODCandidates candidates)
Add a drawable by first evaluating its rendering performance onscreen from worse (LODSetting.Bounds.ON
to most good looking rendering. This method is useful when using facing low performance rendering, e.g. because one chose the fallback EmulGL renderer over native.Using dynamic level of details
This requires to have a properly configuredAdaptiveMouseController
as shown belowchart.add(myDrawable, new LODCandidates()); AdaptiveRenderingPolicy policy = new AdaptiveRenderingPolicy(); policy.optimizeForRenderingTimeLargerThan = 80;// ms policy.optimizeByPerformanceKnowledge = true; EmulGLSkin skin = EmulGLSkin.on(chart); skin.getMouse().setPolicy(policy);
Algorithm
Each Level of Detail configuration is described by aLODSetting
. AllLODSetting
are ranked in aLODCandidates
instance that indicates which are the most good looking settings. We define the best with lowest ID, the worse with highest ID.Training
LOD are evaluated in reverse order, as soon as the drawable is added to the chart. Evaluation store a rendering time for eachLODSetting
- LOD 3 took 40ms
- LOD 2 took 60ms
- LOD 1 took 80ms
- LOD 0 took 100ms
Applying
As soon as the mouse start dragging camera, the mouse controller will seek an acceptable LOD to reach the target- LOD 0 took 100ms // rejected
- LOD 1 took 80ms // rejected
- LOD 2 took 60ms // selected
- LOD 3 took 40ms // ignored
- LOD 0 took 100ms // rejected
- LOD 1 took 80ms // rejected
- LOD 2 took 60ms // rejected
- LOD 3 took 40ms // selected : minimal rendering time above threshold
- Parameters:
drawable
-- Returns:
-
mouseEvent
protected static MouseEvent mouseEvent(Component sourceCanvas, int x, int y)
-
add
public void add(Serie2d serie)
-
add
public void add(Collection<Serie2d> series)
-
getSerie
public Serie2d getSerie(String name, Serie2d.Type type)
-
removeSerie
public Serie2d removeSerie(String name, Serie2d.Type type)
-
remove
public void remove(Serie2d serie)
-
remove
public void remove(Drawable drawable)
-
remove
public void remove(Drawable drawable, boolean updateViews)
-
addLight
public Light addLight(Coord3d position)
Add a light at the given position, using theLight.DEFAULT_COLOR
for the three coloring settings. Warning : The default color being white, any polygon in pure RED, pure GREEN or pure BLUE will have the exact same color when using a light. SeeLight
documentation for this, or change the light color or object color a bit.
-
addLight
public Light addLight(Coord3d position, Color ambiant, Color diffuse, Color specular)
Add a light at the given position.- Parameters:
ambiant
-diffuse
-specular
-- Returns:
-
addLight
public Light addLight(Coord3d position, Color ambiant, Color diffuse, Color specular, float radius)
Add a light at the given position.- Parameters:
ambiant
-diffuse
-specular
-- Returns:
-
addLightOnCamera
public Light addLightOnCamera()
Add a light that is attached to camera, which is moved as soon as the viewpoint changes, using theLight.DEFAULT_COLOR
for the three coloring settings. Warning : The default color being white, any polygon in pure RED, pure GREEN or pure BLUE will have the exact same color when using a light. SeeLight
documentation for this, or change the light color or object color a bit.
-
addLightOnCamera
public Light addLightOnCamera(Color ambiant, Color diffuse, Color specular)
Add a light that is attached to camera, which is moved as soon as the viewpoint changes. If this light was already created, the initial instance is returned, even if the color setting do not match.- Parameters:
ambiant
-diffuse
-specular
-- Returns:
-
updateLightOnCameraPosition
protected void updateLightOnCameraPosition()
-
addLightPairOnCamera
public Light[] addLightPairOnCamera()
-
addLightPairOnCamera
public Light[] addLightPairOnCamera(Color ambiant, Color diffuse, Color specular)
Add a light pair syncronized to camera. Top light is 45° above the camera, bottom light is 45° below the camera. If these lights were already created, the initial instances are returned, even if the color setting do not match.- Parameters:
ambiant
-diffuse
-specular
-- Returns:
-
updateLightPairOnCameraPosition
protected void updateLightPairOnCameraPosition()
-
updateLightsOnCameraPositions
protected void updateLightsOnCameraPositions()
-
setAxeDisplayed
public void setAxeDisplayed(boolean status)
-
setViewPoint
public void setViewPoint(Coord3d viewPoint)
-
getViewPoint
public Coord3d getViewPoint()
-
getViewMode
public ViewPositionMode getViewMode()
-
setScale
public void setScale(Scale scale, boolean notify)
-
setScale
public void setScale(Scale scale)
-
getScale
public Scale getScale()
-
getPainter
public IPainter getPainter()
-
setViewMode
public void setViewMode(ViewPositionMode mode)
-
flip
public float flip(float y)
-
view
public View view()
-
getView
public View getView()
-
getScene
public ChartScene getScene()
-
getCanvas
public ICanvas getCanvas()
-
getAxisLayout
public AxisLayout getAxisLayout()
-
getFactory
public IChartFactory getFactory()
-
getControllers
public List<AbstractCameraController> getControllers()
-
getQuality
public Quality getQuality()
-
setQuality
public void setQuality(Quality quality)
-
-