edu.uci.ics.jung.visualization.renderers.Renderer Maven / Gradle / Ivy
/*
* Copyright (c) 2003, The JUNG Authors
*
* All rights reserved.
*
* This software is open-source under the BSD license; see either
* "license.txt" or
* https://github.com/jrtom/jung/blob/master/LICENSE for a description.
*/
package edu.uci.ics.jung.visualization.renderers;
import edu.uci.ics.jung.visualization.RenderContext;
import edu.uci.ics.jung.visualization.VisualizationModel;
import edu.uci.ics.jung.visualization.spatial.Spatial;
import java.awt.Dimension;
/**
* The interface for drawing nodes, edges, and their labels. Implementations of this class can set
* specific renderers for each element, allowing custom control of each.
*/
public interface Renderer {
void render(
RenderContext rc,
VisualizationModel visualizationModel,
Spatial nodeSpatial,
Spatial edgeSpatial);
void render(RenderContext renderContext, VisualizationModel visualizationModel);
void renderNode(
RenderContext renderContext, VisualizationModel visualizationModel, N v);
void renderNodeLabel(
RenderContext renderContext, VisualizationModel visualizationModel, N v);
void renderEdge(
RenderContext renderContext, VisualizationModel visualizationModel, E e);
void renderEdgeLabel(
RenderContext renderContext, VisualizationModel visualizationModel, E e);
void setNodeRenderer(Node r);
void setEdgeRenderer(Renderer.Edge r);
void setNodeLabelRenderer(NodeLabel r);
void setEdgeLabelRenderer(Renderer.EdgeLabel r);
NodeLabel getNodeLabelRenderer();
Node getNodeRenderer();
Renderer.Edge getEdgeRenderer();
Renderer.EdgeLabel getEdgeLabelRenderer();
interface Node {
void paintNode(
RenderContext renderContext, VisualizationModel visualizationModel, N v);
@SuppressWarnings("rawtypes")
class NOOP implements Node {
public void paintNode(
RenderContext renderContext, VisualizationModel visualizationModel, N v) {}
};
}
interface Edge {
void paintEdge(
RenderContext renderContext, VisualizationModel visualizationModel, E e);
EdgeArrowRenderingSupport getEdgeArrowRenderingSupport();
void setEdgeArrowRenderingSupport(EdgeArrowRenderingSupport edgeArrowRenderingSupport);
@SuppressWarnings("rawtypes")
class NOOP implements Edge {
public void paintEdge(
RenderContext renderContext, VisualizationModel visualizationModel, E e) {}
public EdgeArrowRenderingSupport getEdgeArrowRenderingSupport() {
return null;
}
public void setEdgeArrowRenderingSupport(
EdgeArrowRenderingSupport edgeArrowRenderingSupport) {}
}
}
interface NodeLabel {
void labelNode(
RenderContext renderContext,
VisualizationModel visualizationModel,
N v,
String label);
Position getPosition();
void setPosition(Position position);
void setPositioner(Positioner positioner);
Positioner getPositioner();
@SuppressWarnings("rawtypes")
class NOOP implements NodeLabel {
public void labelNode(
RenderContext renderContext,
VisualizationModel visualizationModel,
N v,
String label) {}
public Position getPosition() {
return Position.CNTR;
}
public void setPosition(Position position) {}
public Positioner getPositioner() {
return new Positioner() {
public Position getPosition(float x, float y, Dimension d) {
return Position.CNTR;
}
};
}
public void setPositioner(Positioner positioner) {}
}
enum Position {
N,
NE,
E,
SE,
S,
SW,
W,
NW,
CNTR,
AUTO
}
interface Positioner {
Position getPosition(float x, float y, Dimension d);
}
}
interface EdgeLabel {
void labelEdge(
RenderContext renderContext,
VisualizationModel visualizationModel,
E e,
String label);
@SuppressWarnings("rawtypes")
class NOOP implements EdgeLabel {
public void labelEdge(
RenderContext renderContext,
VisualizationModel visualizationModel,
E e,
String label) {}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy