我有一个SimpleWeightedGraph,我想在JFrame中的JPanel上绘制它.不幸的是没有画出来.
我读了这篇文章.他们正在使用,ListenableDirectedGraph所以我尝试了一次ListenableUndirectedGraph没有成功.
public class DisplayGraphForm extends javax.swing.JFrame {
public DisplayGraphForm(SimpleWeightedGraph g) {
initComponents(); // graphPanel added to JFrame with BorderLayout (Center)
JGraphModelAdapter adapter = new JGraphModelAdapter(g);
JGraph jgraph = new JGraph(adapter);
graphPanel.add(jgraph);
}
}
Run Code Online (Sandbox Code Playgroud) 我试图随机遍历 jgrapht 中的图形(直到找到一些目标节点)。为此,我需要从 sourceNode 开始,随机选择任何出来的边缘并跟随它。
我知道有一种方法getAllEdges(sourceVertex, targetVertex)可以返回两个给定节点之间的所有边。但是如何在只有 sourceNode 而没有目标的情况下获得所有边?
我试图在单击图像图标时创建线路连接,我已经使用wires.html示例尝试了相同的操作。但这是行不通的。我正在使用与mxGraph反应。如何实现这一点。有什么办法可以做到这一点。
mxEvent.addGestureListeners(
img,
mxUtils.bind(this, function(evt) {
mxConnectionHandler.prototype.isStartEvent = function(me) {
console.log("Here we have to start the line connection");
};
})
);
Run Code Online (Sandbox Code Playgroud)
我必须在bind事件中启动线路连接。有没有什么办法解决这一问题。我已经尝试过,但是没有一个在工作。
我真的需要帮助
在图像中,箭头连接(Multiple points are not supported. Used for directly connecting source to target)工作正常。但是需要实现Line Connection(Multiple points are supported. Starting from source we can click any where to create multiple points till the target connection)。
请检查以下URL作为示例
演示网址:http : //jithin.com/javascript/examples/contexticons.html
源代码URL:https : //jsfiddle.net/fs1ox2kt/
在“ 演示URL”中,单击单元格时,将显示4个图标(“删除”,“调整大小”,“移动”,“连接”)。我已将Delete …
我能够成功解码图形 xml 模型,但在拖动之前单元格不可见
下面的 GIF显示了我的问题
问题:我想在第一个(现在只显示 div)时间完全加载图形,也不需要拖动
这是我如何解码和呈现 xml
var graphXmlStr = ''//xmldata
var doc = mxUtils.parseXml(graphXmlStr)
var codec = new mxCodec(doc);
codec.decode(doc.documentElement, graph.getModel());
Run Code Online (Sandbox Code Playgroud)
我正在使用下面的代码作为graph.htmlLabels我需要的代码下面的 html
graph.convertValueToString = function(cell) {
return cell.value;
}
Run Code Online (Sandbox Code Playgroud)
下面是我的完整代码
var graphXmlStr = ''//xmldata
var doc = mxUtils.parseXml(graphXmlStr)
var codec = new mxCodec(doc);
codec.decode(doc.documentElement, graph.getModel());
Run Code Online (Sandbox Code Playgroud)
请帮助我在此先感谢!!!
嗨,我在边缘验证方面遇到了问题
注意:任何方法都是最受欢迎的,但应该解决问题
下面是我的要求
源 -> Action_1 -> Action_2
来源 -> Action_1 <- Action_2
下面的 Gif 显示了我的要求
在上面的 gif 中,出现的文字是我想避免的文字
这是我尝试过的
graph.multiplicities.push(new mxMultiplicity(
true, 'Source', null, null, 1, 1, ['Action_1','Action_2'],
'Source can have 1 Action and from there it can be multiple',
null));
graph.multiplicities.push(new mxMultiplicity(
false, 'Source', null, null, 0, 0, null,
'Source Must Have No Incoming Edge',
null)); // Type does not matter
Run Code Online (Sandbox Code Playgroud)
这是我提到的演示https://jgraph.github.io/mxgraph/javascript/examples/validation.html ,这里是它的代码 https://github.com/jgraph/mxgraph/blob/master/javascript/examples /validation.html
这是Multiplicity …
我必须在java中开发一个项目,该项目使用斯坦福解析器来分隔句子,并且必须生成一个图表来显示句子中单词之间的关系.例如:俄亥俄州位于美国.输出:

图像显示图形.但输出不必相同,但它必须显示图形形式的单词之间的关系.可以使用Jgraph,Jung生成图表.但最初我必须将解析器软件集成到我的程序中.那么如何整合解析器?
我创建了一个界面,包括mxgraph(javascript),它允许用户单击一个单元格,并在与图形分开的常规表单文本输入中编辑单元格的标签.我想在用户保存表单(ajax submit)后更改单元格的标签,而无需重新加载图表.
我真的不需要做任何花哨的细胞/椎骨标签,但我确实需要能够改变它的文字.如果这是可以避免的,我不需要HTML标签.并且,我还没有在API中找到类似"setLabel"方法的内容.
听起来很简单.我错过了什么?
谢谢
我正在创建一个 React 组件,它将通过使用带有 mxGraph 的 XML 字符串来呈现图形。图形在组件内部渲染,但一些形状,如圆形、菱形和泳道,渲染不正确;它们显示为简单的正方形或矩形。这特别奇怪,因为一些非矩形形状(例如文档)正确显示。
该图是使用jgraph 的“grapheditor”工具的编辑版本创建的,其中包含一些自定义形状:
此图形编辑器工具与参考实现相同,只是更改了 addGeneralPalette() 函数Sidebar.js以使用我们自定义的形状:
/**
* Adds the general palette to the sidebar.
*/
Sidebar.prototype.addGeneralPalette = function(expand)
{
var fns = [
this.createVertexTemplateEntry('ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Helvetica;fontSize=16;fillColor=#e8f5e9;strokeColor=#4caf50;strokeWidth=4;gradientColor=#c8e6c9;', 80, 80, 'Start', 'Start', null, null, 'start begin starting beginning'),
this.createVertexTemplateEntry('shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;strokeColor=#ff9800;strokeWidth=4;perimeterSpacing=0;fontSize=16;gradientColor=#ffe0b2;fillColor=#fff3e0;', 200, 120, 'Process', 'Process', null, null, 'process proc'),
this.createVertexTemplateEntry('rounded=1;whiteSpace=wrap;html=1;strokeColor=#00ACC1;strokeWidth=5;glass=0;comic=0;gradientColor=#b2ebf2;fillColor=#e0f7fa;fontSize=16;fontColor=#000000;', 200, 120, 'Template', 'Template', null, null, 'template temp'),
this.createVertexTemplateEntry('rhombus;whiteSpace=wrap;html=1;rounded=0;glass=0;comic=0;labelBackgroundColor=none;strokeColor=#333333;strokeWidth=4;fillColor=#eeeeee;gradientColor=#e5e5e5;fontFamily=Helvetica;fontSize=16;fontColor=#000000;align=center;', 200, 120, 'Decision', 'Decision', null, null, 'decision decide'),
this.createVertexTemplateEntry('shape=document;whiteSpace=wrap;html=1;boundedLbl=1;strokeWidth=4;strokeColor=#9C27B0;gradientColor=#E1BEE7;fillColor=#F3E5F5;fontSize=16;', 200, 120, 'Documentation', 'Documentation', null, …Run Code Online (Sandbox Code Playgroud) 当我们使用 graph.getSelectionCells() 获取选定的单元格时,它仅返回选定的外部单元格,但是,我还需要获取其子元素。
返回的单元格中不包含其子元素详细信息。
我正在使用一个名为JGraphT的图形库,在我的程序中,我有几个顶点通过边缘连接在一起,并且具有行程成本的权重.
在一个例子中,我只是一个整数,它的工作原理!但是,当我改变这个使用我的班级FlightData作为重量时,它不起作用.
这是我的代码,权重只是一个整数:
List<DefaultWeightedEdge> path = DijkstraShortestPath.findPathBetween(graph, start, end);
for(int i = 0; i < path.size(); i++) {
DefaultWeightedEdge edge = path.get(i);
System.out.println((i+1) + " " + graph.getEdgeSource(edge) + " -> " + graph.getEdgeTarget(edge));
}
Run Code Online (Sandbox Code Playgroud)
这是我的FlightData类的权重代码:
List<FlightData> path = DijkstraShortestPath.findPathBetween(graph, start, end);
for(int i = 0; i < path.size(); i++) {
FlightData f = path.get(i);
System.out.println((i+1) + " " + graph.getEdgeSource(f) + " -> " + graph.getEdgeTarget(f));
}
Run Code Online (Sandbox Code Playgroud)
我的FlightData类只是一个带有访问器方法的类:
import org.jgrapht.graph.DefaultWeightedEdge;
public class FlightData extends DefaultWeightedEdge
{
private …Run Code Online (Sandbox Code Playgroud)