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 Details

  • Constructor Details

  • Method Details

    • black

      public Chart black()
    • white

      public Chart white()
    • color

      public Chart color(Color background, Color axis)
    • 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.
    • view2d

      public Chart view2d(View2D view2D)
    • view3d

      public Chart view3d()
    • show

      public IFrame show(Rectangle rectangle, String title)
      Alias for
      invalid @link
      display()
    • display

      public IFrame display(Rectangle rectangle, String title)
    • dispose

      public void dispose()
    • render

      public void render()
      Trigger a chart rendering. Only usefull if chart Quality.is
    • render

      public void render(int n)
    • 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()
    • updateProjectionsAndRender

      public void updateProjectionsAndRender()
    • newView

      public View newView()
    • addMouseCameraController

      @Deprecated public ICameraMouseController addMouseCameraController()
      Deprecated.
      use addMouse() 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.
      use addKeyboard() 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 a AbstractCameraController to this Chart. Warning: the Chart 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(String title)
    • open

      public IFrame open(String title, int width, int height)
    • 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 a SpaceTransformer, then it will be applied to the drawable. This can be reset by later calling
      invalid @link
      {@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 configured
      invalid @link
      AdaptiveMouseController
      as shown below
       
       chart.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 a LODSetting. All LODSetting are ranked in a LODCandidates 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 each LODSetting
      • 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
      Now if the target time is 30ms and none match the setting, then the fastest configuration is applied
      • 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
      If no LOD configuration is given in the list, then nothing will be applied. Note that a mouse is generated on the fly to register all rendering performance and later decide the best to use when rotating. The mouse is initialized after evaluating performance to ensure the user won't try to trigger rotations before evaluation finishes. In addition to call this method, one should enable the mouse policy allowing to use these performance evaluations.
      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)
    • add

      public void add(Map<String,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)
    • remove

      public void remove(List<? extends Drawable> drawables)
    • addLight

      public Light addLight(Coord3d position)
      Add a light at the given position, using the Light.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. See Light 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 colorForAll)
    • 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 the Light.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. See Light documentation for this, or change the light color or object color a bit.
    • addLightOnCamera

      public Light addLightOnCamera(Color colorForAll)
    • 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 colorForAll)
    • 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 Scene 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)
    • getColorbar

      public IColorbarLegend getColorbar()
      Return the first available colorbar in the view layout, or null if none was created
    • getLegends

      public List<ILegend> getLegends()