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 ParallelChart implements FlowChart { 024 private int n; 025 026 private int xParallel; 027 028 private int yParallel; 029 030 private Color c; 031 032 public ParallelChart() { 033 } 034 035 public ParallelChart(int xParallel, int yParallel, Color c) { 036 this.xParallel = xParallel; 037 this.yParallel = yParallel; 038 this.c = c; 039 } 040 041 public int getN() { 042 return n; 043 } 044 045 public ParallelChart setN(int n) { 046 this.n = n; 047 return this; 048 } 049 050 public int getxParallel() { 051 return xParallel; 052 } 053 054 public ParallelChart setxParallel(int xParallel) { 055 this.xParallel = xParallel; 056 return this; 057 } 058 059 public int getyParallel() { 060 return yParallel; 061 } 062 063 public ParallelChart setyParallel(int yParallel) { 064 this.yParallel = yParallel; 065 return this; 066 } 067 068 public Color getC() { 069 return c; 070 } 071 072 public ParallelChart 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[] xParallels = {(xParallel - 20) * n, xParallel * n, (xParallel + 20) * n, xParallel * n}; 081 int[] yParallels = {yParallel * n, (yParallel - 20) * n, yParallel * n, (yParallel + 20) * n}; 082 graphics.drawPolygon(xParallels, yParallels, 4); 083 084 int[] xPoints1 = {(xParallel - 8) * n, (xParallel + 8) * n}; 085 int[] yPoints1 = {yParallel * n, yParallel * n}; 086 graphics.drawPolyline(xPoints1, yPoints1, xPoints1.length); 087 088 int[] xPoints2 = {xParallel * n, xParallel * n}; 089 int[] yPoints2 = {(yParallel - 8) * n, (yParallel + 8) * n}; 090 graphics.drawPolyline(xPoints2, yPoints2, xPoints2.length); 091 } 092}