2017-01-14 13 views
0

간단한 그래프 (자바 스윙 인터페이스 사용)를 그립니다.jgraphx 버텍스 크기 변경

그래프는 정상이지만 자동/기본 정점 크기는 작습니다. 정점 크기 (직사각형 또는 타원)를 설정하는 방법은 무엇입니까?

나는 그래프는 OK입니다

. 풋() (같은 put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE))하지만 정점의 크기를 사용하여 일부 그래프 동작을 변경할 수 있지만, 기본/자동 정점 크기는 내 목적을 위해 작다.을 설정하는 방법 정점 크기 (사각형 또는 타원)?

나는 jgraphx에 대해 많은 오해 할 수 있습니까?

문서는 (적어도 나를 위해) 매우 비밀, 이해하는 것이 매우 어렵습니다, 나는에 대한 책이나 링크에 대한 제안을 할 수 있습니다 Java 용 jgraphx에 대해 더 잘 이해하십시오.

하나 더 상세 : 그래프 요소에 의해 요소를 내장하지 않지만 그녀의 인내 jGraphXAdapter

앤드류

JGraphXAdapter<Incrocio, Strada> graphAdapter = new JGraphXAdapter<Incrocio, Strada>(listenableGraph);

+1

* * 클래스의 문서 링크가 사용중인 "문서는 이해하기가 매우 어렵습니다." –

+0

한 걸음 앞서 나섰습니다. 세포 지오메트리를 변경하는 정점 크기를 변경할 수 있습니다. \t 모든 셀을 반복하고 정점인지 확인하고 으로 새 크기를 적용합니다. 'mxGeometry geometry = cell.getGeometry() ;. geometry.setWidth(); \t geometry.set Height();' 표시된 그래프의 크기는 새로운 것이지만, 정점을 선택하면 (정점의 그림에서 마우스를 두 번 클릭하여) 선택을 제거하면 정점이 이전 크기로 다시 그려집니다. 모든 의견을 환영합니다. 감사. –

+0

* "어떤 제안이라도 고맙습니다."* 1) 나는 이미 당신에게 하나를주었습니다. 2) 다음 조언을 부탁드립니다. 충고를 무시하면 도움을 청하는 사람들에게 무시당하는 것을 볼 수 있습니다 (무료). –

답변

0

감사를 사용 jgraphT로 만든 그래프에서 왔습니다. 영어는 제 언어가 아니며 때로는 이탈리아어 (제 모국어)로도 실수를합니다. Java에 새로운 기능인 것을 추가하십시오. 이 포럼에서도 새로운 내용 (관련 규칙 및이 내용이 내 재생에 적합한 위치가 아닐 수 있음). 나는주의 깊은 메시지를 이전에 읽지 않았습니다.

부분적인 해결책이 담긴 코드를 넣었습니다. 더 명확 해지기를 바랍니다. 일부 시도 후

package it.rex.view; 

public class StradarioViewBis2 extends JFrame { 

    private JPanel contentPane; 

    // listenableGraph is a complete graph done with JgraphT 
    public StradarioViewBis2(ListenableGraph<Incrocio, Strada> listenableGraph) { 

     JGraphXAdapter<Incrocio, Strada> graphAdapter = 
       new JGraphXAdapter<Incrocio, Strada>(listenableGraph); 

     //graphAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1"); //remove label from edge 

     graphAdapter.getModel().beginUpdate(); 
     try { 
      graphAdapter.clearSelection(); 
      graphAdapter.selectAll(); 
      Object[] cells = graphAdapter.getSelectionCells(); //here you have all cells 

      // Iterate into graph to change cells 
      for (Object c : cells) { 
       mxCell cell = (mxCell) c; //cast 
       mxGeometry geometry = cell.getGeometry(); 

       if (cell.isVertex()) { //isVertex 
        // Here I can change vertex dimensions 
        geometry.setWidth(40); 
        geometry.setHeight(40); 
       }else{ //is not a vertex, so u can get source and target 
        // cell.setStyle("orthogonalEdgeStyle"); 
        // cell.getChildAt(x); //Returns the child at the specified index. (target) 
       } 
      } 
     } 
     finally 
     { 
      graphAdapter.getModel().endUpdate(); 
     } 

     mxIGraphLayout layout = new mxCircleLayout(graphAdapter); // questo sistema le posizione degli elementi 

     layout.execute(graphAdapter.getDefaultParent()); 

     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
     setBounds(100, 100, 550, 450); 
     contentPane = new JPanel(); 
     contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 
     setContentPane(contentPane); 
     contentPane.setLayout(null); 

     mxGraphComponent graphComponent = new mxGraphComponent(graphAdapter); // is JScrollPane extension 

     graphComponent.setPageVisible(true); 
     graphComponent.setBounds(30, 30, 300, 300); 
     contentPane.add(graphComponent); 

     //graphComponent.setEnabled(false); 
     graphComponent.getViewport().setBackground(Color.white); 
     ; 

    } 

} 

, 나는 내가 셀의 레이블을 변경할 때이 세포 밖으로 포커스를 이동할 때 정점의 크기가, 다시 초기 차원없는 것으로 나타났습니다.

그래프의 기본 동작을 변경해야한다고 생각하지만 아직 방법을 찾지 못했습니다.

최고 vetex에 라벨을 편집 한 후, 결과입니다 enter image description here