admin 管理员组

文章数量: 887007

java设置窗口自由缩放,java

我在JPanel中显示了一个钟形树.我的树的构造函数如下所示:

Forest graph = new DelegateForest();

static GraphZoomScrollPane panel = null;

static DefaultModalGraphMouse graphMouse = null;

static JComboBox modeBox = null;

static ScalingControl scaler;

public PanelTree(List clist) {

setBounds(215, 10, 550, 550);

updateData(clist); // adds vertex and edges to graph

treeLayout = new TreeLayout(graph);

vv = new VisualizationViewer(treeLayout, new Dimension(500, 500));

vv.setBackground(Color.white);

vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

// add a listener for ToolTips

vv.setVertexToolTipTransformer(new ToStringLabeller());

vv.getRenderContext()

.setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));

panel = new GraphZoomScrollPane(vv);

add(panel);

graphMouse = new DefaultModalGraphMouse();

vv.setGraphMouse(graphMouse);

modeBox = graphMouse.getModeComboBox();

modeBox.addItemListener(graphMouse.getModeListener());

graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

scaler = new CrossoverScalingControl();

}

但是树很大.因此,我想知道是否有一种方法可以自动缩小以使树适合窗口,否则可以设置一个默认缩放,该默认缩放小于默认缩放.我怎样才能做到这一点 ?

本文标签: java设置窗口自由缩放 java