Package org.gephi.preview.spi
Interfaces for creating new renderers, item builders and render targets.
Create a new Item Builder
-
Create a new module and set
Preview API,Graph API,AttributesAPIandLookupas dependencies. -
Create a new item class which implements
Itemor extendsAbstractItem. TheAbstractItemclass is located in thePreviewPluginmodule so add it as dependency first. An item should be very simple but has a unique identifier returned by itsgetType()method. -
Create a new builder class that implements
ItemBuilder -
Implement the
getType()method and returns the same identifier than theItemyou created earlier. -
Implement the
getItems()method by retrieving objects from the given graph. -
Add @ServiceProvider annotation to your builder, that it can
be found by the system. Set
ItemBuilderas the annotation parameter.
Create a new Renderer
-
Create a new module and set
Preview API,GraphAPI,Processing Wrapper,iText WrapperandLookupas dependencies. -
Create a new class that implements
Renderer. - Implement the renderer methods.
-
Add @ServiceProvider annotation to your builder, that it can
be found by the system. Set
Rendereras the annotation parameter.
Add data to an existing item
To add an additional data attribute to a Node or Edge item, you need to create
a new item builder for the specific type. For instance if one want to add
a new attribute to nodes create a new ItemBuilder for the
type Item.Node. Simply return item objects with the data you
want to add. The system will automatically merge your new data to node items.
Extend or replace an existing renderer
To extend or completely replace a default Renderer by your own implementation, create a new Renderer and set the annotation like below. In addition add Preview Plugin module as a dependency.
@ServiceProvider(service=Renderer.class, position=XXX)
public class MyRenderer extends NodeRenderer
Being XXX the new position of the renderer Then you can reuse parts of the base class or just override them.
Default renderers are:
- org.gephi.preview.plugin.renderers.NodeRenderer
- org.gephi.preview.plugin.renderers.EdgeRenderer
- org.gephi.preview.plugin.renderers.NodeLabelRenderer
- org.gephi.preview.plugin.renderers.EdgeLabelRenderer
- org.gephi.preview.plugin.renderers.ArrowRenderer
Add a new PreviewUI settings panel
Plug-ins can add UI components to the Preview Settings module. Additional components are placed in new tabs and have access to the
current PreviewModel and therefore PreviewProperties.
-
Create a new module and set
Preview APIandLookupas dependencies. -
Create a new class that implements
PreviewUIand implements methods. -
Add @ServiceProvider annotation to your builder, that it can
be found by the system. Set
PreviewUIas the 'service' annotation parameter.
-
Interface Summary Interface Description ItemBuilder Builds and returns newIteminstances.MouseResponsiveRenderer Optionally implement this interface in aRendererthat needs to be responsive to mouse events.PreviewMouseListener Listener for mouse events in Preview.PreviewUI SPI interface to add UI settings components to the Preview.Renderer Renderer describes how a particularItemobject is rendered on a particularRenderTargetinstance.RenderTargetBuilder Builds and returns newRenderTargetinstances.