public static ShapePainter convertStrokePainter(Element e, ShapeNode node, BridgeContext ctx) { Shape shape = node.getShape(); if (shape == null) return null; Stroke stroke = convertStroke(e); if (stroke == null) return null; Paint strokePaint = convertStrokePaint(e, node, ctx); StrokeShapePainter sp = new StrokeShapePainter(shape); sp.setStroke(stroke); sp.setPaint(strokePaint); return sp; }
/** * Returns a <code>ShapePainter</code> defined on the specified element and for the specified * shape node. * * @param e the element with the marker CSS properties * @param node the shape node * @param ctx the bridge context */ public static ShapePainter convertMarkers(Element e, ShapeNode node, BridgeContext ctx) { Value v; v = CSSUtilities.getComputedStyle(e, SVGCSSEngine.MARKER_START_INDEX); Marker startMarker = convertMarker(e, v, ctx); v = CSSUtilities.getComputedStyle(e, SVGCSSEngine.MARKER_MID_INDEX); Marker midMarker = convertMarker(e, v, ctx); v = CSSUtilities.getComputedStyle(e, SVGCSSEngine.MARKER_END_INDEX); Marker endMarker = convertMarker(e, v, ctx); if (startMarker != null || midMarker != null || endMarker != null) { MarkerShapePainter p = new MarkerShapePainter(node.getShape()); p.setStartMarker(startMarker); p.setMiddleMarker(midMarker); p.setEndMarker(endMarker); return p; } else { return null; } }
/** * Returns a <code>ShapePainter</code> defined on the specified element and for the specified * shape node, and using the specified bridge context. * * @param e the element interested in a shape painter * @param node the shape node * @param ctx the bridge context */ public static ShapePainter convertFillAndStroke(Element e, ShapeNode node, BridgeContext ctx) { Shape shape = node.getShape(); if (shape == null) return null; Paint fillPaint = convertFillPaint(e, node, ctx); FillShapePainter fp = new FillShapePainter(shape); fp.setPaint(fillPaint); Stroke stroke = convertStroke(e); if (stroke == null) return fp; Paint strokePaint = convertStrokePaint(e, node, ctx); StrokeShapePainter sp = new StrokeShapePainter(shape); sp.setStroke(stroke); sp.setPaint(strokePaint); CompositeShapePainter cp = new CompositeShapePainter(shape); cp.addShapePainter(fp); cp.addShapePainter(sp); return cp; }
/** * Creates the shape painter associated to the specified element. This implementation creates a * shape painter considering the various fill and stroke properties in addition to the marker * properties. * * @param ctx the bridge context to use * @param e the element that describes the shape painter to use * @param shapeNode the shape node that is interested in its shape painter */ protected ShapePainter createShapePainter(BridgeContext ctx, Element e, ShapeNode shapeNode) { ShapePainter fillAndStroke; fillAndStroke = createFillStrokePainter(ctx, e, shapeNode); ShapePainter markerPainter = createMarkerPainter(ctx, e, shapeNode); Shape shape = shapeNode.getShape(); ShapePainter painter; if (markerPainter != null) { if (fillAndStroke != null) { CompositeShapePainter cp = new CompositeShapePainter(shape); cp.addShapePainter(fillAndStroke); cp.addShapePainter(markerPainter); painter = cp; } else { painter = markerPainter; } } else { painter = fillAndStroke; } return painter; }
protected ShapePainter createShapePainter(BridgeContext ctx, Element e, ShapeNode shapeNode) { Rectangle2D r2d = shapeNode.getShape().getBounds2D(); if ((r2d.getWidth() == 0) || (r2d.getHeight() == 0)) return null; return super.createShapePainter(ctx, e, shapeNode); }