****Proyecto del Punto Medio********


JPanel
paquete calcularrecta.newpackage;
/ / 1 .- Importamos
java.awt.Graphics de importación;
import java.awt .*;
//**************************
////////////////////////////////////////////////// / /
/ / Para Ubicar al Fondo JFrame
importación javax.swing.ImageIcon;
importación java.awt.Dimension;
/////////////////////////////////////////////
    / / Comienzo programar una
Panel public class javax.swing.JPanel { 

/ / / / PARA FONDO DE PANTALLA ////////////////////////////////////////// / /
    Grupo público () {
        this.setSize (700.500);
    }
        @ Override
public void paintComponent (Graphics g) {
        Dimensión tamanio = getSize ();
        ImageIcon imagenFondo = new ImageIcon (. GetClass () getResource ("/ imagen / pizarara.png")); / / getResource ("/ calcularrecta.newpackage / pizarara.png"));
        g.drawImage (imagenFondo.getImage (), 0,0, tamanio.width, tamanio.height, null);
        setOpaque (false);
        super.paintComponent (g);
}
   / / FONDO DE PANTALLA
       / / 2 .- Declaramos las variavles Privadas
       private int x0, y0;
       private int x1, y1;
 //===========================
/ / 3 .- Establecemos metodo escritura Dando clic en Derecho Lugar en blanco y LUEGO Insertar codigo, Luego Seeter
/ / Y despues como activar las variables de las Privadas párrafo q mas rapido mar construccion de Los Ángeles.
  / / COMO RESULTADO:
       public void setX0 (int x0) {
        this.x0 = x0;
    }
    setX1 public void (int x1) {
        this.x1 = x1;
    }
    public void setY0 (int y0) {
        this.y0 = y0;
    }
    public void setY1 (int y1) {
        this.y1 = y1;
    }
   / / Esto! Queda ===========================
     Panel / / public () {
       / / InitComponents ();

      / /}

    @ SuppressWarnings ("unchecked")
    
    / /                          
    initComponents private void () {
        setCursor (java.awt.Cursor nuevo (java.awt.Cursor.DEFAULT_CURSOR));
        javax.swing.GroupLayout diseño = new javax.swing.GroupLayout (este);
        this.setLayout (diseño);
        layout.setHorizontalGroup (
            layout.createParallelGroup (javax.swing.GroupLayout.Alignment.LEADING)
            . AddGap (0, 643, Short.MAX_VALUE)
        );
        layout.setVerticalGroup (
            layout.createParallelGroup (javax.swing.GroupLayout.Alignment.LEADING)
            . AddGap (0, 388, Short.MAX_VALUE)
        );
    } / /                        
/ / 4 .- LUEGO Clic Derecho Insertar, Objeto Redefinir, JComponent, pintura y clic en Generar
  
  public void paint (Graphics g) {
   
   
      super.paint (g);
  / / Programando .....
  / / Establesco color del Marcador o linea
        g.setColor (Color.white);
   / / Establesco Grafico o Figura Geométrica Y Sus Coordenadas ubicando este osea El valor Por Teclado
        g.drawLine (this.x1, this.y1, this.x0, this.y0);
           / / Creo Objeto Calcular Qué es la Clase java Creo q se o mar párrafo llamarlo Con SUS Coordenadas
    Calcular Obj = new Calcular (this.x1, this.y1, this.x0, this.y0);
/ / Creo Una variable doble q es = al Objeto DISTANCIA
    doble Obj.Distancia dist = ();
    / / Creo Una Cadena Donde sí mostrara d
    Cadena Cadena = "Distancia =" + String.valueOf (dist);
/ / LUEGO especifico Donde sí va un Ubicar El gotoxy de texto o
     g.drawString (Cadena, 30130);  
 / / PUNTOS MEDIOS XY //////////////////////////////////////////
     / / X PM
     doble px = Obj.Distx ();
   Cadena pm = "Punto Medio:" + String.valueOf (px);
      g.drawString (por la tarde, 30.160);
      / / PMY
     doble py = Obj.Disty ();
   PMY cadena = "=" + String.valueOf (py);
      g.drawString (PMY, 150160);
 ////////////////////////////////////////////////// //////////////////////////
    }
    / / A continuacion Creamos El actualizador
public void DibujarRecta ()
    {
    / / Repintado: Actualiza Cada Vez q grafique
      repaint ();
    }
/ / Listo ........
    / / Variables declaración - No se puede modificar                    
    / / Fin de la declaración de las variables}



CLASE Java Calcular


paquete calcularrecta.newpackage;


Calcular la clase pública {
/ / Creo las variables de Privadas
    private int x0, y0;
    private int x1, y1;
    / / Creo pública Calcular
Calcular público (int x0, int y0, x1, int y1)
    {
        this.x0 = x0;
        this.y0 = y0;
        this.x1 = x1;
        this.y1 = y1;
    }

/ / Comienzo una Ubicar Para El Ejercicio
/ / DISTANCIA DE UNA RECTA
/ / Estaba en Privada
DistNum doble privada ()
    {
doble nume = this.y1 - this.y0;
   volver nume;
 }
Denom doble privada () {
 doble = deno this.x1 - this.x0;
    volver deno;
}
forma privada doble () {
doble soln = this.DistNum ();
doble vendidos = this.Denom ();
nuevo doble = (soln) / (vendidos);
volver volver;
    }
/ / Aplicar EL RESULTADO
    public double Distancia ()
    {
       doble DISTANCIA = this.form ();
        volver DISTANCIA;
        }


/ / PUNTO MEDIO ////////////////////////////////////////////// ////////////////
/ / Tienen Que servicios publicas Para Ser mostradaaaas

pública Distx doble ()
    {

    doble dex = (+ this.x1 this.x0) / 2;
     volver dex;
 }
Disty públicas doble ()
    {
    / / Int x;
    / / Int y = 0;
    doble dy = (+ this.y1 this.y0) / 2 / / (((this.y1-this.y0) / (this.x1-this.x0)) * (this.x0));
     volver dy;
 }
     pública puntomedios doble ()
    {
       doble px = this.Distx ();
       doble py = this.Disty ();
      / / Si elimino Por Esto q this Por gusto no Funciona El Programa
       doble rp = px + py;
       volver rp;
        }

    }

No hay comentarios:

Publicar un comentario