java.awt.geom.CubicCurve2D#setCurve ( )源码实例Demo

下面列出了java.awt.geom.CubicCurve2D#setCurve ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: brModelo   文件: LivreBase.java
public Shape getRegiaoDocumento() {
    if (Regiao == null) {
        final int v1 = getHeight() / 3;
        final int h1 = getWidth() / 2;
        final int repo = v1 / 3;
        final int L = getLeft();
        final int T = getTop();
        final int TH = T + getHeight() - repo;
        final int LW = L + getWidth();
        CubicCurve2D c = new CubicCurve2D.Double();
        c.setCurve(L, TH, L + h1, TH + v1, LW - h1, TH - v1, LW, TH);
        GeneralPath pa = new GeneralPath();

        pa.moveTo(LW, TH);
        pa.lineTo(LW, T);
        pa.lineTo(L, T);
        pa.lineTo(L, TH);
        pa.append(c, true);
        Regiao = pa;
        final int ptToMove = 3;
        this.reposicionePonto[ptToMove] = new Point(0, -repo);
        ptsToMove[ptToMove] = 1;
    }
    return Regiao;
}
 
源代码2 项目: brModelo   文件: FluxDocumento.java
@Override
public Shape getRegiao() {
    if (Regiao == null) {
        final int v1 = getHeight() / 3;
        final int h1 = getWidth() / 2;
        final int repo = v1 / 3;
        final int L = getLeft();
        final int T = getTop();
        final int TH = T + getHeight() - repo;
        final int LW = L + getWidth();
        CubicCurve2D c = new CubicCurve2D.Double();
        c.setCurve(L, TH, L + h1, TH + v1, LW - h1, TH - v1, LW, TH);
        GeneralPath pa = new GeneralPath();

        pa.moveTo(LW, TH);
        pa.lineTo(LW, T);
        pa.lineTo(L, T);
        pa.lineTo(L, TH);
        pa.append(c, true);
        Regiao = pa;
        setReposicionePontoAbaixo(new Point(0, -repo));        
        ptsToMove[ptToMove] = 1;
    }
    return Regiao;
}
 
源代码3 项目: dragonwell8_jdk   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    FillCubics.Context cctx = (FillCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.fill(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码4 项目: workcraft   文件: Bezier.java
private CubicCurve2D getPartialCurve(double tStart, double tEnd) {
    CubicCurve2D fullCurve = new CubicCurve2D.Double();
    fullCurve.setCurve(connectionInfo.getFirstCenter(), cp1.getPosition(), cp2.getPosition(), connectionInfo.getSecondCenter());
    CurveSplitResult firstSplit = Geometry.splitCubicCurve(fullCurve, tStart);
    double t = (tEnd - tStart) / (1 - tStart);
    return Geometry.splitCubicCurve(firstSplit.curve2, t).curve1;
}
 
源代码5 项目: openjdk-8   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    DrawCubics.Context cctx = (DrawCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.draw(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码6 项目: codebuff   文件: TreeViewer.java
protected void paintEdges(Graphics g, Tree parent) {
	if (!getTree().isLeaf(parent)) {
           BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
                   BasicStroke.JOIN_ROUND);
           ((Graphics2D)g).setStroke(stroke);

		Rectangle2D.Double parentBounds = getBoundsOfNode(parent);
		double x1 = parentBounds.getCenterX();
		double y1 = parentBounds.getMaxY();
		for (Tree child : getTree().getChildren(parent)) {
			Rectangle2D.Double childBounds = getBoundsOfNode(child);
			double x2 = childBounds.getCenterX();
			double y2 = childBounds.getMinY();
			if (getUseCurvedEdges()) {
				CubicCurve2D c = new CubicCurve2D.Double();
				double ctrlx1 = x1;
				double ctrly1 = (y1+y2)/2;
				double ctrlx2 = x2;
				double ctrly2 = y1;
				c.setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2);
				((Graphics2D) g).draw(c);
			} else {
				g.drawLine((int) x1, (int) y1,
						   (int) x2, (int) y2);
			}
			paintEdges(g, child);
		}
	}
}
 
源代码7 项目: jdk8u-jdk   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    FillCubics.Context cctx = (FillCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.fill(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码8 项目: jdk8u-dev-jdk   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    DrawCubics.Context cctx = (DrawCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.draw(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    FillCubics.Context cctx = (FillCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.fill(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码10 项目: openjdk-jdk9   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    FillCubics.Context cctx = (FillCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.fill(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码11 项目: jdk8u_jdk   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    FillCubics.Context cctx = (FillCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.fill(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码12 项目: hottub   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    DrawCubics.Context cctx = (DrawCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.draw(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码13 项目: jdk8u_jdk   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    DrawCubics.Context cctx = (DrawCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.draw(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码14 项目: hottub   文件: RenderTests.java
public void runTest(Object ctx, int numReps) {
    FillCubics.Context cctx = (FillCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g2d.fill(curve);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
源代码15 项目: astor   文件: PiePlot.java
/**
 * Draws a section label on the right side of the pie chart.
 *
 * @param g2  the graphics device.
 * @param state  the state.
 * @param record  the label record.
 */
protected void drawRightLabel(Graphics2D g2, PiePlotState state,
                              PieLabelRecord record) {

    double anchorX = state.getLinkArea().getMaxX();
    double targetX = anchorX + record.getGap();
    double targetY = record.getAllocatedY();

    if (this.labelLinksVisible) {
        double theta = record.getAngle();
        double linkX = state.getPieCenterX() + Math.cos(theta)
                * state.getPieWRadius() * record.getLinkPercent();
        double linkY = state.getPieCenterY() - Math.sin(theta)
                * state.getPieHRadius() * record.getLinkPercent();
        double elbowX = state.getPieCenterX() + Math.cos(theta)
                * state.getLinkArea().getWidth() / 2.0;
        double elbowY = state.getPieCenterY() - Math.sin(theta)
                * state.getLinkArea().getHeight() / 2.0;
        double anchorY = elbowY;
        g2.setPaint(this.labelLinkPaint);
        g2.setStroke(this.labelLinkStroke);
        PieLabelLinkStyle style = getLabelLinkStyle();
        if (style.equals(PieLabelLinkStyle.STANDARD)) {
            g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
        }
        else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
            QuadCurve2D q = new QuadCurve2D.Float();
            q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
            g2.draw(q);
            g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
        }
        else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
            CubicCurve2D c = new CubicCurve2D .Float();
            c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY,
                    linkX, linkY);
            g2.draw(c);
        }
    }

    TextBox tb = record.getLabel();
    tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.LEFT);

}
 
源代码16 项目: openstock   文件: PiePlot.java
/**
 * Draws a section label on the right side of the pie chart.
 *
 * @param g2  the graphics device.
 * @param state  the state.
 * @param record  the label record.
 */
protected void drawRightLabel(Graphics2D g2, PiePlotState state,
                              PieLabelRecord record) {

    double anchorX = state.getLinkArea().getMaxX();
    double targetX = anchorX + record.getGap();
    double targetY = record.getAllocatedY();

    if (this.labelLinksVisible) {
        double theta = record.getAngle();
        double linkX = state.getPieCenterX() + Math.cos(theta)
                * state.getPieWRadius() * record.getLinkPercent();
        double linkY = state.getPieCenterY() - Math.sin(theta)
                * state.getPieHRadius() * record.getLinkPercent();
        double elbowX = state.getPieCenterX() + Math.cos(theta)
                * state.getLinkArea().getWidth() / 2.0;
        double elbowY = state.getPieCenterY() - Math.sin(theta)
                * state.getLinkArea().getHeight() / 2.0;
        double anchorY = elbowY;
        g2.setPaint(this.labelLinkPaint);
        g2.setStroke(this.labelLinkStroke);
        PieLabelLinkStyle style = getLabelLinkStyle();
        if (style.equals(PieLabelLinkStyle.STANDARD)) {
            g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
        }
        else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
            QuadCurve2D q = new QuadCurve2D.Float();
            q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
            g2.draw(q);
            g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
        }
        else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
            CubicCurve2D c = new CubicCurve2D .Float();
            c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY,
                    linkX, linkY);
            g2.draw(c);
        }
    }

    TextBox tb = record.getLabel();
    tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.LEFT);

}
 
源代码17 项目: buffer_bci   文件: PiePlot.java
/**
 * Draws a section label on the right side of the pie chart.
 *
 * @param g2  the graphics device.
 * @param state  the state.
 * @param record  the label record.
 */
protected void drawRightLabel(Graphics2D g2, PiePlotState state,
                              PieLabelRecord record) {

    double anchorX = state.getLinkArea().getMaxX();
    double targetX = anchorX + record.getGap();
    double targetY = record.getAllocatedY();

    if (this.labelLinksVisible) {
        double theta = record.getAngle();
        double linkX = state.getPieCenterX() + Math.cos(theta)
                * state.getPieWRadius() * record.getLinkPercent();
        double linkY = state.getPieCenterY() - Math.sin(theta)
                * state.getPieHRadius() * record.getLinkPercent();
        double elbowX = state.getPieCenterX() + Math.cos(theta)
                * state.getLinkArea().getWidth() / 2.0;
        double elbowY = state.getPieCenterY() - Math.sin(theta)
                * state.getLinkArea().getHeight() / 2.0;
        double anchorY = elbowY;
        g2.setPaint(this.labelLinkPaint);
        g2.setStroke(this.labelLinkStroke);
        PieLabelLinkStyle style = getLabelLinkStyle();
        if (style.equals(PieLabelLinkStyle.STANDARD)) {
            g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
        }
        else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
            QuadCurve2D q = new QuadCurve2D.Float();
            q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
            g2.draw(q);
            g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
        }
        else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
            CubicCurve2D c = new CubicCurve2D .Float();
            c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY,
                    linkX, linkY);
            g2.draw(c);
        }
    }

    TextBox tb = record.getLabel();
    tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.LEFT);

}
 
源代码18 项目: buffer_bci   文件: PiePlot.java
/**
 * Draws a section label on the left side of the pie chart.
 *
 * @param g2  the graphics device.
 * @param state  the state.
 * @param record  the label record.
 */
protected void drawLeftLabel(Graphics2D g2, PiePlotState state,
                             PieLabelRecord record) {

    double anchorX = state.getLinkArea().getMinX();
    double targetX = anchorX - record.getGap();
    double targetY = record.getAllocatedY();

    if (this.labelLinksVisible) {
        double theta = record.getAngle();
        double linkX = state.getPieCenterX() + Math.cos(theta)
                * state.getPieWRadius() * record.getLinkPercent();
        double linkY = state.getPieCenterY() - Math.sin(theta)
                * state.getPieHRadius() * record.getLinkPercent();
        double elbowX = state.getPieCenterX() + Math.cos(theta)
                * state.getLinkArea().getWidth() / 2.0;
        double elbowY = state.getPieCenterY() - Math.sin(theta)
                * state.getLinkArea().getHeight() / 2.0;
        double anchorY = elbowY;
        g2.setPaint(this.labelLinkPaint);
        g2.setStroke(this.labelLinkStroke);
        PieLabelLinkStyle style = getLabelLinkStyle();
        if (style.equals(PieLabelLinkStyle.STANDARD)) {
            g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
        }
        else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
            QuadCurve2D q = new QuadCurve2D.Float();
            q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
            g2.draw(q);
            g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
        }
        else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
            CubicCurve2D c = new CubicCurve2D .Float();
            c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY,
                    linkX, linkY);
            g2.draw(c);
        }
    }
    TextBox tb = record.getLabel();
    tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.RIGHT);

}
 
源代码19 项目: buffer_bci   文件: PiePlot.java
/**
 * Draws a section label on the left side of the pie chart.
 *
 * @param g2  the graphics device.
 * @param state  the state.
 * @param record  the label record.
 */
protected void drawLeftLabel(Graphics2D g2, PiePlotState state,
                             PieLabelRecord record) {

    double anchorX = state.getLinkArea().getMinX();
    double targetX = anchorX - record.getGap();
    double targetY = record.getAllocatedY();

    if (this.labelLinksVisible) {
        double theta = record.getAngle();
        double linkX = state.getPieCenterX() + Math.cos(theta)
                * state.getPieWRadius() * record.getLinkPercent();
        double linkY = state.getPieCenterY() - Math.sin(theta)
                * state.getPieHRadius() * record.getLinkPercent();
        double elbowX = state.getPieCenterX() + Math.cos(theta)
                * state.getLinkArea().getWidth() / 2.0;
        double elbowY = state.getPieCenterY() - Math.sin(theta)
                * state.getLinkArea().getHeight() / 2.0;
        double anchorY = elbowY;
        g2.setPaint(this.labelLinkPaint);
        g2.setStroke(this.labelLinkStroke);
        PieLabelLinkStyle style = getLabelLinkStyle();
        if (style.equals(PieLabelLinkStyle.STANDARD)) {
            g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
        }
        else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
            QuadCurve2D q = new QuadCurve2D.Float();
            q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
            g2.draw(q);
            g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
        }
        else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
            CubicCurve2D c = new CubicCurve2D .Float();
            c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY,
                    linkX, linkY);
            g2.draw(c);
        }
    }
    TextBox tb = record.getLabel();
    tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.RIGHT);

}
 
源代码20 项目: ccu-historian   文件: PiePlot.java
/**
 * Draws a section label on the left side of the pie chart.
 *
 * @param g2  the graphics device.
 * @param state  the state.
 * @param record  the label record.
 */
protected void drawLeftLabel(Graphics2D g2, PiePlotState state,
                             PieLabelRecord record) {

    double anchorX = state.getLinkArea().getMinX();
    double targetX = anchorX - record.getGap();
    double targetY = record.getAllocatedY();

    if (this.labelLinksVisible) {
        double theta = record.getAngle();
        double linkX = state.getPieCenterX() + Math.cos(theta)
                * state.getPieWRadius() * record.getLinkPercent();
        double linkY = state.getPieCenterY() - Math.sin(theta)
                * state.getPieHRadius() * record.getLinkPercent();
        double elbowX = state.getPieCenterX() + Math.cos(theta)
                * state.getLinkArea().getWidth() / 2.0;
        double elbowY = state.getPieCenterY() - Math.sin(theta)
                * state.getLinkArea().getHeight() / 2.0;
        double anchorY = elbowY;
        g2.setPaint(this.labelLinkPaint);
        g2.setStroke(this.labelLinkStroke);
        PieLabelLinkStyle style = getLabelLinkStyle();
        if (style.equals(PieLabelLinkStyle.STANDARD)) {
            g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
            g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
        }
        else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
            QuadCurve2D q = new QuadCurve2D.Float();
            q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
            g2.draw(q);
            g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
        }
        else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
            CubicCurve2D c = new CubicCurve2D .Float();
            c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY,
                    linkX, linkY);
            g2.draw(c);
        }
    }
    TextBox tb = record.getLabel();
    tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.RIGHT);

}