Poniżej opisana jest krok po kroku procedura tworzenia i dodawania do CASTa losowego algorytmu rozkładu.
private final static int AREA_WIDTH = 800; private final static int AREA_HEIGHT = 500; @Override protected void setNodesPositions(Collection<PositionedNode> positionNodes) { Random rand = new Random(new Date().getTime()); for (PositionedNode node : positionNodes) { // whole node must fit in rectangle [0,0] - [AREA_WIDTH,AREA_HEIGHT] // that's why we need to consider node's dimensions int x = rand.nextInt(AREA_WIDTH - node.getDimension().width); int y = rand.nextInt(AREA_HEIGHT - node.getDimension().height); node.setLocation(new Point(x, y)); } }
@Override protected ILayoutAlgorithm getAlgorithm() { return new RandomLayoutAlgorithm(); }
action.label.16 = Random
action.label.16 = Rozk\u0142ad losowy
(polskie znaki w plikach *.properties naleąy wpisywać przy użyciu Unicode escape codes... jest do tego dobre narzędzie (coś z nazwy podobnego do "resource editor"), ale nie pamiętam gdzie można je dostać)
<action class="pl.edu.agh.cast.schema.action.layout.SetRandomLayoutAction" icon="icons/pl/edu/agh/cast/icons/menu/diagram/x.gif" id="pl.edu.agh.cast.menu.diagram.randomlayout.action" label="%action.label.16" menubarPath="diagram/schema" style="push" toolbarPath="diagram/schema"/>
Efekt: