本文整理汇总了Java中edu.uci.ics.jung.algorithms.layout.AbstractLayout类的典型用法代码示例。如果您正苦于以下问题:Java AbstractLayout类的具体用法?Java AbstractLayout怎么用?Java AbstractLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractLayout类属于edu.uci.ics.jung.algorithms.layout包,在下文中一共展示了AbstractLayout类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startLink
import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
/**
* Called when the drawing of a new link/edge is started
*
* @param startVertex
*/
public void startLink(final VertexContext startVertex) {
if (startVertex == null) {
return;
}
final AbstractLayout<Object, JobGraphLink> graphLayout = _graphContext.getGraphLayout();
final int x = (int) graphLayout.getX(startVertex.getVertex());
final int y = (int) graphLayout.getY(startVertex.getVertex());
logger.debug("startLink({})", startVertex);
_startVertex = startVertex;
_startPoint = new Point(x, y);
transformEdgeShape(_startPoint, _startPoint);
_graphContext.getVisualizationViewer().addPostRenderPaintable(_edgePaintable);
transformArrowShape(_startPoint, _startPoint);
_graphContext.getVisualizationViewer().addPostRenderPaintable(_arrowPaintable);
}
示例2: getLayout
import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
private static AbstractLayout<Vertex, Edge> getLayout(GraphJung<Graph> graph, String layoutName) {
switch (layoutName) {
case "KKLayout":
return new KKLayout<>(graph);
case "CircleLayout":
return new CircleLayout<>(graph);
case "FRLayout":
return new FRLayout<>(graph);
case "FRLayout2":
return new FRLayout2<>(graph);
case "ISOMLayout":
return new ISOMLayout<>(graph);
case "SpringLayout":
return new SpringLayout<>(graph);
default:
return new KKLayout<>(graph);
}
}
示例3: writeTo
import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
@Override
public void writeTo(Graph data, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException {
Integer width = Integer.parseInt(Optional.ofNullable(request.getParameter("width")).orElse(DEFAULT_WIDTH));
Integer height = Integer.parseInt(Optional.ofNullable(request.getParameter("height")).orElse(DEFAULT_HEIGHT));
String layoutName = Optional.ofNullable(request.getParameter("layout")).orElse(DEFAULT_LAYOUT);
GraphJung<Graph> graph = new GraphJung<Graph>(data);
AbstractLayout<Vertex, Edge> layout = getLayout(graph, layoutName);
layout.setSize(new Dimension(width, height));
BasicVisualizationServer<Vertex, Edge> viz = new BasicVisualizationServer<>(layout);
viz.setPreferredSize(new Dimension(width, height));
viz.getRenderContext().setEdgeLabelTransformer(edgeLabelTransformer);
viz.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer);
viz.getRenderContext().setVertexFillPaintTransformer(vertexColorTransformer);
BufferedImage bi = renderImage(viz);
String imageType = null;
if (mediaType.equals(CustomMediaTypes.IMAGE_JPEG_TYPE)) {
imageType = "jpg";
} else if (mediaType.equals(CustomMediaTypes.IMAGE_PNG_TYPE)) {
imageType = "png";
}
ImageIO.write(bi, imageType, out);
}
示例4: getScaleFactor
import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
private float getScaleFactor(int imgWidth, int imgHeight) {
MutableTransformer layout2 = vv.getRenderContext()
.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
double top = Double.MAX_VALUE;
double bottom = Double.MAX_VALUE;
double left = Double.MAX_VALUE;
double right = Double.MAX_VALUE;
double maxSize = 0;
for (Vertex v : network.getVertices()) {
Point2D p;
if (layout instanceof AbstractLayout)
p = ((AbstractLayout<Vertex, Edge>) layout).transform(v);
else
p = ((TreeLayout<Vertex, Edge>) layout).transform(v);
Point2D invP = layout2.transform(p);
if (top < invP.getY() || top == Double.MAX_VALUE)
top = invP.getY();
if (bottom > invP.getY() || bottom == Double.MAX_VALUE)
bottom = invP.getY();
if (left > invP.getX() || left == Double.MAX_VALUE)
left = invP.getX();
if (right < invP.getX() || right == Double.MAX_VALUE)
right = invP.getX();
if (v.getSize() > maxSize)
maxSize = v.getSize();
}
double width = Math.abs(left - right);
double height = Math.abs(top - bottom);
if (width > height)
return (float) ((imgWidth - maxSize * 0.5) / width);
else
return (float) ((imgHeight - maxSize * 0.5) / height);
}
示例5: getGraphLayout
import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
public AbstractLayout<Object, JobGraphLink> getGraphLayout() {
Layout<Object, JobGraphLink> layout = getVisualizationViewer().getGraphLayout();
while (layout instanceof LayoutDecorator) {
layout = ((LayoutDecorator<Object, JobGraphLink>) layout).getDelegate();
}
return (AbstractLayout<Object, JobGraphLink>) layout;
}
示例6: centerGraph
import edu.uci.ics.jung.algorithms.layout.AbstractLayout; //导入依赖的package包/类
/**
* This method finds the location of the graph relative to the viewer and
* shifts is so that it appears in the center of JUNG's VisualizationViewer.
*/
public static Point2D centerGraph(VisualizationViewer<Vertex, Edge> vv, BrowsableNetwork network, Layout<Vertex, Edge> layout,
EditingModalGraphMouse<Vertex, Edge> mouse) {
MutableTransformer layout2 = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
double top = Double.MAX_VALUE;
double bottom = Double.MAX_VALUE;
double left = Double.MAX_VALUE;
double right = Double.MAX_VALUE;
for (Vertex v : network.getVertices()) {
Point2D p;
if (layout instanceof AbstractLayout)
p = ((AbstractLayout<Vertex, Edge>) layout).transform(v);
else
p = ((TreeLayout<Vertex, Edge>) layout).transform(v);
Point2D invP = layout2.transform(p);
if (top < invP.getY() || top == Double.MAX_VALUE)
top = invP.getY();
if (bottom > invP.getY() || bottom == Double.MAX_VALUE)
bottom = invP.getY();
if (left > invP.getX() || left == Double.MAX_VALUE)
left = invP.getX();
if (right < invP.getX() || right == Double.MAX_VALUE)
right = invP.getX();
}
if (mouse != null) {
double scale = 0;
do {
scale = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).getScale();
mouse.mouseWheelMoved(new MouseWheelEvent(vv, 0, 0, 0, vv.getWidth() / 2, vv.getHeight() / 2, 1, false, 1, -1, -1));
} while (scale >= 1);
}
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)
.setScale(1, 1, new Point((int) (vv.getCenter().getX() - (right + left) / 2), (int) (vv.getCenter().getY() - (top + bottom) / 2)));
double deltaX = vv.getCenter().getX() - (right + left) / 2;
double deltaY = vv.getCenter().getY() - (top + bottom) / 2;
if (!Double.isInfinite(deltaX) && !Double.isInfinite(deltaY) && !Double.isNaN(deltaX) && !Double.isNaN(deltaY)) {
layout2.translate(deltaX, deltaY);
}
return vv.getCenter();
}