Java Code Examples for org.jfree.util.ShapeUtilities#rotateShape()

The following examples show how to use org.jfree.util.ShapeUtilities#rotateShape() . 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: TextBlock.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the bounds of the text block.
 * 
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param anchorX  the x-coordinate for the anchor point.
 * @param anchorY  the y-coordinate for the anchor point.
 * @param anchor  the text block anchor (<code>null</code> not permitted).
 * @param rotateX  the x-coordinate for the rotation point.
 * @param rotateY  the y-coordinate for the rotation point.
 * @param angle  the rotation angle.
 * 
 * @return The bounds.
 */
public Shape calculateBounds(final Graphics2D g2,
                             final float anchorX, final float anchorY, 
                             final TextBlockAnchor anchor,
                             final float rotateX, final float rotateY, 
                             final double angle) {
    
    final Size2D d = calculateDimensions(g2);
    final float[] offsets = calculateOffsets(
        anchor, d.getWidth(), d.getHeight()
    );
    final Rectangle2D bounds = new Rectangle2D.Double(
        anchorX + offsets[0], anchorY + offsets[1], 
        d.getWidth(), d.getHeight()
    );
    final Shape rotatedBounds = ShapeUtilities.rotateShape(
        bounds, angle, rotateX, rotateY
    );
    return rotatedBounds;   
    
}
 
Example 2
Source File: CategoryAxis.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block, 
                                         CategoryLabelPosition position, 
                                         Graphics2D g2) {
                                                
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(
        0.0, 0.0, size.getWidth(), size.getHeight()
    );
    Shape rotatedBox = ShapeUtilities.rotateShape(
        box, position.getAngle(), 0.0f, 0.0f
    );
    double w = rotatedBox.getBounds2D().getWidth() 
               + insets.getTop() + insets.getBottom();
    return w;
    
}
 
Example 3
Source File: CategoryAxis.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block, 
                                          CategoryLabelPosition position, 
                                          Graphics2D g2) {
                                                
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(
        0.0, 0.0, size.getWidth(), size.getHeight()
    );
    Shape rotatedBox = ShapeUtilities.rotateShape(
        box, position.getAngle(), 0.0f, 0.0f
    );
    double h = rotatedBox.getBounds2D().getHeight() 
               + insets.getTop() + insets.getBottom();
    return h;
    
}
 
Example 4
Source File: CategoryAxis.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example 5
Source File: CategoryAxis.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example 6
Source File: CategoryAxis.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example 7
Source File: CategoryAxis.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example 8
Source File: CategoryAxis.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example 9
Source File: CategoryAxis.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example 10
Source File: CategoryAxis.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example 11
Source File: CategoryAxis.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example 12
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example 13
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example 14
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the width of a text block.
 *
 * @param block  the text block.
 * @param position  the position.
 * @param g2  the graphics device.
 *
 * @return The width.
 */
protected double calculateTextBlockWidth(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft()
            + insets.getRight();
    return w;
}
 
Example 15
Source File: CategoryAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A utility method for determining the height of a text block.
 *
 * @param block  the text block.
 * @param position  the label position.
 * @param g2  the graphics device.
 *
 * @return The height.
 */
protected double calculateTextBlockHeight(TextBlock block,
        CategoryLabelPosition position, Graphics2D g2) {
    RectangleInsets insets = getTickLabelInsets();
    Size2D size = block.calculateDimensions(g2);
    Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(),
            size.getHeight());
    Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(),
            0.0f, 0.0f);
    double h = rotatedBox.getBounds2D().getHeight()
               + insets.getTop() + insets.getBottom();
    return h;
}
 
Example 16
Source File: TransitionView.java    From PIPE with MIT License 5 votes vote down vote up
/**
 * Rotate the transition
 *
 * Currently doesn't work
 * @param angle to rotate
 */
public final void rotate(int angle) {
    shape = ShapeUtilities.rotateShape(unrotated, Math.toRadians(angle), 0,0);
    Rectangle bounds = shape.getBounds();
    Rectangle newBounds = new Rectangle((int)(model.getCentre().getX() + bounds.getX()), (int)(model.getCentre().getY() + bounds.getY()), (int) bounds.getWidth() + getComponentDrawOffset(), (int)bounds.getHeight() + getComponentDrawOffset()) ;
    setBounds(newBounds);
}