济菏高速数据中心代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

150 lines
3.4 KiB

package com.zc.business.domain;
import sun.font.FontDesignMetrics;
import java.awt.*;
/**
* @Description:ruoyi
* @auther: Lenovo
* @date: 2024/2/2616:43
* @param: param
* @return: 结果
*/
public class ImageDTO {
//类型(0:文字,1:矩形)
private int type;
//文字内容
private String text;
//字体颜色和透明度
private Color color;
//字体和大小
private Font font;
//左上角起始点的x坐标
private int x;
//左上角起始点的y坐标
private int y;
//矩形宽度
private int rectWidth;
//矩形高度
private int rectHeight;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public Font getFont() {
return font;
}
public void setFont(Font font) {
this.font = font;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getRectWidth() {
return rectWidth;
}
public void setRectWidth(int rectWidth) {
this.rectWidth = rectWidth;
}
public int getRectHeight() {
return rectHeight;
}
public void setRectHeight(int rectHeight) {
this.rectHeight = rectHeight;
}
/**
* 创建文字ImageDTO, 每一个对象,代表在该图片中要插入的一段文字内容:
* @param text : 文本内容;
* @param color : 字体颜色(前三位)和透明度(第4位,值越小,越透明);
* @param font : 字体的样式和字体大小;
* @param x : 当前字体在该图片位置的横坐标;
* @param y : 当前字体在该图片位置的纵坐标;
* @return
*/
public static ImageDTO createImageDTO(String text,Color color,Font font,int x,int y){
ImageDTO imageDTO = new ImageDTO();
imageDTO.setType(0);
imageDTO.setText(text);
imageDTO.setColor(color);
imageDTO.setFont(font);
FontDesignMetrics metrics = FontDesignMetrics.getMetrics(font);
y = y + metrics.getAscent() - (metrics.getAscent() + metrics.getDescent() - font.getSize()) / 2;
imageDTO.setX(x);
imageDTO.setY(y);
return imageDTO;
}
public ImageDTO(){}
/**
* 创建ImageDTO, 每一个对象,代表在该图片中要插入的矩形:
* @param color : 颜色(前三位)和透明度(第4位,值越小,越透明);
* @param x : 当前矩形在该图片位置的横坐标;
* @param y : 当前矩形在该图片位置的纵坐标;
* @param rectWidth : 当前矩形的宽度;
* @param rectHeight : 当前矩形的高度;
* @return
*/
public static ImageDTO createRectImageDTO(Color color,int x,int y,int rectWidth,int rectHeight){
ImageDTO imageDTO = new ImageDTO();
imageDTO.setType(1);
imageDTO.setColor(color);
imageDTO.setX(x);
imageDTO.setY(y);
imageDTO.setRectWidth(rectWidth);
imageDTO.setRectHeight(rectHeight);
return imageDTO;
}
}