주메뉴 바로가기 본문 바로가기 하단 바로가기

고객지원

기술문의

Layout에 관하여

  • 한상이
  • 2004.03.02
  • 조회수 1,923
안녕하세요. 질문이 있어서 적습니다.

IlpNetwork에서 DataSource에 IltNetworkElement 들과 IltLink들로 위치를
잡아 배치를 했는데요. 장비가 많다보니 만들어 있는 레이아웃을 써야겠는
데요. 특히 CircularLayout 과 다른 레이아웃을 적용했으면 하는데요.

어떻게 해야 레이아웃을 적용할 수 있나요?

API에서 레이아웃에 적용할려면 IlvGraphic 이나 IlvLinkImage 클래스를
써야한다고 본것같습니다.

장비는 IltNetworkElement 클래스를 사용했고, 알람도 표시가 되었구요.
혹시 레이아웃을 적용하기 위해서 IlvGraphic를 사용해야 한다면
알람표시는 상관이 없는지요. 답변부탁드립니다.

댓글 5

  • 방효동2004-03-05
    IlvCircularLayout을 이용한 예제입니다. 참고하시고요.
    IlvGraphic을 사용하지 않아도 되고 알람표시와 관계없습니다.

    public void setNodeLayout(boolean flag)
    {
    final IlpNetworkView view = getNetwork().getView();
    final IltCompositeGrapher grapher = view.getCompositeGrapher();

    if(view != null) // no use layout
    return;

    System.out.println("Circular Layout starting .......");
    if (nodeLayout == null)
    nodeLayout = new IlvCircularLayout();
    nodeLayout.setLinkStyle(IlvCircularLayout.NO_RESHAPE_STYLE);
    //nodeLayout.setLinkStyle(IlvCircularLayout.STRAIGHT_LINE_STYLE);
    nodeLayout.setLevelOffset(50);
    if (flag)
    nodeLayout.setOffset(30);
    else
    nodeLayout.setOffset(50);


    nodeLayout.attach(grapher.getGraphModel());
    nodeLayout.setCoordinatesMode(IlvGraphLayout.VIEW_COORDINATES);
    nodeLayout.setLayoutRegion(new ilog.views.IlvRect(80, 80, 500, 500));

    try
    {
    nodeLayout.performLayout(true, false, true);
    }
    catch (IlvGraphLayoutException e)
    {
    e.printStackTrace();
    }
    }
    아이콘삭제
  • 한상이2004-03-05
    제가 잘 알지는 못하지만. 클러스터를 만들어줘야 되잖아요.
    우선 코드는 아래와 같구요.
    실행하면 다음과같은 익셉션이 납니다.

    Circular Layout starting .......
    java.lang.IllegalArgumentException:
    The nodeilog.tgo.model.IltNetworkElement@2006a0[label="대전_장비1"] must be a node in the attached grapher ilog.tgo.graphic.IltGrapherAdapter@1754699 [ilog.tgo.graphic.IltNetwork@7a36a2]
    at ilog.views.graphlayout.internalutil.LayoutUtil.a(Unknown Source)
    at ilog.views.graphlayout.internalutil.LayoutUtil.CheckInputNode(Unknown Source)
    at ilog.views.graphlayout.circular.IlvCircularLayout.addClusterId(Unknown Source)
    at kt.layer.Demo.setNodeLayout(Unknown Source)
    at kt.layer.Demo.<init>(Unknown Source)
    at kt.layer.Demo.main(Unknown Source)

    다음은 소스입니다.
    package kt.layer;

    import java.awt.*;
    import javax.swing.*;
    import java.util.*;

    import ilog.cpl.graphic.views.IlpShelfItemPosition;
    import ilog.cpl.graphic.IlpRelativePoint;
    import ilog.cpl.graphic.IlpGraphicViewStyleManager;
    import ilog.tgo.datasource.IltDefaultDataSource;
    import ilog.tgo.model.*;
    import ilog.cpl.graphic.IlpPoint;
    import ilog.cpl.service.IlpContext;
    import ilog.cpl.style.IlpStyleManager;
    import ilog.cpl.style.key.IlpFloatKey;
    import ilog.cpl.style.IlpStyle;
    import ilog.cpl.model.IlpObject;
    import ilog.cpl.model.IlpClass;
    import ilog.cpl.IlpNetwork;
    import ilog.cpl.style.key.IlpBooleanKey;
    import ilog.cpl.IlpSystem;
    import ilog.cpl.model.IlpClassManager;
    import ilog.cpl.style.key.IlpColorKey;

    import ilog.views.interactor.IlvUnZoomViewInteractor;
    import ilog.cpl.equipment.IlpEquipmentController;
    import ilog.cpl.network.action.toolbar.*;
    import ilog.cpl.IlpEquipment;
    import ilog.cpl.equipment.IlpEquipmentView;
    import ilog.cpl.network.IlpNetworkView;

    //import kt.test.MapResource;
    //import kt.test.KTLink;

    //import javax.oss.fm.monitor.*;

    import ilog.views.graphlayout.circular.IlvClusterNumber;
    import ilog.views.graphlayout.circular.IlvCircularLayout;
    import ilog.views.graphlayout.IlvGraphLayoutException;
    import ilog.views.graphlayout.IlvGraphLayout;
    import ilog.tgo.graphic.IltCompositeGrapher;

    class Demo extends JPanel
    {
    private Vector vLinkModel;

    IltDefaultDataSource dataSource;
    IlpNetwork networkComponent;
    IlvCircularLayout nodeLayout = new IlvCircularLayout();

    IltNetworkElement iltNeSystem[] = new IltNetworkElement[4];

    public Demo()
    {
    createNetworkComponent();
    makeDataSource();
    makeLink();
    setNodeLayout(true);
    }

    void createNetworkComponent()
    {
    dataSource = new IltDefaultDataSource();
    networkComponent = new IlpNetwork( );

    networkComponent.setDataSource( dataSource );
    setLayout( new BorderLayout() );
    add( networkComponent, BorderLayout.CENTER );
    }

    void makeDataSource()
    {
    vLinkModel = new Vector();

    // 하나
    iltNeSystem[0] = new IltNetworkElement( "code001" );
    iltNeSystem[0].setName( "대전" + "_" + "장비1" );

    iltNeSystem[0].setType( IltNetworkElement.Type.IP_Router2 );
    //iltNeSystem[0].setProperty( MapResource.KEY_MODEL, "AGW-model 1" );
    //iltNeSystem[0].setProperty( MapResource.KEY_TYPE, "Accesss Gateway" );
    //iltNeSystem[0].setProperty( MapResource.KEY_IP, "168.22.1.211" );
    //iltNeSystem.setPosition(new IlpPoint (100, 100));

    vLinkModel.add(iltNeSystem[0]);

    // 두울
    iltNeSystem[1] = new IltNetworkElement( "code002" );
    iltNeSystem[1].setName( "전주" + "_" + "장비1" );

    //iltNeSystem[1].setType( IltNetworkElement.Type.SAN_FiberChannelSwitch );
    //iltNeSystem[1].setProperty( MapResource.KEY_MODEL, "SW-model 3" );
    //iltNeSystem[1].setProperty( MapResource.KEY_TYPE, "SoftSwitch" );
    //iltNeSystem[1].setProperty( MapResource.KEY_IP, "168.22.1.211" );
    //iltNeSystem.setPosition(new IlpPoint (200, 200));

    vLinkModel.add(iltNeSystem[1]);

    // 셋
    iltNeSystem[2] = new IltNetworkElement( "code003" );
    iltNeSystem[2].setName( "전주" + "_" + "장비3" );

    //iltNeSystem[2].setType( IltNetworkElement.Type.SAN_FiberChannelSwitch );
    //iltNeSystem[2].setProperty( MapResource.KEY_MODEL, "SW-model 3" );
    //iltNeSystem[2].setProperty( MapResource.KEY_TYPE, "SoftSwitch" );
    //iltNeSystem[2].setProperty( MapResource.KEY_IP, "168.22.1.211" );
    //iltNeSystem.setPosition(new IlpPoint (200, 200));

    vLinkModel.add(iltNeSystem[2]);

    // 넷
    iltNeSystem[3] = new IltNetworkElement( "code004" );
    iltNeSystem[3].setName( "전주" + "_" + "장비4" );

    //iltNeSystem[3].setType( IltNetworkElement.Type.SAN_FiberChannelSwitch );
    //iltNeSystem[3].setProperty( MapResource.KEY_MODEL, "SW-model 3" );
    //iltNeSystem[3].setProperty( MapResource.KEY_TYPE, "SoftSwitch" );
    //iltNeSystem[3].setProperty( MapResource.KEY_IP, "168.22.1.211" );
    //iltNeSystem.setPosition(new IlpPoint (200, 200));

    vLinkModel.add(iltNeSystem[3]);


    dataSource.addObjects( vLinkModel );
    }

    void makeLink()
    {
    String sLinkKey = "code001" + "-" + "code002";

    IltNetworkElement iltNeFrom = (IltNetworkElement)dataSource.getObject( "code001" );
    IltNetworkElement iltNeTo = (IltNetworkElement)dataSource.getObject( "code002" );

    if ( iltNeFrom == null || iltNeTo == null ) return;

    //IltLink link = new KTLink( sLinkKey, networkComponent );
    IltLink link = new IltLink( sLinkKey );

    link.setFrom(iltNeFrom);
    link.setTo(iltNeTo);

    vLinkModel.add(link);
    dataSource.addObjects( vLinkModel );
    }

    private IlpNetwork getNetwork()
    {
    return networkComponent;
    }

    public void setNodeLayout(boolean flag)
    {
    final IlpNetworkView view = getNetwork().getView();
    final IltCompositeGrapher grapher = view.getCompositeGrapher();

    //if(view != null) // no use layout
    // return;

    System.out.println("Circular Layout starting .......");
    if (nodeLayout == null)
    nodeLayout = new IlvCircularLayout();
    nodeLayout.setLinkStyle(IlvCircularLayout.NO_RESHAPE_STYLE);
    //nodeLayout.setLinkStyle(IlvCircularLayout.STRAIGHT_LINE_STYLE);
    nodeLayout.setLevelOffset(50);
    if (flag)
    nodeLayout.setOffset(30);
    else
    nodeLayout.setOffset(50);



    nodeLayout.attach(grapher.getGraphModel());


    for ( int i=0; i < 4; i++ )
    {
    //grapher.addNode(iltNeSystem[i], true);
    nodeLayout.addClusterId( iltNeSystem[i], new IlvClusterNumber(i+1));
    }


    nodeLayout.setCoordinatesMode(IlvGraphLayout.VIEW_COORDINATES);
    nodeLayout.setLayoutRegion(new ilog.views.IlvRect(80, 80, 500, 500));



    try
    {
    nodeLayout.performLayout(true, false, true);
    }
    catch (IlvGraphLayoutException e)
    {
    e.printStackTrace();
    }
    }

    public static void main( String args[] )
    {
    JFrame f = new JFrame();
    f.getContentPane().add( "Center", new Demo() );
    f.setSize(400,400);
    f.setVisible(true);
    }
    }
    아이콘삭제
  • 방효동2004-03-05
    제되로 적용을 못 하셨네요.

    예제입니다.

    int[] cluster = new int[] { 0, 1, 2};

    int count = 0;
    // ACE 계열
    IlvClusterId clusterId0 = new IlvClusterNumber(cluster[0]);
    // CANS, AC120
    IlvClusterId clusterId1 = new IlvClusterNumber(cluster[1]);
    // MSS 계열
    IlvClusterId clusterId2 = new IlvClusterNumber(cluster[2]);
    String nodeType = "";

    Enumeration enum = grapher.getNodes();

    while (enum.hasMoreElements())
    {
    IltObject object = (IltObject)enum.nextElement();
    if (object.getName() == null)
    continue;
    if (object.hasAttributeValue(nodeTypeAttr))
    {
    if (object.getAttributeValue(nodeTypeAttr) != ilog.cpl.model.IlpAttributeValueHolder.VALUE_NOT_SET)
    {
    nodeType = object.getAttributeValue(nodeTypeAttr).toString();
    }
    }


    IlvGraphic g = object.getLayoutProxy(grapher);
    if (g != null)
    {
    if (nodeType.length() > 0 && nodeType.substring(0,3).equals("ACE"))
    {
    if (count == 0)
    nodeLayout.setRootClusterId(clusterId0);
    nodeLayout.setClusterId(g, clusterId0, count);
    }
    else if (nodeType.length() > 0 && nodeType.substring(0,3).equals("MSS"))
    {
    if (count == 0)
    nodeLayout.setRootClusterId(clusterId2);
    nodeLayout.setClusterId(g, clusterId2, count);
    }
    else
    { // CANS, AC120, etc
    if (count == 0)
    nodeLayout.setRootClusterId(clusterId2);
    nodeLayout.setClusterId(g, clusterId1, count);
    }
    count++;
    }
    }
    아이콘삭제
  • 한상이2004-03-08
    아직 제대루 적용을 제가 못한것같습니다.
    어느부분에 문제가 있는지 봐주세요^^

    Enumeration enum = grapher.getNodes();
    이 부분에서 값이 없는것 같습니다.

    파일은 첨부합니다.
    아이콘삭제
  • 한상이2004-03-18
    코드는 같다구 봐야겠죠.
    클러스터링 하는 부분의 코드의 실행순서를 뒤로 옮기니 되는군요.
    아~~ 되는 코드는 첨부합니다.
    아이콘삭제

댓글 입력