1
1
package com .tech .app .windows .panels ;
2
2
3
+ import com .tech .app .functions .FMaths ;
4
+ import com .tech .app .functions .FUtils ;
3
5
import com .tech .app .models .Arc ;
4
6
import com .tech .app .models .Model ;
5
7
import com .tech .app .models .Place ;
@@ -35,15 +37,21 @@ public class DrawPanel extends JPanel {
35
37
public final double MIN_ZOOM = 0.5 ;
36
38
37
39
/* Variables d'agrandissement et zoom */
38
- public double scaleX = 1 ;
39
- public double scaleY = 1 ;
40
+ public double scaleFactor ;
41
+ public double scaleX ;
42
+ public double scaleY ;
43
+
40
44
public AffineTransform transform ;
41
45
42
46
public DrawPanel (JFrame frame , Model model ) {
47
+ this .scaleFactor = FUtils .OS .isMacOs () ? 2 : 1 ;
48
+ this .scaleX = this .scaleFactor ;
49
+ this .scaleY = this .scaleFactor ;
50
+
43
51
this .frame = frame ;
44
52
this .model = model ;
45
53
this .transform = AffineTransform .getScaleInstance (scaleX , scaleY );
46
- this .setBorder (BorderFactory .createLineBorder (Color .BLACK , 5 ));
54
+ // this.setBorder(BorderFactory.createLineBorder(Color.BLACK, 5));
47
55
}
48
56
49
57
/* Utilisé pour déplacer tous les objets (click-molette) */
@@ -70,16 +78,16 @@ public void updatePosition(Object obj, double x, double y, double scaleX, double
70
78
if (obj != null ) {
71
79
if (obj instanceof Place ) {
72
80
Place p = (Place ) obj ;
73
- if (p .forme .getBounds2D ().contains (x , y )) {
81
+ // if (p.forme.getBounds2D().contains(x, y)) {
74
82
p .updatePosition (p .getX () + dx * 1 / scaleX , p .getY () + dy * 1 / scaleY );
75
83
repaint ();
76
- }
84
+ // }
77
85
} else {
78
86
Transition p = (Transition ) obj ;
79
- if (p .forme .getBounds2D ().contains (x , y )) {
87
+ // if (p.forme.getBounds2D().contains(x, y)) {
80
88
p .updatePosition (p .getX () + dx * 1 / scaleX , p .getY () + dy * 1 / scaleY );
81
89
repaint ();
82
- }
90
+ // }
83
91
}
84
92
}
85
93
}
@@ -124,8 +132,8 @@ public void paintComponent(Graphics g) {
124
132
}
125
133
Color color = g .getColor ();
126
134
g .setColor (Color .BLACK );
127
- g .setFont (new Font ("Console" , Font .PLAIN , (int )(15 /scaleX )));
128
- g .drawString (draggedObject .toString (), (int )(10 /scaleX ), (int )((this .frame .getContentPane ().getSize ().getHeight ()-50 )/scaleY ));
135
+ g .setFont (new Font ("Console" , Font .PLAIN , (int )(scaleFactor * 15 /scaleX )));
136
+ g .drawString (draggedObject .toString (), (int )(10 /scaleX ), (int )((this .frame .getContentPane ().getSize ().getHeight ()-50 )* scaleFactor /scaleY ));
129
137
g .setColor (color );
130
138
}
131
139
@@ -134,11 +142,11 @@ public void paintComponent(Graphics g) {
134
142
private void drawTooltips (Graphics g ) {
135
143
Color color = g .getColor ();
136
144
g .setColor (Color .BLUE );
137
- g .setFont (new Font ("Console" , Font .PLAIN , (int )(15 /scaleX )));
145
+ g .setFont (new Font ("Console" , Font .PLAIN , (int )(15 /scaleX * scaleFactor )));
138
146
if (this .indexOfClickArc == 1 ) {
139
- g .drawString ("Arc origin set" , (int )(10 /scaleX ), (int )((this .frame .getContentPane ().getSize ().getHeight ()-80 )/scaleY ));
147
+ g .drawString ("Arc origin set" , (int )(10 /scaleX * scaleFactor ), (int )((this .frame .getContentPane ().getSize ().getHeight ()-80 )* scaleFactor /scaleY ));
140
148
}
141
- g .drawString ("X:" + mouseX + "-Y:" + mouseY , (int )(10 /scaleX ), (int )(50 /scaleY ));
149
+ // g.drawString("X:" + FMaths.round( mouseX/scaleX,2) + "-Y:" + FMaths.round( mouseY/scaleY, 2), (int)(10/scaleX*scaleFactor ), (int)(50/scaleY*scaleFactor ));
142
150
g .setColor (color );
143
151
}
144
152
@@ -153,7 +161,7 @@ public void clearAll() {
153
161
154
162
/* Ajouter une place au système */
155
163
public void addPlace (double x , double y ){
156
- model .addPlace (new Place ("p " + idPlace , x , y ));
164
+ model .addPlace (new Place ("P " + idPlace , x , y ));
157
165
this .idPlace ++;
158
166
repaint ();
159
167
}
0 commit comments