org.jfree.chart.block.BorderArrangement Java Examples

The following examples show how to use org.jfree.chart.block.BorderArrangement. 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: BorderArrangementTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This test is for a particular bug that arose just prior to the release
 * of JFreeChart 1.0.10.  A BorderArrangement with LEFT, CENTRE and RIGHT
 * blocks that is too wide, by default, for the available space, wasn't
 * shrinking the centre block as expected.
 */
public void testBugX() {
    RectangleConstraint constraint = new RectangleConstraint(
            new Range(0.0, 200.0), new Range(0.0, 100.0));
    BlockContainer container = new BlockContainer(new BorderArrangement());
    BufferedImage image = new BufferedImage(200, 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();

    container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT);
    container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT);
    container.add(new EmptyBlock(30.0, 6.0));
    Size2D size = container.arrange(g2, constraint);
    assertEquals(60.0, size.width, EPSILON);
    assertEquals(6.0, size.height, EPSILON);

    container.clear();
    container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT);
    container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT);
    container.add(new EmptyBlock(300.0, 6.0));
    size = container.arrange(g2, constraint);
    assertEquals(200.0, size.width, EPSILON);
    assertEquals(6.0, size.height, EPSILON);


}
 
Example #2
Source File: ChartImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public void drawLegend(JFreeChart chart){
//remove ipotetical other legend
chart.removeLegend();
BlockContainer wrapper = new BlockContainer(new BorderArrangement());
wrapper.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0));

/*LabelBlock titleBlock = new LabelBlock("Legend Items:",
		new Font("SansSerif", Font.BOLD, 12));
titleBlock.setPadding(5, 5, 5, 5);
wrapper.add(titleBlock, RectangleEdge.TOP);*/

LegendTitle legend = new LegendTitle(chart.getPlot());
BlockContainer items = legend.getItemContainer();
if(styleLegend!=null && styleLegend.getFont()!=null){
	legend.setItemFont(new Font(styleLegend.getFontName(), Font.BOLD, styleLegend.getSize()));
}

items.setPadding(2, 5, 5, 2);
wrapper.add(items);
legend.setWrapper(wrapper);

if(legendPosition.equalsIgnoreCase("bottom")) legend.setPosition(RectangleEdge.BOTTOM);
else if(legendPosition.equalsIgnoreCase("left")) legend.setPosition(RectangleEdge.LEFT);
else if(legendPosition.equalsIgnoreCase("right")) legend.setPosition(RectangleEdge.RIGHT);
else if(legendPosition.equalsIgnoreCase("top")) legend.setPosition(RectangleEdge.TOP);
else legend.setPosition(RectangleEdge.BOTTOM);

legend.setHorizontalAlignment(HorizontalAlignment.CENTER);
chart.addSubtitle(legend);

}
 
Example #3
Source File: BorderArrangementTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
public void testEquals() {
    BorderArrangement b1 = new BorderArrangement();
    BorderArrangement b2 = new BorderArrangement();
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b1));

    b1.add(new EmptyBlock(99.0, 99.0), null);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(99.0, 99.0), null);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM);
    assertTrue(b1.equals(b2));
}
 
Example #4
Source File: BorderArrangementTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
public void testEquals() {
    BorderArrangement b1 = new BorderArrangement();
    BorderArrangement b2 = new BorderArrangement();
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b1));

    b1.add(new EmptyBlock(99.0, 99.0), null);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(99.0, 99.0), null);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP);
    assertTrue(b1.equals(b2));

    b1.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM);
    assertFalse(b1.equals(b2));
    b2.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM);
    assertTrue(b1.equals(b2));
}
 
Example #5
Source File: CompositeTitle.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));
}
 
Example #6
Source File: CompositeTitle.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));
}
 
Example #7
Source File: CompositeTitle.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));
}
 
Example #8
Source File: CompositeTitle.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));
}
 
Example #9
Source File: BorderArrangementTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Immutable - cloning is not necessary.
 */
public void testCloning() {
    BorderArrangement b1 = new BorderArrangement();
    assertFalse(b1 instanceof Cloneable);
}
 
Example #10
Source File: CompositeTitle.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));
}
 
Example #11
Source File: BorderArrangementTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Immutable - cloning is not necessary.
 */
public void testCloning() {
    BorderArrangement b1 = new BorderArrangement();
    assertFalse(b1 instanceof Cloneable);
}
 
Example #12
Source File: CompositeTitle.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));   
}
 
Example #13
Source File: CompositeTitle.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));   
}
 
Example #14
Source File: CompositeTitle.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));
}
 
Example #15
Source File: CompositeTitle.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new composite title with a default border arrangement.
 */
public CompositeTitle() {
    this(new BlockContainer(new BorderArrangement()));
}