org.jungrapht.visualization.layout.algorithms.sugiyama.VertexMetadata Maven / Gradle / Ivy
The newest version!
package org.jungrapht.visualization.layout.algorithms.sugiyama;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** Holds the metadata for LVI vertices as an alternative to copying them */
public class VertexMetadata {
Logger log = LoggerFactory.getLogger(VertexMetadata.class);
protected int rank; // the layer number for this vertex
protected int index; // the index within the layer array for this vertex
protected int pos = -1;
protected double measure = -1; // the median of the positions of the neighbors of this LV
/**
* store the metadata for the supplied vertex
*
* @param vertex
* @param
* @return
*/
public static VertexMetadata of(LV vertex) {
return new VertexMetadata<>(vertex);
}
/**
* apply the saved metadata to the supplied vertex
*
* @param v
*/
public void applyTo(LV v) {
v.setRank(this.rank);
v.setIndex(this.index);
v.setPos(this.pos);
v.setMeasure(this.measure);
}
VertexMetadata(LV vertex) {
this.rank = vertex.getRank();
this.index = vertex.getIndex();
this.pos = vertex.getPos();
this.measure = vertex.getMeasure();
}
@Override
public String toString() {
return "VertexMetadata{"
+ "rank="
+ rank
+ ", index="
+ index
+ ", pos="
+ pos
+ ", measure="
+ measure
+ '}';
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy