Interface PreviewController


  • public interface PreviewController
    Controller that maintain the preview models, one per workspace.

    This controller is a service and can therefore be found in Lookup:

    PreviewController gc = Lookup.getDefault().lookup(PreviewController.class);
    Author:
    Yudi Xue, Mathieu Bastian
    See Also:
    PreviewModel, Item, Renderer
    • Method Detail

      • refreshPreview

        void refreshPreview​(Workspace workspace)
        Refreshes the preview model in workspace.

        This task built all items from ItemBuilder implementations, refresh graph dimensions and call all Renderer.preProcess() method.

        Parameters:
        workspace - the workspace to get the preview model from
      • refreshPreview

        void refreshPreview()
        Refreshes the current preview model.

        This task built all items from ItemBuilder implementations, refresh graph dimensions and call all Renderer.preProcess() method.

      • getModel

        PreviewModel getModel()
        Returns the current preview model in the current workspace.
        Returns:
        the current preview model
      • getModel

        PreviewModel getModel​(Workspace workspace)
        Returns the preview model in workspace.
        Parameters:
        workspace - the workspace to lookup
        Returns:
        the preview model in workspace
      • render

        void render​(RenderTarget target)
        Renders the current preview model to target.

        If preview model managedRenderers is null, this task looks for all Renderer implementations in their default order. Then all items in the preview model are rendered.

        Parameters:
        target - the target to render items to
      • render

        void render​(RenderTarget target,
                    Workspace workspace)
        Renders the preview model in workspace to target.

        If preview model managedRenderers is null, this task looks for all Renderer implementations in their default order. Then all items in the preview model are rendered.

        Parameters:
        target - the target to render items to
        workspace - the workspace to get the preview model from
      • render

        void render​(RenderTarget target,
                    Renderer[] renderers)
        Renders the current preview model to target.

        This task overrides the preview model managedRenderers and uses the given Renderer array, respecting the array order. Then all items in the preview model are rendered.

        Parameters:
        target - the target to render items to
        renderers - renderers to use
      • render

        void render​(RenderTarget target,
                    Renderer[] renderers,
                    Workspace workspace)
        Renders the preview model in workspace to target.

        This task overrides the preview model managedRenderers and uses the given Renderer array, respecting the array order. Then all items in the preview model are rendered.

        Parameters:
        target - the target to render items to
        renderers - renderers to use
        workspace - the workspace to get the preview model from
      • getRenderTarget

        RenderTarget getRenderTarget​(String name)
        Creates a new render target of the given type.

        Default render targets names are RenderTarget.G2D_TARGET, RenderTarget.SVG_TARGET and RenderTarget.PDF_TARGET.

        Render targets usually need some parameters when built. Parameters values should simply be put in the PreviewProperties.

        Parameters:
        name - the name of the render target
        Returns:
        a new render target or null if name is unknown
      • getRenderTarget

        RenderTarget getRenderTarget​(String name,
                                     Workspace workspace)
        Creates a new render target of the given type in the preview model contained by workspace.

        Default render targets names are RenderTarget.G2D_TARGET, RenderTarget.SVG_TARGET and RenderTarget.PDF_TARGET.

        Render targets usually need some parameters when built. Parameters values should simply be put in the PreviewProperties.

        Parameters:
        name - the name of the render target
        workspace - the workspace to get the preview model from
        Returns:
        a new render target or null if name is unknown
      • getRegisteredRenderers

        Renderer[] getRegisteredRenderers()
        Uses Lookup to retrieve registered renderer providers but replaces default renderers with plugins that extend them.
        Returns:
        Registered renderers replacing default renderers with their extension plugins in case they exist
        See Also:
        Renderer
      • isAnyPluginRendererRegistered

        boolean isAnyPluginRendererRegistered()
        Returns true if any renderer plugin is registered.
        Returns:
        True if any plugin renderer is found in the system
      • sendMouseEvent

        boolean sendMouseEvent​(PreviewMouseEvent event)
        Sends a PreviewMouseEvent to the current workspace, if any.
        Parameters:
        event - PreviewMouseEvent
        Returns:
        True if the event was consumed, false otherwise
      • sendMouseEvent

        boolean sendMouseEvent​(PreviewMouseEvent event,
                               Workspace workspace)
        Sends a PreviewMouseEvent to the given workspace.
        Parameters:
        event - PreviewMouseEvent
        workspace - workspace
        Returns:
        True if the event was consumed, false otherwise