Java Code Examples for java.awt.geom.CubicCurve2D#setCurve()

The following examples show how to use java.awt.geom.CubicCurve2D#setCurve() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluxDocumento.java    From brModelo with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: LivreBase.java    From brModelo with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: RenderTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: RenderTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 5
Source File: RenderTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: RenderTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: RenderTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 8
Source File: RenderTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: RenderTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 10
Source File: RenderTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: TreeViewer.java    From codebuff with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
		}
	}
}
 
Example 12
Source File: RenderTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 13
Source File: Bezier.java    From workcraft with MIT License 5 votes vote down vote up
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;
}
 
Example 14
Source File: RenderTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 15
Source File: PiePlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);

}
 
Example 16
Source File: PiePlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);

}
 
Example 17
Source File: PiePlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);

}
 
Example 18
Source File: PiePlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);

}
 
Example 19
Source File: PiePlot.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);

}
 
Example 20
Source File: PiePlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);

}