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 java.awt.*;
019
020/**
021 * 流程图互斥网关
022 */
023public class SerialChart implements FlowChart {
024    private int n;
025
026    private int xSerial;
027
028    private int ySerial;
029
030    private Color c;
031
032    public SerialChart() {
033    }
034
035    public SerialChart(int xSerial, int ySerial, Color c) {
036        this.xSerial = xSerial;
037        this.ySerial = ySerial;
038        this.c = c;
039    }
040
041    public int getN() {
042        return n;
043    }
044
045    public SerialChart setN(int n) {
046        this.n = n;
047        return this;
048    }
049
050    public int getxSerial() {
051        return xSerial;
052    }
053
054    public SerialChart setxSerial(int xSerial) {
055        this.xSerial = xSerial;
056        return this;
057    }
058
059    public int getySerial() {
060        return ySerial;
061    }
062
063    public SerialChart setySerial(int ySerial) {
064        this.ySerial = ySerial;
065        return this;
066    }
067
068    public Color getC() {
069        return c;
070    }
071
072    public SerialChart setC(Color c) {
073        this.c = c;
074        return this;
075    }
076
077    @Override
078    public void draw(Graphics2D graphics) {
079        graphics.setColor(c);
080        int[] xSerials = {(xSerial - 20) * n, xSerial * n, (xSerial + 20) * n, xSerial * n};
081        int[] ySerials = {ySerial * n, (ySerial - 20) * n, ySerial * n, (ySerial + 20) * n};
082        graphics.drawPolygon(xSerials, ySerials, 4);
083
084        int[] xPoints1 = {(xSerial - 6) * n, (xSerial + 6) * n};
085        int[] yPoints1 = {(ySerial - 6) * n, (ySerial + 6) * n};
086        graphics.drawPolyline(xPoints1, yPoints1, xPoints1.length);
087
088        int[] xPoints2 = {(xSerial - 6) * n, (xSerial + 6) * n};
089        int[] yPoints2 = {(ySerial + 6) * n, (ySerial - 6) * n};
090        graphics.drawPolyline(xPoints2, yPoints2, xPoints2.length);
091    }
092}