Skip to content

Commit

Permalink
full gui added
Browse files Browse the repository at this point in the history
full gui added
  • Loading branch information
BookmanTasty committed Oct 12, 2020
1 parent b6ef9b8 commit aee64d4
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="miglayout15-swing.jar" sourcepath="miglayout-src.zip"/>
<classpathentry kind="lib" path="jgoodies-forms-1.8.0.jar" sourcepath="jgoodies-forms-1.8.0-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file modified bin/Gui$1.class
Binary file not shown.
Binary file modified bin/Gui$2.class
Binary file not shown.
Binary file modified bin/Gui$3.class
Binary file not shown.
Binary file modified bin/Gui.class
Binary file not shown.
Binary file modified bin/PngGen.class
Binary file not shown.
Binary file modified bin/gui$4.class
Binary file not shown.
Binary file added bin/gui$5.class
Binary file not shown.
Binary file added bin/gui$6.class
Binary file not shown.
Binary file added bin/gui$7.class
Binary file not shown.
Binary file added bin/gui$8.class
Binary file not shown.
Binary file added jgoodies-forms-1.8.0-sources.jar
Binary file not shown.
Binary file added jgoodies-forms-1.8.0.jar
Binary file not shown.
Binary file added miglayout-src.zip
Binary file not shown.
Binary file added miglayout15-swing.jar
Binary file not shown.
264 changes: 245 additions & 19 deletions src/Gui.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import java.awt.EventQueue;
import java.io.File;
import java.io.IOException;

import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.filechooser.FileSystemView;
import javax.swing.JFrame;
Expand All @@ -10,15 +9,30 @@
import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.JList;

import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.Dimension;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JComboBox;
import javax.swing.JSlider;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;



Expand All @@ -32,7 +46,18 @@ public class gui {
String rdyI = "No seleccionado";
String rdyC = "No seleccionado";
BufferedImage prevIMG;

private JTextField ingUX;
private JTextField ingUY;
private JTextField ingCX;
private JTextField ingCY;
int perUX = 270;
int perUY = 150;
int perCX = 270;
int perCY = 300;
String fuePER = "Calibri";
int fueTAM = 62;


/**
* Launch the application.
*/
Expand Down Expand Up @@ -62,36 +87,40 @@ public gui() {
public void initialize() {
frmvouchersGeneradorDe = new JFrame();
frmvouchersGeneradorDe.setTitle("99Vouchers Generador de Fichas");
frmvouchersGeneradorDe.setResizable(false);
frmvouchersGeneradorDe.setBounds(100, 100, 680, 480);
frmvouchersGeneradorDe.setBounds(100, 100, 718, 502);
frmvouchersGeneradorDe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//cargamos las fuentes l combo box

GraphicsEnvironment graphEnviron =
GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fuentes = graphEnviron.getAllFonts();

JPanel panel = new JPanel();
frmvouchersGeneradorDe.getContentPane().add(panel, BorderLayout.SOUTH);
panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));


JPanel MenuGEN = new JPanel();
frmvouchersGeneradorDe.getContentPane().add(MenuGEN, BorderLayout.SOUTH);
MenuGEN.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

JPanel panel_3 = new JPanel();
FlowLayout flowLayout = (FlowLayout) panel_3.getLayout();
panel.add(panel_3);
MenuGEN.add(panel_3);

JLabel lblNewLabel = new JLabel("Tama\u00F1o en pixeles");
panel_3.add(lblNewLabel);

JPanel panel_2 = new JPanel();
panel.add(panel_2);
MenuGEN.add(panel_2);

JLabel lblNewLabel_1 = new JLabel("Alto");
panel_2.add(lblNewLabel_1);

JLabel cordY = new JLabel("CorY");
JLabel cordY = new JLabel("000");
panel_2.add(cordY);

JLabel lblNewLabel_3 = new JLabel("Ancho");
panel_2.add(lblNewLabel_3);

JLabel cordX = new JLabel("CorX");
JLabel cordX = new JLabel("000");
panel_2.add(cordX);

JButton genV = new JButton("Generar Fichas");
Expand All @@ -105,17 +134,56 @@ public void actionPerformed(ActionEvent e) {

}
});
panel.add(genV);

JPanel panel = new JPanel();
MenuGEN.add(panel);

JLabel lblNewLabel_7 = new JLabel("Posicion del cursor");
panel.add(lblNewLabel_7);

JPanel panel_1 = new JPanel();
frmvouchersGeneradorDe.getContentPane().add(panel_1, BorderLayout.NORTH);
MenuGEN.add(panel_1);

JLabel lblNewLabel_14 = new JLabel("X");
panel_1.add(lblNewLabel_14);

JLabel corRX = new JLabel("0");
panel_1.add(corRX);

JLabel lblNewLabel_16 = new JLabel("Y");
panel_1.add(lblNewLabel_16);

JLabel corRY = new JLabel("0");
panel_1.add(corRY);
MenuGEN.add(genV);

JButton actuFICH = new JButton("Actualizar");
JComboBox fonSEL = new JComboBox(fuentes);

JPanel MenuCarga = new JPanel();
frmvouchersGeneradorDe.getContentPane().add(MenuCarga, BorderLayout.NORTH);

JLabel lblSEL = new JLabel(rdyI);
lblSEL.setForeground(Color.red);
JLabel lblCSV = new JLabel(rdyC);
lblCSV.setForeground(Color.red);
JSlider tamSEL = new JSlider();

JLabel wIcon = new JLabel(new ImageIcon());
wIcon.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (prevIMG != null) {
int coimgx = e.getX();
int coimgy = e.getY();
corRX.setText(coimgx+"");
corRY.setText(coimgy+"");


}

}
});

JButton loadIMG = new JButton("Cargar Plantilla");
loadIMG.addActionListener(new ActionListener() {
Expand All @@ -124,7 +192,7 @@ public void actionPerformed(ActionEvent e) {
lblSEL.setText(rdyI);
lblSEL.setForeground(Color.BLUE);
try {
prevIMG = PngGen.imgGENP(archIMG);
prevIMG = PngGen.imgGENP(archIMG, perUX, perUY, perCX, perCY, fuePER, fueTAM);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Expand All @@ -136,6 +204,15 @@ public void actionPerformed(ActionEvent e) {
ImageIcon preICO = new ImageIcon(prevIMG);
wIcon.setIcon(preICO);

//activamos el menu de edicion
ingUX.setEnabled(true);
ingUY.setEnabled(true);
ingCX.setEnabled(true);
ingCY.setEnabled(true);
fonSEL.setEnabled(true);
actuFICH.setEnabled(true);
tamSEL.setEnabled(true);


}
});
Expand All @@ -150,16 +227,165 @@ public void actionPerformed(ActionEvent e) {
}
});

panel_1.add(loadIMG);
panel_1.add(lblSEL);
panel_1.add(loadCSV);
panel_1.add(lblCSV);
MenuCarga.add(loadIMG);
MenuCarga.add(lblSEL);
MenuCarga.add(loadCSV);
MenuCarga.add(lblCSV);

JPanel visPREP = new JPanel();
visPREP.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
frmvouchersGeneradorDe.getContentPane().add(visPREP, BorderLayout.CENTER);

visPREP.add(wIcon);

JPanel MenuPER = new JPanel();
frmvouchersGeneradorDe.getContentPane().add(MenuPER, BorderLayout.EAST);
MenuPER.setLayout(new GridLayout(0, 1, 0, 0));

JLabel lblNewLabel_2 = new JLabel("\u00A0\u00A0Personalizar");
lblNewLabel_2.setPreferredSize(new Dimension(40, 14));
lblNewLabel_2.setMinimumSize(new Dimension(40, 14));
lblNewLabel_2.setMaximumSize(new Dimension(40, 14));
MenuPER.add(lblNewLabel_2);

JLabel lblNewLabel_4 = new JLabel("\u00A0\u00A0Posici\u00F3n Usuario");
MenuPER.add(lblNewLabel_4);

JPanel perPU = new JPanel();
MenuPER.add(perPU);

JLabel lblNewLabel_8 = new JLabel("X");
perPU.add(lblNewLabel_8);

ingUX = new JTextField();
ingUX.setEnabled(false);
ingUX.setText(perUX+"");
perPU.add(ingUX);
ingUX.setColumns(3);

JLabel lblNewLabel_9 = new JLabel("Y");
perPU.add(lblNewLabel_9);

ingUY = new JTextField();
ingUY.setEnabled(false);
ingUY.setText(perUY+"");
perPU.add(ingUY);
ingUY.setColumns(3);

JLabel lblNewLabel_5 = new JLabel("\u00A0\u00A0Posici\u00F3n Contrase\u00F1a \u00A0\u00A0");
MenuPER.add(lblNewLabel_5);

JPanel perPC = new JPanel();
MenuPER.add(perPC);

JLabel lblNewLabel_10 = new JLabel("X");
perPC.add(lblNewLabel_10);

ingCX = new JTextField();
ingCX.setEnabled(false);
ingCX.setText(perCX+"");
perPC.add(ingCX);
ingCX.setColumns(3);

JLabel lblNewLabel_11 = new JLabel("Y");
perPC.add(lblNewLabel_11);

ingCY = new JTextField();
ingCY.setEnabled(false);
ingCY.setText(perCY+"");
perPC.add(ingCY);
ingCY.setColumns(3);

JLabel lblNewLabel_6 = new JLabel("\u00A0\u00A0Fuente");
MenuPER.add(lblNewLabel_6);

JPanel perFU = new JPanel();
MenuPER.add(perFU);


fonSEL.setEnabled(false);
fonSEL.setPreferredSize(new Dimension(120, 20));
fonSEL.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value != null) {
Font font = (Font) value;
value = font.getName();
}
return super.getListCellRendererComponent(list, value, index,
isSelected, cellHasFocus);
}
});
perFU.add(fonSEL);

JLabel lblNewLabel_12 = new JLabel("\u00A0\u00A0Tama\u00F1o");
MenuPER.add(lblNewLabel_12);

JPanel peTA = new JPanel();
MenuPER.add(peTA);

JLabel lblTAM = new JLabel(fueTAM+"");


tamSEL.setEnabled(false);
tamSEL.setMaximum(99);
tamSEL.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
fueTAM = tamSEL.getValue();
lblTAM.setText(fueTAM+"");

}
});
tamSEL.setValue(62);
tamSEL.setMinimum(5);
tamSEL.setPreferredSize(new Dimension(100, 26));
peTA.add(tamSEL);


peTA.add(lblTAM);

JLabel lblNewLabel_13 = new JLabel("\u00A0\u00A0");
MenuPER.add(lblNewLabel_13);

JPanel perCO = new JPanel();
MenuPER.add(perCO);


actuFICH.setEnabled(false);
actuFICH.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

perUX = Integer.parseInt(ingUX.getText());
perUY = Integer.parseInt(ingUY.getText());
perCX = Integer.parseInt(ingCX.getText());
perCY = Integer.parseInt(ingCY.getText());

String fueTEM = fonSEL.getSelectedItem().toString();
String[] fueREC = fueTEM.split(",");
fuePER = fueREC[1].replace("name=", "");

fueTAM = tamSEL.getValue();


try {
prevIMG = PngGen.imgGENP(archIMG, perUX, perUY, perCX, perCY, fuePER,fueTAM);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int ancho = prevIMG.getWidth();
int largo = prevIMG.getHeight();
cordX.setText(ancho+"");
cordY.setText(largo+"");
ImageIcon preICO = new ImageIcon(prevIMG);
wIcon.setIcon(preICO);
System.out.println(fuePER);
}

});
MenuPER.add(actuFICH);


}

Expand Down
Loading

0 comments on commit aee64d4

Please sign in to comment.