本文整理了Java中edu.uci.ics.jung.algorithms.layout.Layout.transform()
方法的一些代码示例,展示了Layout.transform()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Layout.transform()
方法的具体详情如下:
包路径:edu.uci.ics.jung.algorithms.layout.Layout
类名称:Layout
方法名:transform
暂无
代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2
/**
* @see edu.uci.ics.jung.algorithms.layout.Layout#transform(Object)
*/
public Point2D transform(V v) {
return delegate.transform(v);
}
代码示例来源:origin: griddynamics/jagger
@Override
public Point2D transform(V v) {
Point2D point = delegate.transform(v);
return new Point.Double(point.getX() + xOffset, point.getY() + yOffset);
}
};
代码示例来源:origin: com.github.fburato/highwheel-core
private void shift(final Layout<ElementName, Dependency> l, final int dx,
final int dy) {
for (final ElementName each : l.getGraph().getVertices()) {
final Point2D point = l.transform(each);
point.setLocation(point.getX() + dx, point.getY() + dy);
}
}
}
代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2-experimental
private void copyOldLayout() {
for (ONDEXConcept node : graph.getVertices()) {
Point2D coord = oldLayouter.transform(node);
Point2D coordNew = transform(node);
coordNew.setLocation(coord.getX(), coord.getY());
}
}
代码示例来源:origin: org.pitest/highwheel-core
private void shift(final Layout<ElementName, Dependency> l, final int dx,
final int dy) {
for (final ElementName each : l.getGraph().getVertices()) {
final Point2D point = l.transform(each);
point.setLocation(point.getX() + dx, point.getY() + dy);
}
}
}
代码示例来源:origin: hcoles/highwheel
private void shift(final Layout<ElementName, Dependency> l, final int dx,
final int dy) {
for (final ElementName each : l.getGraph().getVertices()) {
final Point2D point = l.transform(each);
point.setLocation(point.getX() + dx, point.getY() + dy);
}
}
}
代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2
/**
* Returns the location of the vertex. The location is specified first
* by the sublayouts, and then by the base layout if no sublayouts operate
* on this vertex.
* @return the location of the vertex
* @see org.apache.commons.collections15.Transformer#transform(java.lang.Object)
*/
public Point2D transform(V v) {
boolean wasInSublayout = false;
for(Layout<V,E> layout : layouts.keySet()) {
if(layout.getGraph().getVertices().contains(v)) {
wasInSublayout = true;
Point2D center = layouts.get(layout);
// transform by the layout itself, but offset to the
// center of the sublayout
Dimension d = layout.getSize();
AffineTransform at =
AffineTransform.getTranslateInstance(center.getX()-d.width/2,
center.getY()-d.height/2);
return at.transform(layout.transform(v),null);
}
}
if(wasInSublayout == false) {
return delegate.transform(v);
}
return null;
}
代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2
/**
* Calculates the bounds of all nodes in a given viewer.
*
* @return Point2D[] min bounds, max bounds
*/
private Point2D[] calcBounds() {
Point2D[] result = new Point2D[2];
Point2D min = null;
Point2D max = null;
Layout<ONDEXConcept, ONDEXRelation> layout = viewer.getVisualizationViewer().getGraphLayout();
Iterator<ONDEXConcept> it = layout.getGraph().getVertices().iterator();
while (it.hasNext()) {
Point2D point = layout.transform(it.next());
if (min == null) {
min = new Point2D.Double(0, 0);
min.setLocation(point);
}
if (max == null) {
max = new Point2D.Double(0, 0);
max.setLocation(point);
}
min.setLocation(Math.min(min.getX(), point.getX()), Math.min(min.getY(), point.getY()));
max.setLocation(Math.max(max.getX(), point.getX()), Math.max(max.getY(), point.getY()));
}
result[0] = min;
result[1] = max;
return result;
}
代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2
public Collection<V> getVertices(Layout<V,E> layout, Shape rectangle) {
Set<V> pickedVertices = new HashSet<V>();
while(true) {
try {
for(V v : layout.getGraph().getVertices()) {
Point2D p = layout.transform(v);
if(rectangle.contains(p)) {
pickedVertices.add(v);
}
}
break;
} catch(ConcurrentModificationException cme) {}
}
return pickedVertices;
}
代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2
/**
* Gets the vertex nearest to the location of the (x,y) location selected,
* within a distance of <tt>maxDistance</tt>. Iterates through all
* visible vertices and checks their distance from the click. Override this
* method to provde a more efficient implementation.
* @param x
* @param y
* @param maxDistance temporarily overrides member maxDistance
*/
public V getVertex(Layout<V,E> layout, double x, double y, double maxDistance) {
double minDistance = maxDistance * maxDistance;
V closest = null;
while(true) {
try {
for(V v : layout.getGraph().getVertices()) {
Point2D p = layout.transform(v);
double dx = p.getX() - x;
double dy = p.getY() - y;
double dist = dx * dx + dy * dy;
if (dist < minDistance) {
minDistance = dist;
closest = v;
}
}
break;
} catch(ConcurrentModificationException cme) {}
}
return closest;
}
代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2-experimental
double min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY;
for (ONDEXConcept node : nodes) {
Point2D coord = oldLayouter.transform(node);
if (coord.getY() < min)
min = coord.getY();
rest.removeAll(nodes);
for (ONDEXConcept node : rest) {
Point2D coord = oldLayouter.transform(node);
double y = coord.getY();
double x = coord.getX();
Point2D coord = oldLayouter.transform(node);
double y = coord.getY();
double x = coord.getX();
代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer
Point2D tp = (Point2D)transitionLayout.transform(v);
Point2D fp = (Point2D)endLayout.transform(v);
double dx = (fp.getX() - tp.getX()) / (count - counter);
double dy = (fp.getY() - tp.getY()) / (count - counter);
代码示例来源:origin: iTransformers/netTransformer
public void Animator(String vertex) {
Layout<String, String> layout = vv.getGraphLayout();
Point2D q = layout.transform(vertex);
Point2D lvc = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
final double dx = (lvc.getX() - q.getX()) / 10;
final double dy = (lvc.getY() - q.getY()) / 10;
Runnable animator = new Runnable() {
public void run() {
for (int i = 0; i < 10; i++) {
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(dx, dy);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
}
}
}
};
Thread thread = new Thread(animator);
thread.start();
}
代码示例来源:origin: iTransformers/netTransformer
public void EdgeAnimator(Pair edge) {
Layout<String, String> layout = vv.getGraphLayout();
String first = (String) edge.getFirst();
String second = (String) edge.getSecond();
Point2D q = layout.transform(first);
Point2D y = layout.transform(second);
Line2D line = new Line2D.Double(q.getX(), q.getY(), y.getX(), y.getY());
Point2D lvc = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
final double dx = (lvc.getX() - line.getBounds().getCenterX()) / 10;
final double dy = (lvc.getY() - line.getBounds().getCenterY()) / 10;
Runnable edgeAnimator = new Runnable() {
public void run() {
for (int i = 0; i < 10; i++) {
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(dx, dy);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
}
}
}
};
Thread thread = new Thread(edgeAnimator);
thread.start();
}
代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2-default
/**
* Writes y:Geometry tag with node positions.
*
* @param vertex
* V
* @param xmlw
* XMLStreamWriter2
* @throws XMLStreamException
*/
private void writeGeometry(ONDEXConcept vertex, XMLStreamWriter2 xmlw)
throws XMLStreamException {
// get coordinates of node
Point2D coords = viewer.getGraphLayout().transform(vertex);
// get shape of node
Shape shape = viewer.getRenderContext().getVertexShapeTransformer()
.transform(vertex);
Rectangle bounds = shape.getBounds();
xmlw.writeStartElement("y:Geometry");
xmlw.writeAttribute("x", String.valueOf(coords.getX()));
xmlw.writeAttribute("y", String.valueOf(coords.getY()));
xmlw.writeAttribute("width", String.valueOf(bounds.getWidth()));
xmlw.writeAttribute("height", String.valueOf(bounds.getHeight()));
xmlw.writeEndElement();
}
代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2-default
Point2D source = viewer.getGraphLayout().transform(
graph.getSource(edge));
Point2D dest = viewer.getGraphLayout().transform(graph.getDest(edge));
xmlw.writeStartElement("y:Point");
xmlw.writeAttribute("x", String.valueOf(source.getX()));
代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2
@Override
protected void paintIconForVertex(RenderContext<ONDEXConcept, ONDEXRelation> rc, ONDEXConcept v, Layout<ONDEXConcept, ONDEXRelation> layout) {
super.paintIconForVertex(rc, v, layout);
// check for flagged drawing
boolean flagged = false;
AttributeName anFlag = graph.getMetaData().getAttributeName(AppearanceSynchronizer.FLAGGED);
if (anFlag != null && v.getAttribute(anFlag) != null) {
flagged = (Boolean) v.getAttribute(anFlag).getValue();
}
// draw arrow / flag
if (flagged) {
boolean vertexHit = true;
// get the shape to be rendered
Shape shape = createArrow();
Point2D p = layout.transform(v);
p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
float x = (float) p.getX();
float y = (float) p.getY();
// create a transform that translates to the location of
// the vertex to be rendered
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
// transform the vertex shape with xtransform
shape = xform.createTransformedShape(shape);
vertexHit = vertexHit(rc, shape);
// rc.getViewTransformer().transform(shape).intersects(deviceRectangle);
if (vertexHit) {
paintShapeForVertex(rc, v, shape);
}
}
}
代码示例来源:origin: com.github.fburato/highwheel-core
public void labelVertex(final RenderContext<ElementName, Dependency> rc,
final Layout<ElementName, Dependency> layout, final ElementName v,
final String label) {
final Graph<ElementName, Dependency> graph = layout.getGraph();
if (rc.getVertexIncludePredicate().evaluate(
Context.<Graph<ElementName, Dependency>, ElementName> getInstance(
graph, v)) == false) {
return;
}
final GraphicsDecorator g = rc.getGraphicsContext();
final Component component = prepareRenderer(rc,
rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
final Dimension d = component.getPreferredSize();
final int h_offset = -d.width / 2;
final int v_offset = -d.height / 2;
Point2D p = layout.transform(v);
p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
final int x = (int) p.getX();
final int y = (int) p.getY();
g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset,
d.width, d.height, true);
}
代码示例来源:origin: org.pitest/highwheel-core
public void labelVertex(final RenderContext<ElementName, Dependency> rc,
final Layout<ElementName, Dependency> layout, final ElementName v,
final String label) {
final Graph<ElementName, Dependency> graph = layout.getGraph();
if (rc.getVertexIncludePredicate().evaluate(
Context.<Graph<ElementName, Dependency>, ElementName> getInstance(
graph, v)) == false) {
return;
}
final GraphicsDecorator g = rc.getGraphicsContext();
final Component component = prepareRenderer(rc,
rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
final Dimension d = component.getPreferredSize();
final int h_offset = -d.width / 2;
final int v_offset = -d.height / 2;
Point2D p = layout.transform(v);
p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
final int x = (int) p.getX();
final int y = (int) p.getY();
g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset,
d.width, d.height, true);
}
代码示例来源:origin: hcoles/highwheel
public void labelVertex(final RenderContext<ElementName, Dependency> rc,
final Layout<ElementName, Dependency> layout, final ElementName v,
final String label) {
final Graph<ElementName, Dependency> graph = layout.getGraph();
if (rc.getVertexIncludePredicate().evaluate(
Context.<Graph<ElementName, Dependency>, ElementName> getInstance(
graph, v)) == false) {
return;
}
final GraphicsDecorator g = rc.getGraphicsContext();
final Component component = prepareRenderer(rc,
rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
final Dimension d = component.getPreferredSize();
final int h_offset = -d.width / 2;
final int v_offset = -d.height / 2;
Point2D p = layout.transform(v);
p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
final int x = (int) p.getX();
final int y = (int) p.getY();
g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset,
d.width, d.height, true);
}
内容来源于网络,如有侵权,请联系作者删除!