1 46 47 package org.jfree.chart.title; 48 49 import java.awt.Graphics2D ; 50 import java.awt.geom.Rectangle2D ; 51 import java.io.Serializable ; 52 53 import org.jfree.chart.block.BlockContainer; 54 import org.jfree.chart.block.BorderArrangement; 55 import org.jfree.chart.block.RectangleConstraint; 56 import org.jfree.ui.Size2D; 57 58 61 public class CompositeTitle extends Title implements Cloneable , Serializable { 62 63 64 private static final long serialVersionUID = -6770854036232562290L; 65 66 67 private BlockContainer container; 68 69 72 public CompositeTitle() { 73 this(new BlockContainer(new BorderArrangement())); 74 } 75 76 81 public CompositeTitle(BlockContainer container) { 82 if (container == null) { 83 throw new IllegalArgumentException ("Null 'container' argument."); 84 } 85 this.container = container; 86 } 87 88 93 public BlockContainer getContainer() { 94 return this.container; 95 } 96 97 102 public void setTitleContainer(BlockContainer container) { 103 if (container == null) { 104 throw new IllegalArgumentException ("Null 'container' argument."); 105 } 106 this.container = container; 107 } 108 109 118 public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { 119 RectangleConstraint contentConstraint = toContentConstraint(constraint); 120 Size2D contentSize = this.container.arrange(g2, contentConstraint); 121 return new Size2D( 122 calculateTotalWidth(contentSize.getWidth()), 123 calculateTotalHeight(contentSize.getHeight()) 124 ); 125 } 126 127 134 public void draw(Graphics2D g2, Rectangle2D area) { 135 area = trimMargin(area); 136 drawBorder(g2, area); 137 area = trimBorder(area); 138 area = trimPadding(area); 139 this.container.draw(g2, area); 140 } 141 142 151 public Object draw(Graphics2D g2, Rectangle2D area, Object params) { 152 draw(g2, area); 153 return null; 154 } 155 156 163 public boolean equals(Object obj) { 164 if (obj == this) { 165 return true; 166 } 167 if (!(obj instanceof CompositeTitle)) { 168 return false; 169 } 170 if (!super.equals(obj)) { 171 return false; 172 } 173 CompositeTitle that = (CompositeTitle) obj; 174 if (!this.container.equals(that.container)) { 175 return false; 176 } 177 return true; 178 } 179 180 } 181 | Popular Tags |