001/*
002 *    Copyright 2024-2025, Warm-Flow (290631660@qq.com).
003 *
004 *    Licensed under the Apache License, Version 2.0 (the "License");
005 *    you may not use this file except in compliance with the License.
006 *    You may obtain a copy of the License at
007 *
008 *       https://www.apache.org/licenses/LICENSE-2.0
009 *
010 *    Unless required by applicable law or agreed to in writing, software
011 *    distributed under the License is distributed on an "AS IS" BASIS,
012 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *    See the License for the specific language governing permissions and
014 *    limitations under the License.
015 */
016package org.dromara.warm.flow.core.chart;
017
018import org.dromara.warm.flow.core.utils.StringUtils;
019
020import java.awt.*;
021
022/**
023 * 流程图文字
024 */
025public class TextChart implements FlowChart {
026    private int n;
027
028    private int xText;
029
030    private int yText;
031
032    private String title;
033
034    public TextChart() {
035    }
036
037    public TextChart(int xText, int yText, String title) {
038        this.xText = xText;
039        this.yText = yText;
040        this.title = title;
041    }
042
043    public int getN() {
044        return n;
045    }
046
047    public TextChart setN(int n) {
048        this.n = n;
049        return this;
050    }
051
052    public int getxText() {
053        return xText;
054    }
055
056    public TextChart setxText(int xText) {
057        this.xText = xText;
058        return this;
059    }
060
061    public int getyText() {
062        return yText;
063    }
064
065    public TextChart setyText(int yText) {
066        this.yText = yText;
067        return this;
068    }
069
070    public String getTitle() {
071        return title;
072    }
073
074    public TextChart setTitle(String title) {
075        this.title = title;
076        return this;
077    }
078
079    @Override
080    public void draw(Graphics2D graphics) {
081        graphics.setColor(Color.BLACK);
082        graphics.drawString(StringUtils.isEmpty(title) ? "" : title, xText * n, yText * n);
083    }
084}