Draw a link between 2 notes

@see #getLinkPoints(TwoNotesLink) calculates the best link curve
328817
protected void drawLink(Graphics2D g2, TwoNotesLink slurDef) {
		Point2D[] points = null;
		try {
			points = getLinkPoints(slurDef);
		} catch (Exception e) {
			System.err.println("Exception in drawLink : "+e.getMessage());
			e.printStackTrace();
		}
		if ((points == null) || (points.length != 3))
			return;

		//TODO move this in JSlurOrTie.render(g2);
		JSlurOrTie jSlurDef = getJSlurOrTie(slurDef);
		if (jSlurDef.isTuplet()) {
			//we consider tuplet are always above notes
			if (jSlurDef.getTupletControlPoint() == null) {
				jSlurDef.setTupletControlPoint(new Point2D.Double(
					points[START].getX()+(points[END].getX()-points[START].getX())/2,
					points[START].getY()-getMetrics().getSlurAnchorYOffset()*5
				));
			}
			points[CONTROL].setLocation(
				jSlurDef.getTupletControlPoint()
			);
		}
		
//		System.out.println("drawLink "+slurDef);
//		System.out.println("  - start = "+points[START]);
//		System.out.println("  - end = "+points[END]);

		Color previousColor = g2.getColor();
		boolean isAboveNotes = false;
		if (points[CONTROL].getY() < points[START].getY()
			&& (points[CONTROL].getY() < points[END].getY()))
			isAboveNotes = true;
		else if (points[CONTROL].getY() > points[START].getY()
				&& (points[CONTROL].getY() > points[END].getY()))
			isAboveNotes = false;
		else {//problem, mark it red
			g2.setColor(Color.RED);
		}

		GeneralPath path = new GeneralPath();
		path.moveTo((float)points[START].getX(), (float)points[START].getY());
		QuadCurve2D q = new QuadCurve2D.Float();
		q.setCurve(
				points[START],
				newControl(points[START], points[CONTROL], points[END]),
				points[END]);
		path.append(q, true);
		q = new QuadCurve2D.Float();
		double slurThickness = Math.max(1.0,
				getTemplate().getAttributeSize(
						ScoreAttribute.SLUR_THICKNESS));
		if (!isAboveNotes) {
			points[CONTROL].setLocation(points[CONTROL].getX(),
				points[CONTROL].getY()+slurThickness);
		} else {
			points[CONTROL].setLocation(points[CONTROL].getX(),
					points[CONTROL].getY()-slurThickness);
		}
		q.setCurve(
				points[END],
				newControl(points[START], points[CONTROL], points[END]),
				points[START]);
		path.append(q, true);
		g2.fill(path);
		g2.draw(path);

		g2.setColor(previousColor);
	}
159889
function curve( $x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3 )
    {
        // in the current line style, draw a bezier curve from (x0,y0) to (x3,y3) using the other two points
        // as the control points for the curve.
        $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F',$x0).' '.sprintf('%.3F',$y0).' m '.sprintf('%.3F',$x1).' '.sprintf('%.3F',$y1);
        $this->objects[$this->currentContents]['c'].= ' '.sprintf('%.3F',$x2).' '.sprintf('%.3F',$y2).' '.sprintf('%.3F',$x3).' '.sprintf('%.3F',$y3).' c S';
    }
1086173
@Pure
	public final void toPath2D(Path2d path) {
		// loop on parts and build the path to draw
		boolean firstPoint;
		for (final PointGroup grp : groups()) {
			firstPoint = true;
			for (final Point2d pts : grp) {
				final double x = pts.getX();
				final double y = pts.getY();
				if (firstPoint) {
					path.moveTo(x, y);
					firstPoint = false;
				} else {
					path.lineTo(x, y);
				}
			}
		}
	}
811827
private void addChartLinks() {
        this.add(new UpdateChartJsLink("LineChartBasic", ChartjsConfigurations.LINE_BASIC.toString()));
        this.add(new UpdateChartJsLink("BarChartVertical" , ChartjsConfigurations.BAR_VERTICAL.toString()));
        this.add(new UpdateChartJsLink("LineChartMultiAxis", ChartjsConfigurations.LINE_MULTI_AXIS.toString()));
        this.add(new UpdateChartJsLink("LineChartStepped", ChartjsConfigurations.LINE_STEPPED.toString()));
        this.add(new UpdateChartJsLink("LineChartInterpolated", ChartjsConfigurations.LINE_INTERPOLATED.toString()));
        this.add(new UpdateChartJsLink("LineStyles", ChartjsConfigurations.LINE_STYLES.toString()));
        this.add(new UpdateChartJsLink("PointStyles", ChartjsConfigurations.POINT_STYLES.toString()));
        this.add(new UpdateChartJsLink("PointSizes", ChartjsConfigurations.POINT_SIZES.toString()));
        this.add(new UpdateChartJsLink("BarChartHorizontal", ChartjsConfigurations.BAR_HORIZONTAL.toString()));
        this.add(new UpdateChartJsLink("BarChartStacked", ChartjsConfigurations.BAR_STACKED.toString()));
        this.add(new UpdateChartJsLink("BarChartStackedGroup", ChartjsConfigurations.BAR_STACKED_GROUP.toString()));
        this.add(new UpdateChartJsLink("BarChartMultiAxis", ChartjsConfigurations.BAR_MULTI_AXIS.toString()));
        this.add(new UpdateChartJsLink("PieChart", ChartjsConfigurations.PIE.toString()));
        this.add(new UpdateChartJsLink("AreaLineBoundariesChart", ChartjsConfigurations.AREA_LINE_BOUNDARIES.toString()));
        this.add(new UpdateChartJsLink("LineChartStacked", ChartjsConfigurations.LINE_STACKED.toString()));
        this.add(new UpdateChartJsLink("LineChartDataset", ChartjsConfigurations.LINE_DATASET.toString()));
        this.add(new UpdateChartJsLink("RadarChart", ChartjsConfigurations.RADAR.toString()));
        this.add(new UpdateChartJsLink("DoughnutChart", ChartjsConfigurations.DOUGHNUT.toString()));
        this.add(new UpdateChartJsLink("PolarAreaChart", ChartjsConfigurations.POLAR_AREA.toString()));
        this.add(new UpdateChartJsLink("ScatterChart", ChartjsConfigurations.SCATTER.toString()));
        this.add(new UpdateChartJsLink("ScatterChartMultiAxis", ChartjsConfigurations.SCATTER_MULTI_AXIS.toString()));
        this.add(new UpdateChartJsLink("ComboBarLineChart", ChartjsConfigurations.COMBO_BAR_LINE.toString()));
        this.add(new UpdateChartJsLink("LegendPosition", ChartjsConfigurations.LEGEND_POSITION.toString()));
        this.add(new UpdateChartJsLink("StepSize", ChartjsConfigurations.STEP_SIZE.toString()));
        this.add(new UpdateChartJsLink("MinMax", ChartjsConfigurations.MIN_MAX.toString()));
        this.add(new UpdateChartJsLink("GridLines", ChartjsConfigurations.GRID_LINES.toString()));
        this.add(new UpdateChartJsLink("MultilineLabels", ChartjsConfigurations.MULTILINE_LABELS.toString()));
        this.add(new UpdateChartJsLink("LogarithmicLineChart", ChartjsConfigurations.LINE_LOGARITHMIC.toString()));
        this.add(new UpdateChartJsLink("LogarithmicScatterChart", ChartjsConfigurations.SCATTER_LOGARITHMIC.toString()));
        this.add(new UpdateChartJsLink("BubbleChart", ChartjsConfigurations.BUBBLE.toString()));
        this.add(new UpdateChartJsLink("FilteringLabels", ChartjsConfigurations.FILTERING_LABELS.toString()));
        this.add(new UpdateChartJsLink("TimeLine", ChartjsConfigurations.TIME_LINE.toString()));
        this.add(new UpdateChartJsLink("NonNumeric", ChartjsConfigurations.NON_NUMERIC.toString()));
        this.add(new UpdateChartJsLink("TimePoint", ChartjsConfigurations.TIME_POINT.toString()));
        this.add(new UpdateChartJsLink("TimeSeries", ChartjsConfigurations.TIME_SERIES.toString()));
        this.add(new UpdateChartJsLink("TimeCombo", ChartjsConfigurations.TIME_COMBO.toString()));
        this.add(new UpdateChartJsLink("OtherRadar", ChartjsConfigurations.RADAR_2.toString()));
        this.add(new UpdateChartJsLink("Tooltip", ChartjsConfigurations.TOOLTIP.toString()));
        this.add(new UpdateChartJsLink("TooltipHtml", ChartjsConfigurations.TOOLTIP_HTML.toString()));
        this.add(new UpdateChartJsLink("LegendPointStyle", ChartjsConfigurations.LEGEND_POINT_STYLE.toString()));
        this.add(new UpdateChartJsLink("LineChartProgressBar", ChartjsConfigurations.LINE_PROGRESS_BAR.toString()));
        this.add(new UpdateChartJsLink("DataLabellingChart", ChartjsConfigurations.DATA_LABELLING.toString()));
        this.add(new UpdateChartJsLink("TooltipInteractions", ChartjsConfigurations.TOOLTIP_INTERACTIONS.toString()));
    }
202320
public void setLine(double... points) {
        path = new GeneralPath();
        path.moveTo((float) points[0], (float) points[1]);
        segments = new Shape[points.length / 2 - 1];

        for (int i = 2; i < points.length;) {
            switch (points.length - i) {
            case 2:
                lastPart = new Line2D.Float((float) path.getCurrentPoint().getX(), (float) path
                        .getCurrentPoint().getY(), (float) points[i], (float) points[i + 1]);
                path.append(lastPart, true);
                segments[i / 2 - 1] = lastPart;
                i += 2;
                break;
            case 4:
                lastPart = new QuadCurve2D.Float((float) path.getCurrentPoint().getX(),
                        (float) path.getCurrentPoint().getY(), (float) points[i],
                        (float) points[i + 1], (float) points[i + 2], (float) points[i + 3]);
                path.append(lastPart, true);
                segments[i / 2 - 1] = lastPart;
                segments[i / 2] = lastPart;
                i += 4;
                break;
            case 6:
                lastPart = new CubicCurve2D.Double(path.getCurrentPoint().getX(), path
                        .getCurrentPoint().getY(), points[i], points[i + 1], points[i + 2],
                        points[i + 3], points[i + 4], points[i + 5]);
                path.append(lastPart, true);
                segments[i / 2 - 1] = lastPart;
                segments[i / 2] = lastPart;
                segments[i / 2 + 1] = lastPart;
                i += 6;
                break;
            default: // use two points and add one extra between 2nd and 3rd
                float x = (float) (points[i + 2] + points[i + 4]) / 2F;
                float y = (float) (points[i + 3] + points[i + 5]) / 2F;

                lastPart = new CubicCurve2D.Double(path.getCurrentPoint().getX(), path
                        .getCurrentPoint().getY(), points[i], points[i + 1], points[i + 2],
                        points[i + 3], x, y);

                path.append(lastPart, true);
                segments[i / 2 - 1] = lastPart;
                segments[i / 2] = lastPart;

                i += 4;
            }
        }
    }
676197
@Override
	public Links findLinksWithRel(LinkRelation relation, InputStream representation) {

		return relation.isSameAs(IanaLinkRelations.SELF) //
				? addSelfLink(super.findLinksWithRel(relation, representation), representation) //
				: super.findLinksWithRel(relation, representation);

	}
324727
public EvernoteHtmlHelper getLinkedHtmlHelper(@NonNull LinkedNotebook linkedNotebook) throws EDAMUserException, EDAMSystemException, EDAMNotFoundException, TException {
        String key = linkedNotebook.getGuid();

        EvernoteHtmlHelper htmlHelper = mLinkedHtmlHelper.get(key);
        if (htmlHelper == null) {
            String url = linkedNotebook.getNoteStoreUrl();

            EvernoteNoteStoreClient client = getNoteStoreClient(url, EvernotePreconditions.checkNotEmpty(mEvernoteSession.getAuthToken()));
            AuthenticationResult authenticationResult = client.authenticateToSharedNotebook(linkedNotebook.getShareKey());

            htmlHelper = createHtmlHelper(authenticationResult.getAuthenticationToken());

            mLinkedHtmlHelper.put(key, htmlHelper);
        }

        return htmlHelper;
    }
779535
private Node<E> _link(Node<E> node1, Node<E> node2) {
	// maybe there is no real unification here
	if(node1 == node2) return node2;
	// from now on, we know that we unify really disjoint trees
	if(node1.rank > node2.rank) {
	    node2.parent = node1;
	    node1.nbElems += node2.nbElems; 
	    return node1;
	}
	else {
	    node1.parent = node2;
	    if (node1.rank == node2.rank) {
		node2.rank++;
	    }
	    node2.nbElems += node1.nbElems;
	    return node2;
	}
    }
894045
@Override
	protected void drawFirstPassShape(Graphics2D g2, int pass, int series, int item, Shape shape) {
		g2.setStroke(getItemStroke(series, item));
		g2.setPaint(getLinePaint(series)); // this line is different from the original
		g2.draw(shape);
	}
961653
@Pure
	public void toPath2D(Path2d path) {
		// loop on parts and build the path to draw
		for (final BusItinerary iti : busItineraries()) {
			iti.toPath2D(path);
		}
	}
1153292
def draw(molecule, TraversalType=SmilesTraversal):
    """"""
    result = []
    atoms = allAtoms = molecule.atoms

    visitedAtoms = {}
    #
    # Traverse all components of the graph to form
    # the output string
    while atoms:
        atom = _get_lowest_symorder(atoms)
        visitedAtoms[atom] = 1

        visitedBonds = {}
        nextTraverse = TraversalType()
        atomsUsed, bondsUsed = [], []
        _traverse(atom, nextTraverse, None,
                  visitedAtoms, visitedBonds,
                  atomsUsed, bondsUsed, TraversalType)
        atoms = []
        for atom in allAtoms:
            if not visitedAtoms.has_key(atom):
                atoms.append(atom)
        assert nextTraverse.atoms == atomsUsed
        assert nextTraverse.bonds == bondsUsed, "%s %s"%(
            nextTraverse.bonds, bondsUsed)
        

        result.append((str(nextTraverse),
                       atomsUsed, bondsUsed))

    result.sort()
    fragments = []
    for r in result:
        fragments.append(r[0])

    return ".".join(fragments), result
778802
function breadcrumbPoints(d, i) {
  var points = [];
  points.push("0,0");
  points.push(b.w + ",0");
  points.push(b.w + b.t + "," + (b.h / 2));
  points.push(b.w + "," + b.h);
  points.push("0," + b.h);
  if (i > 0) { // Leftmost breadcrumb; don't include 6th vertex.
    points.push(b.t + "," + (b.h / 2));
  }
  return points.join(" ");
}
293253
public void startLink(final VertexContext startVertex) {
        if (startVertex == null) {
            return;
        }

        final AbstractLayout<Object, JobGraphLink> graphLayout = _graphContext.getGraphLayout();
        final int x = (int) graphLayout.getX(startVertex.getVertex());
        final int y = (int) graphLayout.getY(startVertex.getVertex());

        logger.debug("startLink({})", startVertex);

        _startVertex = startVertex;
        _startPoint = new Point(x, y);

        transformEdgeShape(_startPoint, _startPoint);
        _graphContext.getVisualizationViewer().addPostRenderPaintable(_edgePaintable);
        transformArrowShape(_startPoint, _startPoint);
        _graphContext.getVisualizationViewer().addPostRenderPaintable(_arrowPaintable);
    }
754045
function LinkPO(index) {
    this.index = index;

    this.getLine = () => cy.get('path[class="link"]').then(lines => lines[this.index]);
    this.getStyle = () => this.getLine().invoke("attr", "style");
    this.shouldHaveColor = color => this.getStyle().should("contain", `stroke: ${color};`);
    this.shouldHaveOpacity = opacity => this.getStyle().should("contain", `opacity: ${opacity};`);
    this.hasMarker = () =>
        this.getLine()
            .invoke("attr", "marker-end")
            .should("contain", "url(#marker-");
    this.getLabel = () => this.getLine().siblings();
}
894461
public static ConceptId getResourceEdgeId(TransactionOLTP graph, ConceptId conceptId1, ConceptId conceptId2) {
        if (mayHaveResourceEdge(graph, conceptId1, conceptId2)) {
            Optional<Concept> firstConcept = graph.stream(Graql.match(
                    var("x").id(conceptId1.getValue()),
                    var("y").id(conceptId2.getValue()),
                    var("z").rel(var("x")).rel(var("y")))
                    .get("z"))
                    .map(answer -> answer.get("z"))
                    .findFirst();
            if (firstConcept.isPresent()) {
                return firstConcept.get().id();
            }
        }
        return null;
    }
46783
def curve(bez, draw)
      x1, y1, cx1, cy1 = bez.x1, bez.y1, bez.cx1, bez.cy1
      cx2, cy2, x2, y2 = bez.cx2, bez.cy2, bez.x2, bez.y2
      use_cairo do |cc|
        cc.move_to(x1, y1)
        cc.curve_to(cx1, cy1, cx2, cy2, x2, y2)
        cc.fill_n_stroke(draw)
      end
    end
1247365
public final Link getNextLink() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(this, tc, "getNextLink", _positionString());
        }
        Link nextLink = null;
        LinkedList parent = _parent;
        if (null != parent) {
            nextLink = _parent.getNextLink(this);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(this, tc, "getNextLink", nextLink);
        }
        return nextLink;
    }