Package org.jzy3d.chart
Class Chart
- java.lang.Object
-
- org.jzy3d.chart.Chart
-
- Direct Known Subclasses:
AWTChart,GraphChart,SWTChart
public class Chart extends Object
Chartis 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 protectedChart()Chart(IChartFactory factory, Quality quality)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(Collection<Serie2d> series)Chartadd(List<? extends Drawable> drawables)Add a list of drawables and refresh the view of the scene once they are all added.voidadd(Map<String,Serie2d> series)voidadd(Serie2d serie)Chartadd(Drawable drawable)Add a drawable and refresh the view of the scene once it is added.Chartadd(Drawable drawable, boolean updateView)Add a drawable to the scene graph of the chart.Chartadd(Drawable drawable, LODCandidates candidates)Add a drawable by first evaluating its rendering performance onscreen from worse (LODSetting.Bounds.ONto most good looking rendering.voidaddController(AbstractCameraController controller)Add aAbstractCameraControllerto thisChart.ICameraKeyControlleraddKeyboard()ICameraKeyControlleraddKeyboardCameraController()Deprecated.IScreenshotKeyControlleraddKeyboardScreenshotController()LightaddLight(Coord3d position)Add a light at the given position, using theLight.DEFAULT_COLORfor the three coloring settings.LightaddLight(Coord3d position, Color colorForAll)LightaddLight(Coord3d position, Color ambiant, Color diffuse, Color specular)Add a light at the given position.LightaddLight(Coord3d position, Color ambiant, Color diffuse, Color specular, float radius)Add a light at the given position.LightaddLightOnCamera()Add a light that is attached to camera, which is moved as soon as the viewpoint changes, using theLight.DEFAULT_COLORfor the three coloring settings.LightaddLightOnCamera(Color colorForAll)LightaddLightOnCamera(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.ICameraMouseControlleraddMouse()ICameraMouseControlleraddMouseCameraController()Deprecated.IMousePickingControlleraddMousePickingController(int clickWidth)Chartblack()voidclear()protected voidclearControllerList()Chartcolor(Color background, Color axis)protected voidconfigureKeyboardWithAnimator()Switch between on demand/continuous rendering keep to false if animated to avoid double rendering keep to true otherwise the mouse does not updateprotected voidconfigureMouseWithAnimator()Switch between on demand/continuous rendering keep to false if animated to avoid double rendering keep to true otherwise the mouse does not updateIFramedisplay(Rectangle rectangle, String title)voiddispose()floatflip(float y)AxisLayoutgetAxisLayout()ICanvasgetCanvas()List<AbstractCameraController>getControllers()IChartFactorygetFactory()ICameraKeyControllergetKeyboard()ICameraMouseControllergetMouse()IMousePickingControllergetMousePicking()IPaintergetPainter()QualitygetQuality()ScalegetScale()ChartScenegetScene()IScreenshotKeyControllergetScreenshotKey()Serie2dgetSerie(String name, Serie2d.Type type)CameraThreadControllergetThread()ViewgetView()ViewPositionModegetViewMode()Coord3dgetViewPoint()protected static MouseEventmouseEvent(Component sourceCanvas, int x, int y)ViewnewView()IFrameopen()IFrameopen(int width, int height)IFrameopen(String title)IFrameopen(String title, int width, int height)IFrameopen(String title, Rectangle rect)Open the frame if it was not opened beforevoidremove(List<? extends Drawable> drawables)voidremove(Serie2d serie)voidremove(Drawable drawable)voidremove(Drawable drawable, boolean updateViews)voidremoveController(AbstractCameraController controller)Serie2dremoveSerie(String name, Serie2d.Type type)voidrender()Trigger a chart rendering.Objectscreenshot()voidscreenshot(File file)Compute screenshot and save to filevoidsetAnimated(boolean status)voidsetAxeDisplayed(boolean status)voidsetQuality(Quality quality)voidsetScale(Scale scale)voidsetScale(Scale scale, boolean notify)voidsetViewMode(ViewPositionMode mode)voidsetViewPoint(Coord3d viewPoint)IFrameshow(Rectangle rectangle, String title)Alias fordisplay()voidsleep(int mili)A one liner to wait a bit, mainly for test purpose, when needing to have a frame opened and a chart initializedvoidstartAnimation()voidstopAllThreads()voidstopAnimation()protected voidupdateAnimationThreadWithQualitySettings()protected voidupdateLightOnCameraPosition()protected voidupdateLightPairOnCameraPosition()protected voidupdateLightsOnCameraPositions()voidupdateProjectionsAndRender()Viewview()Chartview2d()Toggle the chart for 2D rendering.Chartview3d()Chartwhite()
-
-
-
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 aAbstractCameraControllerto thisChart. Warning: theChartis 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.ONto 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 configuredAdaptiveMouseControlleras 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. AllLODSettingare ranked in aLODCandidatesinstance 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_COLORfor 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. SeeLightdocumentation 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_COLORfor 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. SeeLightdocumentation 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)
-
-