Пример #1
0
  /**
   * 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;
  }