本文整理匯總了Java中edu.uci.ics.jung.algorithms.layout.Layout.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Layout.getSize方法的具體用法?Java Layout.getSize怎麽用?Java Layout.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.uci.ics.jung.algorithms.layout.Layout
的用法示例。
在下文中一共展示了Layout.getSize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeGraph
import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
* Writes a graph as a PNG image.
* @param outputFile the output file
* @param selectedComponent the component to highlight
* @param layout the layout
* @param graph the graph
* @param edgeShapeTransformer the transformer for edge shapes (straight line, curved line, etc)
* @throws IOException if something went wrong
*/
public static void writeGraph(
File outputFile,
Component selectedComponent,
Layout<AbstractType,String> layout,
Graph<AbstractType,String> graph ,
AbstractEdgeShapeTransformer<AbstractType,String> edgeShapeTransformer,
Map<String,String> options )
throws IOException {
VisualizationImageServer<AbstractType,String> vis =
new VisualizationImageServer<AbstractType,String>( layout, layout.getSize());
vis.setBackground( Color.WHITE );
vis.getRenderContext().setEdgeLabelTransformer( new NoStringLabeller ());
vis.getRenderContext().setEdgeShapeTransformer( edgeShapeTransformer );
vis.getRenderContext().setVertexLabelTransformer( new ToStringLabeller<AbstractType> ());
vis.getRenderContext().setVertexShapeTransformer( new VertexShape());
vis.getRenderContext().setVertexFontTransformer( new VertexFont());
Color defaultBgColor = decode( options.get( DocConstants.OPTION_IMG_BACKGROUND_COLOR ), DocConstants.DEFAULT_BACKGROUND_COLOR );
Color highlightBgcolor = decode( options.get( DocConstants.OPTION_IMG_HIGHLIGHT_BG_COLOR ), DocConstants.DEFAULT_HIGHLIGHT_BG_COLOR );
vis.getRenderContext().setVertexFillPaintTransformer( new VertexColor( selectedComponent, defaultBgColor, highlightBgcolor ));
Color defaultFgColor = decode( options.get( DocConstants.OPTION_IMG_FOREGROUND_COLOR ), DocConstants.DEFAULT_FOREGROUND_COLOR );
vis.getRenderContext().setVertexLabelRenderer( new MyVertexLabelRenderer( selectedComponent, defaultFgColor ));
vis.getRenderer().getVertexLabelRenderer().setPosition( Position.CNTR );
BufferedImage image = (BufferedImage) vis.getImage(
new Point2D.Double(
layout.getSize().getWidth() / 2,
layout.getSize().getHeight() / 2),
new Dimension( layout.getSize()));
ImageIO.write( image, "png", outputFile );
}
示例2: setLtoR
import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
private void setLtoR(VisualizationViewer<String,Integer> vv) {
Layout<String,Integer> layout = vv.getModel().getGraphLayout();
Dimension d = layout.getSize();
Point2D center = new Point2D.Double(d.width/2, d.height/2);
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).rotate(-Math.PI/2, center);
}