private void FormaActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_FormaActionPerformed // TODO add your handling code here: if ((Vias.getSelectedItem() != "Vias de administracion") && (Forma.getItemCount()) != 0) { if (Forma.getSelectedItem().equals("Forma")) { Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else { Tipo.removeAllItems(); Tipo.addItem("Tipo"); for (String s : v) { Tipo.addItem(s); } } } } // GEN-LAST:event_FormaActionPerformed
@Override public void uzyjForme(Forma forma) throws NoItemFound, ItemUsed { try { if (checkIfExistsAndFillResultSet(forma)) { int counter = getCounter(); if (counter > 0) { updateCounter(counter - 1, forma); } else { throw new ItemUsed(forma.toString()); } } else { throw new NoItemFound(forma.toString()); } } catch (SQLException ex) { Logger.getLogger(FormaRepositoryDBImpl.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Crea la figura seleccionada. * * @param ini punto inicial a partir del cual crear la figura */ public void createShape(Point2D ini) { if (herramienta != null) { switch (herramienta) { case Forma.PUNTO: figura = new Punto(ini); break; case Forma.LINEA: figura = new Linea(ini); break; case Forma.RECTANGULO: figura = new Rectangulo(ini, false); break; case Forma.RECTANGULO_REDONDEADO: figura = new Rectangulo(ini, true); break; case Forma.ELIPSE: figura = new Elipse(ini); break; case Forma.CURVA: figura = new Curva(ini); terminarCurva = true; break; case Forma.TRAZO_LIBRE: figura = new Linea(ini); break; case Forma.GOMA: figura = new Goma(ini); break; } if (herramienta == Forma.GOMA) { // si queremos usar la goma, dibujamos un rectángulo pequeño en blanco mirelleno = new Relleno(Degradado.liso, Color.WHITE); figura.setPropiedades(Color.WHITE, new BasicStroke(grosor), mirelleno); vForma.add(figura); } else { if (relleno.estaRelleno()) mirelleno = new Relleno(relleno.getDegradado(), (Color) relleno.getColorFondo()); else mirelleno = new Relleno(false); figura.setPropiedades( (Color) color1, trazo, mirelleno); // guarda las propiedades de la figura vForma.add(figura); // añade la forma al vector } } }
private void updateCounter(int counter, Forma forma) throws SQLException { connection.update( "update " + tableName + " set counter =\" " + counter + "\"where idProjektu = \"" + forma.getTyp().name() + "\";"); }
private boolean checkIfExistsAndFillResultSet(Forma forma) throws SQLException { resultSet = connection.execQuery( "select * from " + tableName + " where idProjektu = \"" + forma.getTyp().name() + "\";"); return resultSet.next(); }
@Override public void gira() { super.gira(); /* Ajusta no espaço para poder girar na posição correta */ if (orientacao == 2) { /* S será horizontal (ainda não é) */ if (lateral > 0) lateral--; } else /* S será vertical (ainda não é) */ lateral++; posiciona(); dimensiona(); }
public Mano(final Forma forma) { this.forma = forma.getValor(); }
private void AceptarActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_AceptarActionPerformed // TODO add your handling code here: if (!(Name.getText().equals("") && Cantidad.getText().equals("") && Precio.getText().equals("") && Marca.getText().equals("") && jTextArea1.getText().equals("") && Vias.getSelectedItem().equals("Vias de administracion") && Forma.getSelectedItem().equals("Forma") && Tipo.getSelectedItem().equals("Tipo"))) { if (b == false) { Producto p = new Producto(); p.setName(Name.getText()); p.setId(parseInt(jLabel2.getText())); p.setCantidad(parseInt(Cantidad.getText())); p.setPrecio(parseDouble(Precio.getText())); p.setDescripcion(jTextArea1.getText()); p.setMarca(Marca.getText()); p.setVia((String) Vias.getSelectedItem()); p.setForma((String) Forma.getSelectedItem()); p.setTipo((String) Tipo.getSelectedItem()); Clear(); new Conectar().ModificarProd(p); JOptionPane.showMessageDialog(null, "Su producto fue modificado exitosamente"); dispose(); } else { List<Producto> p1 = new Conectar().ConexionProd(); for (Producto pd : p1) { String s, s1; s = new Search().SetLength("" + pd.getId()); s1 = jLabel2.getText(); if (s.equals(s1)) { double x = pd.getPrecio(), x1 = parseDouble(Precio.getText()); double t = (x + x1) / 2; int y = pd.getCantidad(), y1 = parseInt(Cantidad.getText()); int t1 = y + y1; Producto p = new Producto(); p = pd; p.setPrecio(t); p.setCantidad(t1); Clear(); new Conectar().ModificarProd(p); Calendar c = Calendar.getInstance(); String Fecha = Integer.toString(c.get(Calendar.DATE)); Fecha += "/"; Fecha += Integer.toString(c.get(Calendar.MONTH) + 1); Fecha += "/"; Fecha += Integer.toString(c.get(Calendar.YEAR)); String name = null; try { name = new UseUser().GetUser(); } catch (IOException e) { } name = name.trim(); Producto p2 = new Producto(); p2 = pd; p2.setCantidad(y1); p2.setPrecio(x1); new Conectar().InsertCompra(p2, Fecha, name); JOptionPane.showMessageDialog(null, "Su Compra fue realizada exitosamente"); dispose(); } } } } else if (!(Name.getText().equals("") && Cantidad.getText().equals("") && Precio.getText().equals("") && Marca.getText().equals("") && jTextArea1.getText().equals("") && Vias.getSelectedItem().equals("Vias de administracion") && Forma.getSelectedItem().equals("Forma") && Tipo.getSelectedItem().equals("Tipo") && b)) { } else { JOptionPane.showMessageDialog( null, "Debe de llenar todos los campos", "Informacion Incompleta", JOptionPane.INFORMATION_MESSAGE, null); } } // GEN-LAST:event_AceptarActionPerformed
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); Name = new javax.swing.JTextField(8); jLabel3 = new javax.swing.JLabel(); Marca = new javax.swing.JTextField(8); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); Cantidad = new javax.swing.JTextField(8); Precio = new javax.swing.JTextField(8); jLabel6 = new javax.swing.JLabel(); Vias = new javax.swing.JComboBox(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); Forma = new javax.swing.JComboBox(); Tipo = new javax.swing.JComboBox(); jLabel9 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jPanel5 = new javax.swing.JPanel(); Aceptar = new javax.swing.JButton(); Limpiar = new javax.swing.JButton(); Atras = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setResizable(false); jPanel1.setLayout(new java.awt.BorderLayout()); java.awt.GridBagLayout jPanel2Layout = new java.awt.GridBagLayout(); jPanel2Layout.columnWidths = new int[] { 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0 }; jPanel2Layout.rowHeights = new int[] {0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0}; jPanel2.setLayout(jPanel2Layout); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel1.setText("Id:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel1, gridBagConstraints); jLabel2.setText("jLabel2"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(Name, gridBagConstraints); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel3.setText("Nombre:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(Marca, gridBagConstraints); jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel4.setText("Marca:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel4, gridBagConstraints); jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel5.setText("Cantidad:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel5, gridBagConstraints); Cantidad.addFocusListener( new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { CantidadFocusLost(evt); } }); Cantidad.addKeyListener( new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { CantidadKeyTyped(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(Cantidad, gridBagConstraints); Precio.addFocusListener( new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { PrecioFocusLost(evt); } }); Precio.addKeyListener( new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { PrecioKeyTyped(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(Precio, gridBagConstraints); jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel6.setText("Precio:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 8; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel6, gridBagConstraints); Vias.removeAllItems(); String[] v = { "Oral", "Intramuscular", "Intravenosa", "Subcutánea", "Inhalatoria", "Transdermica", "Nasal", "Oftalmica", "Ótica", "Tópica", "Rectal", "Vaginal" }; Vias.addItem("Vias de administracion"); for (String s : v) { Vias.addItem(s); } Vias.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ViasActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 10; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(Vias, gridBagConstraints); jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel7.setText("Via:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 10; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel7, gridBagConstraints); jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel8.setText("Forma:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 12; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel8, gridBagConstraints); Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { FormaActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 12; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(Forma, gridBagConstraints); Tipo.removeAllItems(); Tipo.addItem("Tipo"); Tipo.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TipoActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 14; gridBagConstraints.gridy = 14; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(Tipo, gridBagConstraints); jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel9.setText("Tipo:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 12; gridBagConstraints.gridy = 14; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(jLabel9, gridBagConstraints); jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER); jPanel1.add(jPanel3, java.awt.BorderLayout.PAGE_START); jPanel4.setLayout(new java.awt.BorderLayout()); jTextArea1.setColumns(20); jTextArea1.setRows(5); jTextArea1.setBorder(javax.swing.BorderFactory.createTitledBorder("Descripción")); jScrollPane1.setViewportView(jTextArea1); jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); Aceptar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); Aceptar.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AceptarActionPerformed(evt); } }); jPanel5.add(Aceptar); Limpiar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); Limpiar.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LimpiarActionPerformed(evt); } }); jPanel5.add(Limpiar); Atras.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); Atras.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AtrasActionPerformed(evt); } }); jPanel5.add(Atras); jPanel4.add(jPanel5, java.awt.BorderLayout.PAGE_END); jPanel1.add(jPanel4, java.awt.BorderLayout.PAGE_END); getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); setSize(new java.awt.Dimension(464, 468)); setLocationRelativeTo(null); } // </editor-fold>//GEN-END:initComponents
private void ViasActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_ViasActionPerformed // TODO add your handling code here: if (Vias.getSelectedItem().equals("Oral")) { String[] v = { "Cápsulas", "Comprimidos", "Grageas", "Preparados líquidos", "Jarabes", "Elixires", "Suspensiones" }; Forma.removeAllItems(); Forma.addItem("Forma"); for (String s : v) { Forma.addItem(s); } } else if (Vias.getSelectedItem().equals("Intramuscular")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Inyección"); } else if (Vias.getSelectedItem().equals("Intravenosa")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Inyección"); } else if (Vias.getSelectedItem().equals("Vias de administracion")) { Forma.removeAllItems(); Forma.addItem("Forma"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Tópica")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Cremas"); Forma.addItem("Spray"); Forma.addItem("Unguento"); Forma.addItem("Jabón"); Forma.addItem("Shampoo"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Ótica")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Gotas"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Subcutánea")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Inyección"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Inhalatoria")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Spray"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Nasal")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Crema"); Forma.addItem("Unguento"); Forma.addItem("Spray"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Oftalmica")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Crema"); Forma.addItem("Gotas"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Transdermica")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Inyección"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Rectal")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Supositorio"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } else if (Vias.getSelectedItem().equals("Vaginal")) { Forma.removeAllItems(); Forma.addItem("Forma"); Forma.addItem("Crema"); Forma.addItem("Ovulos"); Tipo.removeAllItems(); Tipo.addItem("Tipo"); } } // GEN-LAST:event_ViasActionPerformed
@Override public void giraAnti() { super.giraAnti(); posiciona(); dimensiona(); }
@Override public void praDireita() { super.praDireita(); posiciona(); }
@Override public void praEsquerda() { super.praEsquerda(); posiciona(); }
private void createNew(Forma forma) { connection.update( "insert into " + tableName + " (idProjektu) values(\"" + forma.getTyp().name() + "\" );"); }
/** * Pinta el vector de formas sobre el lienzo. * * @param g donde se dibuja */ public void paintShapes(Graphics g) { Graphics2D g2d = (Graphics2D) g; if (img != null) g2d.drawImage(img, 0, 0, this); for (Forma f : vForma) { // recorre el vector de formas g2d.setStroke(f.getTrazo()); if (f.getRelleno().estaRelleno()) { /* colorea el relleno según el tipo */ switch (f.getRelleno().getDegradado()) { case liso: g2d.setPaint((Color) f.getRelleno().getColorFondo()); g2d.fill(f.getFigura()); g2d.setPaint(f.getColor()); // configuramos el color del borde break; case horizontal: gradiente = new GradientPaint( 0, 0, (Color) f.getColor(), getWidth(), 0, (Color) f.getRelleno().getColorFondo()); g2d.setPaint(gradiente); g2d.fill(f.getFigura()); break; case vertical: gradiente = new GradientPaint( 0, 0, (Color) f.getColor(), 0, getHeight(), (Color) f.getRelleno().getColorFondo()); g2d.setPaint(gradiente); g2d.fill(f.getFigura()); break; } } else // en caso de no haber relleno, solo dibujamos el contorno de la figura g2d.setPaint(f.getColor()); g2d.draw(f.getFigura()); } }