This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertice.java
More file actions
executable file
·76 lines (63 loc) · 1.67 KB
/
Vertice.java
File metadata and controls
executable file
·76 lines (63 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*Vértice
El vértice es un punto sobre el plano, que representa un elemento
de un conjunto.
Hereda de ElementoGrafo.
Un vértice es un Elemento del Grafo que tiene: coordenadas en X y en Y, grado.
Se definen el diámetro para dibujar un vértice y el contador de
identificadores.
*/
import java.awt.*;
public final class Vertice extends ElementoGrafo{
//Atributos de Clase
private static int idCont = 0;
private static int diam = 18;
//Atributos de Instancia
private final int x;
private final int y;
private int grado;
//Métodos
//Constructor
public Vertice (int x, int y) {
this.x = x;
this.y = y;
id = ++idCont;
etiqueta = "Vertice " + id;
}
//Establecer conteo de ID
public static void setContID(int id) {
idCont = id;
}
//Obtener coordenada X
public int getX() {
return x;
}
//Obtener coordenada y
public int getY() {
return y;
}
//Establecer el grado del Vértice
public void setGrado(int grado) {
this.grado = grado;
}
//Obtener el grado del Vértice
public int getGrado() {
return grado;
}
//Pintar el punto sobre el Contenedor
public void pintarElemento(Graphics g) {
g.setColor(new Color(33,106,224));
g.fillOval(x - diam/2, y - diam/2, diam, diam);
if (estadoSeleccion) g.setColor(new Color(247,94,34));
else g.setColor(new Color(15,47,99));
((Graphics2D)g).setStroke(new BasicStroke(2));
g.drawOval(x - diam/2, y - diam/2, diam, diam);
}
//Información del Punto
public String toString() {
return ("[" + x + "," + y + "]");
}
//Obtención del Diametro general de un Punto
public static int getDiametro() {
return diam;
}
}