public ShrimpGridLayout( DisplayBean displayBean, Comparator comparator, String name, GridLayoutAlgorithm gridAlgorithm) { super(displayBean, name, gridAlgorithm); this.comparator = comparator; gridAlgorithm.setComparator(comparator); }
/* * (non-Javadoc) * @see ca.uvic.csr.shrimp.DisplayBean.layout.Layout#applyLayout(java.util.Vector, java.awt.geom.Rectangle2D.Double, java.util.Vector, boolean, * boolean) */ public void setupAndApplyLayout( Vector nodes, Rectangle2D.Double bounds, Vector nodesToExclude, boolean showDialog, boolean animate, boolean separateComponents) { Vector nodesToInclude = new Vector(nodes.size()); // Vector addedArcs = new Vector(); for (Iterator iter = nodes.iterator(); iter.hasNext(); ) { ShrimpNode node = (ShrimpNode) iter.next(); if (displayBean.isVisible(node)) { nodesToInclude.add(node); } else { if (!nodesToExclude.contains(node)) { nodesToExclude.add(node); } } } // if we are comparing by attribute, ask the user to choose an attribute if (comparator instanceof NodeAttributeComparator && showDialog) { // find a frame to "own" dialog ChooseAttributeDialog cad = new ChooseAttributeDialog(nodesToInclude); if (cad.isAccepted()) { String selectedAttribute = cad.getSelectedAttribute(); if (selectedAttribute == null) { selectedAttribute = ""; } ((NodeAttributeComparator) comparator).setAttribute(selectedAttribute); for (Iterator iter = ((Vector) nodesToInclude.clone()).iterator(); iter.hasNext(); ) { ShrimpNode node = (ShrimpNode) iter.next(); if (node.getArtifact().getAttribute(selectedAttribute) == null) { nodesToInclude.remove(node); nodesToExclude.add(node); } } } else { return; } } if (nodesToInclude.isEmpty() && nodesToExclude.isEmpty()) { return; } displayBean.getStructuralGroupingManager().handleNodeGrouping(nodes); layoutAlgorithm.setEntityAspectRatio( ((Dimension) displayBean.getCanvasDimension()).getWidth() / ((Dimension) displayBean.getCanvasDimension()).getHeight()); if (displayBean.getSwitchLabelling() && nodesToInclude.size() >= displayBean.getSwitchAtNum()) { displayBean.setLabelMode(nodesToInclude, DisplayConstants.LABEL_MODE_SCALE_BY_NODE_SIZE); } else { displayBean.setLabelMode(nodesToInclude, displayBean.getDefaultLabelMode()); boolean atLeastOneInFixedSizeMode = false; for (Iterator iter = nodesToInclude.iterator(); iter.hasNext() && !atLeastOneInFixedSizeMode; ) { ShrimpNode node = (ShrimpNode) iter.next(); String labelMode = displayBean.getLabelMode(node); atLeastOneInFixedSizeMode = labelMode.equals(DisplayConstants.LABEL_MODE_FIXED) || labelMode.equals(DisplayConstants.LABEL_MODE_SCALE_BY_LEVEL); } if (atLeastOneInFixedSizeMode) { Font font = (Font) displayBean.getLabelFont(); ((GridLayoutAlgorithm) layoutAlgorithm) .setRowPadding(displayBean.getFontHeightOnCanvas(font)); } else { ((GridLayoutAlgorithm) layoutAlgorithm).setRowPadding(0); } } positionIncludedAndExcludedNodes(nodesToInclude, new Vector(), nodesToExclude, bounds, animate); }