* @throws IllegalArgumentException if an unknown symbolizer impl was
* passed in.
*/
private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth,
int legendHeight) {
LiteShape2 sampleShape;
final float hpad = (legendWidth * hpaddingFactor);
final float vpad = (legendHeight * vpaddingFactor);
if (symbolizer instanceof LineSymbolizer) {
if (this.sampleLine == null) {
Coordinate[] coords = {
new Coordinate(hpad, legendHeight - vpad),
new Coordinate(legendWidth - hpad, vpad)
};
LineString geom = geomFac.createLineString(coords);
try{
this.sampleLine = new LiteShape2(geom, null,null, false);
}
catch(Exception e)
{
this.sampleLine = null;
}
}
sampleShape = this.sampleLine;
} else if (symbolizer instanceof PolygonSymbolizer) {
if (this.sampleRect == null) {
final float w = legendWidth - (2 * hpad);
final float h = legendHeight - (2 * vpad);
Coordinate[] coords = {
new Coordinate(hpad, vpad),
new Coordinate(hpad, vpad + h),
new Coordinate(hpad + w, vpad + h),
new Coordinate(hpad + w, vpad),
new Coordinate(hpad, vpad)
};
LinearRing shell = geomFac.createLinearRing(coords);
Polygon geom = geomFac.createPolygon(shell, null);
try{
this.sampleRect = new LiteShape2(geom, null, null,false);
}
catch(Exception e)
{
this.sampleRect = null;
}
}
sampleShape = this.sampleRect;
} else if (symbolizer instanceof PointSymbolizer
|| symbolizer instanceof TextSymbolizer) {
if (this.samplePoint == null) {
Coordinate coord = new Coordinate(legendWidth / 2,
legendHeight / 2);
try{
this.samplePoint = new LiteShape2(geomFac.createPoint(coord), null, null,false);
}
catch(Exception e)
{
this.samplePoint = null;
}