1 43 44 package org.jfree.chart.title; 45 46 import java.awt.Graphics2D ; 47 import java.awt.Shape ; 48 import java.awt.geom.Rectangle2D ; 49 50 import org.jfree.chart.block.Arrangement; 51 import org.jfree.chart.block.BlockContainer; 52 import org.jfree.chart.block.BlockResult; 53 import org.jfree.chart.block.EntityBlockParams; 54 import org.jfree.chart.block.EntityBlockResult; 55 import org.jfree.chart.entity.EntityCollection; 56 import org.jfree.chart.entity.LegendItemEntity; 57 import org.jfree.chart.entity.StandardEntityCollection; 58 59 64 public class LegendItemBlockContainer extends BlockContainer { 65 66 67 private int dataset; 68 69 70 private int series; 71 72 73 private String toolTipText; 74 75 76 private String urlText; 77 78 85 public LegendItemBlockContainer(Arrangement arrangement, int dataset, 86 int series) { 87 super(arrangement); 88 this.dataset = dataset; 89 this.series = series; 90 } 91 92 97 public int getDatasetIndex() { 98 return this.dataset; 99 } 100 101 106 public int getSeriesIndex() { 107 return this.series; 108 } 109 110 117 public String getToolTipText() { 118 return this.toolTipText; 119 } 120 121 128 public void setToolTipText(String text) { 129 this.toolTipText = text; 130 } 131 132 139 public String getURLText() { 140 return this.urlText; 141 } 142 143 150 public void setURLText(String text) { 151 this.urlText = text; 152 } 153 154 164 public Object draw(Graphics2D g2, Rectangle2D area, Object params) { 165 super.draw(g2, area, null); 167 EntityBlockParams ebp = null; 168 BlockResult r = new BlockResult(); 169 if (params instanceof EntityBlockParams) { 170 ebp = (EntityBlockParams) params; 171 if (ebp.getGenerateEntities()) { 172 EntityCollection ec = new StandardEntityCollection(); 173 LegendItemEntity entity = new LegendItemEntity( 174 (Shape ) area.clone()); 175 entity.setSeriesIndex(this.series); 176 entity.setToolTipText(getToolTipText()); 177 entity.setURLText(getURLText()); 178 ec.add(entity); 179 r.setEntityCollection(ec); 180 } 181 } 182 return r; 183 } 184 } 185 | Popular Tags |