Search in sources :

Example 1 with DNodeView

use of org.cytoscape.ding.impl.DNodeView in project cytoscape-impl by cytoscape.

the class ArrowAnnotationImpl method getArgMap.

public Map<String, String> getArgMap() {
    Map<String, String> argMap = super.getArgMap();
    argMap.put(TYPE, ArrowAnnotation.class.getName());
    if (this.lineColor != null)
        argMap.put(ARROWCOLOR, convertColor(this.lineColor));
    argMap.put(ARROWTHICKNESS, Float.toString(this.lineWidth));
    if (source != null)
        argMap.put(SOURCEANN, source.getUUID().toString());
    argMap.put(SOURCETYPE, Integer.toString(this.sourceType.ordinal()));
    argMap.put(SOURCESIZE, Double.toString(this.sourceSize));
    if (this.sourceColor != null)
        argMap.put(SOURCECOLOR, convertColor(this.sourceColor));
    if (target != null && target instanceof Point2D) {
        Point2D xy = (Point2D) target;
        argMap.put(TARGETPOINT, Double.toString(xy.getX()) + "," + Double.toString(xy.getY()));
    } else if (target != null && target instanceof Annotation) {
        argMap.put(TARGETANN, ((DingAnnotation) target).getUUID().toString());
    } else if (target != null && target instanceof CyNode) {
        DNodeView nv = (DNodeView) view.getNodeView((CyNode) target);
        double xCenter = nv.getXPosition();
        double yCenter = nv.getYPosition();
        argMap.put(TARGETNODE, Double.toString(xCenter) + "," + Double.toString(yCenter));
    }
    argMap.put(TARGETTYPE, Integer.toString(this.targetType.ordinal()));
    argMap.put(TARGETSIZE, Double.toString(this.targetSize));
    if (this.targetColor != null)
        argMap.put(TARGETCOLOR, convertColor(this.targetColor));
    return argMap;
}
Also used : ArrowAnnotation(org.cytoscape.view.presentation.annotations.ArrowAnnotation) DNodeView(org.cytoscape.ding.impl.DNodeView) Point2D(java.awt.geom.Point2D) CyNode(org.cytoscape.model.CyNode) ArrowAnnotation(org.cytoscape.view.presentation.annotations.ArrowAnnotation) Annotation(org.cytoscape.view.presentation.annotations.Annotation)

Example 2 with DNodeView

use of org.cytoscape.ding.impl.DNodeView in project cytoscape-impl by cytoscape.

the class ArrowAnnotationImpl method getArrowLine.

private Line2D getArrowLine(Object target, DingAnnotation source) {
    if (usedForPreviews) {
        return new Line2D.Double(10.0, shapeHeight / 2, shapeWidth - 20.0, shapeHeight / 2);
    }
    Point2D targetPoint = null;
    Point2D sourceCenter = centerPoint(source.getComponent().getBounds());
    if (target instanceof Point2D) {
        targetPoint = getComponentCoordinates(((Point2D) target).getX(), ((Point2D) target).getY());
    } else if (target instanceof DingAnnotation) {
        DingAnnotation a = (DingAnnotation) target;
        // get the bounds
        Rectangle targetBounds = a.getComponent().getBounds();
        // Find the closest face and return
        targetPoint = findFace(sourceCenter, targetBounds, targetAnchorType);
    } else if (target instanceof CyNode) {
        // get the target point from ding
        DNodeView nv = (DNodeView) view.getNodeView((CyNode) target);
        Rectangle2D nodeBounds = getNodeBounds(nv);
        targetPoint = findFace(sourceCenter, nodeBounds, targetAnchorType);
    }
    Rectangle sourceBounds = source.getComponent().getBounds();
    Point2D sourcePoint = findFace(targetPoint, sourceBounds, sourceAnchorType);
    return new Line2D.Double(sourcePoint, targetPoint);
}
Also used : DNodeView(org.cytoscape.ding.impl.DNodeView) Point2D(java.awt.geom.Point2D) Rectangle(java.awt.Rectangle) Rectangle2D(java.awt.geom.Rectangle2D) CyNode(org.cytoscape.model.CyNode)

Example 3 with DNodeView

use of org.cytoscape.ding.impl.DNodeView in project cytoscape-impl by cytoscape.

the class DummySpacial method getZOrder.

public double getZOrder(long objKey) {
    CyNode node = networkView.getModel().getNode(objKey);
    if (node == null)
        return 0.0;
    DNodeView nodeView = (DNodeView) networkView.getNodeView(node);
    if (!nodeView.isVisible())
        return 0.0;
    return nodeView.getZPosition();
}
Also used : DNodeView(org.cytoscape.ding.impl.DNodeView) CyNode(org.cytoscape.model.CyNode)

Example 4 with DNodeView

use of org.cytoscape.ding.impl.DNodeView in project cytoscape-impl by cytoscape.

the class DummySpacial method exists.

public boolean exists(long objKey, float[] extentsArr, int offset) {
    // We actually ignore everything but the objKey
    CyNode node = networkView.getModel().getNode(objKey);
    if (node == null)
        return false;
    DNodeView nodeView = (DNodeView) networkView.getNodeView(node);
    if (!nodeView.isVisible())
        return false;
    if (extentsArr == null)
        return true;
    return nodeView.getExtents(extentsArr, offset);
}
Also used : DNodeView(org.cytoscape.ding.impl.DNodeView) CyNode(org.cytoscape.model.CyNode)

Aggregations

DNodeView (org.cytoscape.ding.impl.DNodeView)4 CyNode (org.cytoscape.model.CyNode)4 Point2D (java.awt.geom.Point2D)2 Rectangle (java.awt.Rectangle)1 Rectangle2D (java.awt.geom.Rectangle2D)1 Annotation (org.cytoscape.view.presentation.annotations.Annotation)1 ArrowAnnotation (org.cytoscape.view.presentation.annotations.ArrowAnnotation)1