1 18 package org.apache.batik.bridge; 19 20 import java.awt.Shape ; 21 22 import org.apache.batik.css.engine.SVGCSSEngine; 23 import org.apache.batik.gvt.CompositeShapePainter; 24 import org.apache.batik.gvt.ShapeNode; 25 import org.apache.batik.gvt.ShapePainter; 26 import org.w3c.dom.Element ; 27 28 35 public abstract class SVGDecoratedShapeElementBridge 36 extends SVGShapeElementBridge { 37 38 41 protected SVGDecoratedShapeElementBridge() {} 42 43 44 ShapePainter createFillStrokePainter(BridgeContext ctx, 45 Element e, 46 ShapeNode shapeNode) { 47 return super.createShapePainter(ctx, e, shapeNode); 58 } 59 60 ShapePainter createMarkerPainter(BridgeContext ctx, 61 Element e, 62 ShapeNode shapeNode) { 63 return PaintServer.convertMarkers(e, shapeNode, ctx); 67 } 68 69 79 protected ShapePainter createShapePainter(BridgeContext ctx, 80 Element e, 81 ShapeNode shapeNode) { 82 ShapePainter fillAndStroke; 83 fillAndStroke = createFillStrokePainter(ctx, e, shapeNode); 84 85 ShapePainter markerPainter = createMarkerPainter(ctx, e, shapeNode); 86 87 Shape shape = shapeNode.getShape(); 88 ShapePainter painter; 89 90 if (markerPainter != null) { 91 if (fillAndStroke != null) { 92 CompositeShapePainter cp = new CompositeShapePainter(shape); 93 cp.addShapePainter(fillAndStroke); 94 cp.addShapePainter(markerPainter); 95 painter = cp; 96 } else { 97 painter = markerPainter; 98 } 99 } else { 100 painter = fillAndStroke; 101 } 102 return painter; 103 } 104 105 protected void handleCSSPropertyChanged(int property) { 106 switch(property) { 107 case SVGCSSEngine.MARKER_START_INDEX: 108 case SVGCSSEngine.MARKER_MID_INDEX: 109 case SVGCSSEngine.MARKER_END_INDEX: 110 if (!hasNewShapePainter) { 111 hasNewShapePainter = true; 112 ShapeNode shapeNode = (ShapeNode)node; 113 shapeNode.setShapePainter(createShapePainter(ctx, e, shapeNode)); 114 } 115 break; 116 default: 117 super.handleCSSPropertyChanged(property); 118 } 119 } 120 } 121 122 | Popular Tags |