2011-01-04 20 views
6

जैसे प्रीफ्यूज़ ग्राफ़ किनारों की आवश्यकता है मैंने अपना होमवर्क किया और दोनों को नमूना के लिए Google और स्टैक ओवरफ्लो पर उत्तर देने वाले विषय की खोज की। लेकिन कुछ भी नहीं मिला है।को तीर

मेरी समस्या सामान्य किनारों है जिनके पास तीरों की तरह दृश्य नहीं है।

 
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); 


यहाँ है मैं किनारों के रंग के बारे में क्या देखते हैं, उम्मीद है इन पारदर्शी नहीं होना चाहिए:

यहाँ मैं क्या आशा है कि करने के लिए वहाँ आगे है लक्ष्य से गंतव्य के लिए तीर करना है

 
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); 

इस प्रकार, मुझे आश्चर्य है कि मैं कहां गलत हूं? मेरे किनारों तीर की तरह क्यों नहीं लगते हैं?

किसी भी विचार के लिए धन्यवाद।

अधिक विस्तार के लिए, मैं कोड के सभी पेस्ट करना चाहते हैं:

 
/* 
* 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"); 

    } 
} 


+0

हाय, मेरे सवाल यहां से उत्तर दिया जाता है: https://sourceforge.net/projects/prefuse/forums/forum/343013/topic/4035245/index/page/1 भी मैं एक चल पाया है उदाहरण के लिए निम्नलिखित पृष्ठ में, लेकिन यह मूल ग्राफ खोजकर्ता के लिए जटिल जटिल है: http://goosebumps4all.net/34all/bb/showthread.php?tid=17 यदि मुझे कोड की कुछ पंक्ति देनी होगी, मुख्य पंक्तियां यहां हैं:

... graph = new GraphMLReader().readGraph("socialnet.xml"); ... Table n = graph.getNodeTable(); Table e = graph.getEdgeTable(); Graph g_new = new Graph(n, e, true); 
ध्यान के लिए अग्रिम धन्यवाद। – merve

उत्तर

2

मैं अगर तुम Prefuse मंचों में दिए गए जवाब से संतुष्ट हैं अपनी टिप्पणी से यकीन नहीं है। इसलिए, मैंने कोड के साथ खेला और निम्नलिखित परिवर्तनों के साथ आप जो व्यवहार चाहते हैं उसे प्राप्त करने में सक्षम थे।

मैंने इनपुट एक्सएमएल बदल दिया ताकि ग्राफ तत्व के edgedefault को निर्देशित किया जा सके।

... <graph edgedefault="directed"> ... 

तब कोड में मैं अलग EdgeRenderer edgetypes और arrowtypes के साथ खेला बस सुनिश्चित करें कि मैं पर और तीर बंद कर देते हैं, या उन्हें आगे या पीछे प्रदर्शित करने के लिए मिल सकता है बनाने के लिए। मैंने घुमावदार लाइनों की भी कोशिश की। उदाहरण के लिए:

edgeRenderer = new EdgeRenderer(prefuse.Constants.EDGE_TYPE_CURVE, prefuse.Constants.EDGE_ARROW_FORWARD); 

फिर से, आप पहले से ही अन्य मंचों में इसका उत्तर प्राप्त कर चुके हैं।

0

मैं एक ही प्रश्न पर ठोकर खाई। जो शुरू ही किया है Prefuse पुस्तकालय के भविष्य के उपयोगकर्ता के लिए:

ColorAction arrowColor = new ColorAction("tree.edges", VisualItem.FILLCOLOR, ColorLib.gray(200)); 

और आगे नीचे: क्या आप RadialGraphView उदाहरण के लिए तीर जोड़ना चाहते हैं, तो आपको परिवर्तन ditkin ने उल्लेख किया बनाने के लिए और लाइन जोड़ने की जरूरत है:

// create the filtering and layout: 
[...] 
filter.add(arrowColor); // add this one 

असल में, उत्तर स्रोत फोर्ज थ्रेड में है, लेकिन मैं यहां एक समाधान प्रदान करना चाहता था। मेर्वे से कोड में ये निर्देश शामिल हैं।

संबंधित मुद्दे