001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo;
021:
022: import java.util.logging.Logger;
023:
024: import com.nwoods.jgo.JGoView;
025: import org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.autolayout.TreeLayout;
026: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.IMapperCanvasView;
027: import org.netbeans.modules.soa.mapper.common.IMapperAutoLayout;
028: import org.netbeans.modules.soa.mapper.common.IMapperView;
029:
030: /**
031: * <p>
032: *
033: * Title: </p> BasicCanvasAutoLayout<p>
034: *
035: * Description: </p> BasicCanvasAutoLayout using JGoLayeredDigraphAutoLayout
036: * object to perform the default canvas layout function.<p>
037: *
038: * @author Un Seng Leong
039: * @created January 2, 2003
040: */
041: public class BasicCanvasAutoLayout implements IMapperAutoLayout {
042:
043: /**
044: * the jgo view this auto layout on
045: */
046: private JGoView mView;
047:
048: /**
049: * the mapper canvas contains the jgo view
050: */
051: private IMapperCanvasView mCanvasView;
052:
053: //private DirectedGraphTableLayout mLayout;
054: private TreeLayout mLayout;
055:
056: private Logger mLogger = Logger
057: .getLogger(BasicCanvasAutoLayout.class.getName());
058:
059: /**
060: * Creates a new BasicCanvasAutoLayout object with the specified mapper
061: * canvas view.
062: *
063: * @param canvasView Description of the Parameter
064: */
065: public BasicCanvasAutoLayout(IMapperCanvasView canvasView) {
066: mCanvasView = canvasView;
067: mView = (JGoView) canvasView.getCanvas().getUIComponent();
068: //mLayout = new DirectedGraphTableLayout();
069: mLayout = new TreeLayout();
070: }
071:
072: /**
073: * Return the mapper view that this layout performs to.
074: *
075: * @return the mapper view that this layout performs to.
076: */
077: public IMapperView getView() {
078: return mCanvasView;
079: }
080:
081: /**
082: * Instaniate an JGoLayeredDigraphAutoLayout with defualt configuration to
083: * perform the auto layout of this JGoView specified by the constructor.
084: */
085: public void autoLayout() {
086: if (mView.getDocument().getDefaultLayer().getNumObjects() == 0) {
087: return;
088: }
089:
090: // the paint method can initialize the children width and height
091: if (mView.getGraphics() != null) {
092: //mView.paint(mView.getGraphics());
093: mView.repaint();
094: }
095:
096: mLayout.performLayout(mView.getDocument().getDefaultLayer());
097:
098: // NOTE: JGoAutoLayout has a bug for reuse. Need to instaniate a new
099: // JGoLayoutObject each time to performLayout.
100:
101: /*
102: new JGoLayeredDigraphAutoLayout(
103: mView.getDocument(),
104: new JGoNetwork(mView.getDocument().getDefaultLayer()),
105: 15,
106: 15,
107: JGoLayeredDigraphAutoLayout.LD_DIRECTION_RIGHT,
108: JGoLayeredDigraphAutoLayout.LD_CYCLEREMOVE_DFS,
109: JGoLayeredDigraphAutoLayout.LD_LAYERING_OPTIMALLINKLENGTH,
110: JGoLayeredDigraphAutoLayout.LD_INITIALIZE_DFSOUT,
111: 4,
112: JGoLayeredDigraphAutoLayout.LD_AGGRESSIVE_TRUE).performLayout();
113:
114:
115:
116: // mAutoLayout.setNetwork(new JGoNetwork (mView.getDocument()));
117: // mAutoLayout.performLayout();
118: */
119: mView.invalidate();
120: mView.repaint();
121: }
122: }
|