package DrawImage; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Stroke; import java.util.Vector; import ColorAndFont.ChooseColor; import PbuliClass.Get_Tb_Gass; import PbuliClass.Systems; import person.person_Dell; import relloc.RealLoc; import tbDataModel.Line; import tbDataModel.Point_fence_inout; import tbDataModel.PolygonNew; import tbDataModel.TbGas; import tbDataModel.Tb_fence_inout; import tbDataModel.tb_line; import tbDataModel_Dell.Dell_Fenceinout; import tbDataModel_Dell.Dell_Line; import tbDataModel_Dell.Dell_Polygon; import tbDataModel_Dell.Dell_tbline; import tbDataModel_Dell.Dell_yuan; import tbDataModel_Dell.Map_Dell; import tbDataModel_Dell.Tb_Warnig_Dell; /** * »æÍ¼ */ public class Drawok { static Stroke stroke = new BasicStroke(2);//ÉèÖû­±Ê static Font font = new Font("ËÎÌå", Font.PLAIN, 14); static Font font1 = new Font("ºÚÌå", Font.PLAIN, 16); static Font font2 = new Font("ËÎÌå", Font.PLAIN, 18); /** * »æÖƵç×ÓΧÀ¸ÇøÓò * * @param floorËùÔÚ²ã * @param x_bi * @param y_bi * @param x0 * @param y0 * @param Graphics2D g2 */ public static void fence(String floor, double x_bi, double y_bi, int x0, int y0, int xpy, int ypy, Graphics2D g2,double bi) { /**»æÖÆÒѾ­´æÔÚµÄΧÀ¸¶ÔÏó**/ int size1 = Dell_Polygon.getPolyVec().size(); if (size1 != 0) { for (int i = 0; i < size1; i++) { PolygonNew polyg = Dell_Polygon.getPolyVec().get(i); if (polyg.getAllFloor()==null){ polyg.setAllFloor("0"); } boolean equals = polyg.getAllFloor().equals("1"); if (polyg.getFloor().equals(floor)||equals) { String name = polyg.getName(); if (polyg.getShape().equals("¾ØÐÎ")) { int x = (new Double((polyg.getX()[0] - xpy) / x_bi)).intValue() + x0; int y = (new Double((polyg.getY()[0] - ypy) / y_bi)).intValue() + y0; int w = (new Double(polyg.getX()[1] / x_bi)).intValue(); int h = (new Double(polyg.getY()[1] / y_bi)).intValue(); // g2.setStroke(stroke); Font font = new Font("ºÚÌå", Font.BOLD, 16); g2.setFont(font); g2.setColor(Color.RED); g2.drawString(name, x + w / 2, y + h / 2); g2.setColor(polyg.getColor()); g2.fillRect(x, y, w, h); } else if (polyg.getShape().equals("¶à±ßÐÎ")) { int size = polyg.getX().length; int[] xs = new int[size]; int[] ys = new int[size]; for (int j = 0; j < size; j++) { xs[j] = (new Double((polyg.getX()[j] - xpy) / x_bi)).intValue() + x0; ys[j] = (new Double((polyg.getY()[j] - ypy) / y_bi)).intValue() + y0; } g2.setColor(polyg.getColor()); g2.setStroke(stroke); g2.setColor(Color.RED); g2.drawString(polyg.getName(), xs[0], ys[0]); g2.setColor(polyg.getColor()); g2.fillPolygon(xs, ys, size); } else if (polyg.getShape().equals("һάÏß")) { int size = polyg.getX().length; int[] xs = new int[size]; int[] ys = new int[size]; for (int j = 0; j < size; j++) { xs[j] = (new Double((polyg.getX()[j] - xpy) / x_bi)).intValue() + x0; ys[j] = (new Double((polyg.getY()[j] - ypy) / y_bi)).intValue() + y0; } g2.setColor(polyg.getColor()); g2.setStroke(stroke); g2.setColor(Color.RED); g2.setColor(polyg.getColor()); for (int a = 0; a < size; a++) { g2.setColor(Color.green); g2.fillOval(xs[a] - 5, ys[a] - 5, 10, 10); } for (int z = 0; z < size - 1; z++) { g2.setStroke(stroke); g2.setColor(Color.blue); g2.drawString(polyg.getName(), xs[0], ys[0]); g2.setColor(Color.red); g2.drawLine(xs[z], ys[z], xs[z + 1], ys[z + 1]); } }else if (polyg.getShape().equals("Ô²ÐÎ")) { int posx = (new Double((polyg.getX()[0] - xpy) / x_bi)).intValue() + x0; int posy = (new Double((polyg.getY()[0] - ypy) / y_bi)).intValue() + y0; int r1=2*(new Double(polyg.getBj()[0]/x_bi)).intValue(); int r2=2*(new Double(polyg.getBj()[0]/y_bi)).intValue(); g2.setStroke(stroke); Font font = new Font("ºÚÌå", Font.BOLD, 16); g2.setFont(font); g2.setColor(Color.RED); g2.drawString(name, posx,posy); g2.setColor(polyg.getColor()); g2.fillOval(posx-4, posy-4,8,8); g2.fillOval(posx-r1/2, posy-r2/2,r1,r2); } } } } } /** * »æÖƿɽøÈë¿É³öÇøÓòµÄ¶¥µã */ public static void draw_point_inout(String floor, double x_bi, double y_bi, int x0, int y0, int xpy, int ypy, Graphics2D g2) { int size = Dell_Fenceinout.getPoint_finout_vec().size(); if (size != 0) { for (int i = 0; i < size; i++) { Point_fence_inout pfi = Dell_Fenceinout.getPoint_finout_vec().get(i); String floor1 = pfi.getFloor(); if (floor1.equals(floor)) { // String name=pfi.getName(); int x = (new Double((pfi.getX() - xpy) / x_bi)).intValue() + x0; int y = (new Double((pfi.getY() - ypy) / y_bi)).intValue() + y0; g2.setStroke(stroke); g2.setColor(Color.blue); g2.fillOval(x - 5, y - 5, 10, 10); // Font font=new Font("ºÚÌå",Font.BOLD,16); //g2.setFont(font); //g2.setColor(Color.RED); //g2.drawString(name,x-40, y-10); } } } } /** * »æÖƿɽøÈë¿É³öÇøÓòµÄÖ±Ïß */ public static void draw_point_inoutLine(String floor, Graphics2D g2) { int size = Dell_Fenceinout.getFinout_vec().size(); if (size != 0) { for (int i = 0; i < size; i++) { Tb_fence_inout tfi = Dell_Fenceinout.getFinout_vec().get(i); String zuobiao = tfi.getZuobiao(); String canin = tfi.getCanin(); String[] split = zuobiao.split(";"); String[] split1 = canin.split(","); String[] s = new String[split.length]; for (int j = 1; j < split.length; j++) { String aaa = split[j - 1] + "," + split1[j - 1] + "," + split[j] + "," + split1[j]; String trim = aaa.trim(); s[j - 1] = trim; String bbb = split[0] + "," + split1[0] + "," + split[split.length - 1] + "," + split1[split.length - 1]; String trim1 = bbb.trim(); s[split.length - 1] = trim1; } String floor1 = tfi.getFloor(); if (floor1.equals(floor)) { for (int z = 0; z < s.length; z++) { String[] split2 = s[z].split(","); if ("1".equals(split2[2]) && "1".equals(split2[5])) { int a = Integer.parseInt(split2[0]); int b = Integer.parseInt(split2[1]); int c = Integer.parseInt(split2[3]); int d = Integer.parseInt(split2[4]); int x1 = RealLoc.get_xpos(floor1, a); int y1 = RealLoc.get_ypos(floor1, b); int x2 = RealLoc.get_xpos(floor1, c); ; int y2 = RealLoc.get_ypos(floor1, d); //ÉèÖñʻ­µÄ´Öϸ g2.setStroke(new BasicStroke(3.0f)); g2.setColor(Color.green); g2.drawLine(x1, y1, x2, y2); //g2.drawString("¿É½ø¿É³ö",x2,y2+3); } } } } } } /** * »æÖÆÖ±Ïß */ public static void line(double x_bi, double y_bi, int x0, int y0, Graphics2D g2) { int size = Dell_Line.getLine_vector().size(); if (size != 0) { for (int i = 0; i < size; i++) { Line line = Dell_Line.getLine_vector().get(i); double a = (line.getX1() / x_bi) + x0; double b = (line.getY1() / y_bi) + y0; double c = (line.getX2() / x_bi) + x0; double d = (line.getY2() / y_bi) + y0; int x1 = (int) a; int y1 = (int) b; int x2 = (int) c; int y2 = (int) d; //ÉèÖñʻ­µÄ´Öϸ g2.setStroke(new BasicStroke(3.0f)); g2.setColor(Color.blue); g2.drawLine(x1, y1, x2, y2); g2.drawString("³¤¶È:" + Dell_Line.getLine_vector().get(i).getLenght() + "cm", x2, y2 + 3); } } } /** * »æÖƵã */ public static void drawyuan(double x_bi, double y_bi, int x0, int y0, Graphics2D g2) { int size = Dell_yuan.getYuan_vector().size(); if (size != 0) { for (int i = 0; i < size; i++) { double a = (Dell_yuan.getYuan_vector().get(i).getX() / x_bi) + x0; double b = (Dell_yuan.getYuan_vector().get(i).getY() / y_bi) + y0; int x1 = (int) a; int y1 = (int) b; g2.setColor(ChooseColor.getColo("ÂÌÉ«", 150)); g2.fillOval(x1 - 5, y1 - 5, 10, 10); } } } /** * »æÖÆÆøÌå´«¸ÐÆ÷¶ÔÏó */ public static void gas(String mapfloor, double x_bi, double y_bi, int x0, int y0, Graphics2D g2) { if (Systems.sys().getGas_show().equals("1") && Get_Tb_Gass.get_gass().size() != 0) {//Èç¹ûÆøÌå´«¸ÐÆ÷ÏÔʾÊÇ¿ªÆôµÄ for (TbGas gas : Get_Tb_Gass.get_gass()) {//±éÀúËùÓÐµÄÆøÌå´«¸ÐÆ÷¶ÔÏó int gas_x = Integer.parseInt(gas.getX()) - Map_Dell.get_map(mapfloor).getX0_length(); int gas_y = Integer.parseInt(gas.getY()) - Map_Dell.get_map(mapfloor).getY0_width(); double aa = (gas_x / x_bi) + x0; double bb = (gas_y / y_bi) + y0; int gasx = (int) aa; int gasy = (int) bb; String gas_nongdu = gas.getNong_du() + "%"; if (gas.getNong_du().equals("65535")) { gas_nongdu = ""; } String gas_name = gas.getGas_type(); g2.setColor(Color.green); g2.fillOval(gasx, gasy, 30, 30); g2.setColor(Color.black); g2.setFont(font1); g2.drawString(gas_name, gasx + 4, gasy + 43); g2.setColor(Color.red); g2.drawString(gas_nongdu, gasx + 6, gasy + 22); } } } /** * »æÖƱêÇ©ÔÚÏß×ÜÊý */ public static void tagidnum(int x, int y, int framey, int framex, Graphics2D g2, int online) { if (true) { g2.setColor(ChooseColor.getColo("À¶É«", 70)); g2.fillRoundRect((framex - 500) / 2, framey - 50, 500, 28, 5, 5); g2.setFont(font); g2.setColor(Color.white); int off_online = person_Dell.getPerson_vector().size() - online; g2.drawString("ÔÚÏß:" + online + " ÀëÏß:" + off_online + " δ´¦Àí¸æ¾¯£º" + Tb_Warnig_Dell.getTbwarning_vector().size() + " µ±Ç°¹â±ê£ºX=" + x + " ; Y=" + y, (framex - 500) / 2 + 10, framey - 30); } } /** * »æÖƶ¨Î»ÇøÓò */ public static void lineAndArea(String floor,double x_bi, double y_bi, int x0, int y0, int xpy, int ypy, Graphics2D g2) { line(floor, x_bi, y_bi, x0, y0, xpy, ypy, g2);//»æÖÆÒ»Î¬Ïß area(floor, x_bi, y_bi, x0, y0, xpy, ypy, g2);//»æÖƶþÎ¬ÇøÓò } //»æÖƶþÎ¬ÇøÓò 2023.08.21 zsh private static void area(String floor, double x_bi, double y_bi, int x0, int y0, int xpy, int ypy, Graphics2D g2) { Vector area = Dell_Fenceinout.getFinout_vec(); int size1 = area.size(); if (size1 != 0) { for (int i = 0; i < size1; i++) { Tb_fence_inout tb_fence_inout = area.get(i); String baoliu1 = tb_fence_inout.getBaoliu1(); if (tb_fence_inout.getFloor().equals(floor)||baoliu1.equals("1")) { String zuobiao = tb_fence_inout.getZuobiao(); String[] split = zuobiao.split(";"); int length = split.length; int[] xs = new int[length]; int[] ys = new int[length]; for (int j = 0; j < length; j++) { String s = split[j].trim(); String[] split1 = s.split(","); int x = Integer.parseInt(split1[0].trim()); int y = Integer.parseInt(split1[1].trim()); xs[j] = (new Double((x - xpy) / x_bi)).intValue() + x0; ys[j] = (new Double((y - ypy) / y_bi)).intValue() + y0; } g2.setStroke(stroke); g2.setColor(Color.blue); g2.drawString("¶þÎ¬ÇøÓòid:" + tb_fence_inout.getId() + ",Ô¼Êø:" + tb_fence_inout.getGoroup(), xs[0] + 10, ys[0] - 10); if (tb_fence_inout.getGoroup()==3){ g2.setColor(new Color(178,34,34,100)); }else { g2.setColor(new Color(50, 205, 50, 100)); } g2.fillPolygon(xs, ys, length); } } } } //»æÖÆÒ»Î¬Ïß 023.08.21 zsh private static void line(String floor, double x_bi, double y_bi, int x0, int y0, int xpy, int ypy, Graphics2D g2) { Vector line_vector = Dell_tbline.getLine_vector(); int size = line_vector.size(); if (size != 0) { for (int i = 0; i < size; i++) { tb_line line = line_vector.get(i); String flr = line.getFlr(); String baoliu1 = line.getBaoliu1(); if (flr.equals(floor) || baoliu1.equals("1")) { int length = line.getPx().length; int[] px = new int[length]; int[] py = new int[length]; for (int j = 0; j < length; j++) { int[] px1 = line.getPx(); int[] py1 = line.getPy(); px[j] = new Double((px1[j] - xpy) / x_bi).intValue() + x0; py[j] = (new Double((py1[j] - ypy) / y_bi)).intValue() + y0; } for (int a = 0; a < length; a++) { g2.setColor(Color.green); g2.fillOval(px[a] - 5, py[a] - 5, 10, 10); } for (int z = 0; z < length - 1; z++) { g2.setStroke(stroke); g2.setColor(Color.blue); g2.drawString("һάÏßid:" + line.getLineId() + ",×éid:" + line.getGrp(), px[0], py[0]); g2.setColor(Color.red); g2.drawLine(px[z], py[z], px[z + 1], py[z + 1]); } } } } } }