本文整理汇总了Java中edu.uci.ics.jung.visualization.control.LayoutScalingControl类的典型用法代码示例。如果您正苦于以下问题:Java LayoutScalingControl类的具体用法?Java LayoutScalingControl怎么用?Java LayoutScalingControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LayoutScalingControl类属于edu.uci.ics.jung.visualization.control包,在下文中一共展示了LayoutScalingControl类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DerivationViewer
import edu.uci.ics.jung.visualization.control.LayoutScalingControl; //导入依赖的package包/类
public DerivationViewer(DerivationTree g, Dimension d, Color targetColor, AnchorType anchor) {
super(new CircleLayout<>(g));
anchorStyle = anchor;
DerivationTreeTransformer dtt = new DerivationTreeTransformer(g, d, false);
StaticLayout<Node, DerivationTreeEdge> derivationLayout = new StaticLayout<>(g, dtt);
// derivationLayout.setSize(dtt.getSize());
setGraphLayout(derivationLayout);
scaleToLayout(new LayoutScalingControl());
// g.addCorrespondences();
setPreferredSize(new Dimension(DEFAULT_HEIGHT, DEFAULT_WIDTH));
getRenderContext().setVertexLabelTransformer(new ToStringLabeller<>());
DefaultModalGraphMouse<Node, DerivationTreeEdge> graphMouse = new DefaultModalGraphMouse<>();
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
setGraphMouse(graphMouse);
addKeyListener(graphMouse.getModeKeyListener());
// this.setPickedVertexState(new DerivationTreePickedState(g));
getRenderContext().setVertexFillPaintTransformer(vp);
getRenderContext().setEdgeStrokeTransformer(es);
getRenderContext().setVertexShapeTransformer(ns);
getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
TGT = targetColor;
anchorPoint = dtt.getAnchorPosition(anchorStyle);
}
示例2: mouseWheelMoved
import edu.uci.ics.jung.visualization.control.LayoutScalingControl; //导入依赖的package包/类
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getWheelRotation() == 0) {
return;
}
VisualizationViewer<?, ?> vv = (VisualizationViewer<?, ?>) e.getSource();
new LayoutScalingControl().scale(vv, e.getWheelRotation() > 0 ? in : out, e.getPoint());
vv.repaint();
if (lastTask != null) {
lastTask.cancel(false);
}
lastTask = scheduler.schedule(
() -> Stream.of(listeners.getListeners(JungListener.class)).forEach(l -> l.transformFinished()), 200,
TimeUnit.MILLISECONDS);
}
示例3: fillVV
import edu.uci.ics.jung.visualization.control.LayoutScalingControl; //导入依赖的package包/类
/**
* scale visualisation to fill full visualization viewer space
*
* @author amusial
*/
protected void fillVV() {
// scale
// if layout was scaled, scale it to it original size
if (vv.getRenderContext().getMultiLayerTransformer()
.getTransformer(Layer.LAYOUT).getScaleX() > 1D) {
(new LayoutScalingControl()).scale(vv, (1f / (float) vv
.getRenderContext().getMultiLayerTransformer()
.getTransformer(Layer.LAYOUT).getScaleX()),
new Point2D.Double());
}
// get view bounds
Dimension vd = vv.getPreferredSize();
if (vv.isShowing()) {
vd = vv.getSize();
}
// get visualisation layout size
Dimension ld = vv.getGraphLayout().getSize();
// finally scale it if view bounds are different than visualisation layer bounds
if (vd.equals(ld) == false) {
float heightRatio = (float) (vd.getWidth() / ld.getWidth());
float widthRatio = (float) (vd
.getHeight() / ld.getHeight());
scaler.scale(vv, (heightRatio < widthRatio ? heightRatio
: widthRatio), new Point2D.Double());
}
}
示例4: refreshViewUI
import edu.uci.ics.jung.visualization.control.LayoutScalingControl; //导入依赖的package包/类
/**
* refresh satellite view
* <p>
* TODO: do it better than recreating satellite, probably wont fix TODO:
* visualisation should be centered in the view, centered at the center of the view
* not at the root or selected node, probably done, need testing TODO: visualisation
* should be resized to fill full size of view, something is wrong when
* visualisation scale is >1, fixed by double scaling
*/
public void refreshViewUI() {
// System.out.println("refresh satellite view UI");
// remove old satellite panel
rootPanel.removeAll();
// to get dimension of parent
rootPanel.repaint();
// refresh satellite
refreshSatellite();
// scale
// if layout was scaled, scale it to it original size
if (vv.getRenderContext().getMultiLayerTransformer().getTransformer(
Layer.LAYOUT).getScaleX() > 1D) {
(new LayoutScalingControl()).scale(satellite,
(1f / (float) satellite.getRenderContext()
.getMultiLayerTransformer().getTransformer(
Layer.LAYOUT).getScaleX()),
new Point2D.Double());
}
// get view bounds
Dimension vd = satellite.getPreferredSize();
if (satellite.isShowing()) {
vd = satellite.getSize();
}
// get visualisation layout size
Dimension ld = satellite.getGraphLayout().getSize();
// finally scale it if view bounds are different than visualisation layer bounds
if (vd.equals(ld) == false) {
float heightRatio = (float) (vd.getWidth() / ld.getWidth()), widthRatio = (float) (vd
.getHeight() / ld.getHeight());
satelliteScaler.scale(satellite,
(heightRatio < widthRatio ? heightRatio : widthRatio),
new Point2D.Double());
}
// center
Point2D q = new Point2D.Double(satellite.getGraphLayout().getSize()
.getWidth() / 2, satellite.getGraphLayout().getSize()
.getHeight() / 2);
Point2D lvc = satellite.getRenderContext().getMultiLayerTransformer()
.inverseTransform(satellite.getCenter());
// vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).translate(lvc.getX()
// - q.getX(), lvc.getY() - q.getY());
satellite.getRenderContext().getMultiLayerTransformer().getTransformer(
Layer.LAYOUT).translate(lvc.getX() - q.getX(),
lvc.getY() - q.getY());
// Create and add a panel for visualisation visualization.
rootPanel.add(getSatelliteGraphViewer(), "hfill vfill");
// force repaint of the view
rootPanel.getParent().repaint();
}
示例5: visualize
import edu.uci.ics.jung.visualization.control.LayoutScalingControl; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void visualize(JungNetwork graph, String title, int type)
{
// The Layout<V, E> is parameterized by the vertex and edge types
Layout<JungVertex, JungEdge> layout = null;
switch (type)
{
case CIRCLE:
layout = new CircleLayout<JungVertex, JungEdge>(graph);
break;
case SPRING:
layout = new SpringLayout<JungVertex, JungEdge>(graph);
break;
case FR:
layout = new FRLayout<JungVertex, JungEdge>(graph);
break;
case ISOM:
layout = new ISOMLayout<JungVertex, JungEdge>(graph);
break;
case DAG:
layout = new DAGLayout<JungVertex, JungEdge>(graph);
break;
case SPRING2:
layout = new SpringLayout2<JungVertex, JungEdge>(graph);
break;
default:
layout = new KKLayout<JungVertex, JungEdge>(graph);
}
layout.setSize(new Dimension(800,800)); // sets the initial size of the space
// The BasicVisualizationServer<V,E> is parameterized by the edge types
BasicVisualizationServer<JungVertex,JungEdge> vv =
new BasicVisualizationServer<JungVertex,JungEdge>(layout);
vv.setPreferredSize(new Dimension(900,900)); //Sets the viewing area size
vv.scaleToLayout(new LayoutScalingControl() );
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
frame.pack();
frame.setVisible(true);
}
示例6: ZoomPanGraphMouse
import edu.uci.ics.jung.visualization.control.LayoutScalingControl; //导入依赖的package包/类
public ZoomPanGraphMouse(float in, float out) {
translatingPlugin = new TranslatingGraphMousePlugin();
scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0, in, out);
add(translatingPlugin);
add(scalingPlugin);
}