문제

매뉴얼이나 그에 대한 답을 찾을 수 없었습니다. 나는 verices와 가장자리를 표시하는 jgraphx로 그래프를 만들고 싶지만, 사용자가 아무것도 움직일 수 없으며, 그린 편집 상자가 와류 나 가장자리에 나타나기를 원하지 않습니다. 그것은 단지 디스플레이만을위한 것입니다.

나는 "Hello World"예제 의이 수정을 아무 소용없이 시도했습니다. 제안이 있습니까?

package com.mxgraph.examples.swing;

import java.util.Hashtable;

import javax.swing.JFrame;

import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.util.mxConstants;
import com.mxgraph.view.mxGraph;
import com.mxgraph.view.mxStylesheet;

public class HelloWorld extends JFrame
{

/**
 * 
 */
private static final long serialVersionUID = -2707712944901661771L;

public HelloWorld()
{
    super("Hello, World!");

    mxGraph graph = new mxGraph();
    Object parent = graph.getDefaultParent();

            //my addition of a stylesheet, I used it on the first node to see if it mad
            //a difference, it didn't regarding dragability//////////////////////////////
    mxStylesheet stylesheet = graph.getStylesheet();
    Hashtable<String, Object> style = new Hashtable<String, Object>();
    style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE);
    style.put(mxConstants.STYLE_OPACITY, 50);
    style.put(mxConstants.STYLE_FONTCOLOR, "#774400");
    style.put(mxConstants.STYLE_EDITABLE, false);
    stylesheet.putCellStyle("ROUNDED", style);

            //tried this too///////////////////////////////////////////////
    graph.setCellsEditable(false); 

    graph.getModel().beginUpdate();
    try
    {
        Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80,
                30, "ROUNDED");
        Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
                80, 30);
        graph.insertEdge(parent, null, "Edge", v1, v2);
    }
    finally
    {
        graph.getModel().endUpdate();
    }

    mxGraphComponent graphComponent = new mxGraphComponent(graph);
    getContentPane().add(graphComponent);
}

public static void main(String[] args)
{
    HelloWorld frame = new HelloWorld();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 320);
    frame.setVisible(true);
}

}
도움이 되었습니까?

해결책

전체 그래프 구성 요소를 비활성화 할 수 있습니다 mxGraphComponent:

graphComponent.setEnabled(false);

다른 팁

당신은 무시할 수 있습니다 isCellSelectable 세포 선택을 방지합니다

mxGraph graph = new mxGraph() {

    @Override
      public boolean isCellSelectable(Object cell) {
         if (cell != null) {
            if (cell instanceof mxCell) {
               mxCell myCell = (mxCell) cell;
               if (myCell.isEdge())
                  return false;
            }
         }
         return super.isCellSelectable(cell);
      }
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top