org.foxbpm.engine.impl.diagramview.svg.builder.LanesetSVGBuilder.java Source code

Java tutorial

Introduction

Here is the source code for org.foxbpm.engine.impl.diagramview.svg.builder.LanesetSVGBuilder.java

Source

/**
 * Copyright 1996-2014 FoxBPM ORG.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * @author MAENLIANG
 */
package org.foxbpm.engine.impl.diagramview.svg.builder;

import java.awt.Font;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.foxbpm.engine.impl.diagramview.svg.Point;
import org.foxbpm.engine.impl.diagramview.svg.SVGUtils;
import org.foxbpm.engine.impl.diagramview.svg.vo.RectVO;
import org.foxbpm.engine.impl.diagramview.svg.vo.SvgVO;

/**
 * 
 * ?BUILDER LanesetSVGBuilder
 * 
 * MAENLIANG 201471 ?8:33:07
 * 
 * @version 1.0.0
 * 
 */
public class LanesetSVGBuilder extends AbstractSVGBuilder {
    private static final String FILL_DEFAULT = "F7F7F7";
    /**
     * 
     */
    private RectVO rectVO;

    public LanesetSVGBuilder(SvgVO svgVo) {
        super(svgVo);
        rectVO = SVGUtils.getTaskVOFromSvgVO(svgVo);
    }

    public void setWidth(float width) {
        this.rectVO.setWidth(width);
    }

    public void setHeight(float height) {
        this.rectVO.setHeight(height);
    }

    public void setXAndY(float x, float y) {
        this.rectVO.setX(x);
        this.rectVO.setY(y);

    }

    /**
     * ?? ???
     */
    public void setTextLocationByHerizonFlag(boolean herizonFlag) {
        // ??
        float textX = 0;
        float textY = 0;
        int textWidth = SVGUtils.getTextWidth(this.textVO.getFont(), this.textVO.getElementValue());
        if (herizonFlag) {
            // ??
            textX = this.rectVO.getX() + 10.0f;
            textY = this.rectVO.getY() + this.rectVO.getHeight() / 2 + textWidth / 2;
            this.textVO.setTransform("rotate(270 " + textX + COMMA + textY + BRACKET_SUFFIX);
            StringBuffer styleBuffer = new StringBuffer(this.textVO.getStyle());
            this.textVO.setStyle(styleBuffer.append("").toString());

        } else {
            // ? ??
            textX = this.rectVO.getX() + this.rectVO.getWidth() / 2 - textWidth / 2;
            textY = this.rectVO.getY() + 10.0f;
        }
        this.textVO.setX(textX);
        this.textVO.setY(textY);

    }

    public void setStroke(String stroke) {
        if (StringUtils.isBlank(stroke)) {
            this.rectVO.setStroke(STROKE_DEFAULT);
            return;
        }
        this.rectVO.setStroke(COLOR_FLAG + stroke);
    }

    public void setStrokeWidth(float strokeWidth) {
        this.rectVO.setStrokeWidth(strokeWidth);
    }

    public void setFill(String fill) {
        if (StringUtils.isBlank(fill)) {
            fill = FILL_DEFAULT;
        }
        float x1 = this.rectVO.getX();
        float x2 = x1;
        float y1 = this.rectVO.getY();
        float y2 = y1 + this.rectVO.getHeight();
        this.buildLinearGradient(fill, rectVO, x1, x2, y1, y2);

    }

    public void setTextFont(String fontStr) {
        if (StringUtils.isBlank(fontStr)) {
            Font font = new Font(ARIAL, Font.CENTER_BASELINE, 11);
            this.textVO.setFont(font);
            return;
        }
        String[] fonts = fontStr.split(COMMA);
        StringBuffer styleBuffer = new StringBuffer();
        String style = styleBuffer.append("font-family:").append(fonts[0]).append(";font-size:").append(fonts[1])
                .toString();
        Font font = new Font(fonts[0], Font.PLAIN, Integer.valueOf(fonts[1]));
        this.textVO.setFont(font);
        this.textVO.setStyle(style);
        this.textVO.setFontSize(fonts[1]);
    }

    public void setID(String id) {
        // TODO Auto-generated method stub

    }

    public void setName(String name) {
        // TODO Auto-generated method stub

    }

    public void setStyle(String style) {
        // TODO Auto-generated method stub

    }

    public void setTypeStroke(String stroke) {
        // TODO Auto-generated method stub

    }

    public void setTypeStrokeWidth(float strokeWidth) {
        // TODO Auto-generated method stub

    }

    public void setTypeFill(String fill) {
        // TODO Auto-generated method stub

    }

    public void setTypeStyle(String style) {
        // TODO Auto-generated method stub

    }

    public void setWayPoints(List<Point> pointList) {
        // TODO Auto-generated method stub

    }

}