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.DrawUtils; 019import org.dromara.warm.flow.core.utils.ObjectUtil; 020import org.dromara.warm.flow.core.utils.StringUtils; 021 022import java.awt.*; 023 024/** 025 * 流程图中间节点 026 */ 027public class BetweenChart implements FlowChart { 028 private int n; 029 030 private int xRect; 031 032 private int yRect; 033 034 private Color c; 035 036 private TextChart textChart; 037 038 public BetweenChart() { 039 } 040 041 public BetweenChart(int xRect, int yRect, Color c, TextChart textChart) { 042 this.xRect = xRect; 043 this.yRect = yRect; 044 this.c = c; 045 this.textChart = textChart; 046 } 047 048 public int getN() { 049 return n; 050 } 051 052 public BetweenChart setN(int n) { 053 this.n = n; 054 return this; 055 } 056 057 public int getxRect() { 058 return xRect; 059 } 060 061 public BetweenChart setxRect(int xRect) { 062 this.xRect = xRect; 063 return this; 064 } 065 066 public int getyRect() { 067 return yRect; 068 } 069 070 public BetweenChart setyRect(int yRect) { 071 this.yRect = yRect; 072 return this; 073 } 074 075 public Color getC() { 076 return c; 077 } 078 079 public BetweenChart setC(Color c) { 080 this.c = c; 081 return this; 082 } 083 084 public TextChart getTextChart() { 085 return textChart; 086 } 087 088 public BetweenChart setTextChart(TextChart textChart) { 089 this.textChart = textChart; 090 return this; 091 } 092 093 @Override 094 public void draw(Graphics2D graphics) { 095 graphics.setColor(c); 096 graphics.drawRoundRect((xRect - 50) * n, (yRect - 40) * n, 100 * n, 80 * n, 20 * n, 20 * n); 097 if (ObjectUtil.isNotNull(textChart) && StringUtils.isNotEmpty(textChart.getTitle())) { 098 textChart.setxText(textChart.getxText() - DrawUtils.stringWidth(graphics, textChart.getTitle()) / 2); 099 // 填充文字说明 100 textChart.setN(n).draw(graphics); 101 } 102 } 103}