/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* zeichnen.java
*
* Created on 19.01.2012, 12:23:57
*/
package emin;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Line2D;
/**
*
* @author asa
*/
public class zeichnen extends javax.swing.JPanel {
/** Creates new form zeichnen */
public zeichnen() {
initComponents();
}
int p1_x = this.getX() + 20;
int p2_x = 300;
int p3_x = this.getX() + 20;
int p4_x = 300;
int p5_x = 400;
int p1_y = 30;
int p2_y = 30;
int p3_y = 200;
int p4_y = 200;
int p5_y = 115;
int rect_width = 60;
int rect_hight = 30;
int smalrect_width = 30;
int smalrect_hight = 15;
boolean p1_boolean = false;
boolean p2_boolean = false;
boolean p3_boolean = false;
boolean p4_boolean = false;
boolean p5_boolean = false;
boolean p6_boolean = false;
@Override
public void paint(Graphics g) {
super.paint(g);
//------------------------------------------------------------------------------------------
//**** Signale zwischen einzelnen Elementen ****\\
//------------------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////
Graphics2D g2 = (Graphics2D)g;
g2.setStroke(new BasicStroke(3));//lienen dicke
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);//um alles scharf zu machen
////////////////////////////////////////////////////////////
//p1 - p2
if (p1_boolean || p2_boolean) {
g.setColor(Color.red);
}
else {
g.setColor(Color.BLACK);
}
g.drawLine(p1_x + rect_width, p1_y + (rect_hight / 2), p2_x-(p1_x +rect_width)-40, p1_y+15 );
g.drawLine(p2_x-(p1_x +rect_width)-40+smalrect_width,p1_y+rect_hight/2, p2_x, p2_y + (rect_hight / 2));
//p1-p3
if (p1_boolean || p3_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p1_x + (rect_width / 2), p2_y + rect_hight, p3_x + (rect_width / 2), p5_y+(smalrect_hight/2));
g.drawLine(p1_x + (rect_width / 2), p5_y+(smalrect_hight/2+(smalrect_hight)), p3_x + (rect_width / 2), p3_y);
//p1-p4
if (p1_boolean || p4_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p1_x + (rect_width / 2), p1_y + rect_hight, p4_x-(smalrect_width), p3_y-(rect_hight));
g.drawLine(p4_x, p3_y-(smalrect_hight), p4_x + (rect_width / 2), p4_y);
//p1-p5
if (p1_boolean || p5_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p1_x + (rect_width / 2), p1_y, p1_x + (rect_width / 2), p1_y - rect_hight);
g.drawLine(p1_x + (rect_width / 2), p1_y - rect_hight, p5_x + (rect_width / 2), p1_y - rect_hight);
g.drawLine(p5_x + (rect_width / 2), p1_y - rect_hight, p5_x + (rect_width / 2), p5_y);
//p2-p3
if (p2_boolean || p3_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p2_x + (rect_width / 2), p2_y + rect_hight, p3_x + (rect_width+smalrect_width), p3_y-(rect_hight));
g.drawLine( p3_x + (rect_width), p3_y-(smalrect_hight), p3_x + (rect_width / 2), p3_y);
//p2-p4
if (p2_boolean || p4_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p2_x + (rect_width / 2), p2_y + rect_hight, p2_x + smalrect_width, p5_y+(smalrect_hight/2));
g.drawLine(p2_x + (smalrect_width),p5_y+(smalrect_hight+8), p4_x + (rect_width / 2), p4_y);
//p2-p5
if (p2_boolean || p5_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p2_x + (rect_width / 2), p2_y + rect_hight, p5_x + (rect_width / 2), p5_y);
//p3-p4
if (p3_boolean || p4_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p3_x + rect_width, p3_y + (rect_hight / 2),p2_x-(p1_x +rect_width)-40, p4_y + (rect_hight / 2));
g.drawLine(p2_x-(p1_x +rect_width)-40+smalrect_width, p3_y + (rect_hight / 2), p4_x, p4_y + (rect_hight / 2));
//p3-p5
if (p3_boolean || p5_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p3_x + (rect_width / 2), p3_y + rect_hight, p3_x + (rect_width / 2), p3_y + rect_hight + rect_hight);
g.drawLine(p3_x + (rect_width / 2), p3_y + rect_hight + rect_hight, p5_x + (rect_width / 2), p3_y + rect_hight + rect_hight);
g.drawLine(p5_x + (rect_width / 2), p3_y + rect_hight + rect_hight, p5_x + (rect_width / 2), p5_y + (rect_hight));
//p4-p5
if (p4_boolean || p5_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p4_x + rect_width, p4_y + (rect_hight / 2), p5_x + (rect_width / 2), p5_y + rect_hight);
//p4-p5
if (p5_boolean || p6_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p5_x + rect_width, p5_y + (rect_hight / 2), p5_x+(2*rect_width), p5_y + (rect_hight / 2));
//HWs zu Auswertunsmodul
if (p1_boolean || p2_boolean || p3_boolean || p4_boolean || p5_boolean || p6_boolean) {
g.setColor(Color.red);
} else {
g.setColor(Color.BLACK);
}
g.drawLine(p4_x-(smalrect_width), p3_y-22, (p2_x-(p1_x+rect_width)-55)+rect_width , p3_y-16); //////////////////////////////
g.drawLine(p3_x+rect_width+smalrect_width, p3_y-22,(p2_x-(p1_x+rect_width)-55), p3_y-16); //////////////////////////////
g.drawLine((p2_x-(p1_x+rect_width)-40)+smalrect_width/2, p4_y+(smalrect_hight/2), (p2_x-(p1_x+rect_width)-40)+smalrect_width/2 , p3_y);
g.drawLine(p1_x+(smalrect_width/2)+smalrect_width, (p5_y+(smalrect_hight/2))+7, (p2_x-(p1_x+rect_width)-40)+smalrect_width/2, p3_y-rect_hight);
g.drawLine(p2_x+(smalrect_width/2), (p5_y+(smalrect_hight/2))+7, (p2_x-(p1_x+rect_width)-40)+smalrect_width/2, p3_y-rect_hight);
g.drawLine(p2_x-(p1_x +rect_width)-25, p1_y+smalrect_hight+8, (p2_x-(p1_x+rect_width)-40)+smalrect_width/2, p3_y-rect_hight);
//------------------------------------------------------------------------------------------
//**** Prozessoren ****\\
//------------------------------------------------------------------------------------------
//was zuletzt programmiert wird wird auch zuletzt gezeichnet daher erstmal die lienen und dann die viereck
//und jetzt sieht man die viereck über die lienen
g2.setStroke(new BasicStroke(1));
//***P1***//
g.drawRect(p1_x, p1_y, rect_width, rect_hight);
g.setColor(Color.green);
g.fillRect(p1_x+1, p1_y+1, rect_width-1, rect_hight-1);
if(p1_boolean){
g.setColor(Color.red);
g.fillRect(p1_x+1, p1_y+1, rect_width-1, rect_hight-1);
}
g.setColor(Color.black);
g.drawString("P1", p1_x + 25, p1_y + 20);
//***P2***//
g.drawRect(p2_x, p2_y, rect_width, rect_hight);
g.setColor(Color.green);
g.fillRect(p2_x+1, p2_y+1, rect_width-1, rect_hight-1);
if(p2_boolean){
g.setColor(Color.red);
g.fillRect(p2_x+1, p2_y+1, rect_width-1, rect_hight-1);
}
g.setColor(Color.black);
g.drawString("P2", p2_x + 25, p2_y + 20);
//***P3***//
g.drawRect(p3_x, p3_y, rect_width, rect_hight);
g.setColor(Color.green);
g.fillRect(p3_x+1, p3_y+1, rect_width-1, rect_hight-1);
if(p3_boolean){
g.setColor(Color.red);
g.fillRect(p3_x+1, p3_y+1, rect_width-1, rect_hight-1);
}
g.setColor(Color.black);
g.drawString("P3", p3_x + 25, p3_y + 20);
//***P4***//
g.drawRect(p4_x, p4_y, rect_width, rect_hight);
g.setColor(Color.green);
g.fillRect(p4_x+1, p4_y+1, rect_width-1, rect_hight-1);
if(p4_boolean){
g.setColor(Color.red);
g.fillRect(p4_x+1, p4_y+1, rect_width-1, rect_hight-1);
}
g.setColor(Color.black);
g.drawString("P4", p4_x + 25, p4_y + 20);
//***DPR-Modul***//
g.drawRect(p5_x, p5_y, rect_width, rect_hight);
g.setColor(Color.green);
g.fillRect(p5_x+1, p5_y+1, rect_width-1, rect_hight-1);
if (p5_boolean) {
g.setColor(Color.red);
}
g.setColor(Color.black);
g.drawString("DPR", p5_x + 25, p5_y + 20);
//***Core Com-Modul***//
g.drawRect(p5_x+(2*rect_width), p5_y, rect_width, rect_hight);
g.setColor(Color.green);
g.fillRect(p5_x+(2*rect_width)+1, p5_y+1, rect_width-1, rect_hight-1);
if (p6_boolean) {
g.setColor(Color.red);
}
g.setColor(Color.black);
g.drawString("Core COM", p5_x + 5+ (2*rect_width), p5_y + 20);
//***Auswertungsmodul***//
g.drawRect(p2_x-(p1_x+rect_width)-55 , p3_y-(rect_hight), rect_width, rect_hight);
g.setColor(Color.green);
g.fillRect((p2_x-(p1_x+rect_width)-55)+1 , p3_y-(rect_hight)+1, rect_width-1, rect_hight-1);
if (p6_boolean) {
g.setColor(Color.red);
}
g.setColor(Color.black);
g.drawString("Auswertung", (p2_x-(p1_x+rect_width)-55)+1 , (p3_y-rect_hight/2)+3);
//------------------------------------------------------------------------------------------
//**** HW-Vergleicher ****\\
//------------------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////
//die kleine viereck muss mann mit weiss full machen sonst sieht man die die linen drauf
g.setColor(Color.white);
g.fillRect(p2_x - (p1_x + rect_width) - 40, p1_y + 7, smalrect_width, smalrect_hight);
g.fillRect(p2_x + (smalrect_width / 2), p5_y + (smalrect_hight / 2), smalrect_width, smalrect_hight);
g.fillRect(p2_x - (p1_x + rect_width) - 40, p4_y + (smalrect_hight / 2), smalrect_width, smalrect_hight);
g.fillRect(p1_x + (smalrect_width / 2), p5_y + (smalrect_hight / 2), smalrect_width, smalrect_hight);
g.fillRect(p3_x + rect_width, p3_y - (rect_hight), smalrect_width, smalrect_hight);
g.fillRect(p4_x - (smalrect_width), p3_y - (rect_hight), smalrect_width, smalrect_hight);
/////////////////////////////////////////////////////////////////////
//Zwischen P1 und P2
g.setColor(Color.BLACK);
g.drawRect(p2_x-(p1_x +rect_width)-40, p1_y+7, smalrect_width, smalrect_hight);
g.drawString("HW", p2_x-(p1_x +rect_width)-32, p1_y+20);
//Zwischen P2 und P4
g.setColor(Color.BLACK);
g.drawRect(p2_x+(smalrect_width/2), p5_y+(smalrect_hight/2), smalrect_width, smalrect_hight);
g.drawString("HW", p2_x+25, p5_y+(smalrect_hight/2)+12);
//Zwischen P3 und P4
g.setColor(Color.BLACK);
g.drawRect(p2_x-(p1_x+rect_width)-40, p4_y+(smalrect_hight/2) , smalrect_width, smalrect_hight);
g.drawString("HW", p2_x-(p1_x+rect_width)-32, p4_y+20);
//Zwischen P1 und P3
g.setColor(Color.BLACK);
g.drawRect(p1_x+(smalrect_width/2), p5_y+(smalrect_hight/2) , smalrect_width, smalrect_hight);
g.drawString("HW", p1_x+((rect_width-smalrect_width)-5), p5_y+(smalrect_hight/2)+12);
//Zwischen P1 und P4
g.setColor(Color.BLACK);
g.drawRect(p3_x+rect_width, p3_y-(rect_hight) , smalrect_width, smalrect_hight);
g.drawString("HW", p3_x+rect_width+8, p3_y-(rect_hight-13));
//Zwischen P2 und P4
g.setColor(Color.BLACK);
g.drawRect(p4_x-(smalrect_width), p3_y-(rect_hight) , smalrect_width, smalrect_hight);
g.drawString("HW", p4_x-((rect_width-smalrect_width)-7), p3_y-(rect_hight-13));
}
public boolean isP1_boolean() {
return p1_boolean;
}
public void setP1_boolean(boolean p1_boolean) {
this.p1_boolean = p1_boolean;
}
public boolean isP2_boolean() {
return p2_boolean;
}
public void setP2_boolean(boolean p2_boolean) {
this.p2_boolean = p2_boolean;
}
public boolean isP3_boolean() {
return p3_boolean;
}
public void setP3_boolean(boolean p3_boolean) {
this.p3_boolean = p3_boolean;
}
public boolean isP4_boolean() {
return p4_boolean;
}
public void setP4_boolean(boolean p4_boolean) {
this.p4_boolean = p4_boolean;
}
public boolean isP5_boolean() {
return p5_boolean;
}
public void setP5_boolean(boolean p5_boolean) {
this.p5_boolean = p5_boolean;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setName("Form"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>
// Variables declaration - do not modify
// End of variables declaration
}