public Component prepareRenderer(
     RenderContext<V, E> rc,
     EdgeLabelRenderer graphLabelRenderer,
     Object value,
     boolean isSelected,
     E edge) {
   return rc.getEdgeLabelRenderer()
       .<E>getEdgeLabelRendererComponent(
           rc.getScreenDevice(),
           value,
           rc.getEdgeFontTransformer().transform(edge),
           isSelected,
           edge);
 }
예제 #2
0
 protected void setVertexLabeler(RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   renderContext.setVertexLabelTransformer(new ToStringLabeller<CallGraphNode>());
   Renderer<CallGraphNode, CallGraphLink> renderer = visualizer.getRenderer();
   BasicVertexLabelRenderer<CallGraphNode, CallGraphLink> labelRenderer =
       new BasicVertexLabelRenderer<CallGraphNode, CallGraphLink>();
   labelRenderer.setPosition(Renderer.VertexLabel.Position.CNTR);
   renderer.setVertexLabelRenderer(labelRenderer);
 }
예제 #3
0
 protected void setRenderContextVertexTransformers(
     RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   setVertexLabeler(renderContext);
   renderContext.setVertexFillPaintTransformer(new NodeTypeColorer());
   //	    		MapTransformer.<CallGraphNode, Paint> getInstance(vertexPaints));
   setVertexDrawPaintTransformer(renderContext);
   setVertexShapeTransformer(renderContext);
 }
예제 #4
0
  protected void setRenderContextEdgeTransformers(
      RenderContext<CallGraphNode, CallGraphLink> renderContext) {
    setEdgeLabeler(renderContext);
    renderContext.setEdgeDrawPaintTransformer(
        MapTransformer.<CallGraphLink, Paint>getInstance(edgePaints));
    renderContext.setEdgeStrokeTransformer(
        new Transformer<CallGraphLink, Stroke>() {
          protected final Stroke THIN = new BasicStroke(1);
          protected final Stroke THICK = new BasicStroke(2);

          public Stroke transform(CallGraphLink e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY) return THIN;
            else return THICK;
          }
        });
  }
예제 #5
0
 protected void setEdgeLabeler(RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   ToStringLabeller<CallGraphLink> toStringLabeller = new ToStringLabeller<CallGraphLink>();
   renderContext.setEdgeLabelTransformer(toStringLabeller);
   Renderer<CallGraphNode, CallGraphLink> renderer = visualizer.getRenderer();
   BasicEdgeLabelRenderer<CallGraphNode, CallGraphLink> labelRenderer =
       new BasicEdgeLabelRenderer<CallGraphNode, CallGraphLink>();
   // labelRenderer.setPosition(Renderer.EdgeLabel.Position.CNTR);
   renderer.setEdgeLabelRenderer(labelRenderer);
 }
예제 #6
0
 /**
  * create an instance with passed values
  *
  * @param in override value for scale in
  * @param out override value for scale out
  */
 public AnnotatingModalGraphMouse(
     RenderContext<V, E> rc,
     AnnotatingGraphMousePlugin<V, E> annotatingPlugin,
     float in,
     float out) {
   super(in, out);
   this.rc = rc;
   this.basicTransformer = rc.getMultiLayerTransformer();
   this.annotatingPlugin = annotatingPlugin;
   loadPlugins();
   setModeKeyListener(new ModeKeyAdapter(this));
 }
예제 #7
0
 protected void setVertexDrawPaintTransformer(
     RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   renderContext.setVertexDrawPaintTransformer(
       new Transformer<CallGraphNode, Paint>() {
         public Paint transform(CallGraphNode node) {
           PickedState<CallGraphNode> pickedState = visualizer.getPickedVertexState();
           if (pickedState.isPicked(node)) {
             return PICKED_COLOR;
           } else {
             return UNPICKED_COLOR;
           }
         }
       });
 }
  @Override
  public void labelEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e, String label) {
    if (label == null || label.length() == 0) {
      return;
    }

    Graph<V, E> graph = layout.getGraph();
    // don't draw edge if either incident vertex is not drawn
    Pair<V> endpoints = graph.getEndpoints(e);
    V v1 = endpoints.getFirst();
    V v2 = endpoints.getSecond();
    if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V>getInstance(graph, v1))
        || !rc.getVertexIncludePredicate()
            .evaluate(Context.<Graph<V, E>, V>getInstance(graph, v2))) {
      return;
    }

    Point2D p1 = layout.transform(v1);
    Point2D p2 = layout.transform(v2);
    p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p1);
    p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p2);
    float x1 = (float) p1.getX();
    float y1 = (float) p1.getY();
    float x2 = (float) p2.getX();
    float y2 = (float) p2.getY();

    GraphicsDecorator g = rc.getGraphicsContext();
    float distX = x2 - x1;
    float distY = y2 - y1;
    double totalLength = Math.sqrt(distX * distX + distY * distY);

    double closeness =
        rc.getEdgeLabelClosenessTransformer()
            .transform(Context.<Graph<V, E>, E>getInstance(graph, e))
            .doubleValue();

    int posX = (int) (x1 + (closeness) * distX);
    int posY = (int) (y1 + (closeness) * distY);

    int xDisplacement = 0;
    int yDisplacement = 0;

    /*
     * BUG 1: change X and Y in distXXX xDisplacement = (int) (rc.getLabelOffset() * (distY /
     * totalLength)); yDisplacement = (int) (rc.getLabelOffset() * (-distX / totalLength));
     */

    xDisplacement = (int) (rc.getLabelOffset() * (distX / totalLength));
    yDisplacement = (int) (rc.getLabelOffset() * (-distY / totalLength));

    // BUG 2
    /*
     * Component component = prepareRenderer(rc, rc.getEdgeLabelRenderer(), label,
     * rc.getPickedEdgeState().isPicked(e), e); Dimension d = component.getPreferredSize();
     * Shape edgeShape = rc.getEdgeShapeTransformer().transform(Context.<Graph<V, E>, E>
     * getInstance(graph, e)); double parallelOffset = 1;
     *
     * parallelOffset -= rc.getParallelEdgeIndexFunction().getIndex(graph, e);
     *
     * if (edgeShape instanceof Ellipse2D) { parallelOffset +=
     * edgeShape.getBounds().getHeight(); parallelOffset = -parallelOffset; }
     *
     * parallelOffset *= d.height;
     */

    AffineTransform old = g.getTransform();
    AffineTransform xform = new AffineTransform(old);
    xform.translate(posX + xDisplacement, posY + yDisplacement);

    // BUG 3
    /*
     * double dx = x2 - x1; double dy = y2 - y1; if
     * (rc.getEdgeLabelRenderer().isRotateEdgeLabels()) { double theta = Math.atan2(dy, dx); if
     * (dx < 0) { theta += Math.PI; } xform.rotate(theta); } if (dx < 0) { parallelOffset =
     * -parallelOffset; }
     */

    double parallelOffset = 0.0d;
    Component component =
        prepareRenderer(
            rc, rc.getEdgeLabelRenderer(), label, rc.getPickedEdgeState().isPicked(e), e);
    Dimension d = component.getPreferredSize();
    xform.translate(-d.width / 2.0d, -(d.height / 2.0d - parallelOffset));
    g.setTransform(xform);
    g.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);
    g.setTransform(old);
  }
예제 #9
0
 protected void setVertexShapeTransformer(
     RenderContext<CallGraphNode, CallGraphLink> renderContext) {
   CallGraphNodeShapeTransformer vertexShapeTransformer =
       new CallGraphNodeShapeTransformer(graph.getJungGraph());
   renderContext.setVertexShapeTransformer(vertexShapeTransformer);
 }