Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 需要像箭头一样使用图边吗_Java_Prefuse - Fatal编程技术网

Java 需要像箭头一样使用图边吗

Java 需要像箭头一样使用图边吗,java,prefuse,Java,Prefuse,我做了家庭作业,在谷歌上搜索了一个样本和一个在stackoverflow上回答过的主题。但是什么也没找到 我的问题是,普通的边没有箭头那样的视图 以下是我希望从目标到目标有前进箭头所做的: LabelRenderer nameLabel = new LabelRenderer("name"); nameLabel.setRoundedCorner(8, 8); DefaultRendererFactory rendererFactory = new Default

我做了家庭作业,在谷歌上搜索了一个样本和一个在stackoverflow上回答过的主题。但是什么也没找到

我的问题是,普通的边没有箭头那样的视图

以下是我希望从目标到目标有前进箭头所做的:

LabelRenderer nameLabel = new LabelRenderer("name"); nameLabel.setRoundedCorner(8, 8); DefaultRendererFactory rendererFactory = new DefaultRendererFactory(nameLabel); EdgeRenderer edgeRenderer; edgeRenderer = new EdgeRenderer(prefuse.Constants.EDGE_TYPE_LINE, prefuse.Constants.EDGE_ARROW_FORWARD); rendererFactory.setDefaultEdgeRenderer(edgeRenderer); vis.setRendererFactory(rendererFactory); LabelRenderer nameLabel=新的LabelRenderer(“名称”); 名称标签。设置圆角(8,8); DefaultRenderFactory RenderFactory=新的DefaultRenderFactory(名称标签); Edgerender Edgerender; EdgerEnder=新EdgerEnder(prefuse.Constants.EDGE类型线,prefuse.Constants.EDGE箭头向前); RenderFactory.setDefaultEdgerEnder(EdgerEnder); vis.setrenderfactory(renderfactory); 以下是我看到的边缘颜色,希望它们不能是透明的:

int[] palette = new int[]{ColorLib.rgb(255, 180, 180), ColorLib.rgb(190, 190, 255)}; DataColorAction fill = new DataColorAction("socialnet.nodes", "gender", Constants.NOMINAL, VisualItem.FILLCOLOR, palette); ColorAction text = new ColorAction("socialnet.nodes", VisualItem.TEXTCOLOR, ColorLib.gray(0)); ColorAction edges = new ColorAction("socialnet.edges", VisualItem.STROKECOLOR, ColorLib.gray(200)); ColorAction arrow = new ColorAction("socialnet.edges", VisualItem.FILLCOLOR, ColorLib.gray(200)); ActionList colour = new ActionList(); colour.add(fill); colour.add(text); colour.add(edges); colour.add(arrow); vis.putAction("colour", colour); int[]palete=newint[]{ColorLib.rgb(255,180,180),ColorLib.rgb(190,190,255)}; DataColorAction fill=新的DataColorAction(“socialnet.nodes”,“性别”,Constants.NOMINAL,VisualItem.FILLCOLOR,调色板); ColorAction text=新的ColorAction(“socialnet.nodes”,VisualItem.TEXTCOLOR,ColorLib.gray(0)); ColorAction Edge=新的ColorAction(“socialnet.Edge”,VisualItem.STROKECOLOR,ColorLib.gray(200)); ColorAction箭头=新的ColorAction(“socialnet.edges”,VisualItem.FILLCOLOR,ColorLib.gray(200)); ActionList color=新的ActionList(); 颜色。添加(填充); 颜色。添加(文本); 颜色。添加(边缘); 颜色。添加(箭头); 视觉效果(“颜色”,颜色); 因此,我想知道我错在哪里? 为什么我的边缘看起来不像箭头

谢谢你的建议

有关更多详细信息,我想粘贴所有代码:

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package prefusedeneme; import javax.swing.JFrame; import prefuse.data.*; import prefuse.data.io.*; import prefuse.Display; import prefuse.Visualization; import prefuse.render.*; import prefuse.util.*; import prefuse.action.assignment.*; import prefuse.Constants; import prefuse.visual.*; import prefuse.action.*; import prefuse.activity.*; import prefuse.action.layout.graph.*; import prefuse.controls.*; import prefuse.data.expression.Predicate; import prefuse.data.expression.parser.ExpressionParser; public class SocialNetworkVis { public static void main(String argv[]) { // 1. Load the data Graph graph = null; /* graph will contain the core data */ try { graph = new GraphMLReader().readGraph("socialnet.xml"); /* load the data from an XML file */ } catch (DataIOException e) { e.printStackTrace(); System.err.println("Error loading graph. Exiting..."); System.exit(1); } // 2. prepare the visualization Visualization vis = new Visualization(); /* vis is the main object that will run the visualization */ vis.add("socialnet", graph); /* add our data to the visualization */ // 3. setup the renderers and the render factory // labels for name LabelRenderer nameLabel = new LabelRenderer("name"); nameLabel.setRoundedCorner(8, 8); /* nameLabel decribes how to draw the data elements labeled as "name" */ // create the render factory DefaultRendererFactory rendererFactory = new DefaultRendererFactory(nameLabel); EdgeRenderer edgeRenderer; edgeRenderer = new EdgeRenderer(prefuse.Constants.EDGE_TYPE_LINE, prefuse.Constants.EDGE_ARROW_FORWARD); rendererFactory.setDefaultEdgeRenderer(edgeRenderer); vis.setRendererFactory(rendererFactory); // 4. process the actions // colour palette for nominal data type int[] palette = new int[]{ColorLib.rgb(255, 180, 180), ColorLib.rgb(190, 190, 255)}; /* ColorLib.rgb converts the colour values to integers */ // map data to colours in the palette DataColorAction fill = new DataColorAction("socialnet.nodes", "gender", Constants.NOMINAL, VisualItem.FILLCOLOR, palette); /* fill describes what colour to draw the graph based on a portion of the data */ // node text ColorAction text = new ColorAction("socialnet.nodes", VisualItem.TEXTCOLOR, ColorLib.gray(0)); /* text describes what colour to draw the text */ // edge ColorAction edges = new ColorAction("socialnet.edges", VisualItem.STROKECOLOR, ColorLib.gray(200)); ColorAction arrow = new ColorAction("socialnet.edges", VisualItem.FILLCOLOR, ColorLib.gray(200)); /* edge describes what colour to draw the edges */ // combine the colour assignments into an action list ActionList colour = new ActionList(); colour.add(fill); colour.add(text); colour.add(edges); colour.add(arrow); vis.putAction("colour", colour); /* add the colour actions to the visualization */ // create a separate action list for the layout ActionList layout = new ActionList(Activity.INFINITY); layout.add(new ForceDirectedLayout("socialnet")); /* use a force-directed graph layout with default parameters */ layout.add(new RepaintAction()); /* repaint after each movement of the graph nodes */ vis.putAction("layout", layout); /* add the laout actions to the visualization */ // 5. add interactive controls for visualization Display display = new Display(vis); display.setSize(700, 700); display.pan(350, 350); // pan to the middle display.addControlListener(new DragControl()); /* allow items to be dragged around */ display.addControlListener(new PanControl()); /* allow the display to be panned (moved left/right, up/down) (left-drag)*/ display.addControlListener(new ZoomControl()); /* allow the display to be zoomed (right-drag) */ // 6. launch the visualizer in a JFrame JFrame frame = new JFrame("prefuse tutorial: socialnet"); /* frame is the main window */ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(display); /* add the display (which holds the visualization) to the window */ frame.pack(); frame.setVisible(true); /* start the visualization working */ vis.run("colour"); vis.run("layout"); } } /* *要更改此模板,请选择工具|模板 *然后在编辑器中打开模板。 */ 包预使用项; 导入javax.swing.JFrame; 导入prefuse.data.*; 导入prefuse.data.io.*; 导入prefuse.Display; 导入使用前可视化; 导入prefuse.render.*; 导入prefuse.util.*; 导入prefuse.action.assignment.*; 导入prefuse.Constants; 导入prefuse.visual.*; 导入prefuse.action.*; 导入prefuse.activity.*; 导入prefuse.action.layout.graph.*; 导入prefuse.controls.*; 导入prefuse.data.expression.Predicate; 导入prefuse.data.expression.parser.ExpressionParser; 公共类社会网络{ 公共静态void main(字符串argv[]){ //1.加载数据 图=空; /*图表将包含核心数据*/ 试一试{ graph=newgraphmlreader().readGraph(“socialnet.xml”); /*从XML文件加载数据*/ }捕获(DataIOE异常){ e、 printStackTrace(); System.err.println(“错误加载图形。正在退出…”); 系统出口(1); } //2.准备可视化 可视化vis=新的可视化(); /*vis是运行可视化的主要对象*/ vis.add(“社交网络”,图表); /*将我们的数据添加到可视化中*/ //3.设置渲染器和渲染工厂 //名称标签 LabelRenderer nameLabel=新的LabelRenderer(“名称”); 名称标签。设置圆角(8,8); /*nameLabel描述如何绘制标记为“name”的数据元素*/ //创建渲染工厂 DefaultRenderFactory RenderFactory=新的DefaultRenderFactory(名称标签); Edgerender Edgerender; EdgerEnder=新EdgerEnder(prefuse.Constants.EDGE类型线,prefuse.Constants.EDGE箭头向前); RenderFactory.setDefaultEdgerEnder(EdgerEnder); vis.setrenderfactory(renderfactory); //4.处理行动 //标称数据类型的调色板 int[]palete=newint[]{ColorLib.rgb(255,180,180),ColorLib.rgb(190,190,255)}; /*ColorLib.rgb将颜色值转换为整数*/ //将数据映射到调色板中的颜色 DataColorAction fill=新的DataColorAction(“socialnet.nodes”,“性别”,Constants.NOMINAL,VisualItem.FILLCOLOR,调色板); /*fill描述了基于部分数据绘制图形的颜色*/ //节点文本 ColorAction text=新的ColorAction(“socialnet.nodes”,VisualItem.TEXTCOLOR,ColorLib.gray(0)); /*文本描述绘制文本的颜色*/ //边缘 ColorAction Edge=新的ColorAction(“socialnet.Edge”,VisualItem.STROKECOLOR,ColorLib.gray(200)); ColorAction箭头=新的ColorAction(“socialnet.edges”,VisualItem.FILLCOLOR,ColorLib.gray(200)); /*边描述绘制边的颜色*/ //将颜色指定合并到操作列表中 ActionList color=新的ActionList(); 颜色。添加(填充); 颜色。添加(文本); 颜色。添加(边缘); 颜色。添加(箭头); 视觉效果(“颜色”,颜色); /*将颜色动作添加到可视化中*/ //为布局创建单独的操作列表 ActionList布局=新的ActionList(Activity.INFINITY); 布局。添加(新的ForceDirectedLayout(“socialnet”); /*使用具有默认参数的力导向图形布局*/ layout.add(新的重新维护()); /*每次移动图形节点后重新绘制*/ 视觉效果(“布局”,布局); /*将laout操作添加到可视化中*/ //5.添加用于可视化的交互式控件 显示器=新显示器(vis); 显示。设置大小(700700); display.pan(350350);//向中间平移 display.addControlListener(新的DragControl()); /*允许拖动项目*/ display.addControlListener(新的PanControl()); /*允许平移显示(左/右、上/下移动)(左拖动)*/ display.addControlListener(新ZoomControl()); /*允许缩放显示(
... <graph edgedefault="directed"> ...
edgeRenderer = new EdgeRenderer(prefuse.Constants.EDGE_TYPE_CURVE, prefuse.Constants.EDGE_ARROW_FORWARD);
ColorAction arrowColor = new ColorAction("tree.edges", VisualItem.FILLCOLOR, ColorLib.gray(200));
// create the filtering and layout:
[...]
filter.add(arrowColor); // add this one