1 19 20 28 29 package org.netbeans.modules.xml.nbprefuse.render; 30 31 import org.netbeans.modules.xml.nbprefuse.AnalysisConstants; 32 import prefuse.render.Renderer; 33 import prefuse.render.RendererFactory; 34 import prefuse.visual.AggregateItem; 35 import prefuse.visual.EdgeItem; 36 import prefuse.visual.NodeItem; 37 import prefuse.visual.VisualItem; 38 39 43 public class FindUsagesRendererFactory implements RendererFactory { 44 private NbLabelRenderer nodeRenderer; 45 private NbLabelRenderer fileNodeRenderer; 46 private NbLabelRenderer queryNodeRenderer; 47 private Renderer generalizationRenderer; 48 private Renderer compositionRenderer; 49 private Renderer referenceRenderer; 50 private Renderer fileEdgeRenderer; 51 private Renderer aggregateRenderer; 52 53 54 58 public FindUsagesRendererFactory( 59 NbLabelRenderer nodeRenderer, 60 NbLabelRenderer fileNodeRenderer, 61 Renderer generalizationRenderer, 62 Renderer compositionRenderer, 63 Renderer referenceRenderer, 64 Renderer fileEdgeRenderer 65 ){ 66 this(nodeRenderer, fileNodeRenderer, generalizationRenderer, 67 compositionRenderer, referenceRenderer,fileEdgeRenderer, null ); 68 69 } 70 71 75 public FindUsagesRendererFactory( 76 NbLabelRenderer nodeRenderer, 77 NbLabelRenderer fileNodeRenderer, 78 Renderer generalizationRenderer, 79 Renderer compositionRenderer, 80 Renderer referenceRenderer, 81 Renderer fileEdgeRenderer, 82 Renderer aggregateRenderer 83 ) { 84 this.nodeRenderer = nodeRenderer; 85 nodeRenderer.setVerticalPadding(5); 86 nodeRenderer.setHorizontalPadding(5); 87 this.fileNodeRenderer = fileNodeRenderer; 88 this.aggregateRenderer = aggregateRenderer; 89 fileNodeRenderer.setRoundedCorner(10,10); fileNodeRenderer.setVerticalPadding(5); 91 fileNodeRenderer.setHorizontalPadding(5); 92 this.queryNodeRenderer = new NbLabelRenderer(); 93 queryNodeRenderer.setRoundedCorner(20,20); 94 queryNodeRenderer.setVerticalPadding(10); 95 queryNodeRenderer.setHorizontalPadding(10); 96 this.generalizationRenderer = generalizationRenderer; 97 this.compositionRenderer = compositionRenderer; 98 this.referenceRenderer = referenceRenderer; 99 this.fileEdgeRenderer = fileEdgeRenderer; 100 } 102 public Renderer getRenderer(VisualItem visualItem) { 103 if (visualItem instanceof AggregateItem){ 104 return aggregateRenderer; 105 } 106 if ( visualItem instanceof NodeItem ) { 107 if (visualItem.canGetBoolean(AnalysisConstants.IS_FILE_NODE) && 108 visualItem.getBoolean(AnalysisConstants.IS_FILE_NODE)){ 109 return fileNodeRenderer; 110 } 111 else if (visualItem.canGetBoolean(AnalysisConstants.IS_QUERY_NODE) && 112 visualItem.getBoolean(AnalysisConstants.IS_QUERY_NODE)){ 113 return queryNodeRenderer; 114 } 115 else { 116 return nodeRenderer; 117 } 118 }else if ( visualItem instanceof EdgeItem ) { 119 String type = visualItem.getString(AnalysisConstants.EDGE_TYPE); 120 if (type != null && type.equals(AnalysisConstants.GENERALIZATION)){ 121 return generalizationRenderer; 122 }else if (type != null && type.equals(AnalysisConstants.COMPOSITION)){ 123 return compositionRenderer; 124 }else if (type != null && type.equals(AnalysisConstants.REFERENCE)){ 125 return referenceRenderer; 126 } 127 if (visualItem.getString(AnalysisConstants.EDGE_TYPE) != null && 128 visualItem.getString(AnalysisConstants.EDGE_TYPE).equals(AnalysisConstants.FILE_EDGE_TYPE) ){ 129 return fileEdgeRenderer; 130 } 131 } 132 return fileEdgeRenderer; 133 } } | Popular Tags |