Java Code Examples for org.jfree.data.Range#constrain()

The following examples show how to use org.jfree.data.Range#constrain() . 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: ShortTextTitle.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 2
Source File: ShortTextTitle.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 3
Source File: ShortTextTitle.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 4
Source File: ShortTextTitle.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 5
Source File: RangeTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests the constrain() method for various values.
 */
public void testConstrain() {
    Range r1 = new Range(0.0, 1.0);

    double d = r1.constrain(0.5);
    assertEquals(0.5, d, 0.0000001);

    d = r1.constrain(0.0);
    assertEquals(0.0, d, 0.0000001);

    d = r1.constrain(1.0);
    assertEquals(1.0, d, 0.0000001);

    d = r1.constrain(-1.0);
    assertEquals(0.0, d, 0.0000001);

    d = r1.constrain(2.0);
    assertEquals(1.0, d, 0.0000001);

    d = r1.constrain(Double.POSITIVE_INFINITY);
    assertEquals(1.0, d, 0.0000001);

    d = r1.constrain(Double.NEGATIVE_INFINITY);
    assertEquals(0.0, d, 0.0000001);

    d = r1.constrain(Double.NaN);
    assertTrue(Double.isNaN(d));
}
 
Example 6
Source File: RangeTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests the constrain() method for various values.
 */
public void testConstrain() {
    Range r1 = new Range(0.0, 1.0);
    
    double d = r1.constrain(0.5);
    assertEquals(0.5, d, 0.0000001);
    
    d = r1.constrain(0.0);
    assertEquals(0.0, d, 0.0000001);

    d = r1.constrain(1.0);
    assertEquals(1.0, d, 0.0000001);
    
    d = r1.constrain(-1.0);
    assertEquals(0.0, d, 0.0000001);
    
    d = r1.constrain(2.0);
    assertEquals(1.0, d, 0.0000001);

    d = r1.constrain(Double.POSITIVE_INFINITY);
    assertEquals(1.0, d, 0.0000001);

    d = r1.constrain(Double.NEGATIVE_INFINITY);
    assertEquals(0.0, d, 0.0000001);

    d = r1.constrain(Double.NaN);
    assertTrue(Double.isNaN(d));
}
 
Example 7
Source File: ShortTextTitle.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 8
Source File: ShortTextTitle.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 9
Source File: TextTitle.java    From openstock with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 10
Source File: TextTitle.java    From ccu-historian with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 11
Source File: TextTitle.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 12
Source File: TextTitle.java    From ECG-Viewer with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 13
Source File: TextTitle.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 14
Source File: ShortTextTitle.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 15
Source File: TextTitle.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 16
Source File: TextTitle.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}