11package myPackage ;
22
3- import java .awt .BasicStroke ;
43import java .awt .Dimension ;
54import java .awt .Graphics ;
6- import java .awt .Graphics2D ;
75import java .util .ArrayList ;
86import java .util .List ;
97
@@ -20,7 +18,7 @@ public Graphic() {
2018 @ Override
2119 public void paintComponent (Graphics g ) {
2220 // Paint its background
23- super .paintComponent (g );
21+ // super.paintComponent(g);
2422
2523 int xorigin = 500 , yorigin = 500 ;
2624 int firstx = 0 , firsty = 0 ;
@@ -58,6 +56,13 @@ public void paintComponent(Graphics g) {
5856 float startAngle = (float ) (180 /Math .PI *Math .atan2 (y1 -y0 , x1 -x0 ));
5957 float endAngle = (float ) (180 /Math .PI *Math .atan2 (y2 -y0 , x2 -x0 ));
6058
59+ float endDist = (float )Math .sqrt ((x2 -x0 )*(x2 -x0 ) + (y2 -y0 )*(y2 -y0 ));
60+ float startDist = (float )Math .sqrt ((x1 -x0 )*(x1 -x0 ) + (y1 -y0 )*(y1 -y0 ));
61+
62+ if (endDist != startDist ) {
63+ System .out .println ("Il comando -> " + com + " non può collegare il punto: " + x1 + ";" + (500 - y1 ) + " con il punto " + x2 + ";" + (500 - y2 ) +"." );
64+ }
65+
6166 //System.out.println(x0 + " " + y0 + " " + x1 + " " + y1 + " " + x2 + " " + y2 + " " + r + " " + x + " " + y + " " + width + " " + height + " " + startAngle + " " + endAngle);
6267 if (startAngle - endAngle < 0 )
6368 g .drawArc ((int )x , (int )y , (int )width , (int )height , (int )(360.0 - startAngle ), (int )(startAngle - endAngle ));
@@ -98,14 +103,7 @@ public void paintComponent(Graphics g) {
98103 }
99104 }
100105
101- public static void main (String [] args ) {
102- JFrame frame = new JFrame ("Sample Drawings Using a Graphics Object" );
103- //frame.getContentPane().add(new Graphic());
104- frame .pack ();
105- frame .setVisible (true );
106- }
107-
108- public static void Graphic (List <String > listcom ) {
106+ public static void setArray (List <String > listcom ) {
109107 l = listcom ;
110108
111109}
0 commit comments