APENDICE II CODIGOS

Anuncio
APÉNDICE II. CÓDIGOS
APÉNDICE II. CÓDIGOS
Códigos de programación de las aplicaciones creadas para este proyecto.
1. Código Java de la clases creadas para la Aplicación Java
1.1. Cuadro.java .....................................................
1.2. LocalizacionACS.java ....................................
1.3. HistogramaACS.java ......................................
1.4. Grafica_fchart_ACS.java ...............................
1.5. Grafica_JFC.java ............................................
1.6. Imagen_panel.java ..........................................
2
111
138
144
147
154
2. Código archivos creados para la Aplicación web
2.1. HTML
2.1.1. ACSenJS.html .........................................
2.2. CSS
2.2.1. estilo_0_1.css ..........................................
2.3. JavaScript
2.3.1. localizacionjs_ACSenJS.js .....................
2.3.2. fchart_ACSenJS.js ..................................
2.3.3. imprimir.js ..............................................
2.3.4. Graficas_ACSenJS_1.js ..........................
2.3.5. grafica-lineal-visor_ACSenJS.js .............
1
155
161
163
190
197
198
210
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
1.1. Clase Cuadro.java
package paquete;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;
//informes con ireport
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperPrintManager;
import net.sf.jasperreports.view.JasperViewer;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
/**
*
* @author Eduardo
*/
public class Cuadro extends javax.swing.JFrame {
LocalizacionACS pueblo;
String Nombre_Ciudad;
String vmes[] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre",
"Noviembre", "Diciembre"};
//PanelDatos
JTextField datosEntrada[] = new JTextField[12];
//Panel Calculos
JLabel calculosmes[] = new JLabel[10];
// para tres decimales
DecimalFormat formateador;
//declaracion de vectores para subpanelresultados1
JLabel vmensual[];
JLabel vtitulos[];
JTextField v_txt_neMJ[];
2
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
JTextField v_txt_ENDmes[];
JTextField v_txt_ENTotalmes[];
JTextField v_txt_Sustitucion[];
JTextField v_txt_Deficit0[];
JTextField v_txt_CosteElectrico[];
JTextField v_txt_CosteAuxiliar[];
JTextField v_txt_Ahorro[];
JTextField v_txt_Cobertura[];
//declaracion del numero de collectores proyectado
double nc;
//declaración de vectores para panel datos&resultados2
JTextField v_txt_ocupacion[];
JTextField v_txt_Tred[];
JTextField v_txt_H[];
JTextField v_txt_k[];
JTextField v_txt_E[];
JTextField v_txt_horassol[];
JTextField v_txt_Tamb[];
JTextField v_txt_I[];
JTextField v_txt_Rendimiento[];
JTextField v_txt_Consumom3[];
//declaracion del vector de los txt del dialogo_datosdelsitio DDS
JTextField v_txt_DDS[] = new JTextField[12];
//declaracion de vectores para crear el dialogo_datosmensuales DDM
//declaración de vectores para panel meter datos nuevos
JTextField v_txt_ocupacionn[];
JTextField v_txt_Tredn[];
JTextField v_txt_Hn[];
JTextField v_txt_kn[];
JTextField v_txt_horassoln[];
JTextField v_txt_Tambn[];
//Cuadros de verificación de meses para calcular
JCheckBox[] chMeses;
//f-chart
JLabel titulos[], calor[], titudatos[], cober, etiCSA;
JTextField txtNdia[], txttac[], txttred[], txtQa[];
JTextField txtRi[], txtEa[];
JTextField txtDt[], txtK2[], txtEp[];
JTextField txtD1[], txtD2[], txtf[], txtQu[];
//grafica fchart
JLabel nombres[], resultados[];
Grafica_fchart_ACS gf;
//Resultados fchart MasMenos
JTextField txtf_ocupacion_Mm[], txtf_litrosdia_Mm[], txtf_tuso_Mm[], txtf_inclinacion_Mm[];
JCheckBox[] chMeses_fMasMenos;
double vlo[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double vli[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double vlu[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
//Cancelar cambios de inclinacion en fchart
double primera_Inclinacion;
//Resultados DemandaAportacion (DA) MasMenos
JTextField txtDA_ocupacion_Mm[], txtDA_litrosdia_Mm[], txtDA_tuso_Mm[], txtDA_inclinacion_Mm[];
JCheckBox[] chMeses_DAMasMenos;
double vloDA[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double vliDA[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double vluDA[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
//Guardar Resultados
JLabel titulosGR[], DatosGR_1[], DatosGR_2[], DatosGR_3[], DatosGR_4[], DatosGR_5[], DatosGR_6[],
DatosGR_7[], DatosGR_8[], DatosGR_9[], DatosGR_10[], DatosGR_11[], DatosGR_12[], DatosGR_13[];
JLabel[] DATOSgr[];
int fila;
3
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//Base de datos access
Connection conexion;
Statement sentencia;
DefaultTableModel mt,mtv,mtmes;
//graficaJFC rendimiento panel graficas rendimiento
double b1[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b2[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b3[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b4[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b5[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b6[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b7[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b8[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b9[]={0,0,0,0,0,0,0,0,0,0,0,0};
double b10[]={0,0,0,0,0,0,0,0,0,0,0,0};
double[] b[]={b1,b2,b3,b4,b5,b6,b7,b8,b9,b10};
String ley[]={"","","","","","","","","",""};
/**
* Initializes
*/
public Cuadro() {
initComponents();
PrepararBaseDatos();
PrepararTablaResultados();
PrepararTablaVariacion_anual();
PrepararTabla_mensual();
//this.setSize(1100,800);
pueblo = new LocalizacionACS();
Creacion_subpanelresultados1();
Creacion_subpaneldatosyresultados();
Creacion_panel_meterdatosmensuales();
Crear_Panel_CuadrosVerificacion_meses();
Crear_panel_Resultados_fchart();
Crear_panel_valores_grafica_fchart();
Crear_panel_Resultados_fchart_MasMenos();
Crear_panel_Resultados_DA_MasMenos();
Crear_panel_GuardarResultados();
gf = new Grafica_fchart_ACS();
datosEntrada[0] = txtdatosInclinacion;
datosEntrada[1] = txtdatosDesviacion;
datosEntrada[2] = txtdatoscorreH;
datosEntrada[3] = txtdatosPerdidaglobal;
datosEntrada[4] = txtdatosUsuarios;
datosEntrada[5] = txtdatosLitrosdia;
datosEntrada[6] = txtdatosAreacol;
datosEntrada[7] = txtdatosbcol;
datosEntrada[8] = txtdatosmcol;
datosEntrada[9] = txtdatosTempuso;
datosEntrada[10] = txtdatoscorreb;
datosEntrada[11] = txtdatosPreciokw;
calculosmes[0] = eticalculosmesConsumo;
calculosmes[1] = eticalculosmesSalto;
calculosmes[2] = eticalculosmesTermias;
calculosmes[3] = eticalculosmesDemandaMJ;
calculosmes[4] = eticalculosmesHcor;
calculosmes[5] = eticalculosmesE;
calculosmes[6] = eticalculosmesI;
calculosmes[7] = eticalculosmesENDmes;
4
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
calculosmes[8] = eticalculosmesRendimiento;
calculosmes[9] = eticalculosmesAportacion;
v_txt_DDS[0] = txtinclinacion1;
v_txt_DDS[1] = txtdesviacionNS1;
v_txt_DDS[2] = txtcorreccionH1;
v_txt_DDS[3] = txtperdidasglobales1;
v_txt_DDS[4] = txtusuarios1;
v_txt_DDS[5] = txtlitrosdia1;
v_txt_DDS[6] = txtareacolector1;
v_txt_DDS[7] = txtb1;
v_txt_DDS[8] = txtm1;
v_txt_DDS[9] = txtTempuso1;
v_txt_DDS[10] = txtcorreccionb1;
v_txt_DDS[11] = txtpreciokw1;
pueblo.vfporceocupacion = vlo;//para panel graficas fchart Masmenos ocupacion
pueblo.vfporcelitros = vli;//para panel graficas fchart Masmenos litros
pueblo.vfporcetuso = vlu;//para panel graficas fchart Masmenos Temp de uso (tac)
pueblo.vDAporceocupacion = vloDA;//para panel graficas DA Masmenos ocupacion
pueblo.vDAporcelitros = vliDA;//para panel graficas DA Masmenos litros
pueblo.vDAporcetuso = vluDA;//para panel graficas DA Masmenos Temp de uso (tac)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Buscar los datos de altitud,latitud y temperatura mínima historica
public void BuscaDatos_LatitudAltitudyTempMinima() {
pueblo.BuscaDatosLatitud();
etidatos_Nombre_lat.setText(pueblo.Nombre);
etidatos_Latitud_lat.setText("" + pueblo.getLatitud() + "º");
etidatos_Altitud_lat.setText("" + pueblo.getAltitud());
etidatos_Tminhistorica_lat.setText("" + pueblo.getTempMinHistorica());
}
//Aceptar los datos de entrada
public void Aceptar_DatosdeEntrada() {
// pueblo.setLatitud(Double.parseDouble(datosEntrada[0].getText()));
pueblo.setInclinacion(Double.parseDouble(datosEntrada[0].getText()));
pueblo.setDesNS(Double.parseDouble(datosEntrada[1].getText()));
pueblo.setCorH(Double.parseDouble(datosEntrada[2].getText()));
pueblo.setPerdGlo(Double.parseDouble(datosEntrada[3].getText()));
//pueblo.setNumUsu(Double.parseDouble(datosEntrada[4].getText()));
//pueblo.setLitrosDia(Double.parseDouble(datosEntrada[5].getText()));
pueblo.NumUsu = (Double.parseDouble(datosEntrada[4].getText()));
pueblo.LitrosDia = (Double.parseDouble(datosEntrada[5].getText()));
pueblo.setAreacol(Double.parseDouble(datosEntrada[6].getText()));
pueblo.setbcol(Double.parseDouble(datosEntrada[7].getText()));
pueblo.setmcol(Double.parseDouble(datosEntrada[8].getText()));
pueblo.setTuso(Double.parseDouble(datosEntrada[9].getText()));
pueblo.setCorb(Double.parseDouble(datosEntrada[10].getText()));
pueblo.setPreciokwh(Double.parseDouble(datosEntrada[11].getText()));
}
public void Traspasa_DatosdeEntrada() {
//pasará los valores de las casillas del dialogo_datosdelsitio al panel_datos
for (int i = 0; i < 12; i++) {
datosEntrada[i].setText(v_txt_DDS[i].getText());
}
5
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
public void Asigna_DatosEntrada() {
double La, In, DNS, ch, pg, nu, Ld, Ac, bc, mc, tu, cb, pkw;
// La=Double.parseDouble(v_txt_DDS[0].getText());
In = Double.parseDouble(v_txt_DDS[0].getText());
DNS = Double.parseDouble(v_txt_DDS[1].getText());
ch = Double.parseDouble(v_txt_DDS[2].getText());
pg = Double.parseDouble(v_txt_DDS[3].getText());
nu = Double.parseDouble(v_txt_DDS[4].getText());
Ld = Double.parseDouble(v_txt_DDS[5].getText());
Ac = Double.parseDouble(v_txt_DDS[6].getText());
bc = Double.parseDouble(v_txt_DDS[7].getText());
mc = Double.parseDouble(v_txt_DDS[8].getText());
tu = Double.parseDouble(v_txt_DDS[9].getText());
cb = Double.parseDouble(v_txt_DDS[10].getText());
pkw = Double.parseDouble(v_txt_DDS[11].getText());
//pueblo.setLatitud(La);
pueblo.setInclinacion(In);
pueblo.setDesNS(DNS);
pueblo.setCorH(ch);
pueblo.setPerdGlo(pg);
pueblo.setNumUsu(nu);
pueblo.setLitrosDia(Ld);
pueblo.setAreacol(Ac);
pueblo.setbcol(bc);
pueblo.setmcol(mc);
pueblo.setTuso(tu);
pueblo.setCorb(cb);
pueblo.setPreciokwh(pkw);
}
public void pasar_focoDDS() {
for (int i = 0; i < 11; i++) {
if (v_txt_DDS[i].isFocusOwner()) {
v_txt_DDS[i + 1].requestFocus();
}
}
if (v_txt_DDS[11].isFocusOwner()) {
v_txt_DDS[0].requestFocus();
}
}
public void Creacion_panel_meterdatosmensuales() {
vmensual = new JLabel[12];
JLabel vtitu[] = new JLabel[7];
v_txt_ocupacionn = new JTextField[12];
v_txt_Tredn = new JTextField[12];
v_txt_Hn = new JTextField[12];
v_txt_kn = new JTextField[12];
v_txt_horassoln = new JTextField[12];
v_txt_Tambn = new JTextField[12];
int i;
for (i = 0; i < vmensual.length; i++) {
vmensual[i] = new JLabel();
6
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
vmensual[i].setText(vmes[i]);
vmensual[i].setBounds(10, 40 + 20 * i, 100, 20);
dialogo_datosmensuales.add(vmensual[i]);
v_txt_ocupacionn[i] = new JTextField();
v_txt_ocupacionn[i].setBounds(90, 40 + 20 * i, 75, 20);
v_txt_ocupacionn[i].setText("" + 0);
dialogo_datosmensuales.add(v_txt_ocupacionn[i]);
v_txt_Tredn[i] = new JTextField();
v_txt_Tredn[i].setBounds(175, 40 + 20 * i, 75, 20);
v_txt_Tredn[i].setText("" + 0);
dialogo_datosmensuales.add(v_txt_Tredn[i]);
v_txt_Hn[i] = new JTextField();
v_txt_Hn[i].setBounds(260, 40 + 20 * i, 75, 20);
v_txt_Hn[i].setText("" + 0);
dialogo_datosmensuales.add(v_txt_Hn[i]);
v_txt_kn[i] = new JTextField();
v_txt_kn[i].setBounds(345, 40 + 20 * i, 75, 20);
v_txt_kn[i].setText("" + 0);
dialogo_datosmensuales.add(v_txt_kn[i]);
v_txt_horassoln[i] = new JTextField();
v_txt_horassoln[i].setBounds(430, 40 + 20 * i, 75, 20);
v_txt_horassoln[i].setText("" + 1);
dialogo_datosmensuales.add(v_txt_horassoln[i]);
v_txt_Tambn[i] = new JTextField();
v_txt_Tambn[i].setBounds(515, 40 + 20 * i, 75, 20);
v_txt_Tambn[i].setText("" + 0);
dialogo_datosmensuales.add(v_txt_Tambn[i]);
}
int j;
for (j = 1; j < vtitu.length; j++) {
vtitu[j] = new JLabel();
if (j == 1) {
vtitu[j].setText("Ocupacion");
}
if (j == 2) {
vtitu[j].setText("Tred");
}
if (j == 3) {
vtitu[j].setText("H");
}
if (j == 4) {
vtitu[j].setText("k");
}
if (j == 5) {
vtitu[j].setText("horassol");
}
if (j == 6) {
vtitu[j].setText("Tamb");
}
vtitu[j].setBounds(90 * j, 10, 75, 20);
dialogo_datosmensuales.add(vtitu[j]);
}
7
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
for (i = 0; i < vmensual.length; i++) {
v_txt_ocupacionn[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pasar_focoDmesActionPerformed(evt);
}
});
v_txt_Tredn[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pasar_focoDmesActionPerformed(evt);
}
});
v_txt_Hn[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pasar_focoDmesActionPerformed(evt);
}
});
v_txt_kn[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pasar_focoDmesActionPerformed(evt);
}
});
v_txt_horassoln[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pasar_focoDmesActionPerformed(evt);
}
});
v_txt_Tambn[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pasar_focoDmesActionPerformed(evt);
}
});
}
}
public void pasar_focoDmesActionPerformed(ActionEvent evt) {
int i;
for (i = 0; i < 11; i++) {
if (v_txt_Tambn[i].isFocusOwner()) {
v_txt_Tambn[i + 1].requestFocus();
}
if (v_txt_ocupacionn[i].isFocusOwner()) {
v_txt_ocupacionn[i + 1].requestFocus();
}
if (v_txt_Tredn[i].isFocusOwner()) {
v_txt_Tredn[i + 1].requestFocus();
}
if (v_txt_Hn[i].isFocusOwner()) {
v_txt_Hn[i + 1].requestFocus();
}
8
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
if (v_txt_kn[i].isFocusOwner()) {
v_txt_kn[i + 1].requestFocus();
}
if (v_txt_horassoln[i].isFocusOwner()) {
v_txt_horassoln[i + 1].requestFocus();
}
}
if (v_txt_ocupacionn[11].isFocusOwner()) {//1
v_txt_Tredn[0].requestFocus();
}
if (v_txt_Tredn[11].isFocusOwner()) {//2
v_txt_Hn[0].requestFocus();
}
if (v_txt_Hn[11].isFocusOwner()) {//3
v_txt_kn[0].requestFocus();
}
if (v_txt_kn[11].isFocusOwner()) {//4
v_txt_horassoln[0].requestFocus();
}
if (v_txt_horassoln[11].isFocusOwner()) {//6
v_txt_Tambn[0].requestFocus();
}
//if(v_txt_Tamb[11].isFocusOwner()){//7
// v_txt_Tamb[0].requestFocus();
// }
}
public void Introduce_Datos_Mensuales_pordefecto() {
//double inclina=pueblo.Inclinacion;
pueblo.BuscaDatosMensuales(pueblo.Inclinacion, "");
//vTred=vTr1;vH=vh1;vCork=vck1;vHorasSolUtil=vHSU1;vTamb=vTa1;vDias=vd;vOcupacion=ocu;
for (int i = 0; i < 12; i++) {
v_txt_ocupacionn[i].setText("" + pueblo.vOcupacion[i]);
v_txt_Tredn[i].setText("" + pueblo.vTred[i]);
v_txt_Hn[i].setText("" + pueblo.vH[i]);
v_txt_kn[i].setText("" + pueblo.vCork[i]);
v_txt_horassoln[i].setText("" + pueblo.vHorasSolUtil[i]);
v_txt_Tambn[i].setText("" + pueblo.vTamb[i]);
}
}
public void Cambia_Inclinacion(String lugar) {
Double grados;
if (lugar.equals("inicio")) {
grados = Double.parseDouble(comboInclinacion_DDS.getSelectedItem().toString());
pueblo.setInclinacion(grados);
v_txt_DDS[0].setText("" + grados);
}
pueblo.BuscaDatosMensuales(pueblo.Inclinacion, "");
for (int i = 0; i < 12; i++) {
9
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
v_txt_kn[i].setText("" + pueblo.vCork[i]);
}
}
public void Cancela_Datos_Mensuales() {
int i;
for (i = 0; i < 12; i++) {
v_txt_ocupacionn[i].setText("");
v_txt_Tredn[i].setText("");
v_txt_Hn[i].setText("");
v_txt_kn[i].setText("");
v_txt_horassoln[i].setText("");
v_txt_Tambn[i].setText("");
}
}
//Asignar datos de entrada mensuales
public void Asigna_DatosMesEjemplo() {
/*
* if(pueblo.Nombre.equals("Badajoz")){
*
* double[] vd={31,28,31,30,31,30,31,31,30,31,30,31}; double[]
* ocu={0,0,100,100,100,100,100,100,100,100,100,0}; double[]
* vTr={6,7,9,11,12,13,14,13,12,11,9,6}; double[]
* vh={6.50,10,13.60,18.70,21.80,24.60,25.90,23.80,17.90,12.30,8.20,6.20};
* double[] vck={1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48};
* double[] vHSU={8,9,9,9.5,9.5,9.5,9.5,9.5,9,9,8,7.5}; double[]
* vTa={11,12,15,17,20,25,28,28,25,20,15,11};
* pueblo.setvDias(vd);pueblo.setvOcupacion(ocu);pueblo.setvTred(vTr);pueblo.setvH(vh);
* pueblo.setvCork(vck);pueblo.setvHorasSolUtil(vHSU);pueblo.setvTamb(vTa);
}
*/
}
public void Asigna_DatosMes_dilogo_datosmensuales() {
double[] vd = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
double[] ocu = new double[12];
double[] vTr = new double[12];
double[] vh = new double[12];
double[] vck = new double[12];
double[] vHSU = new double[12];
double[] vTa = new double[12];
for (int i = 0; i < 12; i++) {
ocu[i] = Double.parseDouble(v_txt_ocupacionn[i].getText());
vTr[i] = Double.parseDouble(v_txt_Tredn[i].getText());
vh[i] = Double.parseDouble(v_txt_Hn[i].getText());
vck[i] = Double.parseDouble(v_txt_kn[i].getText());
vHSU[i] = Double.parseDouble(v_txt_horassoln[i].getText());
vTa[i] = Double.parseDouble(v_txt_Tambn[i].getText());
}
pueblo.setvDias(vd);
pueblo.setvOcupacion(ocu);
pueblo.setvTred(vTr);
pueblo.setvH(vh);
pueblo.setvCork(vck);
pueblo.setvHorasSolUtil(vHSU);
pueblo.setvTamb(vTa);
10
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
public void vaciar_Calculosmes() {
for (int i = 0; i < 10; i++) {
calculosmes[i].setText("");
}
}
public void Creacion_subpanelresultados1() {
//subpanelresultados1.setSize(1000,425);
vmensual = new JLabel[12];
vtitulos = new JLabel[10];
//vtitulos=new JLabel[9];
v_txt_neMJ = new JTextField[12];
v_txt_ENDmes = new JTextField[12];
v_txt_ENTotalmes = new JTextField[12];
v_txt_Sustitucion = new JTextField[12];
v_txt_Deficit0 = new JTextField[12];
v_txt_CosteElectrico = new JTextField[12];
v_txt_CosteAuxiliar = new JTextField[12];
v_txt_Ahorro = new JTextField[12];
//añadido
v_txt_Cobertura = new JTextField[12];
int i;
for (i = 0; i < vmensual.length; i++) {
vmensual[i] = new JLabel();
vmensual[i].setText(vmes[i]);
vmensual[i].setBounds(20, 50 + 30 * i, 100, 20);
subpanelresultados1.add(vmensual[i]);
}
vtitulos[0] = new JLabel();
vtitulos[0].setText("meses");
vtitulos[0].setBounds(20, 15, 80, 20);
subpanelresultados1.add(vtitulos[0]);
int j;
for (j = 1; j < vtitulos.length; j++) {
vtitulos[j] = new JLabel();
if (j == 1) {
vtitulos[j].setText("neMJ");
}
if (j == 2) {
vtitulos[j].setText("ENDmes");
}
if (j == 3) {
vtitulos[j].setText("ENTotalmes");
}
if (j == 4) {
vtitulos[j].setText("Sustitución");
}
if (j == 5) {
vtitulos[j].setText("Déficit");
}
if (j == 6) {
vtitulos[j].setText("Coste kwh");
}
if (j == 7) {
vtitulos[j].setText("Coste Aux");
11
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
if (j == 8) {
vtitulos[j].setText("Ahorro");
}
if (j == 9) {
vtitulos[j].setText("Cobertura");
}
vtitulos[j].setBounds(40 + 100 * j, 15, 80, 20);
subpanelresultados1.add(vtitulos[j]);
}
int k;
for (k = 0; k < v_txt_neMJ.length; k++) {
v_txt_neMJ[k] = new JTextField();
v_txt_neMJ[k].setBounds(140, 50 + 30 * k, 80, 20);
v_txt_neMJ[k].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_neMJ[k]);
}
int l;
for (l = 0; l < v_txt_ENDmes.length; l++) {
v_txt_ENDmes[l] = new JTextField();
v_txt_ENDmes[l].setBounds(240, 50 + 30 * l, 80, 20);
v_txt_ENDmes[l].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_ENDmes[l]);
}
int ll;
for (ll = 0; ll < v_txt_ENTotalmes.length; ll++) {
v_txt_ENTotalmes[ll] = new JTextField();
v_txt_ENTotalmes[ll].setBounds(340, 50 + 30 * ll, 80, 20);
v_txt_ENTotalmes[ll].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_ENTotalmes[ll]);
v_txt_Sustitucion[ll] = new JTextField();
v_txt_Sustitucion[ll].setBounds(440, 50 + 30 * ll, 80, 20);
v_txt_Sustitucion[ll].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_Sustitucion[ll]);
v_txt_Deficit0[ll] = new JTextField();
v_txt_Deficit0[ll].setBounds(540, 50 + 30 * ll, 80, 20);
v_txt_Deficit0[ll].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_Deficit0[ll]);
//nuevos
v_txt_CosteElectrico[ll] = new JTextField();
v_txt_CosteElectrico[ll].setBounds(640, 50 + 30 * ll, 80, 20);
v_txt_CosteElectrico[ll].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_CosteElectrico[ll]);
v_txt_CosteAuxiliar[ll] = new JTextField();
v_txt_CosteAuxiliar[ll].setBounds(740, 50 + 30 * ll, 80, 20);
v_txt_CosteAuxiliar[ll].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_CosteAuxiliar[ll]);
v_txt_Ahorro[ll] = new JTextField();
v_txt_Ahorro[ll].setBounds(840, 50 + 30 * ll, 80, 20);
v_txt_Ahorro[ll].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_Ahorro[ll]);
v_txt_Cobertura[ll] = new JTextField();
12
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
v_txt_Cobertura[ll].setBounds(940, 50 + 30 * ll, 80, 20);
v_txt_Cobertura[ll].setHorizontalAlignment(JTextField.RIGHT);
subpanelresultados1.add(v_txt_Cobertura[ll]);
}
}
public void Calcular_ResultadosCostes() {
Aceptar_DatosdeEntrada();
for (int i = 0; i < 12; i++) {
v_txt_ENTotalmes[i].setText("" + pueblo.getvENTotalmes()[i]);
v_txt_Sustitucion[i].setText("" + pueblo.getvSustitucion()[i]);
v_txt_Deficit0[i].setText("" + pueblo.getvDeficit()[i]);
v_txt_CosteElectrico[i].setText("" + pueblo.getvCosteEmes()[i]);
v_txt_CosteAuxiliar[i].setText("" + pueblo.getvCosteAuxmes()[i]);
v_txt_Ahorro[i].setText("" + pueblo.getvAhorromes()[i]);
v_txt_Cobertura[i].setText("" + pueblo.getvCobertura()[i]);
etiresultadosCEanual.setText("" + pueblo.getCosteEanual() + " € ");
etiresultadosCAuxanual.setText("" + pueblo.getCosteAuxAnual() + " € ");
etiresultadosAhorroanual.setText("" + pueblo.getAhorroAnual() + " € ");
double defi, aux, aho;
defi = Double.parseDouble(v_txt_Deficit0[i].getText());
aux = Double.parseDouble(v_txt_CosteAuxiliar[i].getText());
aho = Double.parseDouble(v_txt_Ahorro[i].getText());
if (defi > 0) {
v_txt_Deficit0[i].setForeground(Color.red);
} else {
v_txt_Deficit0[i].setForeground(Color.blue);
}
if (aux > 0) {
v_txt_CosteAuxiliar[i].setForeground(Color.red);
} else {
v_txt_CosteAuxiliar[i].setForeground(Color.blue);
}
if (aho > 0) {
v_txt_Ahorro[i].setForeground(Color.green);
} else {
v_txt_Ahorro[i].setForeground(Color.blue);
}
}
etiresultadosAportacionAnual.setText("" + pueblo.getaportacionAnual() + " % ");
etiresultadosDeficitAnual.setText("" + pueblo.getdeficitEnergeticoAnual() + " MJ ");
//ventana resultados
VerResultados();
}
public void vaciar_resultados_trasNC() {
for (int i = 0; i < 12; i++) {
v_txt_ENTotalmes[i].setText("");
v_txt_Sustitucion[i].setText("");
v_txt_Deficit0[i].setText("");
v_txt_CosteElectrico[i].setText("");
v_txt_CosteAuxiliar[i].setText("");
13
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
v_txt_Ahorro[i].setText("");
v_txt_Cobertura[i].setText("");
}
txtresultadosNC.setText("");
etiresultadosSCresultante.setText("");
etiresultadosDeficitAnual.setText("");
etiresultadosAportacionAnual.setText("");
etiresultadosCEanual.setText("");
etiresultadosCAuxanual.setText("");
etiresultadosAhorroanual.setText("");
}
public void vaciar_panelAcumulacion() {
etiacuNC.setText("");
etiacuSCT.setText("");
etiacuCAm3.setText("");
etiacuNDA.setText("");
etiacuCNC1.setText("");
etiacuCNC2.setText("");
etiacuVT.setText("");
etiacuCV1.setText("");
etiacuCV2.setText("");
txtacuVolm2.setText("");
txtacuVP.setText("");
}
public void Creacion_subpaneldatosyresultados() {
vmensual = new JLabel[12];
vtitulos = new JLabel[11];
v_txt_ocupacion = new JTextField[12];
v_txt_Tred = new JTextField[12];
v_txt_H = new JTextField[12];
v_txt_k = new JTextField[12];
v_txt_E = new JTextField[12];
v_txt_horassol = new JTextField[12];
v_txt_Tamb = new JTextField[12];
v_txt_I = new JTextField[12];
v_txt_Rendimiento = new JTextField[12];
v_txt_Consumom3 = new JTextField[12];
int i;
for (i = 0; i < vmensual.length; i++) {
vmensual[i] = new JLabel();
vmensual[i].setText(vmes[i]);
vmensual[i].setBounds(10, 40 + 20 * i, 100, 20);
subpaneldatosyresultados.add(vmensual[i]);
v_txt_ocupacion[i] = new JTextField();
v_txt_ocupacion[i].setBounds(90, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_ocupacion[i]);
v_txt_Tred[i] = new JTextField();
v_txt_Tred[i].setBounds(170, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_Tred[i]);
v_txt_H[i] = new JTextField();
v_txt_H[i].setBounds(250, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_H[i]);
v_txt_k[i] = new JTextField();
14
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
v_txt_k[i].setBounds(330, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_k[i]);
v_txt_E[i] = new JTextField();
v_txt_E[i].setBounds(410, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_E[i]);
v_txt_horassol[i] = new JTextField();
v_txt_horassol[i].setBounds(490, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_horassol[i]);
v_txt_I[i] = new JTextField();
v_txt_I[i].setBounds(570, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_I[i]);
v_txt_Tamb[i] = new JTextField();
v_txt_Tamb[i].setBounds(650, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_Tamb[i]);
v_txt_Rendimiento[i] = new JTextField();
v_txt_Rendimiento[i].setBounds(730, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_Rendimiento[i]);
v_txt_Consumom3[i] = new JTextField();
v_txt_Consumom3[i].setBounds(810, 40 + 20 * i, 70, 20);
subpaneldatosyresultados.add(v_txt_Consumom3[i]);
}
int j;
for (j = 1; j < vtitulos.length; j++) {
vtitulos[j] = new JLabel();
if (j == 1) {
vtitulos[j].setText("Ocupacion");
}
if (j == 2) {
vtitulos[j].setText("Tred");
}
if (j == 3) {
vtitulos[j].setText("H");
}
if (j == 4) {
vtitulos[j].setText("k");
}
if (j == 5) {
vtitulos[j].setText("E");
}
if (j == 6) {
vtitulos[j].setText("horassol");
}
if (j == 7) {
vtitulos[j].setText("I");
}
if (j == 8) {
vtitulos[j].setText("Tamb");
}
if (j == 9) {
vtitulos[j].setText("Rendimiento");
}
if (j == 10) {
vtitulos[j].setText("Consumo m3");
}
vtitulos[j].setBounds(15 + 80 * j, 10, 100, 20);
subpaneldatosyresultados.add(vtitulos[j]);
}
}
15
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
public void Vaciar_subpaneldatosyresultados() {
for (int i = 0; i < 12; i++) {
v_txt_ocupacion[i].setText("");
v_txt_Tred[i].setText("");
v_txt_H[i].setText("");
v_txt_k[i].setText("");
v_txt_E[i].setText("");
v_txt_horassol[i].setText("");
v_txt_Tamb[i].setText("");
v_txt_I[i].setText("");
v_txt_Rendimiento[i].setText("");
v_txt_Consumom3[i].setText("");
}
}
public void Cancela_Datos_Generales(int lugar) {
if (lugar == 0) {
txtinclinacion1.setText("");
txtdesviacionNS1.setText("");
txtperdidasglobales1.setText("");
txtcorreccionH1.setText("");
txtlitrosdia1.setText("");
txtusuarios1.setText("");
txtcorreccionb1.setText("");
txtareacolector1.setText("");
txtb1.setText("");
txtm1.setText("");
txtTempuso1.setText("");
}//borra los del dialogo
else {
txtdatosInclinacion.setText("");//borra los del panel
txtdatosDesviacion.setText("");
txtdatosPerdidaglobal.setText("");
txtdatoscorreH.setText("");
txtdatosLitrosdia.setText("");
txtdatosUsuarios.setText("");
txtdatoscorreb.setText("");
txtdatosAreacol.setText("");
txtdatosbcol.setText("");
txtdatosmcol.setText("");
txtdatosTempuso.setText("");
txtdatosPreciokw.setText("");
}
}
public void Introduce_Datos_Generales(double[] DG) {
//Valores por defecto
txtinclinacion1.setText("" + DG[0]);
txtdesviacionNS1.setText("" + DG[1]);
txtcorreccionH1.setText("" + DG[2]);
txtperdidasglobales1.setText("" + DG[3]);
txtusuarios1.setText("" + DG[4]);
txtlitrosdia1.setText("" + DG[5]);
txtareacolector1.setText("" + DG[6]);
txtb1.setText("" + DG[7]);
txtm1.setText("" + DG[8]);
txtTempuso1.setText("" + DG[9]);
txtcorreccionb1.setText("" + DG[10]);
16
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
txtpreciokw1.setText("" + DG[11]);
}
//Metodos de cálculo por cuadros
public void Crear_Panel_CuadrosVerificacion_meses() {
chMeses = new JCheckBox[12];
int i;
for (i = 0; i < 6; i++) {
chMeses[i] = new JCheckBox();
chMeses[i].setBounds(10, 10 + 30 * i, 100, 20);
chMeses[i].setText(vmes[i]);
subpanelCVM.add(chMeses[i]);
}
for (i = 6; i < 12; i++) {
chMeses[i] = new JCheckBox();
chMeses[i].setBounds(150, 10 + 30 * (i - 6), 100, 20);
chMeses[i].setText(vmes[i]);
subpanelCVM.add(chMeses[i]);
}
//para que se muestre al pulsar
panel_calculos.repaint();
//para asignar metodo de borrar resultados
}
public void Calculo_mensual_porcuadro() {
for (int i = 0; i < 12; i++) {
pueblo.vOcupacion[i] = Double.parseDouble(v_txt_ocupacionn[i].getText());
if (chMeses[i].isSelected()) {//panel resultados
v_txt_neMJ[i].setText("" + pueblo.getvDemandaMJmes()[i]);
v_txt_ENDmes[i].setText("" + pueblo.getvENDmes()[i]);
} else {
pueblo.vOcupacion[i] = 0; //para meses no seleccionados
//panel resultados
v_txt_neMJ[i].setText("" + pueblo.getvDemandaMJmes()[i]);
v_txt_ENDmes[i].setText("" + pueblo.getvENDmes()[i]);
}
}
}
public void Calculo_resultadosNC_porcuadro() {
etiresultadosDA.setText("" + pueblo.getDemandaAnual());
etiresultadosENanual.setText("" + pueblo.getENDañoM2());
etiresultadosSCteorica.setText("" + pueblo.getSCteorica());
etiresultadosNCteorico.setText("" + pueblo.getNCteorico());
//ventana resultados
VerResultados();
}
public void Vaciar_resultados_porcuadro() {
vaciar_resultados_trasNC();
vaciar_panelAcumulacion();
etiresultadosDA.setText("");
etiresultadosENanual.setText("");
17
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
etiresultadosNCteorico.setText("");
etiresultadosSCteorica.setText("");
}
public void Ver_Datos_y_Resultados(){
//boton "consultar" panel datosyresultados
try{
for (int i = 0; i < 12; i++) {
v_txt_ocupacion[i].setText("" + pueblo.vOcupacion[i]*vloDA[i]);
//v_txt_ocupacion[i].setText("" + pueblo.getvOcupacion()[i]);
v_txt_Tred[i].setText("" + pueblo.getvTred()[i]);
v_txt_H[i].setText("" + pueblo.getvHcor()[i]);
v_txt_k[i].setText("" + pueblo.getvCork()[i]);
v_txt_E[i].setText("" + pueblo.vE[i]);
v_txt_horassol[i].setText("" + pueblo.vHorasSolUtil[i]);
v_txt_Tamb[i].setText("" + pueblo.vTamb[i]);
v_txt_I[i].setText("" + pueblo.vI[i]);
v_txt_Rendimiento[i].setText("" + pueblo.vRendimiento[i]);
v_txt_Consumom3[i].setText("" + pueblo.vConsumo[i]);
}}catch(Exception e){}
}
public void Crear_panel_Resultados_fchart() {
String tit[] = {"mes", "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep",
"Oct", "Nov", "Dic"};
//String titu[]={"N(días)","tac(ºC)","tr(ºC)","Qa","Ri(KJ/m2)","Ea","Dt(s)","k2","Ep"};
String titu[] = {"tr(ºC)", "Qa", "Ri(MJ/m2)", "Ea", "Dt(s)", "k2", "Ep", "D1=Ea/Qa", "D2=Ep/Qa", "f", "Qu=f*Qa"};
titulos = new JLabel[13];
titudatos = new JLabel[11];
//txtNdia=new JTextField[12];txttac=new JTextField[12];
txtD1 = new JTextField[12];
txtD2 = new JTextField[12];
txtf = new JTextField[12];
txtQu = new JTextField[12];
txttred = new JTextField[12];
txtQa = new JTextField[12];
txtRi = new JTextField[12];
txtEa = new JTextField[12];
txtDt = new JTextField[12];
txtK2 = new JTextField[12];
txtEp = new JTextField[12];
cober = new JLabel();
etiCSA = new JLabel();
for (int i = 0; i < tit.length; i++) {
titulos[i] = new JLabel();
titulos[i].setText(tit[i]);
titulos[i].setBounds(20 + 70 * i, 10, 45, 20);
panelfResultados.add(titulos[i]);
}
for (int i = 0; i < titu.length; i++) {
titudatos[i] = new JLabel();
titudatos[i].setText(titu[i]);
titudatos[i].setBounds(10, 40 + 25 * i, 60, 20);
panelfResultados.add(titudatos[i]);
}
/*
* for(int i=0;i<txtNdia.length;i++){ txtNdia[i]=new JTextField();
* txtNdia[i].setBounds(70+70*i,40,45, 20);
*
* panelfResultados.add(txtNdia[i]); } for(int i=0;i<txttac.length;i++){
* txttac[i]=new JTextField();
18
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
*
* txttac[i].setBounds(70+70*i,70,45, 20);
* panelfResultados.add(txttac[i]);
}
*/
for (int i = 0; i < txttred.length; i++) {
txttred[i] = new JTextField();
txttred[i].setBounds(70 + 70 * i, 40, 65, 20);
txttred[i].setBackground(Color.gray);
panelfResultados.add(txttred[i]);
}
for (int i = 0; i < txtQa.length; i++) {
txtQa[i] = new JTextField();
txtQa[i].setBounds(70 + 70 * i, 65, 65, 20);
panelfResultados.add(txtQa[i]);
}
for (int i = 0; i < txtRi.length; i++) {
txtRi[i] = new JTextField();
txtRi[i].setBounds(70 + 70 * i, 90, 65, 20);
txtRi[i].setBackground(Color.gray);
panelfResultados.add(txtRi[i]);
}
for (int i = 0; i < txtEa.length; i++) {
txtEa[i] = new JTextField();
txtEa[i].setBounds(70 + 70 * i, 115, 65, 20);
panelfResultados.add(txtEa[i]);
}
for (int i = 0; i < txtDt.length; i++) {
txtDt[i] = new JTextField();
txtDt[i].setBounds(70 + 70 * i, 140, 65, 20);
txtDt[i].setBackground(Color.gray);
panelfResultados.add(txtDt[i]);
}
for (int i = 0; i < txtK2.length; i++) {
txtK2[i] = new JTextField();
txtK2[i].setBounds(70 + 70 * i, 165, 65, 20);
panelfResultados.add(txtK2[i]);
}
for (int i = 0; i < txtEp.length; i++) {
txtEp[i] = new JTextField();
txtEp[i].setBounds(70 + 70 * i, 190, 65, 20);
txtEp[i].setBackground(Color.gray);
panelfResultados.add(txtEp[i]);
}
for (int i = 0; i < txtD1.length; i++) {
txtD1[i] = new JTextField();
txtD1[i].setBounds(70 + 70 * i, 215, 65, 20);
panelfResultados.add(txtD1[i]);
}
for (int i = 0; i < txtD2.length; i++) {
txtD2[i] = new JTextField();
txtD2[i].setBounds(70 + 70 * i, 240, 65, 20);
txtD2[i].setBackground(Color.gray);
panelfResultados.add(txtD2[i]);
}
for (int i = 0; i < txtf.length; i++) {
txtf[i] = new JTextField();
txtf[i].setBounds(70 + 70 * i, 265, 65, 20);
panelfResultados.add(txtf[i]);
}
for (int i = 0; i < txtQu.length; i++) {
19
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
txtQu[i] = new JTextField();
txtQu[i].setBounds(70 + 70 * i, 290, 65, 20);
txtQu[i].setBackground(Color.gray);
panelfResultados.add(txtQu[i]);
}
cober.setBounds(10, 320, 150, 20);
cober.setText("Cobetura solar anual:");
panelfResultados.add(cober);
etiCSA.setBounds(180, 320, 100, 20);
panelfResultados.add(etiCSA);
panelfResultados.repaint();
}
public void Valoresdefecto_Carga_fchart() {
if (Rbtn_fQa_valorespordefecto.isSelected()) {
Selecciona_ValoresPorDefecto_Qa_fchart();
} else {
txtfQa_Ce.setText("");//Calor específico
txtfQa_N.setText("");//número de usuarios
txtfQa_C.setText("");//consumo ACS litros/día/usuario
txtfQa_tac.setText("");//Temperatura de uso
}
}
public void Calcula_Cargas_fchart() {
try {
for (int i = 0; i < 12; i++) {
txttred[i].setText("" + pueblo.getvTred()[i]);
txtQa[i].setText("" + pueblo.getvfcarga()[i]);
}
} catch (Exception ex) {
}
}
public void Vacia_Cargas_fchart() {
for (int i = 0; i < 12; i++) {
txttred[i].setText("");
txtQa[i].setText("");
txtD1[i].setText("");
txtD2[i].setText("");
txtf[i].setText("");
txtQu[i].setText("");
}
etifQa_Ce.setText("");
etifQa_Consumo.setText("");
etifQa_tac.setText("");
etiCSA.setText("");
}
public void ValoresDefecto_Eabsorbida_fchart() {
if (Rbtn_fEa_valorespordefecto.isSelected()) {
Selecciona_ValoresPorDefecto_Ea_fchart();
} else {
txtfEa_FEO.setText("");
txtfEa_MAI.setText("");
txtfEa_FCCI.setText("");
txtfEa_numpaneles.setText("");
20
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
txtfEa_Sup1.setText("");
}
}
public void Calcula_Eabsorbida_fchart() {
for (int i = 0; i < 12; i++) {
txtRi[i].setText("" + pueblo.getvE()[i]);
txtEa[i].setText("" + pueblo.getvEabsorbida()[i]);
}
}
public void Vacia_Eabsorbida_fchart() {
for (int i = 0; i < 12; i++) {
txtRi[i].setText("");
txtEa[i].setText("");
txtD1[i].setText("");
txtf[i].setText("");
txtQu[i].setText("");
}
etifEa_FEO.setText("");
etifEa_MAI.setText("");
etifEa_FCCI.setText("");
etifEa_Sc.setText("");
etiCSA.setText("");
}
public void ValoresDefecto_Eperdida_fchart() {
if (Rbtn_fEp_valorespordefecto.isSelected()) {
Selecciona_ValoresPorDefecto_Ep_fchart();
} else {
txtfEp_CGP.setText("");
txtfEp_KgA.setText("");
txtfEp_Tmin.setText("");
}
}
public void Calcula_Eperdida_fchart() {
for (int i = 0; i < 12; i++) {
txtDt[i].setText("" + pueblo.getvDt()[i]);
txtK2[i].setText("" + pueblo.getvK2()[i]);
txtEp[i].setText("" + pueblo.getvEperdida()[i]);
}
}
public void Vacia_Eperdida_fchart() {
for (int i = 0; i < 12; i++) {
txtDt[i].setText("");
txtK2[i].setText("");
txtEp[i].setText("");
txtD2[i].setText("");
txtf[i].setText("");
txtQu[i].setText("");
}
etifEp_CGP.setText("");
etifEp_FprUL.setText("");
etifEp_KgA.setText("");
21
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
etifEp_Tmin.setText("");
etifEp_K1.setText("");
etiCSA.setText("");
}
public void Calcula_fchart() {
try {
for (int i = 0; i < 12; i++) {
txtD1[i].setText("" + pueblo.getvD1()[i]);
txtD2[i].setText("" + pueblo.getvD2()[i]);
txtf[i].setText("" + pueblo.getvfchart()[i]);
txtQu[i].setText("" + pueblo.getvEutilcaptada()[i]);
}
etiCSA.setText("" + pueblo.getCoberturaSA());
} catch (Exception ex) {
}
}
public void Crear_panel_valores_grafica_fchart() {
String tit[] = {"mes", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto",
"Septiembre", "Octubre", "Noviembre", "Diciembre", "CSA"};
nombres = new JLabel[14];
resultados = new JLabel[14];
for (int i = 0; i < tit.length; i++) {
nombres[i] = new JLabel();
nombres[i].setText(tit[i]);
nombres[i].setBounds(10, 10 + 20 * i, 70, 20);
panel_valores_grafica_fchart.add(nombres[i]);
}
for (int i = 0; i < tit.length; i++) {
resultados[i] = new JLabel();
resultados[i].setBounds(90, 10 + 20 * i, 70, 20);
resultados[i].setText("");
panel_valores_grafica_fchart.add(resultados[i]);
}
}
public void Crear_panel_Resultados_fchart_MasMenos() {
/*
* String
* tit[]={"mes","Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep",
* "Oct","Nov","Dic"};//para titulos
*/
String tit[] = {"mes", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre",
"Octubre", "Noviembre", "Diciembre"};//para titulos
String titu[] = {"Ocupación", "Litros/día usuario", "Tuso", "Inclinación"};//para titudatos
titulos = new JLabel[13];
titudatos = new JLabel[4];
txtf_ocupacion_Mm = new JTextField[12];
txtf_litrosdia_Mm = new JTextField[12];
txtf_tuso_Mm = new JTextField[12];
chMeses_fMasMenos = new JCheckBox[12];
txtf_inclinacion_Mm = new JTextField[12];
for (int i = 0; i < tit.length; i++) {
titulos[i] = new JLabel();
titulos[i].setText(tit[i]);//meses
22
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
titulos[i].setBounds(50 + 70 * i, 30, 80, 20);//80*45
panelfg_MasMenos.add(titulos[i]);
}
for (int i = 0; i < titu.length; i++) {
titudatos[i] = new JLabel();
titudatos[i].setText(titu[i]);
titudatos[i].setBounds(10, 60 + 25 * i, 90, 20);
panelfg_MasMenos.add(titudatos[i]);
}
for (int i = 0; i < 12; i++) {
txtf_ocupacion_Mm[i] = new JTextField();
txtf_ocupacion_Mm[i].setBounds(120 + 70 * i, 60, 65, 20);
panelfg_MasMenos.add(txtf_ocupacion_Mm[i]);
}
for (int i = 0; i < 12; i++) {
txtf_litrosdia_Mm[i] = new JTextField();
txtf_litrosdia_Mm[i].setBounds(120 + 70 * i, 85, 65, 20);
panelfg_MasMenos.add(txtf_litrosdia_Mm[i]);
}
for (int i = 0; i < 12; i++) {
txtf_tuso_Mm[i] = new JTextField();
txtf_tuso_Mm[i].setBounds(120 + 70 * i, 110, 65, 20);
panelfg_MasMenos.add(txtf_tuso_Mm[i]);
}
for (int i = 0; i < 12; i++) {
txtf_inclinacion_Mm[i] = new JTextField();
txtf_inclinacion_Mm[i].setBounds(120 + 70 * i, 135, 65, 20);
panelfg_MasMenos.add(txtf_inclinacion_Mm[i]);
}
for (int i = 0; i < 12; i++) {
chMeses_fMasMenos[i] = new JCheckBox();
chMeses_fMasMenos[i].setBounds(140 + 70 * i, 160, 65, 20);//160 a 25 del último(135)
//chMeses_fMasMenos[i].setText("");
panelfg_MasMenos.add(chMeses_fMasMenos[i]);
}
//para seleccionar en fchart y DA graf2 a la vez
for (int i = 0; i < 12; i++) {
chMeses_fMasMenos[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Selecciona_mes_Cambios_MmActionPerformed(evt, "fchart");
}
});
}
}
public void Crear_panel_Resultados_DA_MasMenos() {
/*
* String
* tit[]={"mes","Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep",
* "Oct","Nov","Dic"};//para titulos
*/
String tit[] = {"mes", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre",
"Octubre", "Noviembre", "Diciembre"};//para titulos
String titu[] = {"Ocupación", "Litros/día usuario", "Tuso", "Inclinación"};//para titudatos
titulos = new JLabel[13];
23
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
titudatos = new JLabel[4];
txtDA_ocupacion_Mm = new JTextField[12];
txtDA_litrosdia_Mm = new JTextField[12];
txtDA_tuso_Mm = new JTextField[12];
chMeses_DAMasMenos = new JCheckBox[12];
txtDA_inclinacion_Mm = new JTextField[12];
for (int i = 0; i < tit.length; i++) {
titulos[i] = new JLabel();
titulos[i].setText(tit[i]);//meses
titulos[i].setBounds(50 + 70 * i, 30, 80, 20);//80*45
panelDA_MasMenos.add(titulos[i]);
}
for (int i = 0; i < titu.length; i++) {
titudatos[i] = new JLabel();
titudatos[i].setText(titu[i]);
titudatos[i].setBounds(10, 60 + 25 * i, 90, 20);
panelDA_MasMenos.add(titudatos[i]);
}
for (int i = 0; i < 12; i++) {
txtDA_ocupacion_Mm[i] = new JTextField();
txtDA_ocupacion_Mm[i].setBounds(120 + 70 * i, 60, 65, 20);
panelDA_MasMenos.add(txtDA_ocupacion_Mm[i]);
}
for (int i = 0; i < 12; i++) {
txtDA_litrosdia_Mm[i] = new JTextField();
txtDA_litrosdia_Mm[i].setBounds(120 + 70 * i, 85, 65, 20);
panelDA_MasMenos.add(txtDA_litrosdia_Mm[i]);
}
for (int i = 0; i < 12; i++) {
txtDA_tuso_Mm[i] = new JTextField();
txtDA_tuso_Mm[i].setBounds(120 + 70 * i, 110, 65, 20);
panelDA_MasMenos.add(txtDA_tuso_Mm[i]);
}
for (int i = 0; i < 12; i++) {
txtDA_inclinacion_Mm[i] = new JTextField();
txtDA_inclinacion_Mm[i].setBounds(120 + 70 * i, 135, 65, 20);
panelDA_MasMenos.add(txtDA_inclinacion_Mm[i]);
}
for (int i = 0; i < 12; i++) {
chMeses_DAMasMenos[i] = new JCheckBox();
chMeses_DAMasMenos[i].setBounds(140 + 70 * i, 160, 65, 20);//160 a 25 del último(135)
//chMeses_fMasMenos[i].setText("");
panelDA_MasMenos.add(chMeses_DAMasMenos[i]);
}
//para seleccionar en fchart y DA graf2 a la vez
for (int i = 0; i < 12; i++) {
chMeses_DAMasMenos[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Selecciona_mes_Cambios_MmActionPerformed(evt, "DA");
}
});
}
}
public void Comrobar_K1_fchart() {
24
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
try {
pueblo.KgA = Double.parseDouble(txtf_compruebaKgA.getText());
pueblo.fSc
=
Double.parseDouble(txtf_compruebaNumpaneles.getText())
Double.parseDouble(etif_compruebaSupanel.getText());
double pru = pueblo.getPruebak1();
if (pru <= 37.5) {
etif_Prueba_K1.setText("No cumple " + pru + " < 37.5");
etif_Prueba_K1.setForeground(Color.red);
etiresultados_Prueba_K1_3.setText("" + pru);//ventana resultados
etiresultados_Prueba_K1_4.setText("No cumple");//ventana resultados
etiresultados_Prueba_K1_4.setForeground(Color.red);//ventana resultados
} else {
if (pru >= 300) {
etif_Prueba_K1.setText("No cumple " + pru + " > 300");
etif_Prueba_K1.setForeground(Color.red);
etiresultados_Prueba_K1_3.setText("" + pru);//ventana resultados
etiresultados_Prueba_K1_4.setText("No cumple");//ventana resultados
etiresultados_Prueba_K1_4.setForeground(Color.red);//ventana resultados
} else {
etif_Prueba_K1.setText("Cumple 37.5 < " + pru + " < 300");
etif_Prueba_K1.setForeground(Color.blue);
etiresultados_Prueba_K1_3.setText("" + pru);//ventana resultados
etiresultados_Prueba_K1_4.setText("Cumple");//ventana resultados
etiresultados_Prueba_K1_4.setForeground(Color.blue);//ventana resultados
}
}
//ventana resultados
VerResultados();
} catch (Exception ex) {
}
}
public void Cambia_KgAcumulacion_fchart(double incremento) {
double kilos = Double.parseDouble(txtf_compruebaKgA.getText()) + incremento;
if (kilos < 0) {
} else {
txtf_compruebaKgA.setText("" + kilos);
Vacia_Eperdida_fchart();//vacía las etiquetas relacionadas
txtfEp_KgA.setText("" + kilos);//escribe el nuevo valor en el diálogo de datos de Ep
Rbtn_fEp_valorespordefecto.setSelected(false);//y deselecciona valores por defecto
pueblo.KgA = Double.parseDouble(txtf_compruebaKgA.getText());
}//tomamos el nuevo valor
//ventana resultados
VerResultados();
}
public void Cambia_NumeroPaneles_fchart(double incremento) {
double paneles = Double.parseDouble(txtf_compruebaNumpaneles.getText()) + incremento;
if (paneles < 0) {
} else {
txtf_compruebaNumpaneles.setText("" + paneles);
Vacia_Eabsorbida_fchart();
txtfEa_numpaneles.setText("" + paneles);
Rbtn_fEa_valorespordefecto.setSelected(false);
pueblo.numpaneles = Double.parseDouble(txtf_compruebaNumpaneles.getText());
25
*
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
pueblo.Acol = Double.parseDouble(etif_compruebaSupanel.getText());
pueblo.fSc = pueblo.numpaneles * pueblo.Acol;
ConTresDecimales();
pueblo.fSc = Double.valueOf(formateador.format(pueblo.fSc));
txtf_compruebaSc.setText("" + pueblo.fSc);
}
//ventana resultados
VerResultados();
}
public void Cambia_FEObcol_fchart(double incremento) {
double feo = Double.parseDouble(txtf_comprueba_bcol.getText()) + incremento;
ConTresDecimales();
feo = Double.valueOf(formateador.format(feo));
if (feo < 0) {
} else {
txtf_comprueba_bcol.setText("" + feo);
// pueblo.setbcol(feo);//modificacion para quelo marque en Guardar resultados
txtdatosbcol.setText("" + feo);
Vacia_Eabsorbida_fchart();
txtfEa_FEO.setText("" + feo);
Rbtn_fEa_valorespordefecto.setSelected(false);
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
}
public void Cambia_CGPmcol_fchart(double incremento) {
double cgp = Double.parseDouble(txtf_comprueba_mcol.getText()) + incremento;
ConTresDecimales();
cgp = Double.valueOf(formateador.format(cgp));
if (cgp < 0) {
} else {
txtf_comprueba_mcol.setText("" + cgp);
// pueblo.setmcol(cgp);//modificacion para quelo marque en Guardar resultados
txtdatosmcol.setText("" + cgp);
Vacia_Eperdida_fchart();
txtfEp_CGP.setText("" + cgp);
Rbtn_fEa_valorespordefecto.setSelected(false);
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
}
public void Cambia_FCCI_fchart(double incremento) {
double fi = Double.parseDouble(txtf_comprueba_factorIntercambiador.getText()) + incremento;
ConTresDecimales();
fi = Double.valueOf(formateador.format(fi));
if (fi < 0) {
} else {
txtf_comprueba_factorIntercambiador.setText("" + fi);
Vacia_Eabsorbida_fchart();
txtfEa_FCCI.setText("" + fi);
Rbtn_fEa_valorespordefecto.setSelected(false);
26
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
}
public void Cambia_Ocupacion_fchart(double incremento) {
double focupa[] = new double[12];
for (int i = 0; i < 12; i++) {
focupa[i] = Double.parseDouble(txtf_ocupacion_Mm[i].getText()) + incremento;
if (focupa[i] > 100) {
} else {
if (focupa[i] < 0) {
} else {
if (chMeses_fMasMenos[i].isSelected()) {
txtf_ocupacion_Mm[i].setText("" + focupa[i]);
pueblo.vfporceocupacion[i] = focupa[i] / pueblo.vOcupacion[i];
vlo[i] = pueblo.vfporceocupacion[i];
} else {
}
}
}
}
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cambia_litrosdia_fchart(double incremento) {
double flitros[] = new double[12];
for (int i = 0; i < 12; i++) {
flitros[i] = Double.parseDouble(txtf_litrosdia_Mm[i].getText()) + incremento;
if (flitros[i] < 0) {
} else {
if (chMeses_fMasMenos[i].isSelected()) {
// flitros[i]=Double.parseDouble(txtf_litrosdia_Mm[i].getText())+incremento;
// if(flitros[i]<0){}else{
txtf_litrosdia_Mm[i].setText("" + flitros[i]);
pueblo.vfporcelitros[i] = flitros[i] / pueblo.LitrosDia;
vli[i] = pueblo.vfporcelitros[i];
} else {
}
}
}
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cambia_tuso_fchart(double incremento) {
27
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
double ftuso[] = new double[12];
for (int i = 0; i < 12; i++) {
ftuso[i] = Double.parseDouble(txtf_tuso_Mm[i].getText()) + incremento;
if (ftuso[i] > 100) {
} else {
if (ftuso[i] < 0) {
} else {
if (chMeses_fMasMenos[i].isSelected()) {
// ftuso[i]=Double.parseDouble(txtf_tuso_Mm[i].getText())+incremento;
// if(ftuso[i]>100){}else{if(ftuso[i]<0){}else{
txtf_tuso_Mm[i].setText("" + ftuso[i]);
pueblo.vfporcetuso[i] = ftuso[i] / pueblo.tac;
vlu[i] = pueblo.vfporcetuso[i];
} else {
}
}
}
}
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cambia_inclimacionMes_fchart(double incremento) {
double fangulo[] = new double[12];
for (int i = 0; i < 12; i++) {
fangulo[i] = Double.parseDouble(txtf_inclinacion_Mm[i].getText()) + incremento;
if (fangulo[i] > 60) {
} else {
if (fangulo[i] < 35) {
} else {
if (chMeses_fMasMenos[i].isSelected()) {
pueblo.BuscaDatosMensuales(fangulo[i], "aquí");
pueblo.vCork[i] = pueblo.vCork_MasMenos[i];
txtf_inclinacion_Mm[i].setText("" + fangulo[i]);
} else {
}
}
}
}
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cancela_cambios_fchart() {
try {
Asigna_DatosMes_dilogo_datosmensuales();
//Introduce_Datos_Mensuales_pordefecto();
// reinicia el valor de numpanel y kg
Selecciona_ValoresPorDefecto_Qa_fchart();
Selecciona_ValoresPorDefecto_Ea_fchart();
28
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Selecciona_ValoresPorDefecto_Ep_fchart();
int i;
for (i = 0; i < 12; i++) {
txtf_ocupacion_Mm[i].setText("" + pueblo.vOcupacion[i]);
txtf_litrosdia_Mm[i].setText("" + pueblo.LitrosDia);
txtf_tuso_Mm[i].setText("" + pueblo.Tuso);
txtf_inclinacion_Mm[i].setText("" + pueblo.Inclinacion);
chMeses_fMasMenos[i].setSelected(true);//para recalcular con cambia...(0)
}
Cambia_Ocupacion_fchart(0);//recalcula con los valores iniciales
Cambia_litrosdia_fchart(0);//recalcula con los valores iniciales
Cambia_tuso_fchart(0);//recalcula con los valores iniciales
for (i = 0; i < 12; i++) {
if (chMeses_fMasMenos[i].isSelected()) {
chMeses_fMasMenos[i].setSelected(false);
} else {
}
}
CambiayGrafica_fchart();
Comrobar_K1_fchart();
etifEa_FCCI.setBackground(Color.white);
etifEa_FEO.setBackground(Color.white);
etifEp_CGP.setBackground(Color.white);
} catch (Exception ex) {
}
}
public void Selecciona_ValoresPorDefecto_Qa_fchart() {
txtfQa_Ce.setText("4184");//Calor específico
txtfQa_N.setText("" + pueblo.NumUsu);//número de usuarios
txtfQa_C.setText("" + pueblo.LitrosDia);//consumo ACS litros/día/usuario
txtfQa_tac.setText("" + pueblo.Tuso);//Temperatura de uso
}
public void Selecciona_ValoresPorDefecto_Ea_fchart() {
txtfEa_FEO.setText("" + pueblo.bcol);//factor eficiencia óptica del colector
txtfEa_MAI.setText("0.96");//modificación por el ángulo de incidencia
txtfEa_FCCI.setText("0.95");//factor de correccion Captador-Intercambiador
txtfEa_numpaneles.setText("" + pueblo.NCrecomendado);//número de paneles
txtfEa_Sup1.setText("" + pueblo.Acol);//superficie de un panel
}
public void Selecciona_ValoresPorDefecto_Ep_fchart() {
txtfEp_CGP.setText("" + pueblo.mcol);//factor eficiencia óptica del colector
txtfEp_KgA.setText("" + pueblo.VolAcuDiseño);//modificación por el ángulo de incidencia
txtfEp_Tmin.setText("" + pueblo.Tuso);//factor de correccion Captador-Intercambiador
}
public void AceptaDatos_Qa_fchart() {
pueblo.Ce = Double.parseDouble(txtfQa_Ce.getText());
pueblo.N = Double.parseDouble(txtfQa_N.getText());
pueblo.C = Double.parseDouble(txtfQa_C.getText());
pueblo.tac = Double.parseDouble(txtfQa_tac.getText());
etifQa_Ce.setText(txtfQa_Ce.getText());
pueblo.consufQa = pueblo.N * pueblo.C;
etifQa_Consumo.setText("" + pueblo.consufQa);
29
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
etifQa_tac.setText(txtfQa_tac.getText());
}
public void AceptaDatos_Ea_fchart() {
pueblo.FEO = Double.parseDouble(txtfEa_FEO.getText());
pueblo.MAI = Double.parseDouble(txtfEa_MAI.getText());
pueblo.FCCI = Double.parseDouble(txtfEa_FCCI.getText());
pueblo.numpaneles = Double.parseDouble(txtfEa_numpaneles.getText());
if (pueblo.numpaneles == 0) {
String nupal = JOptionPane.showInputDialog(null, "Número de captadores ");
pueblo.numpaneles = Double.parseDouble(nupal);
txtfEa_numpaneles.setText(nupal);
}
pueblo.Sup1 = Double.parseDouble(txtfEa_Sup1.getText());
etifEa_FEO.setText(txtfEa_FEO.getText());
etifEa_MAI.setText(txtfEa_MAI.getText());
etifEa_FCCI.setText(txtfEa_FCCI.getText());
pueblo.fSc = pueblo.numpaneles * pueblo.Sup1;
ConTresDecimales();
pueblo.fSc = Double.valueOf(formateador.format(pueblo.fSc));
etifEa_Sc.setText("" + pueblo.fSc);
//para la comprobación de k1
txtf_compruebaNumpaneles.setText("" + pueblo.numpaneles);
etif_compruebaSupanel.setText("" + pueblo.Sup1);
txtf_compruebaSc.setText("" + pueblo.fSc);
//para variaciones de bcol
txtf_comprueba_bcol.setText("" + pueblo.FEO);
//para variaciones del factor captador-Intercambiador
txtf_comprueba_factorIntercambiador.setText("" + pueblo.FCCI);
}
public void AceptaDatos_Ep_fchart() {
pueblo.CGP = Double.parseDouble(txtfEp_CGP.getText());//coeficiemte global de pérdidas
pueblo.KgA = Double.parseDouble(txtfEp_KgA.getText());//kg de acumulación
if (pueblo.KgA == 0) {
Calcula_VolumenAcu();
Calcula_PruebaAcu();
txtfEp_KgA.setText(""+pueblo.VolAcuDiseño);
pueblo.KgA = Double.parseDouble(txtfEp_KgA.getText());
}
pueblo.Tmin = Double.parseDouble(txtfEp_Tmin.getText());//Temperatura del ACS
pueblo.FCCI = Double.parseDouble(etifEa_FCCI.getText());
etifEp_CGP.setText(txtfEp_CGP.getText());
etifEp_KgA.setText(txtfEp_KgA.getText());
etifEp_Tmin.setText(txtfEp_Tmin.getText());
etifEp_FprUL.setText("" + pueblo.getFprUL());
etifEp_K1.setText("" + pueblo.getK1());
//para comprobar k1
etif_compruebaK1.setText("" + pueblo.getK1());
txtf_compruebaKgA.setText(etifEp_KgA.getText());
//para variaciones de mcol
txtf_comprueba_mcol.setText("" + pueblo.CGP);
}
public void Graficar_fchart() {
double mi = 0;
30
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
double ma = 12;
// double[] csa={pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,
// pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA};
double csa[] = new double[12];
for (int i = 0; i < 12; i++) {
csa[i] = pueblo.CSA;
}
double fmes[] = new double[12];
for (int i = 0; i < 12; i++) {
fmes[i] = pueblo.vf[i] / 100;
}
gf.Dibuja_grafica_fchart(mi, ma, fmes, csa, Color.blue, Color.red, panelgraf);
resultados[0].setText("f");
resultados[13].setText("" + pueblo.CSA);
resultados[13].setForeground(Color.red);
for (int i = 0; i < 12; i++) {
resultados[i + 1].setText("" + pueblo.getvfchart()[i]);
resultados[i + 1].setForeground(Color.blue);
}
}
public void Borra_Grafica_fchart() {
double mi = 0;
double ma = 12;
// double[] csa={pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,
// pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA,pueblo.CSA};
double csa[] = new double[12];
for (int i = 0; i < 12; i++) {
csa[i] = 0;
}
double fmes[] = new double[12];
for (int i = 0; i < 12; i++) {
fmes[i] = 0;
}
gf.Dibuja_grafica_fchart(mi, ma, fmes, csa, Color.blue, Color.red, panelgraf);
resultados[0].setText("f");
resultados[13].setText("");
resultados[13].setForeground(Color.red);
for (int i = 0; i < 12; i++) {
resultados[i + 1].setText("");
resultados[i + 1].setForeground(Color.blue);
}
for (int i = 0; i < 12; i++) {
txtf_ocupacion_Mm[i].setText("");
txtf_litrosdia_Mm[i].setText("");
txtf_tuso_Mm[i].setText("");
txtf_inclinacion_Mm[i].setText("");
chMeses_fMasMenos[i].setSelected(false);
}
}
public void CambiayGrafica_fchart() {
try {
AceptaDatos_Qa_fchart();
Calcula_Cargas_fchart();
31
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
AceptaDatos_Ea_fchart();
Calcula_Eabsorbida_fchart();
AceptaDatos_Ep_fchart();
Calcula_Eperdida_fchart();
Calcula_fchart();
Graficar_fchart();
VerResultados();
} catch (Exception ex) {
}
}
public void Cambia_NumeroColectores(double variacion) {
try {
double colectores = Double.parseDouble(etiacuNC.getText()) + variacion;
if (colectores < 0) {
} else {
etiacuNC.setText("" + colectores);
vaciar_resultados_trasNC();
txtresultadosNC.setText("" + colectores);
nc = Double.parseDouble(txtresultadosNC.getText());
pueblo.setNC(nc);
pueblo.numpaneles = nc;
pueblo.NCrecomendado = nc;
etiresultadosSCresultante.setText("" + pueblo.getSCresultante());
//ventana_resultados
etiresultadosSCresultante1.setText(""+pueblo.getSCresultante());
//
Calcular_ResultadosCostes();
etiacuSCT.setText("" + pueblo.getSCresultante());
etiacuCNC1.setText("" + pueblo.getPruebaSC());
// etiresultadosCNC1.setText(""+pueblo.getPruebaSC());//ventana resultados
String comp = pueblo.getComprobacionSC();
if (comp.contentEquals("Cumple")) {
etiacuCNC2.setForeground(Color.blue);
// etiresultadosCNC2.setForeground(Color.blue);//ventana resultados
} else {
etiacuCNC2.setForeground(Color.red);
// etiresultadosCNC2.setForeground(Color.red);//ventana resultados
}
etiacuCNC2.setText(comp);
// etiresultadosCNC2.setText(comp);//ventana resultados
etiresultadosAportacionAnual.setText("" + pueblo.getaportacionAnual() + " %");
etiresultadosDeficitAnual.setText("" + pueblo.getdeficitEnergeticoAnual());
}
} catch (Exception ex) {
}
}
public void Cambia_VolumenAcumulacion(double variacion) {
double volumen = Double.parseDouble(txtacuVP.getText()) + variacion;
if (volumen < 0) {
} else {
txtacuVP.setText("" + volumen);
pueblo.VolAcuDiseño = volumen;
etiacuCV1.setText("" + pueblo.getPruebaVolAcu());
32
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
String comp = pueblo.getComprobacionVolAcu();
if (comp.contentEquals("Cumple")) {
etiacuCV2.setForeground(Color.blue);
} else {
etiacuCV2.setForeground(Color.red);
}
etiacuCV2.setText(comp);
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
}
public void pasar_focoQafchart() {
JTextField campo[] = new JTextField[4];
campo[0] = txtfQa_Ce;
campo[1] = txtfQa_N;
campo[2] = txtfQa_C;
campo[3] = txtfQa_tac;
for (int i = 0; i < 3; i++) {
if (campo[i].isFocusOwner()) {
campo[i + 1].requestFocus();
}
}
if (campo[3].isFocusOwner()) {
campo[0].requestFocus();
}
}
public void pasar_focoEafchart() {
JTextField campo[] = new JTextField[5];
campo[0] = txtfEa_FEO;
campo[1] = txtfEa_MAI;
campo[2] = txtfEa_FCCI;
campo[3] = txtfEa_numpaneles;
campo[4] = txtfEa_Sup1;
for (int i = 0; i < 4; i++) {
if (campo[i].isFocusOwner()) {
campo[i + 1].requestFocus();
}
}
if (campo[4].isFocusOwner()) {
campo[0].requestFocus();
}
}
public void pasar_focoEpfchart() {
JTextField campo[] = new JTextField[3];
campo[0] = txtfEp_CGP;
campo[1] = txtfEp_KgA;
campo[2] = txtfEp_Tmin;
for (int i = 0; i < 2; i++) {
if (campo[i].isFocusOwner()) {
campo[i + 1].requestFocus();
}
}
if (campo[2].isFocusOwner()) {
campo[0].requestFocus();
33
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
}
public void ConTresDecimales() {
DecimalFormatSymbols simbolo = new DecimalFormatSymbols();
/*simbolo.setDecimalSeparator('.');
formateador = new DecimalFormat("#####.###", simbolo); //variable formateador declarada como global*/
simbolo.setDecimalSeparator('.');
formateador = new DecimalFormat("#####.###", simbolo); //variable formateador declarada como global
}
public void Introduce_datos_calculosporcombomes() {
String mes = combocalculosmes.getSelectedItem().toString();
vaciar_Calculosmes();
// vValorEntradaMensualesDefecto=new double[7];
for (int i = 0; i < vmes.length; i++) {
if (mes.equals(vmes[i])) {
chMeses[i].setSelected(true);//para señalar el cuadro de verificacion
txtdatosmesDias.setText("" + pueblo.vDias[i]);
txtdatosmesOcupacion.setText("" + pueblo.vOcupacion[i]);
txtdatosmesTred.setText("" + pueblo.vTred[i]);
txtdatosmesH.setText("" + pueblo.vH[i]);
txtdatosmesCork.setText("" + pueblo.vCork[i]);
txtdatosmesHorasSol.setText("" + pueblo.vHorasSolUtil[i]);
txtdatosmesTamb.setText("" + pueblo.vTamb[i]);
}
}
}
public void Consulta_calculosporcombomes() {
String mes = combocalculosmes.getSelectedItem().toString();
// eticalculosmesConsumo.setText(""+pueblo.Consumo(0));
for (int i = 0; i < vmes.length; i++) {
if (mes.equals(vmes[i])) {
eticalculosmesConsumo.setText("" + pueblo.getvConsumo()[i]);
eticalculosmesSalto.setText("" + pueblo.getSaltoT()[i]);
eticalculosmesTermias.setText("" + pueblo.getvDemandaTermiasmes()[i]);
eticalculosmesDemandaMJ.setText("" + pueblo.getvDemandaMJmes()[i]);
eticalculosmesHcor.setText("" + pueblo.getvHcor()[i]);
eticalculosmesE.setText("" + pueblo.getvE()[i]);
eticalculosmesI.setText("" + pueblo.getvI()[i]);
eticalculosmesENDmes.setText("" + pueblo.getvENDmes()[i]);
eticalculosmesRendimiento.setText("" + pueblo.getvRendimiento()[i]);
eticalculosmesAportacion.setText("" + pueblo.getvAportacion()[i]);
//panel resultados
v_txt_neMJ[i].setText("" + pueblo.getvDemandaMJmes()[i]);
v_txt_ENDmes[i].setText("" + pueblo.getvENDmes()[i]);
}
}
}
// Gráficas Demanda-Aportación DA histogramasACS.java
public void Grafica_DemandaAportacion() {
//barras finas seguidas
try {
HistogramaACS HDA = new HistogramaACS();
34
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
double[] valores = new double[12];
// Color[] colores=new Color[12];
double dmax = 0;
for (int i = 0; i < 12; i++) {
valores[i] = pueblo.vDemandaMJmes[i] / 100;
if (pueblo.vDemandaMJmes[i] > dmax) {
dmax = pueblo.vDemandaMJmes[i];
}
// colores[i]=Color.orange;
}
double[] valores2 = new double[12];
// Color[] colores2=new Color[12];
double aportamax = 0;
for (int i = 0; i < 12; i++) {
valores2[i] = pueblo.vENTotalmes[i] / 100;
if (pueblo.vENTotalmes[i] > aportamax) {
aportamax = pueblo.vENTotalmes[i];
}
// colores2[i]=Color.red;
}
double referenciaescala;
if (dmax > aportamax) {
referenciaescala = dmax / 100;
} else {
referenciaescala = aportamax / 100;
}
if (dmax == aportamax) {
referenciaescala = dmax / 100;
}//es indiferente un valor u otro
double[] val1 = new double[24];
Color[] colores = new Color[24];
for (int i = 0; i < 24; i += 2) {
val1[i] = valores[i / 2];
colores[i] = Color.orange;//valores pares empezando por cero 0,2,4,...,se corresponden con los valores de
vDemandaMJmes[0,1,2,3,4...11]
}
for (int i = 1; i < 24; i += 2) {
val1[i] = valores2[(i - 1) / 2];
colores[i] = Color.red;//valores impares 1,3,5,7,9...,se corresponden con los valores de
vENTotalmes[0,1,2,3,4...11]
}
HDA.Dibuja_Histograma3_escalado(referenciaescala, val1, colores, panhistoDemandaAportacion1);//averaver
panhistoDemandaAportacion1.validate();
} catch (Exception ex) {
}
}
public void Dibuja_DemandaAportacion() {
try {
//barras gruesas superpuestas
HistogramaACS HDA = new HistogramaACS();
double[] valores = new double[12];
Color[] colores = new Color[12];
double dmax = 0;//demanda maxima
for (int i = 0; i < 12; i++) {
35
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
valores[i] = pueblo.vDemandaMJmes[i] / 100;
if (pueblo.vDemandaMJmes[i] > dmax) {
dmax = pueblo.vDemandaMJmes[i];
}
colores[i] = Color.orange;
}
double[] valores2 = new double[12];
Color[] colores2 = new Color[12];
double aportamax = 0;// aportación máxima
for (int i = 0; i < 12; i++) {
valores2[i] = pueblo.vENTotalmes[i] / 100;
if (pueblo.vENTotalmes[i] > aportamax) {
aportamax = pueblo.vENTotalmes[i];
}
colores2[i] = Color.red;
}
double referenciaescala;
if (dmax > aportamax) {
referenciaescala = dmax / 100;
} else {
referenciaescala = aportamax / 100;
}
if (dmax == aportamax) {
referenciaescala = dmax / 100;
}//es indiferente un valor u otro
double[] val1 = new double[12];
double[] val2 = new double[12];
for (int i = 0; i < 12; i++) {
if (valores[i] < valores2[i]) {
val1[i] = valores2[i];
colores[i] = Color.red;
val2[i] = valores[i];
colores2[i] = Color.orange;
} else {
val1[i] = valores[i];
colores[i] = Color.orange;
val2[i] = valores2[i];
colores2[i] = Color.red;
}
}
// HDA.Dibuja_Histograma2(val1,val2,colores,colores2, panhistoDemandaAportacion);//averaver
HDA.Dibuja_Histograma2_escalado(referenciaescala,
val1,
val2,
colores,
panhistoDemandaAportacion);//averaver
// HDA.Dibuja_Histograma2(valores,valores2,colores,colores2, panhistoDemandaAportacion);
panhistoDemandaAportacion.validate();
} catch (Exception ex) {
}
}
colores2,
public void GraficayDibuja_DemandaAporatacion_Masmenos() {
try {
Calculo_mensual_porcuadro();
Calcular_ResultadosCostes();
Grafica_DemandaAportacion();
Dibuja_DemandaAportacion();
Grafica_DemandaAportacion();//no sé por que, pero para que actualice hay que repetir una orden,la que sea
} catch (Exception ex) {
}
}
36
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
public void borra_Graficas_DA() {
try {
HistogramaACS HDA = new HistogramaACS();
double[] valores = new double[12];
// Color[] colores=new Color[12];
double dmax = 0;
for (int i = 0; i < 12; i++) {
valores[i] = 0;
// colores[i]=Color.orange;
}
double[] valores2 = new double[12];
// Color[] colores2=new Color[12];
double aportamax = 0;
for (int i = 0; i < 12; i++) {
valores2[i] = 0;
}
// colores2[i]=Color.red;
double referenciaescala = 100;
double[] val1 = new double[24];
Color[] colores = new Color[24];
for (int i = 0; i < 24; i += 2) {
val1[i] = valores[i / 2];
colores[i] = Color.orange;//valores pares empezando por cero 0,2,4,...,se corresponden con los valores de
vDemandaMJmes[0,1,2,3,4...11]
}
for (int i = 1; i < 24; i += 2) {
val1[i] = valores2[(i - 1) / 2];
colores[i] = Color.red;//valores impares 1,3,5,7,9...,se corresponden con los valores de
vENTotalmes[0,1,2,3,4...11]
}
HDA.Dibuja_Histograma3_escalado(referenciaescala, val1, colores, panhistoDemandaAportacion1);//averaver
panhistoDemandaAportacion1.validate();
HDA.Dibuja_Histograma2_escalado(referenciaescala,
val1,
valores2,
colores,
colores,
panhistoDemandaAportacion);//averaver
// HDA.Dibuja_Histograma2(valores,valores2,colores,colores2, panhistoDemandaAportacion);
panhistoDemandaAportacion.validate();
for (int i = 0; i < 12; i++) {
txtDA_ocupacion_Mm[i].setText("");
txtDA_litrosdia_Mm[i].setText("");
txtDA_tuso_Mm[i].setText("");
txtDA_inclinacion_Mm[i].setText("");
chMeses_DAMasMenos[i].setSelected(false);
}
} catch (Exception ex) {
}
}
//-------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------// VARIACIONES EN LA GRAFICA DEMANDA APORTACIÓN (DA)
37
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
public void Comprobar_NumeroPaneles() {
// criterio censolar
etiacuNC.setText("" + pueblo.getNCrecomendado());
// txtDA_paneles.setText(""+pueblo.getNCrecomendado());//lo hemos borrado
etiacuSCT.setText("" + pueblo.getSCresultante());
etiacuCAm3.setText("" + pueblo.getConsumoanualACSm3());
etiacuNDA.setText("" + pueblo.getNumDiasAnual());
etiacuCNC1.setText("" + pueblo.getPruebaSC());
String comp = pueblo.getComprobacionSC();
if (comp.contentEquals("Cumple")) {
etiacuCNC2.setForeground(Color.blue);
} else {
etiacuCNC2.setForeground(Color.red);
}
etiacuCNC2.setText(comp);
//ventana resultados
VerResultados();
}
public void Cambia_Ocupacion_DA(double incremento) {
double focupa[] = new double[12];
for (int i = 0; i < 12; i++) {
focupa[i] = Double.parseDouble(txtDA_ocupacion_Mm[i].getText()) + incremento;
if (focupa[i] > 100) {
} else {
if (focupa[i] < 0) {
} else {
if (chMeses_DAMasMenos[i].isSelected()) {
txtDA_ocupacion_Mm[i].setText("" + focupa[i]);
pueblo.vDAporceocupacion[i] = focupa[i] / pueblo.vOcupacion[i];
vloDA[i] = pueblo.vDAporceocupacion[i];
} else {
}
}
}
}
Calculo_resultadosNC_porcuadro();
Comprobar_NumeroPaneles();
}
public void Cambia_litrosdia_DA(double incremento) {
double flitros[] = new double[12];
for (int i = 0; i < 12; i++) {
flitros[i] = Double.parseDouble(txtDA_litrosdia_Mm[i].getText()) + incremento;
if (flitros[i] < 0) {
} else {
if (chMeses_DAMasMenos[i].isSelected()) {
txtDA_litrosdia_Mm[i].setText("" + flitros[i]);
pueblo.vDAporcelitros[i] = flitros[i] / pueblo.LitrosDia;
vliDA[i] = pueblo.vDAporcelitros[i];
} else {
}
}
}
38
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Calculo_resultadosNC_porcuadro();
Comprobar_NumeroPaneles();
}
public void Cambia_tuso_DA(double incremento) {
double ftuso[] = new double[12];
for (int i = 0; i < 12; i++) {
ftuso[i] = Double.parseDouble(txtDA_tuso_Mm[i].getText()) + incremento;
if (ftuso[i] > 100) {
} else {
if (ftuso[i] < 0) {
} else {
if (chMeses_DAMasMenos[i].isSelected()) {
txtDA_tuso_Mm[i].setText("" + ftuso[i]);
pueblo.vDAporcetuso[i] = ftuso[i] / pueblo.Tuso;
vluDA[i] = pueblo.vDAporcetuso[i];
} else {
}
}
}
}
Calculo_resultadosNC_porcuadro();
}
public void Cambia_inclimacionMes_DA(double incremento) {
double fangulo[] = new double[12];
for (int i = 0; i < 12; i++) {
fangulo[i] = Double.parseDouble(txtDA_inclinacion_Mm[i].getText()) + incremento;
if (fangulo[i] > 60) {
} else {
if (fangulo[i] < 35) {
} else {
if (chMeses_DAMasMenos[i].isSelected()) {
pueblo.BuscaDatosMensuales(fangulo[i], "aquí");
pueblo.vCork[i] = pueblo.vCork_MasMenos[i];
txtDA_inclinacion_Mm[i].setText("" + fangulo[i]);
} else {
}
}
}
}
Calculo_resultadosNC_porcuadro();
}
public void Cancela_cambios_DA() {
try {
Asigna_DatosMes_dilogo_datosmensuales();
//Introduce_Datos_Mensuales_pordefecto();
int i;
for (i = 0; i < 12; i++) {
txtDA_ocupacion_Mm[i].setText("" + pueblo.vOcupacion[i]);
txtDA_litrosdia_Mm[i].setText("" + pueblo.LitrosDia);
txtDA_tuso_Mm[i].setText("" + pueblo.Tuso);
txtDA_inclinacion_Mm[i].setText("" + pueblo.Inclinacion);
chMeses_DAMasMenos[i].setSelected(true);//para recalcular con cambia...(0)
39
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
Cambia_Ocupacion_DA(0);//recalcula con los valores iniciales
Cambia_litrosdia_DA(0);//recalcula con los valores iniciales
Cambia_tuso_DA(0);//recalcula con los valores iniciales
Cambia_inclimacionMes_DA(0);
for (i = 0; i < 12; i++) {
if (chMeses_DAMasMenos[i].isSelected()) {
chMeses_DAMasMenos[i].setSelected(false);
} else {
}
}
GraficayDibuja_DemandaAporatacion_Masmenos();
} catch (Exception ex) {
}
}
//----------------------------------------------------------------------//----------------------Cancelar todo-----Nuevo proyecto----------------public void Cancela_Nuevo() {
// comboDDNPloc.setSelectedIndex(0);
etiDDNPloc.setText("");
txtDDNPnuevaloc.setText("");
etiDDNP_nombreciudad.setText("");
//
txtdatoslocalidad.setText("");
// combodatoslocalidad.setSelectedIndex(0);
// dialogodatos_nuevoproyecto.dispose();
etidatos_Nombre_lat.setText("");
etidatos_Latitud_lat.setText("");
etidatos_Altitud_lat.setText("");
etidatos_Tminhistorica_lat.setText("");
for (int i = 0; i < 12; i++) {
datosEntrada[i].setText("");
}
}
public void Cancelar_Todo() {
Cancela_Datos_Mensuales();
if (RbtnDatosmensuales.isSelected()) {
RbtnDatosmensuales.setSelected(false);
}
Cancela_Datos_Generales(0);
if (Rbtn_datosDefecto.isSelected()) {
Rbtn_datosDefecto.setSelected(false);
}
Cancela_Nuevo();
int i;
for (i = 0; i < 12; i++) {
if (chMeses[i].isSelected()) {
chMeses[i].setSelected(false);
} else {
}
40
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//panel resultados
v_txt_neMJ[i].setText("");
v_txt_ENDmes[i].setText("");
}
borra_Graficas_DA();
Vaciar_resultados_porcuadro();
Vaciar_subpaneldatosyresultados();
vaciar_resultados_trasNC();
vaciar_panelAcumulacion();
Cancelar_fchart();
Borrar_Histogramas_RendiAporSustitucion();
Reiniciar_subpanelesResultados();
}
public void Cancelar_fchart() {
Rbtn_fQa_valorespordefecto.setSelected(false);
Rbtn_fEa_valorespordefecto.setSelected(false);
Rbtn_fEp_valorespordefecto.setSelected(false);
Vacia_Cargas_fchart();
Valoresdefecto_Carga_fchart();
Vacia_Eabsorbida_fchart();
ValoresDefecto_Eabsorbida_fchart();
Vacia_Eperdida_fchart();
ValoresDefecto_Eperdida_fchart();
Borra_Grafica_fchart();
etif_compruebaK1.setText("");
txtf_compruebaKgA.setText("");
txtf_compruebaNumpaneles.setText("");
etif_compruebaSupanel.setText("");
txtf_compruebaSc.setText("");
etif_Prueba_K1.setText("");
txtf_comprueba_mcol.setText("");
txtf_comprueba_bcol.setText("");
txtf_comprueba_factorIntercambiador.setText("");
}
public void Borrar_Histogramas_RendiAporSustitucion() {
try {
HistogramaACS HR = new HistogramaACS();
double[] valores = new double[12];
Color[] colores = new Color[12];
for (int i = 0; i < 12; i++) {
valores[i] = 0;
if (valores[i] < 50) {
colores[i] = Color.cyan;
} else {
colores[i] = Color.orange;
}
}
HR.Dibuja_Histograma(valores, colores, panhistorendi);
HR.Dibuja_Histograma(valores, colores, panhistoaport);
HR.Dibuja_Histograma(valores, colores, panhistosusti);
} catch (Exception ex) {
41
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
}
public void Dibuja_Histograma_Rendimiento() {
try {
HistogramaACS HR = new HistogramaACS();
double[] valores = new double[12];
Color[] colores = new Color[12];
for (int i = 0; i < 12; i++) {
valores[i] = pueblo.vRendimiento[i];
if (valores[i] < 50) {
colores[i] = Color.cyan;
} else {
colores[i] = Color.orange;
}
}
HR.Dibuja_Histograma(valores, colores, panhistorendi);
} catch (Exception ex) {
}
}
public void Dibuja_Histograma_Aportacion() {
try {
HistogramaACS HR = new HistogramaACS();
double[] valores = new double[12];
Color[] colores = new Color[12];
for (int i = 0; i < 12; i++) {
valores[i] = pueblo.getASR()[i];
if (valores[i] < 50) {
colores[i] = Color.cyan;
} else {
colores[i] = Color.orange;
}
}
HR.Dibuja_Histograma(valores, colores, panhistoaport);
} catch (Exception ex) {
}
}
public void Dibuja_Histograma_Sustitucion() {
try {
HistogramaACS HR = new HistogramaACS();
double[] valores = new double[12];
Color[] colores = new Color[12];
for (int i = 0; i < 12; i++) {
valores[i] = pueblo.vSustitucion[i];
if (valores[i] < 100) {
valores[i] = valores[i] * 100;
}
if (valores[i] < 50) {
colores[i] = Color.cyan;
} else {
colores[i] = Color.orange;
}
}
HR.Dibuja_Histograma(valores, colores, panhistosusti);
} catch (Exception ex) {
42
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
}
public void Dibuja_Histogramas_RendiAporSustitucion() {
try {
Calculo_mensual_porcuadro();
Calcular_ResultadosCostes();
Dibuja_Histograma_Rendimiento();
Dibuja_Histograma_Aportacion();
Dibuja_Histograma_Sustitucion();
} catch (Exception ex) {
}
}
//---------------------------------------------------------------//---------------------GUARDAR RESULTADOS------------------------public void Crear_panel_GuardarResultados() {
//para titulos*/
String tit[] = {"Provincia", "Temp ACS", "Consumo", "Demanda MJ", "Superficie", "nº paneles",
"b", "m", "Inclinación", "Acumulación", "MJ/m2 año", "Aportación", "CSA"};
int numcol = tit.length;
titulosGR = new JLabel[numcol];
//nº de filas 13
DatosGR_1 = new JLabel[numcol];
DatosGR_2 = new JLabel[numcol];
DatosGR_3 = new JLabel[numcol];
DatosGR_4 = new JLabel[numcol];
DatosGR_5 = new JLabel[numcol];
DatosGR_6 = new JLabel[numcol];
DatosGR_7 = new JLabel[numcol];
DatosGR_8 = new JLabel[numcol];
DatosGR_9 = new JLabel[numcol];
DatosGR_10 = new JLabel[numcol];
DatosGR_11 = new JLabel[numcol];
DatosGR_12 = new JLabel[numcol];
DatosGR_13 = new JLabel[numcol];
//creacion de titulos
for (int i = 0; i < tit.length; i++) {
titulosGR[i] = new JLabel();
titulosGR[i].setText(tit[i]);//meses
titulosGR[i].setBounds(120 + 80 * i, 30, 65, 20);//80*45
titulosGR[i].setBounds(12 + 80 * i, 30, 65, 20);//80*45
titulosGR[i].setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
panel_proyectos.add(titulosGR[i]);
}
//simplificar agrupan
//Creacion de filas de datos
JLabel[][] dATOSgr = {DatosGR_1, DatosGR_2, DatosGR_3, DatosGR_4, DatosGR_5, DatosGR_6,
DatosGR_7, DatosGR_8, DatosGR_9, DatosGR_10, DatosGR_11, DatosGR_12, DatosGR_13};
for (int j = 0; j < dATOSgr.length; j++) {
for (int i = 0; i < tit.length; i++) {
dATOSgr[j][i] = new JLabel();//hay j filas y i columnas
dATOSgr[j][i].setBounds(120 + 80 * i, 60 + 25 * j, 65, 20);
dATOSgr[j][i].setBounds(12 + 80 * i, 60 + 25 * j, 65, 20);
panel_proyectos.add(dATOSgr[j][i]);
}
}
43
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//bordes de etiquetas
for (int j = 0; j < dATOSgr.length; j++) {
for (int i = 0; i < tit.length; i += 2) {
dATOSgr[j][i].setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
}
for (int i = 1; i < tit.length; i += 2) {
dATOSgr[j][i].setBorder(new
javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
}
}
//opcion de borrar fila
/*
* for(int j=0;j<dATOSgr.length;j++){//para todas las filas{ for(int
* i=0;i<tit.length;i++){//para todas las columnas{ fila=j;
* dATOSgr[j][i].addMouseListener(new java.awt.event.MouseAdapter() {
* public void mouseReleased(java.awt.event.MouseEvent evt) {
* Borrar_Linea_MmMouseReleased(fila);
*
*}
* });}
*
*}
*/
for (int i = 0; i < tit.length; i++) {//para todas las columnas{
dATOSgr[0][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(0);
}
});
dATOSgr[1][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(1);
}
});
dATOSgr[2][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(2);
}
});
dATOSgr[3][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(3);
}
});
dATOSgr[4][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(4);
}
});
dATOSgr[5][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
44
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Borrar_Linea_MmMouseReleased(5);
}
});
dATOSgr[6][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(6);
}
});
dATOSgr[7][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(7);
}
});
dATOSgr[8][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(8);
}
});
dATOSgr[9][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(9);
}
});
dATOSgr[10][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(10);
}
});
dATOSgr[11][i].addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
Borrar_Linea_MmMouseReleased(11);
}
});
}
}
public void Rellena_GuardarResultados(JLabel gr[]) {
//para titulos*/
/*
* String tit[]={"Provincia","Temp ACS","Consumo","Demanda
* MJ","Superficie","nº paneles",
* "b","m","Inclinación","Acumulación","MJ solar","Aportación","CSA"};
*/
double tuGR = 0;
double ptusomedio = 0;
for (int i = 0; i < 12; i++) {
ptusomedio = ptusomedio + pueblo.vDAporcetuso[i];
}
ptusomedio = ptusomedio / 12;
tuGR = pueblo.Tuso * ptusomedio;
double litrosGR = 0;
double plitrosmedio = 0;
double pocupamedio = 0;
for (int i = 0; i < 12; i++) {
plitrosmedio = plitrosmedio + pueblo.vDAporcelitros[i];
45
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
pocupamedio = pocupamedio + pueblo.vDAporceocupacion[i];
}
plitrosmedio = plitrosmedio / 12;
pocupamedio = pocupamedio / 12;
litrosGR = pueblo.ConsumoanualACSm3 * plitrosmedio * pocupamedio;
ConTresDecimales();
litrosGR = Double.valueOf(formateador.format(litrosGR));
//-------------------------gr[0].setText(pueblo.Nombre);
//gr[1].setText(""+pueblo.Tuso);
gr[1].setText("" + tuGR);
//gr[2].setText(""+pueblo.ConsumoanualACSm3);
gr[2].setText("" + litrosGR);
gr[3].setText("" + pueblo.DemandaAnual);
gr[4].setText("" + pueblo.SCresultante);
gr[5].setText("" + pueblo.numpaneles);
gr[6].setText("" + pueblo.bcol);
gr[7].setText("" + pueblo.mcol);
//gr[6].setText(""+txtf_comprueba_bcol.getText());
//gr[7].setText(""+txtf_comprueba_mcol.getText());
//gr[8].setText(""+pueblo.Inclinacion);txtf_inclinacion_Mm[i]
gr[8].setText("" + txtf_inclinacion_Mm[0].getText());
for (int i = 0; i < 11; i++) {
if (txtf_inclinacion_Mm[i].getText().equals(txtf_inclinacion_Mm[i + 1].getText())) {
} else {
gr[8].setBackground(Color.red);
}
}
gr[9].setText("" + pueblo.VolAcuDiseño);
gr[10].setText("" + pueblo.ENDañoM2);
gr[11].setText("" + pueblo.aportacionAnual);
gr[12].setText("" + pueblo.CSA);
}
//Agrupar órdenes para variaciones mas menos en fchart y graf demandaAportacion
public void Selecciona_mesesTodos_Mm() {
//fchart
int i;
for (i = 0; i < 12; i++) {
if (chMeses_fMasMenos[i].isSelected()) {
} else {
chMeses_fMasMenos[i].setSelected(true);
}
}
//DemandaAportacion graf2
for (i = 0; i < 12; i++) {
if (chMeses_DAMasMenos[i].isSelected()) {
} else {
chMeses_DAMasMenos[i].setSelected(true);
}
}
}
public void Cambia_Ocupacion_Mm(double inc) {
//fchart
Cambia_Ocupacion_fchart(inc);//incrementa un 5%
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
46
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//DemandaAportacion graf2
Cambia_Ocupacion_DA(inc);//incrementa un 5%
GraficayDibuja_DemandaAporatacion_Masmenos();
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cambia_LitrosDia_Mm(double li) {
//fchart
Cambia_litrosdia_fchart(li);//incrementa en 5
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
//DemandaAportacion graf2
Cambia_litrosdia_DA(li);//incrementa un 5%
GraficayDibuja_DemandaAporatacion_Masmenos();
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cambia_Tuso_Mm(double tus) {
//fchart
Cambia_tuso_fchart(tus);//incrementa en 5
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
//DemandaAportacion graf2
Cambia_tuso_DA(tus);//incrementa un 5%
GraficayDibuja_DemandaAporatacion_Masmenos();
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cambia_Inclinacion_Mm(double incli) {
//fchart
try {
Cambia_inclimacionMes_fchart(incli);
CambiayGrafica_fchart();
//DemandaAportacion graf2
Cambia_inclimacionMes_DA(incli);
GraficayDibuja_DemandaAporatacion_Masmenos();
Calculo_resultadosNC_porcuadro();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Seleccione una inclinación");
}
//ventana resultados
47
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
}
public void Cancela_Cambios_Mn() {
Cancela_cambios_DA();
Cancela_cambios_fchart();
}
public void Selecciona_mes_Cambios_MmActionPerformed(ActionEvent evt, String lugar) {
//SELECCIONA A LA VEZ EN FCHART Y DA GRAF2
int valor = 100;
if (lugar.contains("fchart")) {
for (int i = 0; i < 12; i++) {
if (chMeses_fMasMenos[i].isSelected()) {
valor = 0;
} else {
valor = 100;
}
if (valor == 0) {
chMeses_fMasMenos[i].setSelected(true);
chMeses_DAMasMenos[i].setSelected(true);
} else {
chMeses_fMasMenos[i].setSelected(false);
chMeses_DAMasMenos[i].setSelected(false);
}
}
} else {
for (int i = 0; i < 12; i++) {
if (chMeses_DAMasMenos[i].isSelected()) {
valor = 1;
} else {
valor = 100;
}
if (valor == 1) {
chMeses_DAMasMenos[i].setSelected(true);
chMeses_fMasMenos[i].setSelected(true);
} else {
chMeses_DAMasMenos[i].setSelected(false);
chMeses_fMasMenos[i].setSelected(false);
}
}
}
}
public void Borrar_Linea_MmMouseReleased(int linea) {
JLabel[][] dATOSgr = {DatosGR_1, DatosGR_2, DatosGR_3, DatosGR_4, DatosGR_5, DatosGR_6,
DatosGR_7, DatosGR_8, DatosGR_9, DatosGR_10, DatosGR_11, DatosGR_12, DatosGR_13};
String tit[] = {"Provincia", "Temp ACS", "Consumo", "Demanda MJ", "Superficie", "nº paneles",
"b", "m", "Inclinación", "Acumulación", "MJ/m2 año", "Aportación", "CSA"};
//for(int j=0;j<dATOSgr.length;j++){
for (int i = 0; i < tit.length; i++) {
}
int resp = JOptionPane.showConfirmDialog(null, "Borrar linea de resultados", null, 0);
if (resp == 0) {
48
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
// for(int j=0;j<dATOSgr.length;j++){
for (int i = 0; i < tit.length; i++) {
dATOSgr[linea][i].setText("");
dATOSgr[linea][i].setBackground(Color.GRAY);
}
// }
} else {
}
//}
}
//Botones finales guardar resultados
public void Guardar_Resultados_finales() {
if (DatosGR_1[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_1);
} else {
if (DatosGR_2[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_2);
} else {
if (DatosGR_3[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_3);
} else {
if (DatosGR_4[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_4);
} else {
if (DatosGR_5[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_5);
} else {
if (DatosGR_6[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_6);
} else {
if (DatosGR_7[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_7);
} else {
if (DatosGR_8[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_8);
} else {
if (DatosGR_9[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_9);
} else {
if (DatosGR_10[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_10);
} else {
if (DatosGR_10[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_11);
} else {
if (DatosGR_10[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_12);
} else {
if (DatosGR_10[0].getText().isEmpty()) {
Rellena_GuardarResultados(DatosGR_13);
} else {
}
}
}
}
}
}
}
}
}
49
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
}
}
}
}
public void VerResultados() {
//sustituimos la ventana dialogo por los subpanelresultados2_8,9,10
//simplemente cambiando el destino de los resultados
try {
//subpanelresultados2_8
etiresultadosDA3.setText("" + pueblo.getDemandaAnual());
etiresultadosENanual3.setText("" + pueblo.getENDañoM2());
etiresultadosSCteorica3.setText("" + pueblo.getSCteorica());
etiresultadosNCteorico3.setText("" + pueblo.getNCteorico());
etiresultadosCAm5.setText("" + pueblo.getConsumoanualACSm3());
//subpanelresultados2_9
etiresultadosAportacionAnual2.setText("" + pueblo.getaportacionAnual());
etiresultadosDeficitAnual2.setText("" + pueblo.getdeficitEnergeticoAnual());
etiresultadosCEanual2.setText("" + pueblo.getCosteEanual());
etiresultadosCAuxanual2.setText("" + pueblo.getCosteAuxAnual());
etiresultadosAhorroanual2.setText("" + pueblo.getAhorroAnual());
etiresultadosCSA2.setText("" + pueblo.getCoberturaSA());
//subpanelresultados2_10
etiresultadosSCresultante2.setText("" + pueblo.getSCresultante());
etiresultadosVolumen2.setText("" + pueblo.VolAcuDiseño);
etiresultadosbcol2.setText("" + pueblo.getbcol());
etiresultadosmcol2.setText("" + pueblo.getmcol());
etiresultadosFCCI2.setText("" + pueblo.getFCCI());
Prueba_Resultados();
} catch (Exception ex) {
}
}
public void Prueba_Resultados() {
//sustituimos la ventana dialogo por los subpanelresultados2_10
//simplemente cambiando el destino de los resultados
try {
//VolumeAcu teorico / Volumen proyectado V/M
etiresultadosCV3.setText("" + pueblo.getPruebaVolAcu());//ventana resultados
String comp = pueblo.getComprobacionVolAcu();
if (comp.contentEquals("Cumple")) {
etiresultadosCV4.setForeground(Color.blue);
} //ventana resultados
else {
etiresultadosCV4.setForeground(Color.red);
}//ventana resultados
etiresultadosCV4.setText(comp);
//Consumo diario/ Superfici panel M/A
etiresultadosCNC3.setText("" + pueblo.getPruebaSC());//ventana resultados
String comp2 = pueblo.getComprobacionSC();
if (comp2.contentEquals("Cumple")) {
etiresultadosCNC4.setForeground(Color.blue);
}//ventana resultados
50
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
else {
etiresultadosCNC4.setForeground(Color.red);
}//ventana resultados
etiresultadosCNC4.setText(comp2);//ventana resultados
//Consumo /superficie M/A prueba K1
double pru = pueblo.getPruebak1();
if (pru <= 37.5) {
etiresultados_Prueba_K1_3.setText("" + pru);//ventana resultados
etiresultados_Prueba_K1_4.setText("No cumple");//ventana resultados
etiresultados_Prueba_K1_4.setForeground(Color.red);//ventana resultados
} else {
if (pru >= 300) {
etiresultados_Prueba_K1_3.setText("" + pru);//ventana resultados
etiresultados_Prueba_K1_4.setText("No cumple");//ventana resultados
etiresultados_Prueba_K1_4.setForeground(Color.red);//ventana resultados
} else {
etiresultados_Prueba_K1_3.setText("" + pru);//ventana resultados
etiresultados_Prueba_K1_4.setText("Cumple");//ventana resultados
etiresultados_Prueba_K1_4.setForeground(Color.blue);//ventana resultados
}
}
} catch (Exception ex) {
}
}
//////////////////////////////////////////////////////////////////////////
//base de datos
//1.-creamos carpeta Base con el archivo Access baseResultadosACS.mdb
//2.-Variables globales para la conexión y sentencia
//3.-Cargar controlador, crear objetos conexión y sentencia "PrepararBaseDatos()","Cerrar_la_conexion()"
//4.-JTable "tablaResultadosACS" donde visualizar los datos,"PrepararTablaResultados()"
//5.-Método para guardar los resultados "GuardarResultadosACS()"
public void PrepararBaseDatos(){
try {//1.-Cargar el controlador de Access=sun.jdbc.odbcOdbcDriver, segun el tipo de basedeDatos
//en MySQL se usa la cadena: com.mysql.jdbc.Driver
String controlador = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(controlador).newInstance();//para activar el controlador
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en la carga del controlador --"+e);
}
//2.-Creamos el objeto conexion conection
try {
//String
DNS="jdbc:odbc:Driver={Microsoft
Access
Driver
(*.mdb)};DBQ="+"carpeta
en
este
proyecto\\nombreArchivo.MDB";
String DNS = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+"Base\\baseResultadosACS.mdb";
String user = "";
String password = "";
conexion = DriverManager.getConnection(DNS,user,password);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error en la conexión "+e);
}
//3.-Creamos el objeto sentencia
try{
sentencia=(Statement) conexion.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY
);}
catch(Exception e){JOptionPane.showMessageDialog(null,"Error en la sentencia "+e);
51
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Cerrar_la_conexion();}
}
void Cerrar_la_conexion(){//cuando cerremos la ventana
try{conexion.close();}
catch(Exception e){JOptionPane.showMessageDialog(null,"No se pudo cerrar la conexión "+e);}
}
public void PrepararTablaResultados(){
//representacion de la BD en la JTable TablaResultados
/*String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","inclinacion","acumulacion","MJ/m2año","aportacion","CSA"};*/
String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","inclinacion","acumulacion","MJ/m2año","aportacion","CSA","V/M","M/A","C/A"};
mt=new DefaultTableModel(null,titulos);
tablaResultadosACS.setModel(mt);
}
public void PrepararTablaVariacion_anual(){
//representacion de la BD en la JTable tablaVariacion_anual
/* String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","FCCI","MAI","inclinacion","acumulacion","MJ/m2año","aportacion","CSA"};*/
String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","FCCI","MAI","inclinacion","acumulacion","MJ/m2año","aportacion","CSA","V/M","M/A","C/A"};
mtv=new DefaultTableModel(null,titulos);
tablaVariacion_anual.setModel(mtv);
}
public void PrepararTabla_mensual(){
//representacion de la BD en la JTable tablaVariacion_anual
/* String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","FCCI","MAI","inclinacion","acumulacion","MJ/m2año","aportacion","CSA"};*/
String titulos[]={"Id","mes","ocupacion","consumo m3","Tred","Tamb",
"Tacs","inclinacion","horas sol","rendimiento","demanda","aportacion","sustitucion","Qa","Ea","Ep","f"};
mtmes=new DefaultTableModel(null,titulos);
tablamensual.setModel(mtmes);
}
public void GuardarResultadosACS(int loveo){
//para los datos
//String numfila,loc,prov,tempACS,consu,dem,sup,numpan,b,m,inc,acu,mjm2año,apor,csa;
String numfila,loc,prov,tempACS,consu,dem,sup,numpan,b,m,inc,acu,mjm2año,apor,csa,VM,MA,CA;
//para la instrucción
String sql;
//para los datos
double tuGR=0;
double ptusomedio = 0;
for (int i = 0; i < 12; i++) {
ptusomedio = ptusomedio + pueblo.vDAporcetuso[i];
}
ptusomedio = ptusomedio / 12;
tuGR = pueblo.Tuso * ptusomedio;
double litrosGR = 0;
double plitrosmedio = 0;
double pocupamedio = 0;
for (int i = 0; i < 12; i++) {
plitrosmedio = plitrosmedio + pueblo.vDAporcelitros[i];
pocupamedio = pocupamedio + pueblo.vDAporceocupacion[i];
}
plitrosmedio = plitrosmedio / 12;
pocupamedio = pocupamedio / 12;
/*litrosGR = pueblo.ConsumoanualACSm3 * plitrosmedio * pocupamedio;*/
litrosGR = pueblo.getConsumoanualACSm3();
/* ConTresDecimales();
litrosGR = Double.valueOf(formateador.format(litrosGR));*/
52
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
try{
//extaemos los datos de donde estén,en este caso del mismo lugar que las etiquetas gr[i] del panel proyectos
loc=Nombre_Ciudad;
prov=pueblo.Nombre;
tempACS=""+tuGR;
consu=""+litrosGR;
dem=""+pueblo.DemandaAnual;
sup=""+pueblo.SCresultante;
numpan=""+pueblo.numpaneles;
b=""+pueblo.bcol;
m=""+pueblo.mcol;
inc="" + pueblo.Inclinacion;
acu="" + pueblo.VolAcuDiseño;
mjm2año="" + pueblo.ENDañoM2;
apor="" + pueblo.aportacionAnual;
csa="" + pueblo.CSA;
//condiciones de diseño
if(etiresultadosCV4.getText().equals("Cumple")){VM="si";}else{VM="no";}
if(etiresultados_Prueba_K1_4.getText().equals("Cumple")){MA="si";}else{MA="no";}
if(etiresultadosCNC4.getText().equals("Cumple")){CA="si";}else{CA="no";}
//capturamos el numero del ultimo registro
ResultSet r=sentencia.executeQuery("select * from resultadosACS order by Numero");
r.last();
int id=r.getInt("Numero")+1;
//construye y ejecuta la instrucción
sql="insert into ResultadosACS values (";
sql+=id+",";
sql+="'"+loc+"',";
sql+="'"+prov+"',";
sql+="'"+tempACS+"',";
sql+="'"+consu+"',";
sql+="'"+dem+"',";
sql+="'"+sup+"',";
sql+="'"+numpan+"',";
sql+="'"+b+"',";
sql+="'"+m+"',";
sql+="'"+inc+"',";
sql+="'"+acu+"',";
sql+="'"+mjm2año+"',";
sql+="'"+apor+"',";
sql+="'"+csa+"',";
sql+="'"+VM+"',";
sql+="'"+MA+"',";
sql+="'"+CA+"')";
sentencia.executeUpdate(sql);
//elimina fila 0
Eliminar_fila_enBlanco("resultadosACS");
//verlo en jtable actualizado
if(loveo==0){VerResultados_enJTable(0);}else{
if(loveo==1){VerResultados_enJTable(1);}}
}catch(Exception e){JOptionPane.showMessageDialog(null,"error al guardar los resultados en la BD"+e);
}
}
public void GuardarVariacionAnual(int loveo){
//para los datos
53
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
/*String numfila,loc,prov,tempACS,dem,sup,numpan,b,m,fcci,mai,inc,acu,mjm2año,apor,csa;*/
/*String numfila,loc,prov,tempACS,dem,sup,numpan,b,m,fcci,mai,inc,acu,mjm2año,apor,csa,VM,MA,CA;*/
String numfila,loc,prov,tempACS,dem,numpan,b,m,fcci,mai,inc,mjm2año,apor,csa,VM,MA,CA;
Double consu,sup,acu;
//para la instrucción
String sql;
//para los datos
double tuGR=0;
double ptusomedio = 0;
for (int i = 0; i < 12; i++) {
ptusomedio = ptusomedio + pueblo.vDAporcetuso[i];
}
ptusomedio = ptusomedio / 12;
tuGR = pueblo.Tuso * ptusomedio;
// para que salga la temperatura media anual con un decimal
DecimalFormatSymbols simbolo = new DecimalFormatSymbols();
simbolo.setDecimalSeparator('.');
DecimalFormat form = new DecimalFormat("#####.#", simbolo);
tuGR=Double.valueOf(form.format(tuGR));
double litrosGR = 0;
double plitrosmedio = 0;
double pocupamedio = 0;
for (int i = 0; i < 12; i++) {
plitrosmedio = plitrosmedio + pueblo.vDAporcelitros[i];
pocupamedio = pocupamedio + pueblo.vDAporceocupacion[i];
}
plitrosmedio = plitrosmedio / 12;
pocupamedio = pocupamedio / 12;
/*litrosGR = pueblo.ConsumoanualACSm3 * plitrosmedio * pocupamedio;*/
litrosGR = pueblo.getConsumoanualACSm3();
/* ConTresDecimales();
litrosGR = Double.valueOf(formateador.format(litrosGR));*/
try{
//extaemos los datos de donde estén,en este caso del mismo lugar que las etiquetas gr[i] del panel proyectos
loc=Nombre_Ciudad;
prov=pueblo.Nombre;
tempACS=""+tuGR;
/*consu=""+litrosGR;*/
consu=litrosGR;
dem=""+pueblo.DemandaAnual;
//sup=""+pueblo.SCresultante;
sup=pueblo.SCresultante;
numpan=""+pueblo.numpaneles;
b=""+pueblo.bcol;
m=""+pueblo.mcol;
fcci=""+pueblo.FCCI;
mai=""+pueblo.MAI;
/*inc="" + txtf_inclinacion_Mm[0].getText();*/
inc="" + pueblo.Inclinacion;
if(txtf_inclinacion_Mm[0].getText().isEmpty()){}else{
for (int i = 0; i < 11; i++) {
if (txtf_inclinacion_Mm[i].getText().equals(txtf_inclinacion_Mm[i + 1].getText())) {}
else {inc= txtf_inclinacion_Mm[0].getText()+"*";}//nuevo
}}
//acu="" + pueblo.VolAcuDiseño;
acu=pueblo.VolAcuDiseño;
mjm2año="" + pueblo.ENDañoM2;
apor="" + pueblo.aportacionAnual;
csa="" + pueblo.CSA;
//condiciones de diseño
54
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
if(etiresultadosCV4.getText().equals("Cumple")){VM="sí";}else{VM="no";}
if(etiresultados_Prueba_K1_4.getText().equals("Cumple")){MA="sí";}else{MA="no";}
if(etiresultadosCNC4.getText().equals("Cumple")){CA="sí";}else{CA="no";}
//capturamos el numero del ultimo registro
ResultSet r=sentencia.executeQuery("select * from variacionesFchartAnual order by Numero");
r.last();
int id=r.getInt("Numero")+1;
//construye y ejecuta la instrucción
sql="insert into variacionesFchartAnual values (";
sql+=id+",";
sql+="'"+loc+"',";
sql+="'"+prov+"',";
sql+="'"+tempACS+"',";
/*sql+="'"+consu+"',";*/
sql+=consu+",";
sql+="'"+dem+"',";
//sql+="'"+sup+"',";
sql+=sup+",";
sql+="'"+numpan+"',";
sql+="'"+b+"',";
sql+="'"+m+"',";
sql+="'"+fcci+"',";
sql+="'"+mai+"',";
sql+="'"+inc+"',";
//sql+="'"+acu+"',";
sql+=acu+",";
sql+="'"+mjm2año+"',";
sql+="'"+apor+"',";
sql+="'"+csa+"',";
sql+="'"+VM+"',";
sql+="'"+MA+"',";
sql+="'"+CA+"')";
sentencia.executeUpdate(sql);
//elimina fila 0
Eliminar_fila_enBlanco("variacionesFchartAnual");
//verlo en jtable actualizado
if(loveo==0){VervariacionesFchartAnual_enJTable(0);}else{
if(loveo==1){VervariacionesFchartAnual_enJTable(1);}}
}catch(Exception e){JOptionPane.showMessageDialog(null,"error al guardar los resultados en la BD"+e);
}
}
public void guardar_variacionesycomprobaciones(){
//para los datos
String numfila,loc,prov,tempACS,dem,sup,numpan,b,m,fcci,mai,inc,acu,mjm2año,apor,csa,VM,MA,CA;//,consu
Double consu;
//para la instrucción
String sql;
//para los datos
double tuGR=0;
double ptusomedio = 0;
for (int i = 0; i < 12; i++) {
ptusomedio = ptusomedio + pueblo.vDAporcetuso[i];
}
ptusomedio = ptusomedio / 12;
tuGR = pueblo.Tuso * ptusomedio;
// para que salga la temperatura media anual con un decimal
DecimalFormatSymbols simbolo = new DecimalFormatSymbols();
simbolo.setDecimalSeparator('.');
DecimalFormat form = new DecimalFormat("#####.#", simbolo);
55
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
tuGR=Double.valueOf(form.format(tuGR));
double litrosGR = 0;
double plitrosmedio = 0;
double pocupamedio = 0;
for (int i = 0; i < 12; i++) {
plitrosmedio = plitrosmedio + pueblo.vDAporcelitros[i];
pocupamedio = pocupamedio + pueblo.vDAporceocupacion[i];
}
plitrosmedio = plitrosmedio / 12;
pocupamedio = pocupamedio / 12;
/*litrosGR = pueblo.ConsumoanualACSm3 * plitrosmedio * pocupamedio;*/
litrosGR = pueblo.getConsumoanualACSm3();
/* ConTresDecimales();
litrosGR = Double.valueOf(formateador.format(litrosGR));*/
try{
//extaemos los datos de donde estén,en este caso del mismo lugar que las etiquetas gr[i] del panel proyectos
loc=Nombre_Ciudad;
prov=pueblo.Nombre;
tempACS=""+tuGR;
consu=litrosGR;
dem=""+pueblo.DemandaAnual;
sup=""+pueblo.SCresultante;
numpan=""+pueblo.numpaneles;
b=""+pueblo.bcol;
m=""+pueblo.mcol;
fcci=""+pueblo.FCCI;
mai=""+pueblo.MAI;
inc="" + pueblo.Inclinacion;
if(txtf_inclinacion_Mm[0].getText().isEmpty()){}else{
for (int i = 0; i < 11; i++) {
if (txtf_inclinacion_Mm[i].getText().equals(txtf_inclinacion_Mm[i + 1].getText())) {}
else {inc= txtf_inclinacion_Mm[0].getText()+"*";}}}
acu="" + pueblo.VolAcuDiseño;
mjm2año="" + pueblo.ENDañoM2;
apor="" + pueblo.aportacionAnual;
csa="" + pueblo.CSA;
if(etiresultadosCV4.getText().equals("Cumple")){VM="si";}else{VM="no";}
if(etiresultados_Prueba_K1_4.getText().equals("Cumple")){MA="si";}else{MA="no";}
if(etiresultadosCNC4.getText().equals("Cumple")){CA="si";}else{CA="no";}
//capturamos el numero del ultimo registro
ResultSet r=sentencia.executeQuery("select * from variacionesycomprobaciones order by Numero");
r.last();
int id=r.getInt("Numero")+1;
//construye y ejecuta la instrucción
sql="insert into variacionesycomprobaciones values (";
sql+=id+",";
sql+="'"+loc+"',";
sql+="'"+prov+"',";
sql+="'"+tempACS+"',";
/*sql+="'"+consu+"',";*/
sql+=consu+",";
sql+="'"+dem+"',";
sql+="'"+sup+"',";
sql+="'"+numpan+"',";
sql+="'"+b+"',";
sql+="'"+m+"',";
sql+="'"+fcci+"',";
sql+="'"+mai+"',";
sql+="'"+inc+"',";
sql+="'"+acu+"',";
56
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
sql+="'"+mjm2año+"',";
sql+="'"+apor+"',";
sql+="'"+csa+"',";
sql+="'"+VM+"',";
sql+="'"+MA+"',";
sql+="'"+CA+"')";
sentencia.executeUpdate(sql);
//elimina fila 0
/* Eliminar_fila_enBlanco("variacionesFchartAnual");*/
//verlo en jtable actualizado
/*if(loveo==0){VervariacionesFchartAnual_enJTable(0);}else{
if(loveo==1){VervariacionesFchartAnual_enJTable(1);}}*/
}catch(Exception e){JOptionPane.showMessageDialog(null,"error al guardar los resultados en la BD"+e);
}
}
public void GuardarTablamensual(){
Ver_Datos_y_Resultados();//para rellenar panel datos&resultados
//para los datos
String[] mes,ocupacion,consumom3,tred,tamb,tacs,inclina,hsol,rendi,deman,aport,sust,qa,ea,ep,f;
mes=new String[12];
ocupacion=new String[12];consumom3=new String[12];tred=new String[12];
tamb=new String[12];tacs=new String[12];inclina=new String[12];hsol=new String[12];
rendi=new String[12];deman=new String[12];aport=new String[12];sust=new String[12];
qa=new String[12];ea=new String[12];ep=new String[12];f=new String[12];
//para la instrucción
String sql;
//para los datos
int numfila[]={1,2,3,4,5,6,7,8,9,10,11,12};
try{
//extaemos los datos de donde estén,en este caso del mismo lugar que las etiquetas gr[i] del panel proyectos
for(int i=0;i<12;i++){
mes[i]=vmes[i];
ocupacion[i]=v_txt_ocupacion[i].getText();
consumom3[i]=v_txt_Consumom3[i].getText();
tred[i]=v_txt_Tred[i].getText();
tamb[i]=v_txt_Tamb[i].getText();
tacs[i]=txtf_tuso_Mm[i].getText();
inclina[i]=txtf_inclinacion_Mm[i].getText();
hsol[i]=v_txt_horassol[i].getText();
rendi[i]=v_txt_Rendimiento[i].getText();
deman[i]=v_txt_neMJ[i].getText();
aport[i]=v_txt_ENTotalmes[i].getText();
sust[i]=v_txt_Sustitucion[i].getText();
qa[i]=txtQa[i].getText();
ea[i]=txtEa[i].getText();
ep[i]=txtEp[i].getText();
f[i]=txtf[i].getText();
}
//capturamos el numero del ultimo registro
/*ResultSet r=sentencia.executeQuery("select * from tabla_mensual order by Numes");
r.last();
int id=r.getInt("Numes")+1;*/
ResultSet r=sentencia.executeQuery("select * from variacionesFchartAnual order by Numero");
r.last();
//int id=r.getInt("Numes")+1;
int id=r.getInt("Numero");//asignamos el mismo numero
57
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//introducefila en blanco para separar
String fila0="insert into tabla_mensual values(";
//fila0+=0+",'"+pueblo.Nombre+"',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')";
fila0+=id+",'"+pueblo.Nombre+"',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')";
sentencia.executeUpdate(fila0);
//construye y ejecuta la instrucción
for(int i=0;i<12;i++){
sql="insert into tabla_mensual values (";
sql+=id+",";
//sql+=numfila[i]+",";
sql+="'"+mes[i]+"',";
sql+="'"+ocupacion[i]+"',";
sql+="'"+consumom3[i]+"',";
sql+="'"+tred[i]+"',";
sql+="'"+tamb[i]+"',";
sql+="'"+tacs[i]+"',";
sql+="'"+inclina[i]+"',";
sql+="'"+hsol[i]+"',";
sql+="'"+rendi[i]+"',";
sql+="'"+deman[i]+"',";
sql+="'"+aport[i]+"',";
sql+="'"+sust[i]+"',";
sql+="'"+qa[i]+"',";
sql+="'"+ea[i]+"',";
sql+="'"+ep[i]+"',";
sql+="'"+f[i]+"')";
sentencia.executeUpdate(sql);}
//elimina fila 0
/* Eliminar_fila_enBlanco("variacionesFchartAnual");*/
//verlo en jtable actualizado
/*if(loveo==0){VervariacionesFchartAnual_enJTable(0);}else{
if(loveo==1){VervariacionesFchartAnual_enJTable(1);}}*/
}catch(Exception e){JOptionPane.showMessageDialog(null,"error al guardar los resultados en la BD"+e);
}
}
public void VerResultados_enJTable(int loveo){
String consulta;
try{
//extraemos los datos de la BD
consulta="select * from resultadosACS order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
/*String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","inclinacion","acumulacion","MJ/m2año","aportacion","CSA"};*/
String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","inclinacion","acumulacion","MJ/m2año","aportacion","CSA","V/M","M/A","C/A"};
mt=new DefaultTableModel(null,titulos);
//añadimos el contenido de cada fila
String fila[]=new String[18];
while(r.next()){
fila[0]=r.getString("Numero");
fila[1]=r.getString("localizacion");
fila[2]=r.getString("provincia");
fila[3]=r.getString("tempACS");
fila[4]=r.getString("consumo");
fila[5]=r.getString("demanda");
fila[6]=r.getString("superficie");
fila[7]=r.getString("paneles");
58
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
fila[8]=r.getString("b");
fila[9]=r.getString("m");
fila[10]=r.getString("inclinacion");
fila[11]=r.getString("acumulacion");
fila[12]=r.getString("MJm2anual");
fila[13]=r.getString("aportacion");
fila[14]=r.getString("CSA");
fila[15]=r.getString("V/M");
fila[16]=r.getString("M/A");
fila[17]=r.getString("C/A");
mt.addRow(fila);
}tablaResultadosACS.setModel(mt);
if(loveo==0){}else{if(loveo==1){
BD_Resultados.setSize(950,800);
BD_Resultados.setModal(true);
BD_Resultados.setVisible(true);}}
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar la JTable"+ e);
}
}
public void VervariacionesFchartAnual_enJTable(int loveo){
String consulta;
try{
//extraemos los datos de la BD
consulta="select * from variacionesFchartAnual order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
/* String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","FCCI","MAI","inclinacion","acumulacion","MJ/m2año","aportacion","CSA"};*/
String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","FCCI","MAI","inclinacion","acumulacion","MJ/m2año","aportacion","CSA","V/M","M/A","C/A"};
mtv=new DefaultTableModel(null,titulos);
//añadimos el contenido de cada fila
//String fila[]=new String[17];
String fila[]=new String[20];
while(r.next()){
fila[0]=r.getString("Numero");
fila[1]=r.getString("localizacion");
fila[2]=r.getString("provincia");
fila[3]=r.getString("tempACS");
/*fila[4]=r.getString("consumo");*/
fila[4]=""+r.getDouble("consumo");
fila[5]=r.getString("demanda");
//fila[6]=r.getString("superficie");
fila[6]=""+r.getDouble("superficie");
fila[7]=r.getString("paneles");
fila[8]=r.getString("b");
fila[9]=r.getString("m");
fila[10]=r.getString("FCCI");
fila[11]=r.getString("MAI");
fila[12]=r.getString("inclinacion");
//fila[13]=r.getString("acumulacion");
fila[13]=""+r.getDouble("acumulacion");
fila[14]=r.getString("MJm2anual");
fila[15]=r.getString("aportacion");
fila[16]=r.getString("CSA");
fila[17]=r.getString("V/M");
fila[18]=r.getString("M/A");
59
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
fila[19]=r.getString("C/A");
mtv.addRow(fila);
}tablaVariacion_anual.setModel(mtv);
if(loveo==0){}else{if(loveo==1){
//BD_Variacion_anual.setSize(950,800);
BD_Variacion_anual.setSize(1050,800);
BD_Variacion_anual.setModal(true);
BD_Variacion_anual.setVisible(true);}}
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar la JTable"+ e);
}
}
public void VerTablamensual_enJTable(int loveo){
String consulta;
try{
//extraemos los datos de la BD
consulta="select * from tabla_mensual order by Numes";
ResultSet r=sentencia.executeQuery(consulta);
/* String titulos[]={"Id","localizacion","provincia","tempACS","consumo","demanda","superficie",
"paneles","b","m","FCCI","MAI","inclinacion","acumulacion","MJ/m2año","aportacion","CSA"};*/
String titulos[]={"Id","mes","ocupacion","consumo m3","Tred","Tamb",
"Tacs","inclinacion","horas sol","rendimiento","demanda","aportacion","sustitucion","Qa","Ea","Ep","f"};
mtmes=new DefaultTableModel(null,titulos);
//añadimos el contenido de cada fila
//String fila[]=new String[17];
String fila[]=new String[17];
while(r.next()){
fila[0]=r.getString("Numes");
fila[1]=r.getString("mes");
fila[2]=r.getString("ocupacion");
fila[3]=r.getString("consumo m3");
fila[4]=r.getString("Tred");
fila[5]=r.getString("Tamb");
fila[6]=r.getString("Tacs");
fila[7]=r.getString("inclinacion");
fila[8]=r.getString("horas sol");
fila[9]=r.getString("rendimiento");
fila[10]=r.getString("demanda");
fila[11]=r.getString("aportacion");
fila[12]=r.getString("sustitucion");
fila[13]=r.getString("Qa");
fila[14]=r.getString("Ea");
fila[15]=r.getString("Ep");
fila[16]=r.getString("f");
mtmes.addRow(fila);
}tablamensual.setModel(mtmes);
if(loveo==0){}else{if(loveo==1){
//BD_Variacion_anual.setSize(950,800);
BD_tablamensual.setSize(1050,800);
BD_tablamensual.setModal(true);
BD_tablamensual.setVisible(true);}}
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar la JTable"+ e);
}
}
public void EliminaFila(){
int filasel;//fila seleccionada
int confirma;//para confirmar que se quiere eliminar
String N;//para buscar la fila seleccionada en la BD
60
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
try{
//extraemos los datos de la BD
String consulta="select * from resultadosACS";
ResultSet r=sentencia.executeQuery(consulta);
//identificamos la fila seleccionada en la tabla
filasel=tablaResultadosACS.getSelectedRow();
if(filasel==-1){JOptionPane.showMessageDialog(null,"Seleccione la fila a eliminar");
}else{
//pide confirmacion
confirma=JOptionPane.showConfirmDialog(null,"¿desea
eliminar
el
registro
seleccionado","Eliminar",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
//extrae el numero de la filasel de latabla y elimina el registro de la BD que tenga ese Nº
mt=(DefaultTableModel)tablaResultadosACS.getModel();
N=(String)mt.getValueAt(filasel,0);//el Nº está en la columna 0 de la filasel
int N2=Integer.parseInt(N);//en la BD es numerico
//añadido para no eliminar cuando solo queda 1 fila
r.first();
int num0=r.getInt("Numero");
r.last();
int id=r.getInt("Numero");
if(num0==id){PonerFila_enBlanco();
String EliminaN="delete from resultadosACS where Numero="+N2;//esto lo pongo yo para ver la sentencia a parte
sentencia.executeUpdate(EliminaN);}
else{
String EliminaN="delete from resultadosACS where Numero="+N2;//esto lo pongo yo para ver la
sentencia a parte
sentencia.executeUpdate(EliminaN);}
}
}
VerResultados_enJTable(1);//actualiza tabla y la muestra(1)
}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar");
}
}
public void EliminaFilaVariaciones(){
int filasel;//fila seleccionada
int confirma;//para confirmar que se quiere eliminar
String N;//para buscar la fila seleccionada en la BD
try{
//extraemos los datos de la BD
String consulta="select * from variacionesFchartAnual";
ResultSet r=sentencia.executeQuery(consulta);
//identificamos la fila seleccionada en la tabla
filasel=tablaVariacion_anual.getSelectedRow();
if(filasel==-1){JOptionPane.showMessageDialog(null,"Seleccione la fila a eliminar");
}else{
//pide confirmacion
confirma=JOptionPane.showConfirmDialog(null,"¿desea
eliminar
seleccionado","Eliminar",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
//extrae el numero de la filasel de latabla y elimina el registro de la BD que tenga ese Nº
mtv=(DefaultTableModel)tablaVariacion_anual.getModel();
N=(String)mtv.getValueAt(filasel,0);//el Nº está en la columna 0 de la filasel
int N2=Integer.parseInt(N);//en la BD es numerico
//añadido para no eliminar cuando solo queda 1 fila
r.first();
int num0=r.getInt("Numero");
61
el
registro
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
r.last();
int id=r.getInt("Numero");
if(num0==id){PonerFilaVariaciones_enBlanco();
String EliminaN="delete from variacionesFchartAnual where Numero="+N2;//esto lo pongo yo para ver la
sentencia a parte
sentencia.executeUpdate(EliminaN);}
else{
String EliminaN="delete from variacionesFchartAnual where Numero="+N2;//esto lo pongo yo para ver
la sentencia a parte
sentencia.executeUpdate(EliminaN);}
}
}
VervariacionesFchartAnual_enJTable(1);//actualiza tabla y la nuestra
}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar");
}
}
public void EliminaFilasTablamensual(){
int filasel;//fila seleccionada
int confirma;//para confirmar que se quiere eliminar
String N;//para buscar la fila seleccionada en la BD
try{
//extraemos los datos de la BD
String consulta="select * from tabla_mensual order by Numes";
ResultSet r=sentencia.executeQuery(consulta);
//identificamos la fila seleccionada en la tabla
filasel=tablamensual.getSelectedRow();
if(filasel==-1){JOptionPane.showMessageDialog(null,"Seleccione la fila a eliminar");
}else{
//pide confirmacion
confirma=JOptionPane.showConfirmDialog(null,"¿desea
eliminar
el
registro
seleccionado","Eliminar",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
//extrae el numero de la filasel de latabla
mtmes=(DefaultTableModel)tablamensual.getModel();
N=(String)mtmes.getValueAt(filasel,0);//el Nº está en la columna 0 de la filasel
int N2=Integer.parseInt(N);//en la BD es numerico
String mes=(String)mtmes.getValueAt(filasel,1);
String ocu=(String)mtmes.getValueAt(filasel,2);
if(mes.equals(" ")){JOptionPane.showMessageDialog(null,"seleccione una provincia");
}else{if(ocu.equals(" ")){
String EliminaN12="delete from tabla_mensual where Numes="+N2;
sentencia.executeUpdate(EliminaN12);
}else{JOptionPane.showMessageDialog(null,"seleccione una provincia");}}
//añadido para no eliminar cuando solo queda 1 fila
/* r.first();
int num0=r.getInt("Numero");
r.last();
int id=r.getInt("Numero");
if(num0==id){PonerFilaVariaciones_enBlanco();
String EliminaN="delete from variacionesFchartAnual where Numero="+N2;//esto lo pongo yo para ver la
sentencia a parte
sentencia.executeUpdate(EliminaN);}
else{
String EliminaN="delete from variacionesFchartAnual where Numero="+N2;//esto lo pongo yo para ver
la sentencia a parte
sentencia.executeUpdate(EliminaN);}*/
62
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}VerTablamensual_enJTable(1);
}
}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar");
}
}
public void EliminaFilaVariaciones_todas(){
int confirma;//para confirmar que se quiere eliminar
try{
//extraemos los datos de la BD
String consulta="select * from variacionesFchartAnual";
ResultSet r=sentencia.executeQuery(consulta);
//pide confirmacion
confirma=JOptionPane.showConfirmDialog(null,"¿desea eliminar todos los registros de esta tabla","Eliminar
todo",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
r.first();
int num0=r.getInt("Numero");//el primero
r.last();
//elimina todos los registros con número mayor al primero
String EliminaN="delete from variacionesFchartAnual where Numero>"+num0;//esto lo pongo yo para ver la
sentencia a parte
sentencia.executeUpdate(EliminaN);
//añadido para no eliminar cuando solo queda 1 fila, añade una fila en blanco y luego borra la que había
PonerFilaVariaciones_enBlanco();
if(num0==0){}else{
String EliminaN0="delete from variacionesFchartAnual where Numero="+num0;//esto lo pongo yo para ver
la sentencia a parte
sentencia.executeUpdate(EliminaN0);}
}
VervariacionesFchartAnual_enJTable(1);//actualiza tabla y la nuestra
}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar "+e);}
}
public void EliminaFilaResultados_todas(){
int confirma;//para confirmar que se quiere eliminar
try{
//extraemos los datos de la BD
String consulta="select * from resultadosACS";
ResultSet r=sentencia.executeQuery(consulta);
//pide confirmacion
confirma=JOptionPane.showConfirmDialog(null,"¿desea eliminar todos los registros de esta tabla","Eliminar
todo",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
r.first();
int num0=r.getInt("Numero");//el primero
r.last();
//elimina todos los registros con número mayor al primero
String EliminaN="delete from resultadosACS where Numero>"+num0;//esto lo pongo yo para ver la sentencia
a parte
sentencia.executeUpdate(EliminaN);
//añadido para no eliminar cuando solo queda 1 fila, añade una fila en blanco y luego borra la que había
PonerFila_enBlanco();
if(num0==0){}else{
String EliminaN0="delete from resultadosACS where Numero="+num0;//esto lo pongo yo para ver la
sentencia a parte
63
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
sentencia.executeUpdate(EliminaN0);}
}
VerResultados_enJTable(1);//actualiza tabla y la nuestra
}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar "+e);}
}
public void EliminaFilaVariaciones_selecionadas(){
int confirma;//para confirmar que se quiere eliminar
try{int f1=Integer.parseInt(txteliminafila1.getText());
int f2=Integer.parseInt(txteliminafila2.getText()); //filas seleccionadas
int f11=f1+1;
if(txteliminafila1.getText().isEmpty())
{JOptionPane.showMessageDialog(null,"seleccione los números de fila de menor a mayor");}
if(txteliminafila2.getText().isEmpty())
{JOptionPane.showMessageDialog(null,"seleccione los números de fila de menor a mayor");}
if(f1>f2){JOptionPane.showMessageDialog(null,"seleccione los números de fila de menor a mayor");}
else{
//extraemos los datos de la BD
String consulta="select * from variacionesFchartAnual";
ResultSet r=sentencia.executeQuery(consulta);
//pide confirmacion
confirma=JOptionPane.showConfirmDialog(null,"¿desea eliminar todos los registros desde "+f11+" hasta
"+f2,"Eliminar todo",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
String EliminaN="delete from variacionesFchartAnual where Numero>"+f1+" and Numero<="+f2;//esto lo
pongo yo para ver la sentencia a parte
sentencia.executeUpdate(EliminaN);
VervariacionesFchartAnual_enJTable(1);//actualiza tabla y la nuestra
}}}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar "+e);}
}
public void EliminaFilaResultados_selecionadas(){
int confirma;//para confirmar que se quiere eliminar
try{int f1=Integer.parseInt(txteliminafila4.getText());
int f2=Integer.parseInt(txteliminafila3.getText()); //filas seleccionadas
int f11=f1+1;
if(txteliminafila4.getText().isEmpty())
{JOptionPane.showMessageDialog(null,"seleccione los números de fila de menor a mayor");}
if(txteliminafila3.getText().isEmpty())
{JOptionPane.showMessageDialog(null,"seleccione los números de fila de menor a mayor");}
if(f1>f2){JOptionPane.showMessageDialog(null,"seleccione los números de fila de menor a mayor");}
else{
//extraemos los datos de la BD
String consulta="select * from resultadosACS";
ResultSet r=sentencia.executeQuery(consulta);
//pide confirmacion
confirma=JOptionPane.showConfirmDialog(null,"¿desea eliminar todos los registros desde "+f11+" hasta
"+f2,"Eliminar todo",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
String EliminaN="delete from resultadosACS where Numero>"+f1+" and Numero<="+f2;//esto lo pongo yo
para ver la sentencia a parte
sentencia.executeUpdate(EliminaN);
VerResultados_enJTable(1);//actualiza tabla y la nuestra
64
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}}}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar "+e);}
}
public void PonerFila_enBlanco(){
String sql;//para la instrucción
try{//capturamos el numero del ultimo registro
ResultSet r=sentencia.executeQuery("select * from resultadosACS order by Numero");
r.last();
int id=r.getInt("Numero");
//construye y ejecuta la instrucción
sql="insert into ResultadosACS values (";
sql+=0+",";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ')";
sentencia.executeUpdate(sql);
//verlo en jtable actualizado
VerResultados_enJTable(1);
}catch(Exception e){JOptionPane.showMessageDialog(null,"error al guardar los resultados en la BD"+e);
}
}
public void PonerFilaVariaciones_enBlanco(){
String sql;//para la instrucción
try{//capturamos el numero del ultimo registro
ResultSet r=sentencia.executeQuery("select * from variacionesFchartAnual order by Numero");
r.last();
int id=r.getInt("Numero");
//construye y ejecuta la instrucción
sql="insert into variacionesFchartAnual values (";
sql+=0+",";
sql+="' ',";
sql+="' ',";
sql+="' ',";
/*sql+="' ',";*/
sql+=0+",";
sql+="' ',";
//sql+="' ',";
sql+=0+",";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
65
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
sql+="' ',";
sql+="' ',";
//sql+="' ',";
sql+=0+",";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ',";
sql+="' ')";
sentencia.executeUpdate(sql);
//verlo en jtable actualizado
VervariacionesFchartAnual_enJTable(1);
}catch(Exception e){JOptionPane.showMessageDialog(null,"error al guardar los resultados en la BD"+e);
}
}
//para quitar la fila en blanco
public void Eliminar_fila_enBlanco(String tabla){
try{
//extraemos los datos de la BD y busca si hay fila0
//String consulta="select * from resultadosACS";
String consulta="select * from "+tabla;
ResultSet r=sentencia.executeQuery(consulta);
r.first();
String fila0=r.getString("Numero");
if(fila0.equals(""+0)){
//identificamos la fila con numero 0 en la tabla y la borramos
String Elimina_fila0="delete from "+tabla+" where Numero="+0;//esto lo pongo yo para ver la sentencia a parte
sentencia.executeUpdate(Elimina_fila0);
//actualiza tabla
no hace falta porque ya lo hace GuardarresultadosACS
// VerResultados_enJTable();
}else{}
}catch(Exception e){JOptionPane.showMessageDialog(null,"No se puede elimminar");}
}
//para guardar resultados en la BD y en la JTables sin mostralo
public void Almacena_simulacion_sinverlo(){
//pide confirmacion
try{
int confirma;
confirma=JOptionPane.showConfirmDialog(null,"¿desea guardar todos los datos y resultados","Guardar
datos",JOptionPane.YES_NO_OPTION);
if(confirma==JOptionPane.YES_OPTION){
GuardarResultadosACS(0);
GuardarVariacionAnual(0);
JOptionPane.showMessageDialog(null,"Guardado en base de datos");
}else{}}catch(Exception e){JOptionPane.showMessageDialog(null,"algo no va bien "+e);}
}
//-------------------------------------------------------------------------------//Borrar contenido de loa subpaneles resultados
public void Reiniciar_subpanelesResultados(){
etiresultadosDA3.setText("");
etiresultadosENanual3.setText("");
etiresultadosSCteorica3.setText("");
etiresultadosNCteorico3.setText("");
etiresultadosCAm5.setText("");
66
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
etiresultadosAportacionAnual2.setText("");
etiresultadosDeficitAnual2.setText("");
etiresultadosCSA2.setText("");
etiresultadosAhorroanual2.setText("");
etiresultadosCAuxanual2.setText("");
etiresultadosCEanual2.setText("");
etiresultadosSCresultante2.setText("");
etiresultadosVolumen2.setText("");
etiresultadosbcol2.setText("");
etiresultadosmcol2.setText("");
etiresultadosFCCI2.setText("");
etiresultadosCV3.setText("");
etiresultadosCNC3.setText("");
etiresultados_Prueba_K1_3.setText("");
etiresultadosCV4.setText("");
etiresultadosCNC4.setText("");
etiresultados_Prueba_K1_4.setText("");
}
//////////////////////////////////////////////////////////
////GRAFICAS CON JFREECHART
public void Dibuja_RenAporSus_JFC(){
Grafica_JFC grafica=new Grafica_JFC();
grafica.Dibuja_Barras_JFree(pueblo.vRendimiento,panJF_Rendi,etiJF_Rendi,"Rendimiento","mes","%");
grafica.Dibuja_Barras_JFree(pueblo.ASR,panJF_Aporta,etiJF_Aporta,"Aportación solar relativa","mes","%");
grafica.Dibuja_Barras_JFree(pueblo.vSustitucion,panJF_Sut,etiJF_Sut,"Sustitución","mes","100%");
}
public void Dibuja_DemandaAportacion_JFC() {
Grafica_JFC grafica=new Grafica_JFC();
grafica.Dibuja_2Barras_JFree(
pueblo.vDemandaMJmes,pueblo.vENTotalmes,panJF_DA,etiJF_DA,
"Demanda-Aportación","mes","MJ","Demanda","Aportación");
}
public void Dibuja_fChart_JFC(){
Grafica_JFC grafica=new Grafica_JFC();
double[] v1=new double[12];
double[] v2=new double[12];
for(int i=0;i<v1.length;i++){
v2[i]=pueblo.vf[i]/100;//dividimos por 100 para que se vean bien las dos lineas v2azul
v1[i]=pueblo.CSA;}//linea horizontal con el valor de cobertura solar anual v1roja
grafica.Dibuja_2Lineas_JFree(v1,v2,panJF_fchart,etiJF_fchart,"F-chart","mes","f","CSA","fmes");
}
public void Dibuja_y_Guarda_enArchivo(){
dialogo_graf_RenAporSus_JFC.setSize(950,650);
dialogo_graf_RenAporSus_JFC.setResizable(true);
dialogo_graf_RenAporSus_JFC.setVisible(true);
dialogo_graf_RenAporSus_JFC.dispose();
Dibuja_RenAporSus_JFC();
dialogo_graf_DemApor_JFC.setSize(950,650);
dialogo_graf_DemApor_JFC.setResizable(true);
dialogo_graf_DemApor_JFC.setVisible(true);
dialogo_graf_DemApor_JFC.dispose();
67
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Dibuja_DemandaAportacion_JFC();
dialogo_graf_fchar_JFC.setSize(950,650);
dialogo_graf_fchar_JFC.setResizable(true);
dialogo_graf_fchar_JFC.setVisible(true);
dialogo_graf_fchar_JFC.dispose();
Dibuja_fChart_JFC();
Grafica_JFC guardar_bmp=new Grafica_JFC();
guardar_bmp.Guarda_grafica_enArchivo(etiJF_fchart,"fchart");
guardar_bmp.Guarda_grafica_enArchivo(etiJF_DA,"DemandaAportacion");
guardar_bmp.Guarda_grafica_enArchivo(etiJF_Rendi,"Rendimiento");
guardar_bmp.Guarda_grafica_enArchivo(etiJF_Aporta,"Aportacion");
guardar_bmp.Guarda_grafica_enArchivo(etiJF_Sut,"Sustitucion");
//guardar en archivo los paneles
Imagen_panel dibujo=new Imagen_panel();
dibujo.Archiva_Imagem_jpg("panel_datos",panel_datos);
dibujo.Archiva_Imagem_jpg("panel_resultados",panel_resultados);
Ver_Datos_y_Resultados();
dibujo.Archiva_Imagem_jpg("panel_datosyresultados",panel_datosyresultados);
dibujo.Archiva_Imagem_jpg("panel_acumulador",panel_acumulador);
dibujo.Archiva_Imagem_jpg("panel_FCHART",panel_FCHART);
dibujo.Archiva_Imagem_jpg("panel_grafica_fchart",panel_grafica_fchart);
dibujo.Archiva_Imagem_jpg("panel_GRAF2",panel_GRAF2);
}
public void DibujayGuarda_Grafica_Variaciones(String varX) {
Grafica_JFC grafica=new Grafica_JFC();
grafica.Dibuja_Variaciones2Lineas_JFree(sentencia,varX, panJF_var, etiJF_var);
grafica.Guarda_grafica_enArchivo(etiJF_var, varX+"variaciones");
}
public void Informa_por_paneles(String rutainforme) {
try{//Guarda en la tabla los datos del proyecto
//En la JTable
GuardarResultadosACS(1);
//dibuja las graficas y las archiva
Dibuja_y_Guarda_enArchivo();
//se coloca en el ultimo registro y captura el número de proyecto
String consulta="select * from resultadosACS order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
r.last();
int p=Integer.parseInt(r.getString("Numero"));//es un dato numérico
Map parametros=new HashMap();
parametros.put("numeroproyecto",p);//numeroproyecto es el nombre que le dimos al parametro en ireport
//rutainforme="Informesireport\\Informepp_entradaycalculos.jasper" ;archivo jasper generado por irepor en la
capeta
//Informesireport de nuestro proyecto netbean
JasperPrint informe=JasperFillManager.fillReport(rutainforme,parametros,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle("INFORME Instalación solar térmica para ACS en "+r.getString("provincia"));
ventanavisor.setVisible(true);
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);}
}
////////////////////----------------------------------\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//calculo rapido con un botón
public void Acepta_Nuevo(String boton) {
String loc = etiDDNPloc.getText();
String loc2=etiDDNP_nombreciudad.getText();
String lugar="";
if(loc2.isEmpty()){lugar=loc;Nombre_Ciudad=loc;}//guarda el nombre para los informes}
68
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
else{lugar=loc2+" ("+loc+")";Nombre_Ciudad=loc2;}
if (etiDDNPloc.getText().isEmpty()) {
JOptionPane.showMessageDialog(null, "Debe indicar una provincia");
} else {
dialogodatos_nuevoproyecto.dispose();
pueblo.setNombre(loc);//guarda el nombre de la provincia para los datos por defecto de la provincia
BuscaDatos_LatitudAltitudyTempMinima();
double lati = pueblo.getLatitud();
double alti = pueblo.getAltitud();
double tmh = pueblo.getTempMinHistorica();
etilocalidad.setText(lugar + " lat: " + lati + "º alt: " + alti + " m Tmín: " + tmh + "ºC");
etilocalidad1.setText(lugar + " lat: " + lati + "º alt: " + alti + " m Tmín: " + tmh + "ºC");
etilocalidad2.setText(lugar + " lat: " + lati + "º alt: " + alti + " m Tmín: " + tmh + "ºC");
etilocalidad3.setText(lugar + " lat: " + lati + "º alt: " + alti + " m Tmín: " + tmh + "ºC");
etilocalidad4.setText(lugar + " lat: " + lati + "º alt: " + alti + " m Tmín: " + tmh + "ºC");
etilocalidad5.setText(lugar + " lat: " + lati + "º alt: " + alti + " m Tmín: " + tmh + "ºC");
}
if(boton.equals("Calcula todo")){}
else{if(boton.equals("continuar")){
dialogo_datosdelsitio.setSize(500, 400);
dialogo_datosdelsitio.setLocation(300, 300);
dialogo_datosdelsitio.setTitle("Datos generales de " + lugar);
dialogo_datosdelsitio.setVisible(true);}}
}
public void Continuar_Datosdelsitio() {
Asigna_DatosEntrada();
if (pueblo.Inclinacion == 0) {
JOptionPane.showMessageDialog(null, "Seleccione una Inclinación");
} else {
Traspasa_DatosdeEntrada();
dialogo_datosdelsitio.setVisible(false);
dialogo_datosmensuales.setSize(650, 400);
dialogo_datosmensuales.setTitle("Datos mensuales de " + etiDDNPloc.getText());
dialogo_datosmensuales.setLocation(650, 10);
dialogo_datosmensuales.setVisible(true);
}
}
public void Continuar_Datosmensuales() {
Asigna_DatosMes_dilogo_datosmensuales();
dialogo_datosmensuales.setVisible(false);
Paneles.setSelectedComponent(panel_calculos);
}
public void Calcula_Superficieresultante() {
if (txtresultadosNC.getText().equals("")) {
String nuco = JOptionPane.showInputDialog(null, "Introduce el número de colectores a instalar");
txtresultadosNC.setText(nuco);
}
nc = Double.parseDouble(txtresultadosNC.getText());
pueblo.setNC(nc);
pueblo.numpaneles = nc;
etiresultadosSCresultante.setText("" + pueblo.getSCresultante());
//ventana resultados
VerResultados();
}
public void Calcula_panelresultados() {
try {
69
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//
etiacuNC.setText("" + pueblo.getNCrecomendado());
Comprobar_NumeroPaneles();
txtDA_paneles.setText(""+pueblo.getNCrecomendado());//lo hemos eliminado
Calcular_ResultadosCostes();
} catch (Exception ex) {
}
}
public void Calcula_VolumenAcu() {
if (txtacuVolm2.getText().equals("")) {
txtacuVolm2.setText("70");
}
double volm2 = Double.parseDouble(txtacuVolm2.getText());
pueblo.setVolAcum2(volm2);
etiacuVT.setText("" + pueblo.getVolAcuTeorico());
}
public void Calcula_PruebaAcu() {
if (txtacuVolm2.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Debe calcular el volumen teórico");
} else {
if (txtacuVP.getText().equals("")) {
String vp = JOptionPane.showInputDialog(null, "Introduce el volumen proyectado en litros");
txtacuVP.setText(vp);
}
pueblo.VolAcuDiseño = Double.parseDouble(txtacuVP.getText());
etiacuCV1.setText("" + pueblo.getPruebaVolAcu());
String comp = pueblo.getComprobacionVolAcu();
if (comp.contentEquals("Cumple")) {
etiacuCV2.setForeground(Color.blue);
} else {
etiacuCV2.setForeground(Color.red);
}
etiacuCV2.setText(comp);
}
}
public void Boton_Gordo() {
try{
Acepta_Nuevo("Calcula todo");
//datos del sitio
Rbtn_datosDefecto.setSelected(true);
double[] DG = {45,0,1.05,0.15,32,40,2.01,0.83,4.8,45,0.94,0.12} ;
Introduce_Datos_Generales(DG);
Asigna_DatosEntrada();
Traspasa_DatosdeEntrada();
comboInclinacion_DDS.setSelectedIndex(3);
//Continuar_Datosdelsitio();
//datos mensuales
RbtnDatosmensuales.setSelected(true);
Introduce_Datos_Mensuales_pordefecto();
Asigna_DatosMes_dilogo_datosmensuales();
//Continuar_Datosmensuales();
//calculos
for (int i = 0; i < 12; i++) {
chMeses[i].setSelected(true);}//selecciona todos
Aceptar_DatosdeEntrada();
Calculo_mensual_porcuadro();
Vaciar_resultados_porcuadro();
Vaciar_subpaneldatosyresultados();
70
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
// Paneles.setSelectedComponent(panel_resultados);
//panel resultados
Calculo_resultadosNC_porcuadro();
Calcula_Superficieresultante();
Calcula_panelresultados();
//panel acumulador
Calcula_VolumenAcu();
Calcula_PruebaAcu();
//panel fchart
//Qa
Rbtn_fQa_valorespordefecto.setSelected(true);
Valoresdefecto_Carga_fchart();
AceptaDatos_Qa_fchart();
Calcula_Cargas_fchart();
//Ea
Rbtn_fEa_valorespordefecto.setSelected(true);
ValoresDefecto_Eabsorbida_fchart();
AceptaDatos_Ea_fchart();
Calcula_Eabsorbida_fchart();
//Ep
Rbtn_fEp_valorespordefecto.setSelected(true);
ValoresDefecto_Eperdida_fchart();
AceptaDatos_Ep_fchart();
Calcula_Eperdida_fchart();
//Calculaf
Calcula_fchart();
//iniciar simulaciones MasMenos
Cancela_cambios_fchart();
Cancela_cambios_DA();
}catch(Exception e){JOptionPane.showMessageDialog(null,"Algo no va bien, puede que falle: "+e);}
}
//////////////////////////////////////////////////////////////////////
//Informes por variables
public void Info_Variable(String var,String titulo) {
try{//var es el campo de la tabla que variamos
//titulo es de la ventana donde sale el informe
String rutainforme="Informesireport\\Info_Variable_"+var+".jasper";//fichero jasper generado con ireport dentro
del proyecto netbean
JasperPrint informe=JasperFillManager.fillReport(rutainforme,null,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle(titulo);
ventanavisor.setVisible(true);}
catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar informe"+e);
}
}
//////////////////
//grafica de barras del informe general
public void DibujayGuarda_InformeGeneral_JFC() {
Grafica_JFC grafica=new Grafica_JFC();
grafica.Dibuja_4Barras_JFree(sentencia,panJF_general,etiJF_general,"demanda" );
grafica.Dibuja_4Barras_JFree(sentencia,panJF_general1,etiJF_general1,"MJm2anual" );
grafica.Dibuja_4Barras_JFree(sentencia,panJF_general2,etiJF_general2,"aportacion" );
grafica.Dibuja_4Barras_JFree(sentencia,panJF_general3,etiJF_general3,"CSA" );
//MJm2anual,aportacion,CSA
grafica.Guarda_grafica_enArchivo(etiJF_general,"general_demanda");
grafica.Guarda_grafica_enArchivo(etiJF_general1,"general_MJm2anual");
grafica.Guarda_grafica_enArchivo(etiJF_general2,"general_aportacion");
grafica.Guarda_grafica_enArchivo(etiJF_general3,"general_CSA");
}
71
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
public void Informe_mensual() {
/*try{//Guarda en la tabla los datos del proyecto
//En la JTable
GuardarResultadosACS(1);
//dibuja las graficas y las archiva
Dibuja_y_Guarda_enArchivo();
//se coloca en el ultimo registro y captura el número de proyecto
String consulta="select * from resultadosACS order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
r.last();
int p=Integer.parseInt(r.getString("Numero"));//es un dato numérico
Map parametros=new HashMap();
parametros.put("numeroproyecto",p);//numeroproyecto es el nombre que le dimos al parametro en ireport
//rutainforme="Informesireport\\Informepp_entradaycalculos.jasper" ;archivo jasper generado por irepor en la
capeta
//Informesireport de nuestro proyecto netbean
JasperPrint informe=JasperFillManager.fillReport(rutainforme,parametros,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle("INFORME Instalación solar térmica para ACS en "+r.getString("provincia"));
ventanavisor.setVisible(true);
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);}
}*/
try{
//1.- Guardar resultados y recoger el numero del último registro
Guardar_Resultados_finales();
GuardarResultadosACS(0);
GuardarVariacionAnual(0);
GuardarTablamensual();
VerTablamensual_enJTable(0);
String subconsulta="select * from variacionesFchartAnual order by Numero";
ResultSet r=sentencia.executeQuery(subconsulta);
r.last();
//int p_subinfo=Integer.parseInt(r.getString("Numero"));//es un dato numérico
int p_subinfo=r.getInt("Numero");//es un dato numérico
Map parametro_subinfo=new HashMap();
parametro_subinfo.put("num_subinfo",p_subinfo);//num_subinfo es el nombre que le dimos al parametro en
ireport
String rutasubinforme="Informesireport\\Subinforme_mensual2.jasper";
JasperPrint subinforme=JasperFillManager.fillReport(rutasubinforme,parametro_subinfo,conexion);
JasperViewer ventanavisor1=new JasperViewer(subinforme,false);
ventanavisor1.setVisible(true);
String consulta="select * from tabla_mensual order by Numes";
ResultSet rr=sentencia.executeQuery(consulta);
rr.last();
int p_info=rr.getInt("Numes");//es un dato numérico
Map parametro_info=new HashMap();
parametro_info.put("num_info",p_info);//num_subinfo es el nombre que le dimos al parametro en ireport
String rutainforme="Informesireport\\Informe_mensual2.jasper";
JasperPrint informe=JasperFillManager.fillReport(rutainforme,parametro_info,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle("INFORME Instalación solar térmica para ACS en ");//+rr.getString("provincia"));
ventanavisor.setVisible(true);
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);}
}
//grafica rendimiento en fucion de b m tem
public void dibuja_lineasderendimiento() {
Selecciona_mesesTodos_Mm();
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
72
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
CambiayGrafica_fchart();
//nuevo
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
etiRen_b.setText(""+pueblo.bcol);
etiRen_m.setText(""+pueblo.mcol);
etiRen_Temp.setText(txtf_tuso_Mm[0].getText());
Grafica_JFC grafica=new Grafica_JFC();
//double b[]=new double[12];
if(b1[5]==0){for(int
i=0;i<12;i++){b1[i]=pueblo.vRendimiento[i];}b=new
double[1][12];b[0]=b1;ley[0]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.getText()+")";
grafica.Dibuja_10Lineas_JFree(b,1,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b2[5]==0){for(int
i=0;i<12;i++){b2[i]=pueblo.vRendimiento[i];}b=new
double[2][12];b[0]=b1;b[1]=b2;ley[1]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.getText()+")";
grafica.Dibuja_10Lineas_JFree(b,2,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b3[5]==0){for(int i=0;i<12;i++){b3[i]=pueblo.vRendimiento[i];}b=new double[3][12];b[0]=b1;b[1]=b2;
b[2]=b3;ley[2]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.getText()+")";
grafica.Dibuja_10Lineas_JFree(b,3,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b4[5]==0){for(int i=0;i<12;i++){b4[i]=pueblo.vRendimiento[i];}b=new double[4][12];b[0]=b1;b[1]=b2;
b[2]=b3;b[3]=b4;ley[3]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.getText()+")";
grafica.Dibuja_10Lineas_JFree(b,4,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b5[5]==0){for(int i=0;i<12;i++){b5[i]=pueblo.vRendimiento[i];}b=new double[5][12];b[0]=b1;b[1]=b2;
b[2]=b3;b[3]=b4;b[4]=b5;ley[4]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.getText()+")";
grafica.Dibuja_10Lineas_JFree(b,5,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b6[5]==0){for(int i=0;i<12;i++){b6[i]=pueblo.vRendimiento[i];}b=new double[6][12];b[0]=b1;b[1]=b2;
b[2]=b3;b[3]=b4;b[4]=b5;b[5]=b6;ley[5]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.getText()+")";
grafica.Dibuja_10Lineas_JFree(b,6,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b7[5]==0){for(int i=0;i<12;i++){b7[i]=pueblo.vRendimiento[i];}b=new double[7][12];b[0]=b1;b[1]=b2;
b[2]=b3;b[3]=b4;b[4]=b5;b[5]=b6;b[6]=b7;ley[6]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.getText(
)+")";
grafica.Dibuja_10Lineas_JFree(b,7,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b8[5]==0){for(int i=0;i<12;i++){b8[i]=pueblo.vRendimiento[i];}b=new double[8][12];b[0]=b1;b[1]=b2;
b[2]=b3;b[3]=b4;b[4]=b5;b[5]=b6;b[6]=b7;b[7]=b8;ley[7]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRen_Temp.
getText()+")";
grafica.Dibuja_10Lineas_JFree(b,8,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b9[5]==0){for(int i=0;i<12;i++){b9[i]=pueblo.vRendimiento[i];}b=new double[9][12];b[0]=b1;b[1]=b2;
b[2]=b3;b[3]=b4;b[4]=b5;b[5]=b6;b[6]=b7;b[7]=b8;b[8]=b9;ley[8]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol+","+etiRe
n_Temp.getText()+")";
73
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
grafica.Dibuja_10Lineas_JFree(b,9,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}else{
if(b10[5]==0){for(int i=0;i<12;i++){b10[i]=pueblo.vRendimiento[i];}b=new double[10][12];b[0]=b1;b[1]=b2;
b[2]=b3;b[3]=b4;b[4]=b5;b[5]=b6;b[6]=b7;b[7]=b8;b[8]=b9;b[9]=b10;ley[9]="(b,m,T)=("+pueblo.bcol+","+pueblo.mcol
+","+etiRen_Temp.getText()+")";
grafica.Dibuja_10Lineas_JFree(b,10,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento",ley);
}
}}}}}}}}}
}
public void Imprimegrafica_VariacionesRendimiento(){
Grafica_JFC grafica=new Grafica_JFC();
grafica.Guarda_grafica_enArchivo(etiRenJFC_graficas,"RendimientoVariaciones");
//informe directo
try{
String rutainforme="informesireport\\InfoVar_Rendimiento_paneles.jasper";
JasperPrint informe=JasperFillManager.fillReport(rutainforme,null,conexion);
JasperPrintManager.printReport(informe,true);
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar el informe"+" "+e);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
métodos privados
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Cuadro().setVisible(true);
}
});
}
private void btnNuevoproyectoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// Nuevo_Proyecto();
Cancelar_Todo();
dialogodatos_nuevoproyecto.setSize(400, 400);
dialogodatos_nuevoproyecto.setLocation(300, 300);
dialogodatos_nuevoproyecto.setTitle("Localización");
comboDDNPloc.setSelectedIndex(0);
etiDDNPloc.setText("");
dialogodatos_nuevoproyecto.setVisible(true);
}
private void btncalculosConsultarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
74
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Consulta_calculosporcombomes();
}
private void combocalculosmesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Introduce_datos_calculosporcombomes();
/*
* String mes=combocalculosmes.getSelectedItem().toString();
* vaciar_Calculosmes(); // vValorEntradaMensualesDefecto=new double[7];
* for(int i=0;i<vmes.length;i++){ if(mes.equals(vmes[i])){
* chMeses[i].setSelected(true);//para señalar el cuadro de verificacion
*
* txtdatosmesDias.setText(""+pueblo.vDias[i]);
* txtdatosmesOcupacion.setText(""+pueblo.vOcupacion[i]);
* txtdatosmesTred.setText(""+pueblo.vTred[i]);
* txtdatosmesH.setText(""+pueblo.vH[i]);
* txtdatosmesCork.setText(""+pueblo.vCork[i]);
* txtdatosmesHorasSol.setText(""+pueblo.vHorasSolUtil[i]);
* txtdatosmesTamb.setText(""+pueblo.vTamb[i]);
*
* }}
*/
}
private void btncalculosModificarDatosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Reiniciar_subpanelesResultados();
dialogo_datosdelsitio.setSize(500, 400);
dialogo_datosdelsitio.setLocation(300, 300);
dialogo_datosdelsitio.setVisible(true);
}
private void btnSeleccionaTodosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int i;
for (i = 0; i < 12; i++) {
if (chMeses[i].isSelected()) {
} else {
chMeses[i].setSelected(true);
}
}
}
private void btnCancelaSeleccionMesesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int i;
for (i = 0; i < 12; i++) {
if (chMeses[i].isSelected()) {
chMeses[i].setSelected(false);
} else {
}
}
}
private void btnCalcula_porcuadrosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (pueblo.Nombre.equals("")) {
JOptionPane.showMessageDialog(null, "Debe introducir los datos necesarios");
}// Nuevo_Proyecto();
75
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
if (pueblo.Tuso == 0) {
JOptionPane.showMessageDialog(null, "Debe introducir los datos necesarios");
}//Nuevo_Datos_DelSitio();
if (pueblo.vH[1] == 0) {
JOptionPane.showMessageDialog(null, "Debe introducir los datos necesarios");
}// Nuevo_Datos_Mensuales();
Aceptar_DatosdeEntrada();
Calculo_mensual_porcuadro();
Vaciar_resultados_porcuadro();
Vaciar_subpaneldatosyresultados();
Paneles.setSelectedComponent(panel_resultados);
}
private void btnresultadosNCteoricoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Calculo_resultadosNC_porcuadro();
}
private void txtresultadosNCMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
vaciar_resultados_trasNC();
vaciar_panelAcumulacion();
}
private void btnresultadosSCActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Calcula_Superficieresultante();
}
private void btnresultadosCostesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Calcula_panelresultados();
}
private void btndatosyresultados_ConsultarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Ver_Datos_y_Resultados();
}
private void btndatosyresultadosModificardatosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Reiniciar_subpanelesResultados();
dialogo_datosdelsitio.setSize(500, 400);
dialogo_datosdelsitio.setLocation(300, 300);
dialogo_datosdelsitio.setVisible(true);
}
private void btnDA_Mas_colectoresActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_NumeroColectores(1);
GraficayDibuja_DemandaAporatacion_Masmenos();
Cambia_NumeroPaneles_fchart(1);
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
76
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
VerResultados();
Almacena_simulacion_sinverlo();
}
private void btnDA_menos_colectoresActionPerformed(java.awt.event.ActionEvent evt) {
Cambia_NumeroColectores(-1);
GraficayDibuja_DemandaAporatacion_Masmenos();
Cambia_NumeroPaneles_fchart(-1);
//ventana resultados
Calculo_resultadosNC_porcuadro();
Cambia_NumeroColectores(0);
VerResultados();
Almacena_simulacion_sinverlo();
}
private void btnacuCalculaVolumenActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Calcula_VolumenAcu();
}
private void btnf_Mas_VolAcuActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_VolumenAcumulacion(100);
Cambia_KgAcumulacion_fchart(100);//Aumenta 100Kg
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
}
private void btnf_menos_VolAcuActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_VolumenAcumulacion(-100);
Cambia_KgAcumulacion_fchart(-100);//Aumenta 100Kg
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
}
private void btnacuCompruebavolumenActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Calcula_PruebaAcu();
//ventana resultados
VerResultados();
}
private void btn_calcular_fQaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (etifQa_Ce.getText().isEmpty()) {
dialogo_fQa.setSize(400, 400);
dialogo_fQa.setVisible(true);
} else {
Calcula_Cargas_fchart();
77
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
}
private void btn_datos_fQaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_fQa.setSize(400, 400);
dialogo_fQa.setVisible(true);
Vacia_Cargas_fchart();
}
private void btn_Calcula_fEaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (etifEa_FEO.getText().isEmpty()) {
dialogo_fEa.setSize(400, 400);
dialogo_fEa.setVisible(true);
} else {
Calcula_Eabsorbida_fchart();
}
}
private void btn_datos_fEaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_fEa.setSize(400, 400);
dialogo_fEa.setVisible(true);
Vacia_Eabsorbida_fchart();
}
private void btn_Calcula_fEpActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (etifEp_CGP.getText().isEmpty()) {
dialogo_fEp.setSize(400, 400);
dialogo_fEp.setVisible(true);
} else {
Calcula_Eperdida_fchart();
}
}
private void btn_datos_fEpActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_fEp.setSize(400, 400);
dialogo_fEp.setVisible(true);
Vacia_Eperdida_fchart();
}
private void btn_Calcula_fchartActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{Calcula_fchart();
VerResultados();
Almacena_simulacion_sinverlo();
}catch(Exception e){}
}
private void btnf_Graficar_fchartActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_cambios_fchart();
Cancela_cambios_fchart();
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
78
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
private void btnf_ComprobarK1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Comrobar_K1_fchart();
Almacena_simulacion_sinverlo();
}
private void btnf_Mas_kgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_KgAcumulacion_fchart(100);//Aumenta 100Kg
Cambia_VolumenAcumulacion(100);
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
VerResultados();
Almacena_simulacion_sinverlo();
}
private void btnf_menos_kgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_KgAcumulacion_fchart(-100);//Disminuye 100kg
Cambia_VolumenAcumulacion(-100);
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
VerResultados();
Almacena_simulacion_sinverlo();
}
private void btnf_Mas_panelesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_NumeroPaneles_fchart(1);//incrementa el numero de paneles en 1
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
Cambia_NumeroColectores(1);
Almacena_simulacion_sinverlo();
}
private void btnf_menos_panelesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_NumeroPaneles_fchart(-1);//diminuye el número de paneles en 1
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
Cambia_NumeroColectores(-1);
Almacena_simulacion_sinverlo();
}
private void txtf_comprueba_mcolKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
}
private void txtf_comprueba_bcolKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
}
79
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private void btnf_Mas_mcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_CGPmcol_fchart(0.1);
/*
* Calculo_mensual_porcuadro();//añadido para que recalcule MJ/m2
* Vaciar_resultados_porcuadro(); Vaciar_subpaneldatosyresultados();
* Calculo_resultadosNC_porcuadro(); Comprobar_NumeroPaneles();
Calcular_ResultadosCostes();//añadido
*/
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_Mas_bcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_FEObcol_fchart(0.01);
// Calculo_mensual_porcuadro();//añadido
// Vaciar_resultados_porcuadro();
// Vaciar_subpaneldatosyresultados();
// Calculo_resultadosNC_porcuadro();
// Comprobar_NumeroPaneles();
// Calcular_ResultadosCostes();//añadido
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
//nuevo
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_menos_bcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_FEObcol_fchart(-0.01);
/*
* Calculo_mensual_porcuadro();//añadido Vaciar_resultados_porcuadro();
* Vaciar_subpaneldatosyresultados(); Calculo_resultadosNC_porcuadro();
* Comprobar_NumeroPaneles();
Calcular_ResultadosCostes();//añadido
*/
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_menos_mcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_CGPmcol_fchart(-0.1);
/*
* Calculo_mensual_porcuadro();//añadido Vaciar_resultados_porcuadro();
* Vaciar_subpaneldatosyresultados(); Calculo_resultadosNC_porcuadro();
* Comprobar_NumeroPaneles();
Calcular_ResultadosCostes();//añadido
*/
80
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_Mastuso_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Tuso_Mm(5);//incrementa en 5
/*
* Cambia_tuso_fchart(5);//incrementa en 5 Comrobar_K1_fchart();
* etif_compruebaK1.setText(""+pueblo.getK1());
CambiayGrafica_fchart();
*/
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_menostuso_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Tuso_Mm(-5);//incrementa en -5
/*
* Cambia_tuso_fchart(-5);//incrementa en -5 Comrobar_K1_fchart();
* etif_compruebaK1.setText(""+pueblo.getK1());
CambiayGrafica_fchart();
*/
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_Masliitrosdia_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_LitrosDia_Mm(5);//incrementa en 5
/*
* Cambia_litrosdia_fchart(5);//incrementa en 5 Comrobar_K1_fchart();
* etif_compruebaK1.setText(""+pueblo.getK1());
CambiayGrafica_fchart();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_menoslitrosdia_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_LitrosDia_Mm(-5);//incrementa en -5
/*
* Cambia_litrosdia_fchart(-5);//incrementa en -5 Comrobar_K1_fchart();
* etif_compruebaK1.setText(""+pueblo.getK1());
CambiayGrafica_fchart();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_Masocupacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Ocupacion_Mm(5);//incrementa un 5%
/*
* Cambia_Ocupacion_fchart(5);//incrementa un 5% Comrobar_K1_fchart();
* etif_compruebaK1.setText(""+pueblo.getK1());
81
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
CambiayGrafica_fchart();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_menosocupacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Ocupacion_Mm(-5);//incrementa un 5%
/*
* Cambia_Ocupacion_fchart(-5);//disminuye un 5% Comrobar_K1_fchart();
* etif_compruebaK1.setText(""+pueblo.getK1());
CambiayGrafica_fchart();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnf_todos_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
/*
* int i; for(i=0;i<12;i++){ if(chMeses_fMasMenos[i].isSelected()){}
* else{chMeses_fMasMenos[i].setSelected(true);}}
*
*/
Selecciona_mesesTodos_Mm();
}
private void btnf_Cancelar_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_Cambios_Mn(); // Cancela_cambios_fchart();
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void comboDDNPlocActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String loc = comboDDNPloc.getSelectedItem().toString();
etiDDNPloc.setText(loc);
}
private void txtDDNPnuevalocKeyReleased(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
/* comboDDNPloc.setSelectedIndex(0);
String loc = txtDDNPnuevaloc.getText();
etiDDNPloc.setText(loc);*/
String loc = txtDDNPnuevaloc.getText();
etiDDNP_nombreciudad.setText(loc);
}
private void txtDDNPnuevalocKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
}
private void btnDDNPCancelalocActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_Nuevo();
dialogodatos_nuevoproyecto.dispose();
/*
* txtdatoslocalidad.setText("");
82
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
* combodatoslocalidad.setSelectedIndex(0);
* dialogodatos_nuevoproyecto.dispose();
* etidatos_Nombre_lat.setText(""); etidatos_Latitud_lat.setText("");
* etidatos_Altitud_lat.setText("");
etidatos_Tminhistorica_lat.setText("");
*/
}
private void btnDDNPAceptalocActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Acepta_Nuevo("continuar");
}
private void txtperdidasglobales1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtlitrosdia1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtdesviacionNS1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtcorreccionH1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtusuarios1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtpreciokw1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtcorreccionb1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtTempuso1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
83
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private void txtb1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtareacolector1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void txtm1txtinclinacion1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoDDS();
}
private void btn_ContinuarDatosdelsitioActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Continuar_Datosdelsitio();
}
private void btn_CancelarDatosdelsitioActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_Datos_Generales(0);
if (Rbtn_datosDefecto.isSelected()) {
Rbtn_datosDefecto.setSelected(false);
}
}
private void btnVolver_DatosdelsitioActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_Datos_Generales(0);
if (Rbtn_datosDefecto.isSelected()) {
Rbtn_datosDefecto.setSelected(false);
}
dialogo_datosdelsitio.dispose();
dialogodatos_nuevoproyecto.setVisible(true);
}
private void Rbtn_datosDefectoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double[] DG = new double[12];
if (Rbtn_datosDefecto.isSelected()) {
// DG[0]=45;
DG[1] = 0;
DG[2] = 1.05;
DG[3] = 0.15;
DG[4] = 32;
DG[5] = 40;
DG[6] = 2.01;
DG[7] = 0.83;
DG[8] = 4.8;
DG[9] = 45;
DG[10] = 0.94;
DG[11] = 0.12;
} else {
Cancela_Datos_Generales(0);
}
84
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Introduce_Datos_Generales(DG);
}
private void btnContinuardatosmensualesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Continuar_Datosmensuales();
}
private void btnCancelarDatosMensualesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_Datos_Mensuales();
if (RbtnDatosmensuales.isSelected()) {
RbtnDatosmensuales.setSelected(false);
}
}
private void btnVolverDatosMensualesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// Cancela_Datos_Generales();
if (RbtnDatosmensuales.isSelected()) {
RbtnDatosmensuales.setSelected(false);
}
dialogo_datosmensuales.dispose();
// Cancela_Datos_Generales(1);Cancela_Datos_Mensuales();
dialogo_datosdelsitio.setVisible(true);
}
private void RbtnDatosmensualesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (RbtnDatosmensuales.isSelected()) {
Introduce_Datos_Mensuales_pordefecto();
} else {
Cancela_Datos_Mensuales();
}
}
private void txtfQa_CeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoQafchart();//sirve para los demás campos de texto del panel Qa
}
private void txtfQa_CeKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fQa_valorespordefecto.isSelected()) {
Rbtn_fQa_valorespordefecto.setSelected(false);
}
}
private void btnfQa_AceptarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AceptaDatos_Qa_fchart();
dialogo_fQa.dispose();
}
private void txtfQa_tactxtfQa_CeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoQafchart();//sirve para los demás campos de texto del panel Qa
85
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
private void txtfQa_tacKeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
}
private void txtfQa_tacKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fQa_valorespordefecto.isSelected()) {
Rbtn_fQa_valorespordefecto.setSelected(false);
}
}
private void txtfQa_CeActionPerformed1(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoQafchart();//sirve para los demás campos de texto del panel Qa
}
private void txtfQa_CKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fQa_valorespordefecto.isSelected()) {
Rbtn_fQa_valorespordefecto.setSelected(false);
}
}
private void txtfQa_NtxtfQa_CeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoQafchart();//sirve para los demás campos de texto del panel Qa
}
private void txtfQa_NKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fQa_valorespordefecto.isSelected()) {
Rbtn_fQa_valorespordefecto.setSelected(false);
}
}
private void Rbtn_fQa_valorespordefectoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Valoresdefecto_Carga_fchart();
}
private void Rbtn_fEa_valorespordefectoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ValoresDefecto_Eabsorbida_fchart();
}
private void txtfEa_FCCItxtfEa_FEOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoEafchart();//sirve para los demás campos de texto del panel Ea
}
private void txtfEa_FCCIKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEa_valorespordefecto.isSelected()) {
Rbtn_fEa_valorespordefecto.setSelected(false);
}
}
private void txtfEa_MAItxtfEa_FEOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
86
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
pasar_focoEafchart();//sirve para los demás campos de texto del panel Ea
}
private void txtfEa_MAIKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEa_valorespordefecto.isSelected()) {
Rbtn_fEa_valorespordefecto.setSelected(false);
}
}
private void txtfEa_FEOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoEafchart();//sirve para los demás campos de texto del panel Ea
}
private void txtfEa_FEOKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEa_valorespordefecto.isSelected()) {
Rbtn_fEa_valorespordefecto.setSelected(false);
}
}
private void btnfEa_AceptarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AceptaDatos_Ea_fchart();
dialogo_fEa.dispose();
}
private void txtfEa_numpanelestxtfEa_FEOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoEafchart();//sirve para los demás campos de texto del panel Ea
}
private void txtfEa_numpanelesKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEa_valorespordefecto.isSelected()) {
Rbtn_fEa_valorespordefecto.setSelected(false);
}
}
private void txtfEa_Sup1txtfEa_FEOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoEafchart();//sirve para los demás campos de texto del panel Ea
}
private void txtfEa_Sup1KeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEa_valorespordefecto.isSelected()) {
Rbtn_fEa_valorespordefecto.setSelected(false);
}
}
private void btnfEp_AceptarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AceptaDatos_Ep_fchart();
dialogo_fEp.dispose();
}
private void txtfEp_CGPActionPerformed(java.awt.event.ActionEvent evt) {
87
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
// TODO add your handling code here:
pasar_focoEpfchart();//sirve para los demás campos de texto del panel Ep
}
private void txtfEp_CGPKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEp_valorespordefecto.isSelected()) {
Rbtn_fEp_valorespordefecto.setSelected(false);
}
}
private void txtfEp_TmintxtfEp_CGPActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoEpfchart();//sirve para los demás campos de texto del panel Ep
}
private void txtfEp_TminKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEp_valorespordefecto.isSelected()) {
Rbtn_fEp_valorespordefecto.setSelected(false);
}
}
private void txtfEp_KgAtxtfEp_CGPActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pasar_focoEpfchart();//sirve para los demás campos de texto del panel Ep
}
private void txtfEp_KgAKeyTyped(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (Rbtn_fEp_valorespordefecto.isSelected()) {
Rbtn_fEp_valorespordefecto.setSelected(false);
}
}
private void Rbtn_fEp_valorespordefectoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ValoresDefecto_Eperdida_fchart();
}
private void comboInclinacion_DDSActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
Cambia_Inclinacion("inicio");
// primera_Inclinacion=Double.parseDouble(v_txt_DDS[0].getText());
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Seleccione una inclinación");
}
}
private void btnf_MasInclinacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Inclinacion_Mm(5);
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
/*
* try{ Cambia_inclimacionMes_fchart(5); CambiayGrafica_fchart(); }
* catch(Exception e){JOptionPane.showMessageDialog(null,"Seleccione una inclinación");}
*/
}
88
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private void btnf_menosinclinacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Inclinacion_Mm(-5);
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
/*
* try{ Cambia_inclimacionMes_fchart(-5); CambiayGrafica_fchart(); }
* catch(Exception e){JOptionPane.showMessageDialog(null,"Seleccione una inclinación");}
*/
}
private void btnf_Mas_factorIntercambiadorActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_FCCI_fchart(0.01);
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
Almacena_simulacion_sinverlo();
}
private void btnf_menos_factorIntercambiadorActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_FCCI_fchart(-0.01);
Comrobar_K1_fchart();
etif_compruebaK1.setText("" + pueblo.getK1());
CambiayGrafica_fchart();
Almacena_simulacion_sinverlo();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(null, " Carga diaria litros/día (C)\n\n Área de captadores m2 (A)");
}
private void btnDA_Mastuso_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Tuso_Mm(5);//incrementa en 5
/*
* Cambia_tuso_DA(5);//incrementa un 5%
*
* GraficayDibuja_DemandaAporatacion_Masmenos();
*/
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_menostuso_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Tuso_Mm(-5);//incrementa en -5
/*
* Cambia_tuso_DA(-5);//incrementa un 5%
*
* GraficayDibuja_DemandaAporatacion_Masmenos();
*/
Ver_Datos_y_Resultados();//actualiza rendimiento del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_Masliitrosdia_MmActionPerformed(java.awt.event.ActionEvent evt) {
89
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
// TODO add your handling code here:
Cambia_LitrosDia_Mm(5);// incrementa 5 litros
/*
* Cambia_litrosdia_DA(5);//incrementa un 5%
*
* GraficayDibuja_DemandaAporatacion_Masmenos();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_menoslitrosdia_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_LitrosDia_Mm(-5);// incrementa -5 litros
/*
* Cambia_litrosdia_DA(-5);//incrementa un 5%
*
* GraficayDibuja_DemandaAporatacion_Masmenos();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_Masocupacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Ocupacion_Mm(5);//incrementa un 5%
/*
* Cambia_Ocupacion_DA(5);//incrementa un 5%
*
* GraficayDibuja_DemandaAporatacion_Masmenos();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_menosocupacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Ocupacion_Mm(-5);//incrementa un -5%
/*
* Cambia_Ocupacion_DA(-5);//incrementa un 5%
*
* GraficayDibuja_DemandaAporatacion_Masmenos();
*/
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_todos_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
/*
* int i; for(i=0;i<12;i++){ if(chMeses_DAMasMenos[i].isSelected()){}
* else{chMeses_DAMasMenos[i].setSelected(true);}}
*/
Selecciona_mesesTodos_Mm();
}
private void btnDA_Cancelar_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_Cambios_Mn(); // Cancela_cambios_DA();
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
90
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_MasInclinacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Inclinacion_Mm(5);
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnDA_menosinclinacion_MmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Inclinacion_Mm(-5);
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void btnInicio_Graf2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cancela_cambios_DA();
Ver_Datos_y_Resultados();//actualiza casillas ocupación y consumo del panel datos y resultados
Almacena_simulacion_sinverlo();
}
private void PanelesMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void panel_GRAF2MouseReleased(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
GraficayDibuja_DemandaAporatacion_Masmenos();
}
private void PanelesMouseReleased(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
GraficayDibuja_DemandaAporatacion_Masmenos();
CambiayGrafica_fchart();
Dibuja_Histogramas_RendiAporSustitucion();
}
private void panel_histogramasMouseReleased(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
Dibuja_Histogramas_RendiAporSustitucion();
}
private void btnGuardarResultadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//para todos los botones guardar
Guardar_Resultados_finales();//en el panel proyectos guardados
GuardarResultadosACS(1);//En BD y en la JTable
GuardarVariacionAnual(1);
}
private void btnBorra_GuardarResustadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
/*
91
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
* JLabel[][]
* dATOSgr={DatosGR_1,DatosGR_2,DatosGR_3,DatosGR_4,DatosGR_5,DatosGR_6,
* DatosGR_7,DatosGR_8,DatosGR_9,DatosGR_10}; for(int
* j=0;j<dATOSgr.length-1;j++){if(dATOSgr[j+1][0].getText().isEmpty()){
* for(int i=0;i<dATOSgr[i].length;i++){dATOSgr[j][i].setText("");}}}
* for(int i=0;i<dATOSgr[i].length;i++){dATOSgr[9][i].setText("");}
*/
JLabel[][] dATOSgr = {DatosGR_1, DatosGR_2, DatosGR_3, DatosGR_4, DatosGR_5, DatosGR_6,
DatosGR_7, DatosGR_8, DatosGR_9, DatosGR_10, DatosGR_11, DatosGR_12, DatosGR_13};
int numfilas = dATOSgr.length;
int numcolumnas = dATOSgr[0].length;
for (int j = 0; j < numfilas - 1; j++) {
if (dATOSgr[j + 1][0].getText().isEmpty()) {
for (int i = 0; i < numcolumnas; i++) {
dATOSgr[j][i].setText("");
dATOSgr[j][i].setBackground(Color.GRAY);
}
}
}
for (int i = 0; i < numcolumnas; i++) {
dATOSgr[12][i].setText("");
dATOSgr[12][i].setBackground(Color.GRAY);
}
}
private void btnVerResultados_G2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// VerResultados();
//ventana_resultados0.setVisible(true);
VerResultados_enJTable(1);
VervariacionesFchartAnual_enJTable(1);
}
private void btnGuardar_graf2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Guardar_Resultados_finales();
GuardarResultadosACS(1);
GuardarVariacionAnual(1);
}
private void btnGuadar_fchartActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Guardar_Resultados_finales();
GuardarResultadosACS(1);
GuardarVariacionAnual(1);
}
private void btnVerresultados_fchartActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// VerResultados();
// ventana_resultados0.setVisible(true);
92
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
VerResultados_enJTable(1);
VervariacionesFchartAnual_enJTable(1);
}
private void btnresultados1AyudaVM1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(null, " 0.8<V/M<1.2\n\n "
+ "Acumulador teorico litros (V)\n\n Acumulador propuesto (M)", "Comprueba Acumulador", 3);
}
private void btnresultados1AyudaCA1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(null, " 60<C/A<100\n\n "
+ "Carga diaria litros/día (C)\n\n Área de captadores m2 (A)", "Comprueba Superficie método DA", 3);
}
private void btnresultados1AyudaMA1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(null, " 37.5<M/A<300\n\n Acumulador "
+ "propuesto kg (M)\n\n Superficie captadores m2 (A)", "Comprueba factor K1 método f-chart", 3);
}
private void btnEliminar_RegistroBDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
EliminaFila();
}
private void btnCerrar_ResultadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
BD_Resultados.dispose();
}
private void btnInforme_BDResultadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
String rutainforme="Informesireport\\Informeagosto13.jasper";//fichero jasper generado con ireport dentro del
proyecto netbean
JasperPrint informe=JasperFillManager.fillReport(rutainforme,null,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle("INFORME DE PRUEBA");
ventanavisor.setVisible(true);}
catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar informe"+e);
}
}
private void btnInformeProvincia_BDResultadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
String rutainforme="Informesireport\\InformeACS_con_parametros.jasper";//Localizacion es el nombre que le
dimos al parametro en ireport
Map parametros=new HashMap();
String prov=cboInformeProvincia_BDResultados.getSelectedItem().toString();
if(prov=="provincia"){JOptionPane.showMessageDialog(null,"Seleccione una provincia");
}else{
parametros.put("Localizacion",prov);
JasperPrint informe=JasperFillManager.fillReport(rutainforme,parametros,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle("INFORME DE PROVINCIA");
ventanavisor.setVisible(true);}
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);
}
93
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
private void btnVergraf_RenAporSusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_graf_RenAporSus_JFC.setSize(950,650);
dialogo_graf_RenAporSus_JFC.setResizable(true);
// dialogo_graf_RenAporSus_JFC.setModal(true);
dialogo_graf_RenAporSus_JFC.setVisible(true);
Dibuja_RenAporSus_JFC();
}
private void btnVergraf_DAActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_graf_DemApor_JFC.setSize(700,650);
dialogo_graf_DemApor_JFC.setResizable(true);
// dialogo_graf_DemApor_JFC.setModal(true);
dialogo_graf_DemApor_JFC.setVisible(true);
Dibuja_DemandaAportacion_JFC();
}
private void btnVergrar_fchartActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_graf_fchar_JFC.setSize(700,650);
dialogo_graf_fchar_JFC.setResizable(true);
// dialogo_graf_DemApor_JFC.setModal(true);
dialogo_graf_fchar_JFC.setVisible(true);
Dibuja_fChart_JFC();
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Boton_Gordo();
}
private void btnInformeGeneralActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//informe para 10paneles 1500 litros y 45º de inclinacion y 45ºC
dialogo_graf_InformeGeneral.setSize(1200,850);
dialogo_graf_InformeGeneral.setResizable(true);
dialogo_graf_InformeGeneral.setVisible(true);
DibujayGuarda_InformeGeneral_JFC();
dialogo_graf_InformeGeneral.dispose();
try{
String rutainforme="Informesireport\\Informegeneral.jasper";//fichero jasper generado con ireport dentro del
proyecto netbean
JasperPrint informe=JasperFillManager.fillReport(rutainforme,null,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle("INFORME GENERAL");
ventanavisor.setVisible(true);}
catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar informe"+e);
}
//para las gráficas
try{
String rutainforme1="Informesireport\\info_graf_general_demanda.jasper";
String rutainforme2="Informesireport\\info_graf_general_MJm2anual.jasper";
String rutainforme3="Informesireport\\info_graf_general_aportacion.jasper";
String rutainforme4="Informesireport\\info_graf_general_CSA.jasper";//fichero jasper generado con ireport dentro
del proyecto netbean
94
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
JasperPrint informe1=JasperFillManager.fillReport(rutainforme1,null,conexion);
JasperPrint informe2=JasperFillManager.fillReport(rutainforme2,null,conexion);
JasperPrint informe3=JasperFillManager.fillReport(rutainforme3,null,conexion);
JasperPrint informe4=JasperFillManager.fillReport(rutainforme4,null,conexion);
JasperViewer ventanavisor1=new JasperViewer(informe1,false);
JasperViewer ventanavisor2=new JasperViewer(informe2,false);
JasperViewer ventanavisor3=new JasperViewer(informe3,false);
JasperViewer ventanavisor4=new JasperViewer(informe4,false);
ventanavisor1.setTitle("INFORME GENERAL gráfica demanda");
ventanavisor1.setVisible(true);
ventanavisor2.setTitle("INFORME GENERAL gráfica MJm2anual");
ventanavisor2.setVisible(true);
ventanavisor3.setTitle("INFORME GENERAL gráfica aportación");
ventanavisor3.setVisible(true);
ventanavisor4.setTitle("INFORME GENERAL gráfica CSA");
ventanavisor4.setVisible(true);}
catch(Exception e){JOptionPane.showMessageDialog(null,"Error al mostrar informe"+e);
}
}
private void btnGuardarGraficas_enArchivoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//dibuja y gauarda las graficas para el informe
Dibuja_y_Guarda_enArchivo();
}
private void btnInformegraficoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{//Guarda en la tabla los datos del proyecto
//En la JTable
GuardarResultadosACS(1);
//dibuja las graficas y las archiva
Dibuja_y_Guarda_enArchivo();
//se coloca en el ultimo registro y captura el número de proyecto
String consulta="select * from resultadosACS order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
r.last();
int np=Integer.parseInt(r.getString("Numero"));//es un dato numérico
/////////////
String rutainforme="Informesireport\\Informe grafico.jasper";//numeproye es el nombre que le dimos al parametro
en ireport
Map parametros=new HashMap();
parametros.put("numeproye",np);
JasperPrint informe=JasperFillManager.fillReport(rutainforme,parametros,conexion);
JasperViewer ventanavisor=new JasperViewer(informe,false);
ventanavisor.setTitle("INFORME GRAFICO Instalación solar térmica para ACS en "+r.getString("provincia"));
ventanavisor.setVisible(true);
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);}
}
private void formWindowClosing(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(null,"Salir y cerrar la conexion con la BD");
Cerrar_la_conexion();
95
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
private void btn_dibuja_panelesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Imagen_panel dibujo=new Imagen_panel();
String nom=cbo_dibuja_paneles.getSelectedItem().toString();
JPanel panel=new JPanel();
String nA="";//nombre que le daremos al archivo imagen en la carpeta Graficas
try{
if(nom=="paneles"){JOptionPane.showMessageDialog(null,"Selecione un panel");}
else{if(nom.equals("Datos")){nA="panel_datos";panel=panel_datos;}
if(nom.equals("Resultados")){nA="panel_resultados";panel=panel_resultados;}
if(nom.equals("Datos y Resultados")){Ver_Datos_y_Resultados();
nA="panel_datosyresultados";panel=panel_datosyresultados;}
if(nom.equals("Acumulador")){nA="panel_acumulador";panel=panel_acumulador;}
if(nom.equals("Calculo FChart")){nA="panel_FCHART";panel=panel_FCHART;}
if(nom.equals("Variaciones FChart")){nA="panel_grafica_fchart";panel=panel_grafica_fchart;}
if(nom.equals("Demanda Aportacion")){nA="panel_GRAF2";panel=panel_GRAF2;}
dibujo.Archiva_Imagem_jpg(nA,panel);
dibujo.Pinta_arcivo_enJLabel(nA, eti_graf_paneles);}
}catch(Exception e){JOptionPane.showMessageDialog(null,"algo no va bien, puede que: "+e);
}
}
private void btn_Ver_dialogo_graf_panelesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_graf_paneles.setSize(1100,850);
dialogo_graf_paneles.setResizable(true);
// dialogo_graf_DemApor_JFC.setModal(true);
dialogo_graf_paneles.setVisible(true);
}
private void btnInformeppanelesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Informa_por_paneles("Informesireport\\Informepp_entradaycalculos.jasper");
Informa_por_paneles("Informesireport\\Informepp_datosyresultados.jasper");
Informa_por_paneles("Informesireport\\Informepp_CalculoFchart.jasper");
/* try{//Guarda en la tabla los datos del proyecto
//En la JTable
GuardarResultadosACS();
//dibuja las graficas y las archiva
Dibuja_y_Guarda_enArchivo();
//se coloca en el ultimo registro y captura el número de proyecto
String consulta="select * from resultadosACS order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
r.last();
int np=Integer.parseInt(r.getString("Numero"));//es un dato numérico
String rutainforme1="Informesireport\\Informepp_entradaycalculos.jasper";//numeroproyecto es el nombre que le
dimos al parametro en ireport
Map parametros=new HashMap();
parametros.put("numeroproyecto",np);
JasperPrint informe1=JasperFillManager.fillReport(rutainforme1,parametros,conexion);
JasperViewer ventanavisor1=new JasperViewer(informe1,false);
ventanavisor1.setTitle("INFORME Instalación solar térmica para ACS en "+r.getString("provincia"));
ventanavisor1.setVisible(true);
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);}
/////
try{//Guarda en la tabla los datos del proyecto
//En la JTable
GuardarResultadosACS();
96
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
//dibuja las graficas y las archiva
Dibuja_y_Guarda_enArchivo();
//se coloca en el ultimo registro y captura el número de proyecto
String consulta="select * from resultadosACS order by Numero";
ResultSet s=sentencia.executeQuery(consulta);
s.last();
int np2=Integer.parseInt(s.getString("Numero"));//es un dato numérico
String rutainforme2="Informesireport\\Informepp_datosyresultados.jasper";//numeroproyecto es el nombre que le
dimos al parametro en ireport
Map parametros2=new HashMap();
parametros2.put("numeroproyecto",np2);
JasperPrint informe2=JasperFillManager.fillReport(rutainforme2,parametros2,conexion);
JasperViewer ventanavisor2=new JasperViewer(informe2,false);
ventanavisor2.setTitle("INFORME Instalación solar térmica para ACS en "+s.getString("provincia"));
ventanavisor2.setVisible(true);
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);}
/////
try{//Guarda en la tabla los datos del proyecto
//En la JTable
GuardarResultadosACS();
//dibuja las graficas y las archiva
Dibuja_y_Guarda_enArchivo();
//se coloca en el ultimo registro y captura el número de proyecto
String consulta="select * from resultadosACS order by Numero";
ResultSet t=sentencia.executeQuery(consulta);
t.last();
int np3=Integer.parseInt(t.getString("Numero"));//es un dato numérico
String rutainforme3="Informesireport\\Informepp_CalculoFchart.jasper";;//numeroproyecto es el nombre que le
dimos al parametro en ireport
Map parametros3=new HashMap();
parametros3.put("numeroproyecto",np3);
JasperPrint informe3=JasperFillManager.fillReport(rutainforme3,parametros3,conexion);
JasperViewer ventanavisor3=new JasperViewer(informe3,false);
ventanavisor3.setTitle("INFORME Instalación solar térmica para ACS en "+t.getString("provincia"));
ventanavisor3.setVisible(true);
/////
}catch(Exception e){JOptionPane.showMessageDialog(null,"Error en el informe"+" "+ e);}*/
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
GuardarVariacionAnual(1);
}
private void btnCerrar_VariacionesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
BD_Variacion_anual.dispose();
}
private void btn_EliminaRegistro_variacionesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
EliminaFilaVariaciones();
}
private void btn_Eliminatodo_tablaVariacionActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
EliminaFilaVariaciones_todas();
}
private void btneliminaVariasFilasActionPerformed(java.awt.event.ActionEvent evt) {
97
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
// TODO add your handling code here:
EliminaFilaVariaciones_selecionadas();
}
private void btnInforme_variacionesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//DibujayGuarda_Grafica_Variaciones("consumo");
int info=comboInfo_Variacion.getSelectedIndex();
if(info==0){JOptionPane.showMessageDialog(null,"Seleccione una variable");}
else{ dialogo_graf_variaciones_JFC.setSize(950,650);
dialogo_graf_variaciones_JFC.setResizable(true);
dialogo_graf_variaciones_JFC.setVisible(true);
if(info==1){DibujayGuarda_Grafica_Variaciones("consumo");
Info_Variable("consumo","INFORME VARIACIONES CON EL CONSUMO DE ACS");}
if(info==2){DibujayGuarda_Grafica_Variaciones("tempACS");
Info_Variable("tempACS","INFORME VARIACIONES CON LA TEMPERATURA DEL ACS");}
if(info==3){DibujayGuarda_Grafica_Variaciones("inclinacion");
Info_Variable("inclinacion","INFORME VARIACIONES CON LA INCLINACIÓN DE LOS PANELES");}
if(info==4){DibujayGuarda_Grafica_Variaciones("acumulacion");
Info_Variable("acumulacion","INFORME VARIACIONES CON EL VOLUMEN DEL ACUMULADOR");}
if(info==5){DibujayGuarda_Grafica_Variaciones("superficie");
Info_Variable("superficie","INFORME VARIACIONES CON LA SUPERFICIE DE CAPTADORES");}
if(info==6){DibujayGuarda_Grafica_Variaciones("b");
Info_Variable("b","INFORME VARIACIONES CON EL FACTOR DE EFICIENCIA ÓPTICA (b)");}
if(info==7){DibujayGuarda_Grafica_Variaciones("m");
Info_Variable("m","INFORME VARIACIONES CON EL m DE LOS COLECTORES");}
if(info==8){DibujayGuarda_Grafica_Variaciones("FCCI");
Info_Variable("FCCI","INFORME VARIACIONES CON EL FCCI factor intercambiador");}
if(info==9){DibujayGuarda_Grafica_Variaciones("MAI");
Info_Variable("MAI","INFORME MAI ángulo de incidencia");}
dialogo_graf_variaciones_JFC.dispose();}
}
private void btn_Elimina_todo_tablaResultadosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
EliminaFilaResultados_todas();
}
private void btnVerResultados_paneldatosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Guardar_Resultados_finales();
GuardarResultadosACS(1);
GuardarVariacionAnual(1);
}
private void btnVergraf_variacionesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_graf_variaciones_JFC.setSize(700,650);
dialogo_graf_variaciones_JFC.setResizable(true);
// dialogo_graf_DemApor_JFC.setModal(true);
dialogo_graf_variaciones_JFC.setVisible(true);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int info=combografica_var.getSelectedIndex();
if(info==0){JOptionPane.showMessageDialog(null,"Seleccione una variable");}
if(info==1){DibujayGuarda_Grafica_Variaciones("consumo");}
98
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
if(info==2){DibujayGuarda_Grafica_Variaciones("consumo");}
if(info==3){DibujayGuarda_Grafica_Variaciones("tempACS");}
if(info==4){DibujayGuarda_Grafica_Variaciones("inclinacion");}
if(info==5){DibujayGuarda_Grafica_Variaciones("superficie");}
if(info==6){DibujayGuarda_Grafica_Variaciones("acumulacion");}
if(info==7){DibujayGuarda_Grafica_Variaciones("b");}
if(info==8){DibujayGuarda_Grafica_Variaciones("m");}
if(info==9){DibujayGuarda_Grafica_Variaciones("FCCI");}
if(info==10){DibujayGuarda_Grafica_Variaciones("MAI");}
}
private void btneliminaVariasFilas1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
EliminaFilaResultados_selecionadas();
}
private void btn_VergrafInfo_generalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dialogo_graf_InformeGeneral.setSize(1200,850);
dialogo_graf_InformeGeneral.setResizable(true);
dialogo_graf_InformeGeneral.setVisible(true);
DibujayGuarda_InformeGeneral_JFC();
}
private void btnEliminagrupoTablamensualActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
EliminaFilasTablamensual();
}
private void btnCerrarTablamensualActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
BD_tablamensual.dispose();
}
private void btnVertablamensual_BDVAActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
GuardarTablamensual();
VerTablamensual_enJTable(1);
}
private void btn_verTablamensualActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
GuardarTablamensual();
VerTablamensual_enJTable(1);
}
private void btnInformemensualActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Informe_mensual();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
etiRen_b.setText(""+pueblo.bcol);
etiRen_m.setText(""+pueblo.mcol);
etiRen_Temp.setText(txtf_tuso_Mm[0].getText());
Grafica_JFC grafica=new Grafica_JFC();
grafica.Dibuja_Linea_JFree(pueblo.vRendimiento,panRenJFC_graficas,
etiRenJFC_graficas,"rendimiento","mes","rendimiento");
//double cero[]={0,0,0,0,0,0,0,0,0,0,0,0};
for(int i=0;i<b.length;i++){for(int j=0;j<12;j++){b[i][j]=0;}};//cero[j];}};
99
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
}
private void btnRen_Mas_bcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_FEObcol_fchart(0.05);
dibuja_lineasderendimiento();
}
private void btnRen_menos_bcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_FEObcol_fchart(-0.05);
dibuja_lineasderendimiento();
}
private void btnRen_Mas_mcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_CGPmcol_fchart(0.5);
dibuja_lineasderendimiento();
}
private void btnRen_menos_mcolActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_CGPmcol_fchart(-0.5);
dibuja_lineasderendimiento();
}
private void btnRen_Mas_TempActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Tuso_Mm(5);
dibuja_lineasderendimiento();
}
private void btnRen_menos_TempActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Cambia_Tuso_Mm(-5);
dibuja_lineasderendimiento();
}
private void btnImprime_graficaRendimientoActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Imprimegrafica_VariacionesRendimiento();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
variables
// Variables declaration - do not modify
private javax.swing.JDialog BD_Resultados;
private javax.swing.JDialog BD_Variacion_anual;
private javax.swing.JDialog BD_tablamensual;
private javax.swing.JScrollPane JScrollPan;
private javax.swing.JTabbedPane Paneles;
private javax.swing.JRadioButton RbtnDatosmensuales;
private javax.swing.JRadioButton Rbtn_datosDefecto;
private javax.swing.JRadioButton Rbtn_fEa_valorespordefecto;
private javax.swing.JRadioButton Rbtn_fEp_valorespordefecto;
private javax.swing.JRadioButton Rbtn_fQa_valorespordefecto;
private javax.swing.JButton btnBorra_GuardarResustados;
private javax.swing.JButton btnCalcula_porcuadros;
private javax.swing.JButton btnCancelaSeleccionMeses;
private javax.swing.JButton btnCancelarDatosMensuales;
private javax.swing.JButton btnCerrarTablamensual;
100
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JButton btnCerrar_Resultados;
private javax.swing.JButton btnCerrar_Variaciones;
private javax.swing.JButton btnContinuardatosmensuales;
private javax.swing.JButton btnDA_Cancelar_Mm;
private javax.swing.JButton btnDA_MasInclinacion_Mm;
private javax.swing.JButton btnDA_Mas_colectores;
private javax.swing.JButton btnDA_Masliitrosdia_Mm;
private javax.swing.JButton btnDA_Masocupacion_Mm;
private javax.swing.JButton btnDA_Mastuso_Mm;
private javax.swing.JButton btnDA_menos_colectores;
private javax.swing.JButton btnDA_menosinclinacion_Mm;
private javax.swing.JButton btnDA_menoslitrosdia_Mm;
private javax.swing.JButton btnDA_menosocupacion_Mm;
private javax.swing.JButton btnDA_menostuso_Mm;
private javax.swing.JButton btnDA_todos_Mm;
private javax.swing.JButton btnDDNPAceptaloc;
private javax.swing.JButton btnDDNPCancelaloc;
private javax.swing.JButton btnEliminagrupoTablamensual;
private javax.swing.JButton btnEliminar_RegistroBD;
private javax.swing.JButton btnGuadar_fchart;
private javax.swing.JButton btnGuardarGraficas_enArchivo;
private javax.swing.JButton btnGuardarResultados;
private javax.swing.JButton btnGuardar_graf2;
private javax.swing.JButton btnImprime_graficaRendimiento;
private javax.swing.JButton btnInformeGeneral;
private javax.swing.JButton btnInformeProvincia_BDResultados;
private javax.swing.JButton btnInforme_BDResultados;
private javax.swing.JButton btnInforme_variaciones;
private javax.swing.JButton btnInformegrafico;
private javax.swing.JButton btnInformemensual;
private javax.swing.JButton btnInformeppaneles;
private javax.swing.JButton btnInicio_Graf2;
private javax.swing.JButton btnNuevoproyecto;
private javax.swing.JButton btnRen_Mas_Temp;
private javax.swing.JButton btnRen_Mas_bcol;
private javax.swing.JButton btnRen_Mas_mcol;
private javax.swing.JButton btnRen_menos_Temp;
private javax.swing.JButton btnRen_menos_bcol;
private javax.swing.JButton btnRen_menos_mcol;
private javax.swing.JButton btnSeleccionaTodos;
private javax.swing.JButton btnVerResultados_G2;
private javax.swing.JButton btnVerResultados_paneldatos;
private javax.swing.JButton btnVergraf_DA;
private javax.swing.JButton btnVergraf_RenAporSus;
private javax.swing.JButton btnVergraf_variaciones;
private javax.swing.JButton btnVergrar_fchart;
private javax.swing.JButton btnVerresultados_fchart;
private javax.swing.JButton btnVertablamensual_BDVA;
private javax.swing.JButton btnVolverDatosMensuales;
private javax.swing.JButton btnVolver_Datosdelsitio;
private javax.swing.JButton btn_Calcula_fEa;
private javax.swing.JButton btn_Calcula_fEp;
private javax.swing.JButton btn_Calcula_fchart;
private javax.swing.JButton btn_CancelarDatosdelsitio;
private javax.swing.JButton btn_ContinuarDatosdelsitio;
private javax.swing.JButton btn_EliminaRegistro_variaciones;
private javax.swing.JToggleButton btn_Elimina_todo_tablaResultados;
private javax.swing.JButton btn_Eliminatodo_tablaVariacion;
private javax.swing.JButton btn_Ver_dialogo_graf_paneles;
private javax.swing.JButton btn_VergrafInfo_general;
private javax.swing.JButton btn_calcular_fQa;
101
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JButton btn_datos_fEa;
private javax.swing.JButton btn_datos_fEp;
private javax.swing.JButton btn_datos_fQa;
private javax.swing.JButton btn_dibuja_paneles;
private javax.swing.JButton btn_verTablamensual;
private javax.swing.JButton btnacuCalculaVolumen;
private javax.swing.JButton btnacuCompruebavolumen;
private javax.swing.JButton btncalculosConsultar;
private javax.swing.JButton btncalculosModificarDatos;
private javax.swing.JButton btndatosyresultadosModificardatos;
private javax.swing.JButton btndatosyresultados_Consultar;
private javax.swing.JButton btneliminaVariasFilas;
private javax.swing.JButton btneliminaVariasFilas1;
private javax.swing.JButton btnfEa_Aceptar;
private javax.swing.JButton btnfEp_Aceptar;
private javax.swing.JButton btnfQa_Aceptar;
private javax.swing.JButton btnf_Cancelar_Mm;
private javax.swing.JButton btnf_ComprobarK1;
private javax.swing.JButton btnf_Graficar_fchart;
private javax.swing.JButton btnf_MasInclinacion_Mm;
private javax.swing.JButton btnf_Mas_VolAcu;
private javax.swing.JButton btnf_Mas_bcol;
private javax.swing.JButton btnf_Mas_factorIntercambiador;
private javax.swing.JButton btnf_Mas_kg;
private javax.swing.JButton btnf_Mas_mcol;
private javax.swing.JButton btnf_Mas_paneles;
private javax.swing.JButton btnf_Masliitrosdia_Mm;
private javax.swing.JButton btnf_Masocupacion_Mm;
private javax.swing.JButton btnf_Mastuso_Mm;
private javax.swing.JButton btnf_menos_VolAcu;
private javax.swing.JButton btnf_menos_bcol;
private javax.swing.JButton btnf_menos_factorIntercambiador;
private javax.swing.JButton btnf_menos_kg;
private javax.swing.JButton btnf_menos_mcol;
private javax.swing.JButton btnf_menos_paneles;
private javax.swing.JButton btnf_menosinclinacion_Mm;
private javax.swing.JButton btnf_menoslitrosdia_Mm;
private javax.swing.JButton btnf_menosocupacion_Mm;
private javax.swing.JButton btnf_menostuso_Mm;
private javax.swing.JButton btnf_todos_Mm;
private javax.swing.JButton btnresultados1AyudaCA1;
private javax.swing.JButton btnresultados1AyudaMA1;
private javax.swing.JButton btnresultados1AyudaVM1;
private javax.swing.JButton btnresultadosCostes;
private javax.swing.JButton btnresultadosNCteorico;
private javax.swing.JButton btnresultadosSC;
private javax.swing.JComboBox cboInformeProvincia_BDResultados;
private javax.swing.JComboBox cbo_dibuja_paneles;
private javax.swing.JComboBox comboDDNPloc;
private javax.swing.JComboBox comboInclinacion_DDS;
private javax.swing.JComboBox comboInfo_Variacion;
private javax.swing.JComboBox combocalculosmes;
private javax.swing.JComboBox combografica_var;
private javax.swing.JDialog dialogo_datosdelsitio;
private javax.swing.JDialog dialogo_datosmensuales;
private javax.swing.JDialog dialogo_fEa;
private javax.swing.JDialog dialogo_fEp;
private javax.swing.JDialog dialogo_fQa;
private javax.swing.JDialog dialogo_graf_DemApor_JFC;
private javax.swing.JDialog dialogo_graf_InformeGeneral;
private javax.swing.JDialog dialogo_graf_RenAporSus_JFC;
102
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JDialog dialogo_graf_fchar_JFC;
private javax.swing.JDialog dialogo_graf_paneles;
private javax.swing.JDialog dialogo_graf_variaciones_JFC;
private javax.swing.JDialog dialogodatos_nuevoproyecto;
private javax.swing.JLabel etiDDNP_nombreciudad;
private javax.swing.JLabel etiDDNPloc;
private javax.swing.JLabel etiJF_Aporta;
private javax.swing.JLabel etiJF_DA;
private javax.swing.JLabel etiJF_Rendi;
private javax.swing.JLabel etiJF_Sut;
private javax.swing.JLabel etiJF_fchart;
private javax.swing.JLabel etiJF_general;
private javax.swing.JLabel etiJF_general1;
private javax.swing.JLabel etiJF_general2;
private javax.swing.JLabel etiJF_general3;
private javax.swing.JLabel etiJF_var;
private javax.swing.JLabel etiRenJFC_graficas;
private javax.swing.JLabel etiRen_Temp;
private javax.swing.JLabel etiRen_b;
private javax.swing.JLabel etiRen_m;
private javax.swing.JLabel eti_graf_paneles;
private javax.swing.JLabel etiacuCAm3;
private javax.swing.JLabel etiacuCNC1;
private javax.swing.JLabel etiacuCNC2;
private javax.swing.JLabel etiacuCV1;
private javax.swing.JLabel etiacuCV2;
private javax.swing.JLabel etiacuNC;
private javax.swing.JLabel etiacuNDA;
private javax.swing.JLabel etiacuSCT;
private javax.swing.JLabel etiacuVT;
private javax.swing.JLabel etialfa1;
private javax.swing.JLabel etialfa2;
private javax.swing.JLabel eticalculosmesAportacion;
private javax.swing.JLabel eticalculosmesConsumo;
private javax.swing.JLabel eticalculosmesDemandaMJ;
private javax.swing.JLabel eticalculosmesE;
private javax.swing.JLabel eticalculosmesENDmes;
private javax.swing.JLabel eticalculosmesHcor;
private javax.swing.JLabel eticalculosmesI;
private javax.swing.JLabel eticalculosmesRendimiento;
private javax.swing.JLabel eticalculosmesSalto;
private javax.swing.JLabel eticalculosmesTermias;
private javax.swing.JLabel etidatos_Altitud_lat;
private javax.swing.JLabel etidatos_Latitud_lat;
private javax.swing.JLabel etidatos_Nombre_lat;
private javax.swing.JLabel etidatos_Tminhistorica_lat;
private javax.swing.JLabel etifEa_FCCI;
private javax.swing.JLabel etifEa_FEO;
private javax.swing.JLabel etifEa_MAI;
private javax.swing.JLabel etifEa_Sc;
private javax.swing.JLabel etifEp_CGP;
private javax.swing.JLabel etifEp_FprUL;
private javax.swing.JLabel etifEp_K1;
private javax.swing.JLabel etifEp_KgA;
private javax.swing.JLabel etifEp_Tmin;
private javax.swing.JLabel etifFormulaEa;
private javax.swing.JLabel etifFormulaEa1;
private javax.swing.JLabel etifQa_Ce;
private javax.swing.JLabel etifQa_Consumo;
private javax.swing.JLabel etifQa_tac;
private javax.swing.JLabel etif_Prueba_K1;
103
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JLabel etif_compruebaK1;
private javax.swing.JLabel etif_compruebaSupanel;
private javax.swing.JLabel etilocalidad;
private javax.swing.JLabel etilocalidad1;
private javax.swing.JLabel etilocalidad2;
private javax.swing.JLabel etilocalidad3;
private javax.swing.JLabel etilocalidad4;
private javax.swing.JLabel etilocalidad5;
private javax.swing.JLabel etilogo_inicio;
private javax.swing.JLabel etiresultadosAhorroanual;
private javax.swing.JLabel etiresultadosAhorroanual2;
private javax.swing.JLabel etiresultadosAportacionAnual;
private javax.swing.JLabel etiresultadosAportacionAnual2;
private javax.swing.JLabel etiresultadosCAm5;
private javax.swing.JLabel etiresultadosCAuxanual;
private javax.swing.JLabel etiresultadosCAuxanual2;
private javax.swing.JLabel etiresultadosCEanual;
private javax.swing.JLabel etiresultadosCEanual2;
private javax.swing.JLabel etiresultadosCNC3;
private javax.swing.JLabel etiresultadosCNC4;
private javax.swing.JLabel etiresultadosCSA2;
private javax.swing.JLabel etiresultadosCV3;
private javax.swing.JLabel etiresultadosCV4;
private javax.swing.JLabel etiresultadosDA;
private javax.swing.JLabel etiresultadosDA3;
private javax.swing.JLabel etiresultadosDeficitAnual;
private javax.swing.JLabel etiresultadosDeficitAnual2;
private javax.swing.JLabel etiresultadosENanual;
private javax.swing.JLabel etiresultadosENanual3;
private javax.swing.JLabel etiresultadosFCCI2;
private javax.swing.JLabel etiresultadosNCteorico;
private javax.swing.JLabel etiresultadosNCteorico3;
private javax.swing.JLabel etiresultadosSCresultante;
private javax.swing.JLabel etiresultadosSCresultante2;
private javax.swing.JLabel etiresultadosSCteorica;
private javax.swing.JLabel etiresultadosSCteorica3;
private javax.swing.JLabel etiresultadosVolumen2;
private javax.swing.JLabel etiresultados_Prueba_K1_3;
private javax.swing.JLabel etiresultados_Prueba_K1_4;
private javax.swing.JLabel etiresultadosbcol2;
private javax.swing.JLabel etiresultadosmcol2;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel100;
private javax.swing.JLabel jLabel101;
private javax.swing.JLabel jLabel102;
private javax.swing.JLabel jLabel103;
private javax.swing.JLabel jLabel104;
private javax.swing.JLabel jLabel105;
private javax.swing.JLabel jLabel106;
private javax.swing.JLabel jLabel107;
private javax.swing.JLabel jLabel108;
private javax.swing.JLabel jLabel109;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel110;
private javax.swing.JLabel jLabel111;
104
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JLabel jLabel112;
private javax.swing.JLabel jLabel113;
private javax.swing.JLabel jLabel114;
private javax.swing.JLabel jLabel115;
private javax.swing.JLabel jLabel116;
private javax.swing.JLabel jLabel117;
private javax.swing.JLabel jLabel118;
private javax.swing.JLabel jLabel119;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel120;
private javax.swing.JLabel jLabel121;
private javax.swing.JLabel jLabel122;
private javax.swing.JLabel jLabel123;
private javax.swing.JLabel jLabel124;
private javax.swing.JLabel jLabel125;
private javax.swing.JLabel jLabel126;
private javax.swing.JLabel jLabel127;
private javax.swing.JLabel jLabel128;
private javax.swing.JLabel jLabel129;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel130;
private javax.swing.JLabel jLabel131;
private javax.swing.JLabel jLabel132;
private javax.swing.JLabel jLabel133;
private javax.swing.JLabel jLabel134;
private javax.swing.JLabel jLabel135;
private javax.swing.JLabel jLabel136;
private javax.swing.JLabel jLabel137;
private javax.swing.JLabel jLabel138;
private javax.swing.JLabel jLabel139;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel140;
private javax.swing.JLabel jLabel141;
private javax.swing.JLabel jLabel142;
private javax.swing.JLabel jLabel143;
private javax.swing.JLabel jLabel144;
private javax.swing.JLabel jLabel145;
private javax.swing.JLabel jLabel146;
private javax.swing.JLabel jLabel147;
private javax.swing.JLabel jLabel148;
private javax.swing.JLabel jLabel149;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel150;
private javax.swing.JLabel jLabel151;
private javax.swing.JLabel jLabel152;
private javax.swing.JLabel jLabel153;
private javax.swing.JLabel jLabel154;
private javax.swing.JLabel jLabel155;
private javax.swing.JLabel jLabel156;
private javax.swing.JLabel jLabel157;
private javax.swing.JLabel jLabel158;
private javax.swing.JLabel jLabel159;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel160;
private javax.swing.JLabel jLabel161;
private javax.swing.JLabel jLabel162;
private javax.swing.JLabel jLabel163;
private javax.swing.JLabel jLabel164;
private javax.swing.JLabel jLabel165;
private javax.swing.JLabel jLabel166;
private javax.swing.JLabel jLabel167;
105
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JLabel jLabel168;
private javax.swing.JLabel jLabel169;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel170;
private javax.swing.JLabel jLabel171;
private javax.swing.JLabel jLabel172;
private javax.swing.JLabel jLabel173;
private javax.swing.JLabel jLabel174;
private javax.swing.JLabel jLabel175;
private javax.swing.JLabel jLabel176;
private javax.swing.JLabel jLabel177;
private javax.swing.JLabel jLabel178;
private javax.swing.JLabel jLabel179;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel180;
private javax.swing.JLabel jLabel181;
private javax.swing.JLabel jLabel182;
private javax.swing.JLabel jLabel183;
private javax.swing.JLabel jLabel184;
private javax.swing.JLabel jLabel185;
private javax.swing.JLabel jLabel186;
private javax.swing.JLabel jLabel187;
private javax.swing.JLabel jLabel188;
private javax.swing.JLabel jLabel189;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel194;
private javax.swing.JLabel jLabel196;
private javax.swing.JLabel jLabel197;
private javax.swing.JLabel jLabel198;
private javax.swing.JLabel jLabel199;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel200;
private javax.swing.JLabel jLabel201;
private javax.swing.JLabel jLabel202;
private javax.swing.JLabel jLabel203;
private javax.swing.JLabel jLabel204;
private javax.swing.JLabel jLabel205;
private javax.swing.JLabel jLabel206;
private javax.swing.JLabel jLabel207;
private javax.swing.JLabel jLabel208;
private javax.swing.JLabel jLabel209;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel210;
private javax.swing.JLabel jLabel211;
private javax.swing.JLabel jLabel212;
private javax.swing.JLabel jLabel213;
private javax.swing.JLabel jLabel214;
private javax.swing.JLabel jLabel215;
private javax.swing.JLabel jLabel216;
private javax.swing.JLabel jLabel217;
private javax.swing.JLabel jLabel218;
private javax.swing.JLabel jLabel219;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel220;
private javax.swing.JLabel jLabel221;
private javax.swing.JLabel jLabel222;
private javax.swing.JLabel jLabel224;
private javax.swing.JLabel jLabel226;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel230;
106
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JLabel jLabel233;
private javax.swing.JLabel jLabel235;
private javax.swing.JLabel jLabel236;
private javax.swing.JLabel jLabel237;
private javax.swing.JLabel jLabel238;
private javax.swing.JLabel jLabel239;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel240;
private javax.swing.JLabel jLabel241;
private javax.swing.JLabel jLabel242;
private javax.swing.JLabel jLabel243;
private javax.swing.JLabel jLabel244;
private javax.swing.JLabel jLabel245;
private javax.swing.JLabel jLabel246;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel32;
private javax.swing.JLabel jLabel33;
private javax.swing.JLabel jLabel34;
private javax.swing.JLabel jLabel35;
private javax.swing.JLabel jLabel36;
private javax.swing.JLabel jLabel37;
private javax.swing.JLabel jLabel38;
private javax.swing.JLabel jLabel39;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel40;
private javax.swing.JLabel jLabel41;
private javax.swing.JLabel jLabel42;
private javax.swing.JLabel jLabel43;
private javax.swing.JLabel jLabel44;
private javax.swing.JLabel jLabel45;
private javax.swing.JLabel jLabel46;
private javax.swing.JLabel jLabel47;
private javax.swing.JLabel jLabel48;
private javax.swing.JLabel jLabel49;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel50;
private javax.swing.JLabel jLabel51;
private javax.swing.JLabel jLabel52;
private javax.swing.JLabel jLabel53;
private javax.swing.JLabel jLabel54;
private javax.swing.JLabel jLabel55;
private javax.swing.JLabel jLabel56;
private javax.swing.JLabel jLabel57;
private javax.swing.JLabel jLabel58;
private javax.swing.JLabel jLabel59;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel60;
private javax.swing.JLabel jLabel61;
private javax.swing.JLabel jLabel62;
private javax.swing.JLabel jLabel63;
private javax.swing.JLabel jLabel64;
private javax.swing.JLabel jLabel65;
private javax.swing.JLabel jLabel66;
private javax.swing.JLabel jLabel67;
107
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JLabel jLabel68;
private javax.swing.JLabel jLabel69;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel70;
private javax.swing.JLabel jLabel71;
private javax.swing.JLabel jLabel72;
private javax.swing.JLabel jLabel73;
private javax.swing.JLabel jLabel74;
private javax.swing.JLabel jLabel75;
private javax.swing.JLabel jLabel76;
private javax.swing.JLabel jLabel77;
private javax.swing.JLabel jLabel78;
private javax.swing.JLabel jLabel79;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel80;
private javax.swing.JLabel jLabel81;
private javax.swing.JLabel jLabel82;
private javax.swing.JLabel jLabel83;
private javax.swing.JLabel jLabel84;
private javax.swing.JLabel jLabel85;
private javax.swing.JLabel jLabel86;
private javax.swing.JLabel jLabel87;
private javax.swing.JLabel jLabel88;
private javax.swing.JLabel jLabel89;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel jLabel90;
private javax.swing.JLabel jLabel91;
private javax.swing.JLabel jLabel92;
private javax.swing.JLabel jLabel93;
private javax.swing.JLabel jLabel94;
private javax.swing.JLabel jLabel95;
private javax.swing.JLabel jLabel96;
private javax.swing.JLabel jLabel97;
private javax.swing.JLabel jLabel98;
private javax.swing.JLabel jLabel99;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel13;
private javax.swing.JPanel jPanel14;
private javax.swing.JPanel jPanel16;
private javax.swing.JPanel jPanel17;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JPanel panJF_Aporta;
private javax.swing.JPanel panJF_DA;
private javax.swing.JPanel panJF_Rendi;
private javax.swing.JPanel panJF_Sut;
private javax.swing.JPanel panJF_fchart;
private javax.swing.JPanel panJF_general;
private javax.swing.JPanel panJF_general1;
private javax.swing.JPanel panJF_general2;
private javax.swing.JPanel panJF_general3;
private javax.swing.JPanel panJF_var;
private javax.swing.JPanel panRenJFC_graficas;
private javax.swing.JPanel pan_graf_paneles;
108
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JPanel panelDA_MasMenos;
private javax.swing.JPanel panel_Cargas_fchart;
private javax.swing.JPanel panel_FCHART;
private javax.swing.JPanel panel_GRAF2;
private javax.swing.JPanel panel_Informes_BD_Resultados;
private javax.swing.JPanel panel_JFreeChart;
private javax.swing.JPanel panel_Rendimiento_JFC;
private javax.swing.JPanel panel_acumulador;
private javax.swing.JPanel panel_calculos;
private javax.swing.JPanel panel_comprobacion_fk1;
private javax.swing.JPanel panel_datos;
private javax.swing.JPanel panel_datosyresultados;
private javax.swing.JPanel panel_fEa;
private javax.swing.JPanel panel_fEa1;
private javax.swing.JPanel panel_grafica_fchart;
private javax.swing.JPanel panel_histogramas;
private javax.swing.JPanel panel_proyectos;
private javax.swing.JPanel panel_resultados;
private javax.swing.JPanel panel_valores_grafica_fchart;
private javax.swing.JPanel panelfEp;
private javax.swing.JPanel panelfEp1;
private javax.swing.JPanel panelfResultados;
private javax.swing.JPanel panelfg_MasMenos;
private javax.swing.JPanel panelgraf;
private javax.swing.JPanel panhistoDemandaAportacion;
private javax.swing.JPanel panhistoDemandaAportacion1;
private javax.swing.JPanel panhistoaport;
private javax.swing.JPanel panhistorendi;
private javax.swing.JPanel panhistosusti;
private javax.swing.JPanel subpanelCVM;
private javax.swing.JPanel subpanelcalculo1;
private javax.swing.JPanel subpanelcalculos2;
private javax.swing.JPanel subpanelcalculos3;
private javax.swing.JPanel subpaneldatos2;
private javax.swing.JPanel subpaneldatos3;
private javax.swing.JPanel subpaneldatos_Latitud;
private javax.swing.JPanel subpaneldatosyresultados;
private javax.swing.JPanel subpanelresultados1;
private javax.swing.JPanel subpanelresultados2;
private javax.swing.JPanel subpanelresultados2_1;
private javax.swing.JPanel subpanelresultados2_10;
private javax.swing.JPanel subpanelresultados2_2;
private javax.swing.JPanel subpanelresultados2_3;
private javax.swing.JPanel subpanelresultados2_8;
private javax.swing.JPanel subpanelresultados2_9;
private javax.swing.JTable tablaResultadosACS;
private javax.swing.JTable tablaVariacion_anual;
private javax.swing.JTable tablamensual;
private javax.swing.JTextField txtDDNPnuevaloc;
private javax.swing.JTextField txtTempuso1;
private javax.swing.JTextField txtacuVP;
private javax.swing.JTextField txtacuVolm2;
private javax.swing.JTextField txtareacolector1;
private javax.swing.JTextField txtb1;
private javax.swing.JTextField txtcorreccionH1;
private javax.swing.JTextField txtcorreccionb1;
private javax.swing.JTextField txtdatosAreacol;
private javax.swing.JTextField txtdatosDesviacion;
private javax.swing.JTextField txtdatosInclinacion;
private javax.swing.JTextField txtdatosLitrosdia;
private javax.swing.JTextField txtdatosPerdidaglobal;
109
APÉNDICE II. CÓDIGOS. JAVA. Cuadro.java
private javax.swing.JTextField txtdatosPreciokw;
private javax.swing.JTextField txtdatosTempuso;
private javax.swing.JTextField txtdatosUsuarios;
private javax.swing.JTextField txtdatosbcol;
private javax.swing.JTextField txtdatoscorreH;
private javax.swing.JTextField txtdatoscorreb;
private javax.swing.JTextField txtdatosmcol;
private javax.swing.JTextField txtdatosmesCork;
private javax.swing.JTextField txtdatosmesDias;
private javax.swing.JTextField txtdatosmesH;
private javax.swing.JTextField txtdatosmesHorasSol;
private javax.swing.JTextField txtdatosmesOcupacion;
private javax.swing.JTextField txtdatosmesTamb;
private javax.swing.JTextField txtdatosmesTred;
private javax.swing.JTextField txtdesviacionNS1;
private javax.swing.JTextField txteliminafila1;
private javax.swing.JTextField txteliminafila2;
private javax.swing.JTextField txteliminafila3;
private javax.swing.JTextField txteliminafila4;
private javax.swing.JTextField txtfEa_FCCI;
private javax.swing.JTextField txtfEa_FEO;
private javax.swing.JTextField txtfEa_MAI;
private javax.swing.JTextField txtfEa_Sup1;
private javax.swing.JTextField txtfEa_numpaneles;
private javax.swing.JTextField txtfEp_CGP;
private javax.swing.JTextField txtfEp_KgA;
private javax.swing.JTextField txtfEp_Tmin;
private javax.swing.JTextField txtfQa_C;
private javax.swing.JTextField txtfQa_Ce;
private javax.swing.JTextField txtfQa_N;
private javax.swing.JTextField txtfQa_tac;
private javax.swing.JTextField txtf_compruebaKgA;
private javax.swing.JTextField txtf_compruebaNumpaneles;
private javax.swing.JTextField txtf_compruebaSc;
private javax.swing.JTextField txtf_comprueba_bcol;
private javax.swing.JTextField txtf_comprueba_factorIntercambiador;
private javax.swing.JTextField txtf_comprueba_mcol;
private javax.swing.JTextField txtinclinacion1;
private javax.swing.JTextField txtlitrosdia1;
private javax.swing.JTextField txtm1;
private javax.swing.JTextField txtperdidasglobales1;
private javax.swing.JTextField txtpreciokw1;
private javax.swing.JTextField txtresultadosNC;
private javax.swing.JTextField txtusuarios1;
// End of variables declaration
}
110
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
1.2. Clase LocalizacionACS.java
package paquete;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import javax.swing.JOptionPane;
/**
*
* @author Eduardo
*/
public class LocalizacionACS {
// para tres decimales
DecimalFormat formateador;
//propiedades datos de entrada
String Nombre;
double Latitud,Altitud,TempMinHistorica;
double Inclinacion;
double DesNS,CorH,PerdGlo,NumUsu,LitrosDia,Acol,bcol,mcol,Tuso,Corb,Preciokwh;
//propiedades vectores datos mensuales
double vDias[],vOcupacion[],vTred[],vH[],vCork[],vHorasSolUtil[],vTamb[];
//Propiedades a calcular
double[] vConsumo,vSalto,vDemandaMJmes,vDemandaTermiasmes,vHcor,vE,vI,vRendimiento,vAportacion,
vENDmes,vENDdia;
double[] vCobertura;
double[] vENTotalmes,vSustitucion,vDeficit,vCEmes,vCAuxmes,vAhorromes;
double deficitEnergeticoAnual,aportacionAnual;
double ENDañoM2,DemandaAnual,SCteorica,NCteorico,NCrecomendado,SCresultante,CEanual,CAuxAnual,
AhorroAnual;
double ConsumoanualACSm3,NumDiasAnual,PruebaSC,VolAcuTeorico,VolAcuM2,PruebaVolAcu,
VolAcuDiseño;
//para los histogramas de Aportacion Solar Relativa
double[] ASR;
//f-chart
double[] vfcarga;
double Ce,N,C,tac,consufQa;//para calcular vfcargas
double[] vEabsorbida, vRadiacion;
double Fadim,FEO,MAI,FCCI,numpaneles,Sup1,fSc;
double[] vEperdida,vK2,vDt;
double CGP,KgA,Tmin,K1,FprUL,FrUL,ppc;
double[] vD1,vD2,vf,vEutilc;
double CSA; //cobertura solar anual
double pruebak1;
double[] vfporceocupacion,vfporcelitros,vfporcetuso;
double vCork_MasMenos[];
//grafica DemandaAportacion
double SCR;// superficie total colectora;
double[] vDAporceocupacion,vDAporcelitros,vDAporcetuso;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Constructor
public LocalizacionACS(){
Nombre="";
111
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
Latitud=40;DesNS=0;CorH=1.05;PerdGlo=0.15;NumUsu=32;LitrosDia=40;
Acol=2.01;bcol=0.83;mcol=4.8;Tuso=45;Corb=0.94;Preciokwh=0.12;
vDias=new double[12];vOcupacion=new double[12];vH=new double[12];vCork=new double[12];
vHorasSolUtil=new double[12];vTamb=new double[12];
vConsumo=new double[12];vSalto=new double[12];vDemandaMJmes=new double[12];
vDemandaTermiasmes=new double[12];vHcor=new double[12];
vE=new double[12];vI=new double[12];vRendimiento=new double[12];
vAportacion=new double[12];vENDmes=new double[12];vENDdia=new double[12];
vCobertura=new double[12];
vENTotalmes=new double[12];vSustitucion=new double[12];vDeficit=new double[12];
vCEmes=new double[12];vCAuxmes=new double[12];vAhorromes=new double[12];
ASR=new double[12];
vfcarga=new double[12];vEabsorbida=new double[12];vEperdida=new double[12];vK2=new double[12];
vDt=new double[12];
vD1=new double[12];vD2=new double[12];vf=new double[12];vEutilc=new double[12];
vfporceocupacion=new double[12];vfporcelitros=new double[12];vfporcetuso=new double[12];
vCork_MasMenos=new double[12];
vDAporceocupacion=new double[12];vDAporcelitros=new double[12];vDAporcetuso=new double[12];
}//fin del constructor;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Métodos de la clase LocalizacionACS
//Métodos set para asignar valores
public void setNombre(String nom){Nombre=nom;}
public void setAltitud(double alt){Altitud=alt;}
public void setLatitud(double lat){Latitud=lat;}
public void setTempMinHistorica(double tmh){TempMinHistorica=tmh;};
public void setInclinacion(double inc){Inclinacion=inc;}
public void setDesNS(double des){DesNS=des;}
public void setCorH(double corh){CorH=corh;}
public void setPerdGlo(double per){PerdGlo=per;}
public void setNumUsu(double num){NumUsu=num;}
public void setLitrosDia(double ld){LitrosDia=ld;}
public void setAreacol(double acol){Acol=acol;}
public void setbcol(double b){bcol=b;}
public void setmcol(double m){mcol=m;}
public void setCorb(double cb){Corb=cb;}
public void setTuso(double tu){Tuso=tu;}
public void setPreciokwh(double pk){Preciokwh=pk;}
//Métodos set para vectores de valores mensuales
public void setvDias(double[] vd){vDias=vd;}
public void setvOcupacion(double[] vo){vOcupacion=vo;}
public void setvTred(double[] tr){vTred=tr;}
public void setvH(double[] h){vH=h;}
public void setvCork(double[] ck){vCork=ck;}
public void setvHorasSolUtil(double[] hs){vHorasSolUtil=hs;}
public void setvTamb(double[] ta){vTamb=ta;}
112
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
//para determinar el nº de colectores
public void setNC(double nc){NCrecomendado=nc;}
//para calcular el volumen de acumulación
public void setVolAcum2(double va){VolAcuM2=va;}
//para variar la ocupacion mensual en fchart
public void setvocupa(double[] ocup){vfporceocupacion=ocup;}
//para variar el consumo mensual en fchart
public void setvlitros(double[] vl){vfporcelitros=vl;}
//para variar la temperatura de uso mensual en fchart
public void setvtuso(double[] tus){vfporcetuso=tus;}
//para variar la ocupacion mensual en fchart
public void setvocupaDA(double[] ocup){vDAporceocupacion=ocup;}
//para variar el consumo mensual en fchart
public void setvlitrosDA(double[] vl){vDAporcelitros=vl;}
//para variar la temperatura de uso mensual en fchart
public void setvtusoDA(double[] tus){vDAporcetuso=tus;}
//Métodos get para consultar datos
public String getNombre(){return Nombre;}
public double getAltitud(){return Altitud;}
public double getLatitud(){return Latitud;}
public double getTempMinHistorica(){return TempMinHistorica;}
public double getInclinacion(){return Inclinacion;}
public double getDesNS(){return DesNS;}
public double getCorH(){return CorH;}
public double getPerdGlo(){return PerdGlo;}
public double getNumUsu(){return NumUsu;}
public double getLitrosDia(){return LitrosDia;}
public double getAcol(){return Acol;}
public double getbcol(){return bcol;}
public double getmcol(){return mcol;}
public double getCorb(){return Corb;}
public double getTuso(){return Tuso;}
public double getPreciokwh(){return Preciokwh;}
//Métodos get para consultar vectores de datos mensuales
public double[] getvDias(){return vDias;}
public double[] getvOcupacion(){return vOcupacion;}
public double[] getvTred(){return vTred;}
public double[] getvh(){return vH;}
public double[] getvCork(){return vCork;}
public double[] getvHorasSolUtil(){return vHorasSolUtil;}
public double[] getvTamb(){return vTamb;}
//Métodos de cálculos
113
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
public void Calcula_vConsumo(){
for(int i=0;i<12;i++){
vConsumo[i]=(LitrosDia*NumUsu*vDias[i]*vOcupacion[i])/100000;
//añadido
vConsumo[i]=vConsumo[i]*vDAporceocupacion[i];//para los calculo variando la ocupacion en DA
vConsumo[i]=vConsumo[i]*vDAporcelitros[i];//para los calculo variando los litros en DA
//hasta aqui
ConTresDecimales();
vConsumo[i]=Double.valueOf(formateador.format(vConsumo[i]));
}
}
public void Calcula_vSalto() {
for(int i=0;i<12;i++){
// Tuso=Tuso*vDAporcetuso[i];
vSalto[i]=Tuso-vTred[i];
}
}
public void Calcula_vDemandaTermiasmes() {
Calcula_vConsumo();Calcula_vSalto();
for(int i=0;i<12;i++){
vDemandaTermiasmes[i]=vConsumo[i]*vSalto[i];//Termias/mes
ConTresDecimales();
vDemandaTermiasmes[i]=Double.valueOf(formateador.format(vDemandaTermiasmes[i]));
}
}
public void Calcula_vDemandaMJmes() {
for(int i=0;i<12;i++){
vConsumo[i]=(LitrosDia*NumUsu*vDias[i]*vOcupacion[i])/100000;
vSalto[i]=Tuso-vTred[i];
vConsumo[i]=vConsumo[i]*vDAporceocupacion[i];//para los calculo variando la ocupacion en DA
vConsumo[i]=vConsumo[i]*vDAporcelitros[i];//para los calculo variando los litros en DA
vSalto[i]=Tuso*vDAporcetuso[i]-vTred[i];//para los calculo variando los litros en DA
vDemandaMJmes[i]=vConsumo[i]*vSalto[i]*4.184;//MJ/mes
ConTresDecimales();
vDemandaMJmes[i]=Double.valueOf(formateador.format(vDemandaMJmes[i]));
}
}
public void Calcula_vDemandaDA() {
for(int i=0;i<12;i++){
vConsumo[i]=(LitrosDia*NumUsu*vDias[i]*vOcupacion[i])/100000;
vSalto[i]=Tuso-vTred[i];
vConsumo[i]=vConsumo[i]*vDAporceocupacion[i];//para los calculo variando la ocupacion en DA
vConsumo[i]=vConsumo[i]*vDAporcelitros[i];//para los calculo variando los litros en DA
vSalto[i]=Tuso*vDAporcetuso[i]-vTred[i];//para los calculo variando los litros en DA
vDemandaMJmes[i]=vConsumo[i]*vSalto[i]*4.184;//MJ/mes
ConTresDecimales();
vDemandaMJmes[i]=Double.valueOf(formateador.format(vDemandaMJmes[i]));
}
114
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
}
public void Calcula_vHcor() {
for(int i=0;i<12;i++){
vHcor[i]=vH[i]*CorH;
ConTresDecimales();
vHcor[i]=Double.valueOf(formateador.format(vHcor[i]));
}
}
public void Calcula_vE(){
Calcula_vHcor();
for(int i=0;i<12;i++){
vE[i]=0.94*vCork[i]*vHcor[i];
ConTresDecimales();
vE[i]=Double.valueOf(formateador.format(vE[i]));
}
}
public void Calcula_vI() {
Calcula_vE();
for(int i=0;i<12;i++){
vI[i]=277.778*vE[i]/vHorasSolUtil[i];
ConTresDecimales();
vI[i]=Double.valueOf(formateador.format(vI[i]));
}
}
public void Calcula_vRendimiento() {
Calcula_vI();//con esto calcula I
for(int i=0;i<12;i++){
//vRendimiento[i]=100*Corb*bcol-100*mcol*(Tuso-vTamb[i])/vI[i];
vRendimiento[i]=100*Corb*bcol-100*mcol*(Tuso*vfporcetuso[i]-vTamb[i])/vI[i];
// if(vRendimiento[i]<20){vRendimiento[i]=0;}
if(vRendimiento[i]<0){vRendimiento[i]=0;}
ConTresDecimales();
vRendimiento[i]=Double.valueOf(formateador.format(vRendimiento[i]));}
}
public void Calcula_vAportacion() {
Calcula_vRendimiento();//con esto calcula I que calcula E
for(int i=0;i<12;i++){
if(vOcupacion[i]>0){vAportacion[i]=vE[i]*vRendimiento[i]/100;}// hemos añadido /100
else{vAportacion[i]=0;}
ConTresDecimales();
vAportacion[i]=Double.valueOf(formateador.format(vAportacion[i]));
}
}
public void Calcula_aportacionAnual() {
Calcula_DemandaAnual();
Calcula_DeficitEnergeticoAnual();
aportacionAnual=100*(DemandaAnual-deficitEnergeticoAnual)/DemandaAnual;
ConTresDecimales();
aportacionAnual=Double.valueOf(formateador.format(aportacionAnual));
}
115
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
public void Calcula_Aportacion_Solar_Relativa() {
Calcula_vAportacion();
int i;double maxApor=0;double[] Apor=new double[12];
for(i=0;i<12;i++){Apor[i]=vAportacion[i];}
for(i=0;i<12;i++){
if(Apor[i]>maxApor){maxApor=Apor[i];}else{}}
double maximaAportacion=maxApor;
for(i=0;i<12;i++){ASR[i]=
ASR[i]=100*(double)Apor[i]/(double)maximaAportacion;
}
}
public void Calcula_vENDdia() {
Calcula_vAportacion();
for(int i=0;i<12;i++){
vENDdia[i]=vAportacion[i]*(1-PerdGlo);// hemos quitado /100 ya que está en la aportacion
}
}
public void Calcula_vENDmes(){
ConTresDecimales();
Calcula_vENDdia();
for(int i=0;i<12;i++){
vENDmes[i]=vENDdia[i]*vDias[i];
vENDmes[i]=Double.valueOf(formateador.format(vENDmes[i]));
}
}
public void Calcula_ENDañoM2(){
Calcula_vENDmes();
ENDañoM2=0;
for(int i=0;i<12;i++){
ENDañoM2=ENDañoM2+vENDmes[i];}
ConTresDecimales();
ENDañoM2=Double.valueOf(formateador.format(ENDañoM2));
}
public void Calcula_DemandaAnual(){
Calcula_vDemandaMJmes();
DemandaAnual=0;
for(int i=0;i<12;i++){
DemandaAnual=DemandaAnual+vDemandaMJmes[i];
}ConTresDecimales();
DemandaAnual=Double.valueOf(formateador.format(DemandaAnual));
}
public void Calcula_SCteorica(){
Calcula_DemandaAnual();
Calcula_ENDañoM2();
SCteorica=DemandaAnual/ENDañoM2;
ConTresDecimales();
SCteorica=Double.valueOf(formateador.format(SCteorica));
}
public void Calcula_NCteorico(){
Calcula_SCteorica();
NCteorico=SCteorica/Acol;
ConTresDecimales();
116
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
NCteorico=Double.valueOf(formateador.format(NCteorico));
}
public void Calcula_SCresultante(){
//Calcula_NCrecomendado();
SCresultante=NCrecomendado*Acol;
ConTresDecimales();
SCresultante=Double.valueOf(formateador.format(SCresultante));
}
public void Calcula_vENTotalmes(){
Calcula_vENDmes();
Calcula_SCresultante();
for(int i=0;i<12;i++){
vENTotalmes[i]=vENDmes[i]*SCresultante;
ConTresDecimales();
vENTotalmes[i]=Double.valueOf(formateador.format(vENTotalmes[i]));
}
}
//para la gradica demanda-Aportacion
public void Calcula_vENTotalmes_DA(){
Calcula_vENDmes();
SCR=numpaneles*Acol;
for(int i=0;i<12;i++){
vENTotalmes[i]=vENDmes[i]*SCR;
ConTresDecimales();
vENTotalmes[i]=Double.valueOf(formateador.format(vENTotalmes[i]));
}
}
public void Calcula_vSustitucion(){
Calcula_vDemandaMJmes();
Calcula_vENTotalmes();
for(int i=0;i<12;i++){
if(vOcupacion[i]==0){vSustitucion[i]=0;}
else{double sust=vENTotalmes[i]/vDemandaMJmes[i];
/* if(sust>1){vSustitucion[i]=100;}
else{vSustitucion[i]=sust;}*/
/**/vSustitucion[i]=sust;}
ConTresDecimales();
vSustitucion[i]=Double.valueOf(formateador.format(vSustitucion[i]));
}
}
public void Calcula_vDeficit(){
Calcula_vDemandaMJmes();
Calcula_vENTotalmes();
for(int i=0;i<12;i++){
vDeficit[i]=vDemandaMJmes[i]-vENTotalmes[i];
ConTresDecimales();
vDeficit[i]=Double.valueOf(formateador.format(vDeficit[i]));
}
}
public void Calcula_vCobertura(){
Calcula_vDeficit();
for(int i=0;i<12;i++){
117
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
vCobertura[i]=100*(1-vDeficit[i]/vDemandaMJmes[i]);
ConTresDecimales();
vCobertura[i]=Double.valueOf(formateador.format(vCobertura[i]));
}
}
public void Calcula_DeficitEnergeticoAnual(){
double defi=0;
Calcula_vDeficit();
for(int i=0;i<12;i++){
if(vDeficit[i]<0){}else{defi=defi+vDeficit[i];}
}
ConTresDecimales();
deficitEnergeticoAnual=Double.valueOf(formateador.format(defi));
}
public void Calcula_vCosteEmes(){
Calcula_vDemandaMJmes();
for(int i=0;i<12;i++){
vCEmes[i]=Preciokwh/3.6*vDemandaMJmes[i];
ConTresDecimales();
vCEmes[i]=Double.valueOf(formateador.format(vCEmes[i]));
}
}
public void Calcula_CosteEanual(){
Calcula_DemandaAnual();
CEanual=Preciokwh/3.6*DemandaAnual;
ConTresDecimales();
CEanual=Double.valueOf(formateador.format(CEanual));
}
public void Calcula_vCosteAuxmes(){
Calcula_vDeficit();
for(int i=0;i<12;i++){
if(vDeficit[i]>0){vCAuxmes[i]=Preciokwh/3.6*vDeficit[i];}
else{vCAuxmes[i]=0;}
ConTresDecimales();
vCAuxmes[i]=Double.valueOf(formateador.format(vCAuxmes[i]));
}
}
public void Calcula_CosteAuxAnual(){
Calcula_vCosteAuxmes();
CAuxAnual=0;
for(int i=0;i<12;i++){
CAuxAnual=CAuxAnual+vCAuxmes[i];}
ConTresDecimales();
CAuxAnual=Double.valueOf(formateador.format(CAuxAnual));
}
public void Calcula_vAhorromes(){
Calcula_vCosteEmes();
Calcula_vCosteAuxmes();
for(int i=0;i<12;i++){
vAhorromes[i]=vCEmes[i]-vCAuxmes[i];
ConTresDecimales();
vAhorromes[i]=Double.valueOf(formateador.format(vAhorromes[i]));
}
}
public void Calcula_AhorroAnual(){
Calcula_vAhorromes();
118
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
AhorroAnual=0;
for(int i=0;i<12;i++){
AhorroAnual=AhorroAnual+vAhorromes[i];
}
ConTresDecimales();
AhorroAnual=Double.valueOf(formateador.format(AhorroAnual));
}
public void Calcula_ConsumoanualACSm3(){
Calcula_vConsumo();
ConsumoanualACSm3=0;
for(int i=0;i<12;i++){
ConsumoanualACSm3=ConsumoanualACSm3+vConsumo[i];
}
ConTresDecimales();
ConsumoanualACSm3=Double.valueOf(formateador.format(ConsumoanualACSm3));
}
public void Calcula_NumDiasAnual(){
NumDiasAnual=0;
for(int i=0;i<12;i++){
NumDiasAnual=NumDiasAnual+vDias[i]*vOcupacion[i]/100;
}ConTresDecimales();
NumDiasAnual=Double.valueOf(formateador.format(NumDiasAnual));
}
public void Calcula_VolAcuTeorico(){
// VolAcuM2=70;
Calcula_SCresultante();
VolAcuTeorico=SCresultante*VolAcuM2;
ConTresDecimales();
VolAcuTeorico=Double.valueOf(formateador.format(VolAcuTeorico));
}
public void Calcula_PruebaSC(){
Calcula_ConsumoanualACSm3();
Calcula_NumDiasAnual();
Calcula_SCresultante();
PruebaSC=1000*ConsumoanualACSm3/(NumDiasAnual*SCresultante);
ConTresDecimales();
PruebaSC=Double.valueOf(formateador.format(PruebaSC));
}
public void Calcula_PruebaVolAcu(){
//VolAcuDiseño=2000;
Calcula_VolAcuTeorico();
PruebaVolAcu=VolAcuTeorico/VolAcuDiseño;
ConTresDecimales();
PruebaVolAcu=Double.valueOf(formateador.format(PruebaVolAcu));
}
//f-chart
public void Calcula_vfcarga(){
for(int i=0;i<12;i++){
vfcarga[i]=(Ce*N*C*vDias[i]*(tac-vTred[i]))/Math.pow(10,6);//MJ/mes
vfcarga[i]=(Ce*N*C*vDias[i]*(tac*vfporcetuso[i]-vTred[i]))/Math.pow(10,6);//para los calculo variando la
Temp de uso en fchart
vfcarga[i]=vfcarga[i]*vfporceocupacion[i];//para los calculo variando la ocupacion en fchart
vfcarga[i]=vfcarga[i]*vfporcelitros[i];//para los calculo variando los litros en fchart
119
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
ConTresDecimales();
vfcarga[i]=Double.valueOf(formateador.format(vfcarga[i]));
}
}
public void Calcula_Fadim(){
Fadim=FEO*MAI*FCCI;
}
public void Calcula_vEabsorbidaf(){
Calcula_vE();
Calcula_Fadim();
for(int i=0;i<12;i++){
vEabsorbida[i]=fSc*Fadim*vE[i]*vDias[i];//Mj/mes
ConTresDecimales();
vEabsorbida[i]=Double.valueOf(formateador.format(vEabsorbida[i]));
}
}
public void Calcula_FprUL(){
FprUL=CGP*FCCI;
ConTresDecimales();
FprUL=Double.valueOf(formateador.format(FprUL));
}
public void Calcula_vDt(){
for(int i=0;i<12;i++){
vDt[i]=vDias[i]*24*3600;
ConTresDecimales();
vDt[i]=Double.valueOf(formateador.format(vDt[i]));
}
}
public void Calcula_K1(){
double ka1=(KgA/(75*fSc));
K1=Math.pow(ka1,-0.25);
ConTresDecimales();
K1=Double.valueOf(formateador.format(K1));
}
public void Calcula_vK2(){
for(int i=0;i<12;i++){
vK2[i]=(11.6+1.18*Tmin*vfporcetuso[i]+3.86*vTred[i]-2.32*vTamb[i])/(100-vTamb[i]);
ConTresDecimales();
vK2[i]=Double.valueOf(formateador.format(vK2[i]));
}
}
public void Calcula_vEperdidaf(){
Calcula_vDt();
for(int i=0;i<12;i++){
vEperdida[i]=fSc*CGP*0.95*(100-vTamb[i])*vDt[i]/1000000;//Mj/mes
ConTresDecimales();
vEperdida[i]=Double.valueOf(formateador.format(vEperdida[i]));
}
120
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
}
public void Calcula_D1(){
Calcula_vfcarga();
Calcula_vEabsorbidaf();
for(int i=0;i<12;i++){
vD1[i]=vEabsorbida[i]/vfcarga[i];
ConTresDecimales();
vD1[i]=Double.valueOf(formateador.format(vD1[i]));
}
}
public void Calcula_D2(){
Calcula_vfcarga();
Calcula_vEperdidaf();
Calcula_K1();
Calcula_vK2();
for(int i=0;i<12;i++){
vD2[i]=vEperdida[i]*K1*vK2[i]/vfcarga[i];
ConTresDecimales();
vD2[i]=Double.valueOf(formateador.format(vD2[i]));
}
}
public void Calcula_fchart(){
Calcula_D1();
Calcula_D2();
for(int i=0;i<12;i++){
vf[i]=1.029*vD1[i]-0.065*vD2[i]0.245*Math.pow(vD1[i],2)+0.0018*Math.pow(vD2[i],2)+0.0215*Math.pow(vD1[i],3);
//if(vf[i]>1){vf[i]=1;}
vf[i]=vf[i]*100;
ConTresDecimales();
vf[i]=Double.valueOf(formateador.format(vf[i]));
}
}
public void Calcula_vEutilcaptada(){
Calcula_vfcarga();
Calcula_fchart();
for(int i=0;i<12;i++){
vEutilc[i]=vfcarga[i]*vf[i]/100;
ConTresDecimales();
vEutilc[i]=Double.valueOf(formateador.format(vEutilc[i]));
}
}
public void Calcula_CoberturaSA(){
Calcula_vfcarga();Calcula_vEutilcaptada();
double sumaQu=0;double sumaQa=0;
for(int i=0;i<12;i++){
sumaQu=sumaQu+vEutilc[i];
sumaQa=sumaQa+vfcarga[i];
}
CSA=sumaQu/sumaQa;
ConTresDecimales();
CSA=Double.valueOf(formateador.format(CSA));
}
public void Comprueba_K1_fchart(){
pruebak1=KgA/fSc;
121
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
ConTresDecimales();pruebak1=Double.valueOf(formateador.format(pruebak1));
}
//---------------------------------------------//Demanda Aportacion
public double[] getvConsumo(){
Calcula_vConsumo();
return vConsumo;
}
public double[] getSaltoT(){
Calcula_vSalto();
return vSalto;
}
public double[] getvDemandaTermiasmes(){
Calcula_vDemandaTermiasmes();
return vDemandaTermiasmes;
}
public double[] getvDemandaMJmes(){
Calcula_vDemandaMJmes();
return vDemandaMJmes;
}
public double[] getvHcor(){
Calcula_vHcor();
return vHcor;
}
public double[] getvE(){
Calcula_vE();
return vE;
}
public double[] getvI(){
Calcula_vI();
return vI;
}
public double[] getvRendimiento(){
Calcula_vRendimiento();
return vRendimiento;
}
public double[] getvAportacion(){
Calcula_vAportacion();
return vAportacion;
}
public double getaportacionAnual(){
Calcula_aportacionAnual();
return aportacionAnual;
}
public double[] getvENDdia(){
Calcula_vENDdia();
return vENDdia;
}
public double[] getvENDmes(){
Calcula_vENDmes();
return vENDmes;
}
public double getENDañoM2(){
Calcula_ENDañoM2();
122
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
return ENDañoM2;
}
public double getDemandaAnual(){
Calcula_DemandaAnual();
return DemandaAnual;
}
public double getSCteorica(){
Calcula_SCteorica();
return SCteorica;
}
public double getNCteorico(){
Calcula_NCteorico();
return NCteorico;
}
public double getNCrecomendado(){
//Calcula_NCrecomendado();
return NCrecomendado;
}
public double getSCresultante(){
Calcula_SCresultante();
return SCresultante;
}
public double[] getvENTotalmes(){
Calcula_vENTotalmes();
return vENTotalmes;
}
//para la gradica demanda-Aportacion
public double[] getvENTotalmes_DA(){
Calcula_vENTotalmes_DA();
return vENTotalmes;
}
public double[] getvSustitucion(){
Calcula_vSustitucion();
return vSustitucion;
}
public double[] getvDeficit(){
Calcula_vDeficit();
return vDeficit;
}
public double[] getvCobertura(){
Calcula_vCobertura();
return vCobertura;
}
public double getdeficitEnergeticoAnual(){
Calcula_DeficitEnergeticoAnual();
return deficitEnergeticoAnual;
}
public double[] getvCosteEmes(){
Calcula_vCosteEmes();
return vCEmes;
}
public double getCosteEanual(){
Calcula_CosteEanual();
return CEanual;
}
123
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
public double[] getvCosteAuxmes(){
Calcula_vCosteAuxmes();
return vCAuxmes;
}
public double getCosteAuxAnual(){
Calcula_CosteAuxAnual();
return CAuxAnual;
}
public double[] getvAhorromes(){
Calcula_vAhorromes();
return vAhorromes;
}
public double getAhorroAnual(){
Calcula_AhorroAnual();
return AhorroAnual;
}
public double getConsumoanualACSm3(){
Calcula_ConsumoanualACSm3();
return ConsumoanualACSm3;
}
public double getNumDiasAnual(){
Calcula_NumDiasAnual();
return NumDiasAnual;
}
public double getVolAcuTeorico(){
Calcula_VolAcuTeorico();
return VolAcuTeorico;
}
public double getPruebaSC(){
Calcula_PruebaSC();
return PruebaSC;
}
public String getComprobacionSC(){
Calcula_PruebaSC();
String CSC;
if(PruebaSC<60){CSC="No cumple";}
else{if(PruebaSC>100){CSC="No cumple";}else{CSC="Cumple";}}
return CSC;
}
public double getPruebaVolAcu(){
Calcula_PruebaVolAcu();
return PruebaVolAcu;
}
public String getComprobacionVolAcu(){
Calcula_PruebaVolAcu();
String CVA;
if(PruebaVolAcu<0.8){CVA="No cumple";}
else{if(PruebaVolAcu>1.2){CVA="No cumple";}else{CVA="Cumple";}}
return CVA;
}
public double[] getASR(){
Calcula_Aportacion_Solar_Relativa();
return ASR;}
public double[] getvfcarga(){
Calcula_vfcarga();
124
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
return vfcarga;
}
public double[] getvEabsorbida(){
Calcula_vEabsorbidaf();
return vEabsorbida;
}
public double getFprUL(){
Calcula_FprUL();
return FprUL;
}
public double getFCCI(){
return FCCI;
}
public double[] getvDt(){
Calcula_vDt();
return vDt;
}
public double getK1(){
Calcula_K1();
return K1;
}
public double[] getvK2(){
Calcula_vK2();
return vK2;
}
public double[] getvEperdida(){
Calcula_vEperdidaf();
return vEperdida;
}
public double[] getvD1(){
Calcula_D1();
return vD1;
}
public double[] getvD2(){
Calcula_D2();
return vD2;
}
public double[] getvfchart(){
Calcula_fchart();
return vf;
}
public double[] getvEutilcaptada(){
Calcula_vEutilcaptada();
return vEutilc;
}
public double getCoberturaSA(){
Calcula_CoberturaSA();
return CSA;
}
public double getPruebak1(){
Comprueba_K1_fchart();
return pruebak1;
}
public double[] getvDemandaDa(){
//Calcula_vfcarga();
125
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
Calcula_vDemandaMJmes();
return vDemandaMJmes;
}
public void BuscaDatosMensuales(double inclina, String sitio){
double[] vd={31,28,31,30,31,30,31,31,30,31,30,31};
double[] ocu={100,100,100,100,100,100,100,100,100,100,100,100};
double[] vHSU={8,9,9,9.5,9.5,9.5,9.5,9.5,9,9,8,7.5};//para latitudes entre +25º y +45º (hemisferio Norte)
vDias=vd;vOcupacion=ocu;vHorasSolUtil=vHSU;
//Álava1 42.9
double[] vTr1={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh1={4.6,6.9,11.2,13,14.8,16.6,18.1,17.3,14.3,9.5,5.5,4.1};
double[] vck1={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa1={7,7,11,12,15,19,21,21,19,15,10,7};
//Albacete2 39
double[] vTr2={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh2={6.5,10.5,15,19.2,21.2,25.1,26.7,23.2,18.8,12.4,8.4,6.4};
double[] vck2={1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48};
double[] vTa2={6,8,11,13,17,22,26,26,22,16,11,7};
//Alicante3 38.4
double[] vTr3={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh3={8.5,12,16.3,18.9,23.1,24.8,25.8,22.5,18.3,13.6,9.8,7.6};
double[] vck3={1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47};
double[] vTa3={13,14,16,18,21,25,28,28,26,21,17,14};
//Almeria4 36.9
double[] vTr4={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh4={8.9,12.2,16.4,19.6,23.1,24.6,25.3,22.5,18.5,13.9,10,8};
double[] vck4={1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45};
double[] vTa4={15,15,16,18,21,24,27,28,26,22,18,16};
//Asturias5 43
double[] vTr5={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh5={5.3,7.7,10.6,12.2,15,15.2,16.8,14.8,12.4,9.8,5.9,4.6};
double[] vck5={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa5={9,10,11,12,15,18,20,20,19,16,12,10};
//Ávila6 40.7
double[] vTr6={4,5,7,9,10,11,12,11,10,9,7,4};
double[] vh6={6,9.1,13.5,17.7,19.4,22.3,26.3,25.3,18.8,11.2,6.9,5.2};
double[] vck6={1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52};
double[] vTa6={4,5,8,11,14,18,22,22,18,13,8,5};
//Badajoz7 38.9
double[] vTr7={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh7={6.50,10,13.60,18.70,21.80,24.60,25.90,23.80,17.90,12.30,8.20,6.20};
double[] vck7={1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48};
double[] vTa7={11,12,15,17,20,25,28,28,25,20,15,11};
//Baleares8 39.6
double[] vTr8={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh8={7.2,10.7,14.4,16.2,21,22.7,24.2,20.6,16.4,12.1,8.5,6.5};
double[] vck8={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5};
double[] vTa8={12,13,14,17,19,23,26,27,25,20,16,14};
//Barcelona9 41.4 42
double[] vTr9={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh9={6.5,9.5,12.9,16.1,18.6,20.3,21.6,18.1,14.6,10.8,7.2,5.8};
double[] vck9={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa9={11,12,14,17,20,24,26,26,24,20,16,12};
//Burgos10 42.3
double[] vTr10={4,5,7,9,10,11,12,11,10,9,7,4};
126
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
double[] vh10={5.1,7.9,12.4,16,18.7,21.5,23,20.7,16.7,10.1,6.5,4.5};
double[] vck10={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa10={5,10,9,11,14,18,21,21,18,13,9,5};
//Cáceres11 39.5
double[] vTr11={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh11={6.8,10,14.7,19.6,22.1,25.1,28.1,25.4,19.7,12.7,8.9,6.6};
double[] vck11={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.54,1.52};
double[] vTa11={10,11,14,16,19,25,28,28,25,19,14,10};
//Cádiz12 36.5
double[] vTr12={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh12={8.1,11.5,15.7,18.5,22.2,23.8,25.9,23,18.1,14.2,10,7.4};
double[] vck12={1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45};
double[] vTa12={13,15,17,19,21,24,27,27,25,22,18,15};
//Cantabria13 43.5
double[] vTr13={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh13={5,7.4,11,13,16.1,17,18.4,15.5,13,9.5,5.8,4.5};
double[] vck13={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa13={11,11,14,14,16,19,21,21,20,17,14,12};
//Castellón14 40
double[] vTr14={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh14={8,12.2,15.5,17.4,20.6,21.4,23.9,19.5,16.6,13.1,8.6,7.3};
double[] vck14={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5};
double[] vTa14={13,13,15,17,20,24,26,27,25,21,16,13};
//Ceuta15 35.9
double[] vTr15={8,9,10,12,13,13,14,13,13,12,11,8};
double[] vh15={8.9,13.1,18.6,21,24.3,26.7,26.8,24.3,19.1,14.2,11,8.6};
double[] vck15={1.34,1.23,1.1,0.97,0.87,0.87,0.84,0.87,0.98,1.14,1.32,1.44,1.43};
double[] vTa15={15,15,16,17,19,23,25,26,24,21,18,16};
//Ciudad Real16 39
double[] vTr16={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh16={7,10.1,15,18.7,21.4,23.7,25.3,23.2,18.8,12.5,8.7,6.5};
double[] vck16={1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48};
double[] vTa16={7,9,12,15,18,23,28,27,20,17,11,8};
//Córdoba17 37.9
double[] vTr17={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh17={7.2,10.1,15.1,18.5,21.8,25.9,28.5,25.1,19.9,12.6,8.6,6.9};
double[] vck17={1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47};
double[] vTa17={11,13,16,18,21,26,30,30,26,21,16,12};
//La Coruña18 43.4
double[] vTr18={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh18={5.4,8,11.4,12.4,15.4,16.2,17.4,15.3,13.9,10.9,6.4,5.1};
double[] vck18={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa18={12,12,14,14,16,19,20,21,20,17,14,12};
//Cuenca19 40.1
double[] vTr19={4,5,7,9,10,11,12,11,10,9,7,4};
double[] vh19={5.9,8.8,12.9,17.4,18.7,22,25.5,22.3,17.5,11.2,7.2,5.5};
double[] vck19={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5};
double[] vTa19={5,6,9,12,15,20,24,23,20,14,9,6};
//Gerona20 42
double[] vTr20={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh20={7.1,10.5,14.2,15.9,18.7,19,22.3,18.5,14.9,11.7,7.8,6.6};
double[] vck20={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa20={9,10,13,15,19,23,26,25,23,18,13,10};
//Granada21 37.2
double[] vTr21={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh21={7.8,10.8,15.2,18.5,21.9,24.8,26.7,23.6,18.8,12.9,9.6,7.1};
double[] vck21={1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45};
double[] vTa21={9,10,13,16,18,24,27,27,24,18,13,9};
127
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
//Guadalajara22 40.6
double[] vTr22={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh22={6.5,9.2,14,17.9,19.4,22.7,25,23.2,17.8,11.7,7.8,5.6};
double[] vck22={1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52};
double[] vTa22={7,8,12,14,18,22,26,26,22,16,10,8};
//Guipúzcoa23 43.3
double[] vTr23={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh23={5.5,7.7,11,.3,11.7,14.6,16.2,16.1,13.6,12.7,10.3,6.2,5};
double[] vck23={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa23={10,10,13,14,16,19,21,21,20,17,13,10};
//Huelva24 37.3
double[] vTr24={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh24={7.6,11.3,16,19.5,24.1,25.6,28.7,25.6,21.2,14.5,9.2,7.5};
double[] vck24={1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45};
double[] vTa24={13,14,16,20,21,24,27,27,25,21,17,14};
//Huesca25 42.1
double[] vTr25={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh25={6.1,9.6,14.3,18.7,20.3,22.1,23.1,20.9,16.9,11.3,7.2,5.1};
double[] vck25={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa25={7,8,12,15,18,22,25,25,21,16,11,7};
//Jaén26 37.8
double[] vTr26={8,9,11,13,14,15,17,16,14,13,11,7};
double[] vh26={6.7,10.1,14.4,18,20.3,24.4,26.7,24.1,19.2,11.9,8.1,6.5};
double[] vck26={1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47};
double[] vTa26={11,11,14,17,21,26,30,29,25,19,15,10};
//León27 42.6
double[] vTr27={4,5,7,9,10,11,12,11,10,9,7,4};
double[] vh27={5.8,8.7,13.8,17.2,19.5,22.1,24.2,20.9,17.2,10,4,7,4.8};
double[] vck27={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa27={5,6,10,12,15,19,22,22,19,14,9,6};
//Lérida28 41.7
double[] vTr28={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh28={6,9.9,10,18.8,20.9,22.6,23.8,21.3,16.8,12.1,7.2,4.8};
double[] vck28={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa28={7,10,14,15,21,24,27,27,23,18,11,8};
//Lugo29 43
double[] vTr29={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh29={5.1,7.6,11.7,15.2,17.1,19.5,20.2,18.4,15,9.9,6.2,4.5};
double[] vck29={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa29={8,9,11,13,15,18,20,21,19,15,11,8};
//Madrid30 40.4
double[] vTr30={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh30={6.7,10.6,13.6,18.8,20.9,23.5,26,23.1,16.9,11.4,7.5,5.9};
double[] vck30={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5};
double[] vTa30={6,8,11,13,18,23,28,26,21,15,11,7};
//Málaga31 36.7
double[] vTr31={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh31={8.3,12,15.5,18.5,23.2,24.5,26.5,23.2,19,13.6,9.3,8};
double[] vck31={1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45};
double[] vTa31={15,15,17,19,21,25,27,28,26,22,18,15};
//Melilla32 35.3
double[] vTr32={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh32={9.4,12.6,17.2,20.3,23,24.8,24.8,22.6,18.3,14.2,10.9,8.7};
double[] vck32={1.33,1.22,1.09,0.96,0.86,0.82,0.86,0.97,1.13,1.3,1.42,1.41};
double[] vTa32={15,15,16,18,21,25,27,28,26,22,18,16};
//Murcia33 38
double[] vTr33={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh33={10.1,14.8,16.6,20.4,24.2,25.6,27.7,23.5,18.6,13.9,9.8,8.1};
128
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
double[] vck33={1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47};
double[] vTa33={12,12,15,17,21,25,28,28,25,20,16,12};
//Navarra34 42.8
double[] vTr34={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh34={5,7.4,12.3,14.5,17.1,18.9,20.5,18.2,16.2,10.2,6,4.5};
double[] vck34={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa34={7,7,11,13,16,20,22,23,20,15,10,8};
//Orense35 42.3
double[] vTr35={5,7,9,11,12,13,14,13,12,11,9,6};
double[] vh35={4.7,7.3,11.3,14,16.2,17.6,18.3,16.6,14.3,9.4,5.6,4.3};
double[] vck35={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa35={9,9,13,15,18,21,24,23,21,16,12,9};
//Palencia36 42
double[] vTr36={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh36={5.3,9,13.2,17.5,19.7,21.8,24.1,21.6,17.1,10.9,6.6,4.6};
double[] vck36={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa36={5,7,10,13,16,20,23,23,20,14,9,6};
//Las Palmas37 28.2
double[] vTr37={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh37={11.2,14.2,17.8,19.6,21.7,22.5,24.3,21.9,19.8,15.1,12.3,10.7};
double[] vck37={1.23,1.14,1.01,0.89,0.79,0.75,0.79,0.89,1.04,1.2,1.3,1.3};
double[] vTa37={20,20,21,22,23,24,25,25,26,25,23,21};
//Pontevedra38 42.4
double[] vTr38={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh38={5.5,8.2,13,15.7,17.5,20.4,22,18.9,15.1,11.3,6.8,5.5};
double[] vck38={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa38={11,12,14,16,18,20,22,23,20,17,14,12};
//La Rioja 42.5
double[] vTr39={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh39={5.6,8.8,13.7,16.6,19.2,21.4,23.3,20.8,16.2,10.7,6.8,4.8};
double[] vck39={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa39={7,9,12,14,18,21,24,24,21,16,11,8};
//Salamanca40 41
double[] vTr40={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh40={6.1,9.5,13.5,17.1,19.7,22.8,24.6,22.6,17.5,11.3,7.4,5.2};
double[] vck40={1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52};
double[] vTa40={6,7,10,13,16,20,24,23,20,14,9,6};
//Sta.C.Tenerife41 28.5
double[] vTr41={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh41={10.7,13.3,18.1,21.5,25.7,26.5,29.3,26.6,21.2,16.2,10.8,9.3};
double[] vck41={1.23,1.14,1.01,0.89,0.79,0.75,0.79,0.89,1.04,1.2,1.3,1.3};
double[] vTa41={19,20,20,21,22,24,26,27,26,25,23,20};
//Segovia42 41
double[] vTr42={4,5,7,9,10,11,12,11,10,9,7,4};
double[] vh42={5.7,8.8,13.4,18.4,20.4,22.6,25.7,24.9,18.8,11.4,6.8,5.1};
double[] vck42={1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52};
double[] vTa42={4,6,10,12,15,20,24,23,20,14,9,5};
//Sevilla43 37.4
double[] vTr43={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh43={7.3,10.6,14.4,19.2,22.4,24.3,24.9,23,17.9,12.3,8.8,6.9};
double[] vck43={1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45};
double[] vTa43={11,13,14,17,21,25,29,29,24,20,16,12};
//Soria44 41.8
double[] vTr44={4,5,7,9,10,11,12,11,10,9,7,4};
double[] vh44={5.9,8.7,12.8,17.1,19.7,21.8,24.1,22.3,17.5,11.1,7.6,5.6};
double[] vck44={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa44={4,6,9,11,14,19,22,22,18,13,8,5};
//Tarragona45 41.1
129
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
double[] vTr45={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh45={7.3,10.7,14.9,17.6,20.2,22.5,23.8,20.5,16.4,12.3,8.8,6.3};
double[] vck45={1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52};
double[] vTa45={11,12,14,16,19,22,25,26,23,20,15,12};
//Teruel46 40.4
double[] vTr46={4,5,7,9,10,11,12,11,10,9,7,4};
double[] vh46={6.1,8.8,12.9,16.7,18.4,20.6,21.8,20.7,16.9,11,7.1,5.3};
double[] vck46={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5};
double[] vTa46={5,6,9,12,16,20,23,24,19,14,9,6};
//Toledo47 39.9
double[] vTr47={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh47={6.2,9.5,14,19.3,21,24.4,27.2,24.5,18.1,11.9,7.6,5.6};
double[] vck47={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5};
double[] vTa47={7,9,13,15,19,24,28,27,23,17,12,8};
//Valencia48 39.5 39
double[] vTr48={8,9,11,13,14,15,16,15,14,13,11,8};
double[] vh48={7.2,10.6,14.9,18.1,20.6,22.8,23.8,20.7,16.7,12,8.7,6.6};
double[] vck48={1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48};
double[] vTa48={12,13,15,17,20,23,26,27,24,20,16,13};
//Valladolid49 41.7
double[] vTr49={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh49={5.5,8.8,13.9,17.2,19.9,22.6,25.1,23,18.3,11.2,6.9,4.2};
double[] vck49={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa49={4,6,9,12,17,21,24,23,18,13,8,4};
//Vizcaya50 43.3
double[] vTr50={6,7,9,11,12,13,14,13,12,11,9,6};
double[] vh50={5,7.1,10.8,12.7,15.5,16.7,17.9,15.7,13.1,9.3,6,4.6};
double[] vck50={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vTa50={10,11,12,13,16,20,22,22,20,16,13,18};
//Zamora51 41.5
double[] vTr51={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh51={5.4,8.9,13.2,17.3,22.2,21.6,23.5,22,17.2,11.1,6.7,4.6};
double[] vck51={1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52};
double[] vTa51={6,7,11,13,16,21,24,23,20,15,10,6};
//Zaragoza52 41.7
double[] vTr52={5,6,8,10,11,12,13,12,11,10,8,5};
double[] vh52={6.3,9.8,15.2,18.3,21.8,24.2,25.1,23.4,18.3,12.1,7.4,5.7};
double[] vck52={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[] vTa52={8,10,13,16,19,23,26,26,23,17,12,9};
/* //
double[] vTr={};
double[] vh={};
double[] vck={};
double[] vTa={};
if(Nombre.equals("")){vTred=vTr;vH=vh;vCork=vck;vTamb=vTa;}*/
//Inclinacion=45
//Valores de corrección k para distintas inclinaciones
//if(Inclinacion==inclina){vCork=vck;}
/*inclinación 35º--------------------------------------------------------------------------------*/
/*43º*/double[] vcki35_1={1.41,1.31,1.2,1.09,1.01,0.98,1.01,1.1,1.25,1.42,1.52,1.5};
double[] vcki35_5,vcki35_13,vcki35_18,vcki35_23,vcki35_27,vcki35_29,vcki35_34,vcki35_50;
vcki35_5=vcki35_1;vcki35_13=vcki35_1;vcki35_18=vcki35_1;vcki35_23=vcki35_1;
vcki35_27=vcki35_1;vcki35_29=vcki35_1;vcki35_34=vcki35_1;vcki35_50=vcki35_1;
130
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
/*39º*/double[] vcki35_2={1.35,1.27,1.16,1.05,0.97,0.94,0.98,1.06,1.2,1.35,1.45,1.43};
double[] vcki35_7,vcki35_16,vcki35_48;
vcki35_7=vcki35_2;vcki35_16=vcki35_2;vcki35_48=vcki35_2;
/*38º*/double[] vcki35_3={1.34,1.25,1.15,1.04,0.96,0.94,0.97,1.05,1.19,1.34,1.43,1.42};
double[] vcki35_17,vcki35_26,vcki35_33;
vcki35_17=vcki35_3;vcki35_26=vcki35_3;vcki35_33=vcki35_3;
/*37º*/double[] vcki35_4={1.33,1.24,1.14,1.03,0.96,0.93,0.96,1.04,1.17,1.32,1.42,1.41};
double[] vcki35_12,vcki35_21,vcki35_24,vcki35_31,vcki35_43;
vcki35_12=vcki35_4;vcki35_21=vcki35_4;vcki35_24=vcki35_4;vcki35_31=vcki35_4;vcki35_43=vcki35_4;
/*41º*/double[] vcki35_6={1.38,1.29,1.18,1.07,0.99,0.96,0.99,1.08,1.22,1.38,1.49,1.47};
double[] vcki35_9,vcki35_22,vcki35_40,vcki35_42,vcki35_45,vcki35_51;
vcki35_9=vcki35_6;vcki35_22=vcki35_6;vcki35_40=vcki35_6;vcki35_42=vcki35_6;
vcki35_45=vcki35_6;vcki35_51=vcki35_6;
/*40º*/double[] vcki35_8={1.37,1.28,1.17,1.06,0.98,0.95,0.98,1.07,1.21,1.37,1.47,1.45};
double[] vcki35_11,vcki35_14,vcki35_19,vcki35_30,vcki35_46,vcki35_47;
vcki35_11=vcki35_8;vcki35_14=vcki35_8;vcki35_19=vcki35_8;
vcki35_30=vcki35_8;vcki35_46=vcki35_8;vcki35_47=vcki35_8;
/*42º*/double[] vcki35_10={1.39,1.3,1.19,1.08,1,0.97,1,1.09,1.23,1.4,1.51,1.48};
double[] vcki35_28,vcki35_44,vcki35_20,vcki35_25,vcki35_35,vcki35_36,vcki35_38,vcki35_39,vcki35_49,
vcki35_52;
vcki35_28=vcki35_10;vcki35_44=vcki35_10;vcki35_20=vcki35_10;vcki35_25=vcki35_10;
vcki35_35=vcki35_10;vcki35_36=vcki35_10;vcki35_38=vcki35_10;vcki35_39=vcki35_10;
vcki35_49=vcki35_10;vcki35_52=vcki35_10;
/*36º*/double[] vcki35_15={1.32,1.23,1.13,1.02,0.95,0.92,0.95,1.03,1.16,1.31,1.4,1.39};
/*35º*/double[] vcki35_32={1.31,1.22,1.12,1.02,0.94,0.91,0.94,1.02,1.15,1.29,1.39,1.38};
/*28º*/double[] vcki35_37={1.23,1.16,1.06,0.96,0.88,0.85,0.88,0.96,1.08,1.21,1.29,1.29};
double[]vcki35_41=vcki35_37;
/*inclinación 40º--------------------------------------------------------------------------------*/
/*43º*/double[] vcki40_1={1.43,1.33,1.2,1.07,0.98,0.95,0.98,1.09,1.25,1.44,1.56,1.54};
double[] vcki40_5,vcki40_13,vcki40_18,vcki40_23,vcki40_27,vcki40_29,vcki40_34,vcki40_50;
vcki40_5=vcki40_1;vcki40_13=vcki40_1;vcki40_18=vcki40_1;vcki40_23=vcki40_1;
vcki40_27=vcki40_1;vcki40_29=vcki40_1;vcki40_34=vcki40_1;vcki40_50=vcki40_1;
/*39º*/double[] vcki40_2={1.37,1.27,1.15,1.03,0.94,0.91,0.94,1.04,1.19,1.37,1.48,1.46};
double[] vcki40_7,vcki40_16,vcki40_48;
vcki40_7=vcki40_2;vcki40_16=vcki40_2;vcki40_48=vcki40_2;
/*38º*/double[] vcki40_3={1.36,1.26,1.14,1.02,0.93,0.9,0.93,1.03,1.18,1.35,1.46,1.45};
double[] vcki40_17,vcki40_26,vcki40_33;
vcki40_17=vcki40_3;vcki40_26=vcki40_3;vcki40_33=vcki40_3;
/*37º*/double[] vcki40_4={1.35,1.25,1.13,1.01,0.92,0.89,0.92,1.02,1.17,1.34,1.44,1.43};
double[] vcki40_12,vcki40_21,vcki40_24,vcki40_31,vcki40_43;
vcki40_12=vcki40_4;vcki40_21=vcki40_4;vcki40_24=vcki40_4;vcki40_31=vcki40_4;
vcki40_43=vcki40_4;
/*41º*/double[] vcki40_6={1.4,1.3,1.18,1.05,0.96,0.93,0.96,1.06,1.22,1.4,1.52,1.5};
131
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
double[] vcki40_9,vcki40_22,vcki40_40,vcki40_42,vcki40_45,vcki40_51;
vcki40_9=vcki40_6;vcki40_22=vcki40_6;vcki40_40=vcki40_6;vcki40_42=vcki40_6;
vcki40_45=vcki40_6;vcki40_51=vcki40_6;
/*40º*/double[] vcki40_8={1.39,1.29,1.16,1.04,0.95,0.92,0.95,1.05,1.21,1.39,1.5,1.48};
double[] vcki40_11,vcki40_14,vcki40_19,vcki40_30,vcki40_46,vcki40_47;
vcki40_11=vcki40_8;vcki40_14=vcki40_8;vcki40_19=vcki40_8;
vcki40_30=vcki40_8;vcki40_46=vcki40_8;vcki40_47=vcki40_8;
/*42º*/double[] vcki40_10={1.42,1.31,1.19,1.06,0.97,0.94,0.97,1.08,1.24,1.42,1.54,1.52};
double[] vcki40_28,vcki40_44,vcki40_20,vcki40_25,vcki40_35,vcki40_36,vcki40_38,vcki40_39,vcki40_49,
vcki40_52;
vcki40_28=vcki40_10;vcki40_44=vcki40_10;vcki40_20=vcki40_10;vcki40_25=vcki40_10;
vcki40_35=vcki40_10;vcki40_36=vcki40_10;vcki40_38=vcki40_10;vcki40_39=vcki40_10;
vcki40_49=vcki40_10;vcki40_52=vcki40_10;
/*36º*/double[] vcki40_15={1.33,1.24,1.12,1,0.91,0.88,0.91,1.01,1.16,1.32,1.43,1.41};
/*35º*/double[] vcki40_32={1.32,1.23,1.11,0.99,0.9,0.87,0.9,1,1.14,1.3,1.41,1.4};
/*28º*/double[] vcki40_37={1.24,1.15,1.04,0.92,0.85,0.8,0.84,0.93,1.06,1.21,1.3,1.3};
double[]vcki40_41=vcki40_37;
/*Inclinación 45º---------------------------------------------------------------------------*/
/*43º*/double[] vcki45_1={1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57};
double[] vcki45_5,vcki45_13,vcki45_18,vcki45_23,vcki45_27,vcki45_29,vcki45_34,vcki45_50;
vcki45_5=vcki45_1;vcki45_13=vcki45_1;vcki45_18=vcki45_1;vcki45_23=vcki45_1;
vcki45_27=vcki45_1;vcki45_29=vcki45_1;vcki45_34=vcki45_1;vcki45_50=vcki45_1;
/*39º*/double[] vcki45_2={1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48};
double[] vcki45_7,vcki45_16,vcki45_48;
vcki45_7=vcki45_2;vcki45_16=vcki45_2;vcki45_48=vcki45_2;
/*38º*/double[] vcki45_3={1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47};
double[] vcki45_17,vcki45_26,vcki45_33;
vcki45_17=vcki45_3;vcki45_26=vcki45_3;vcki45_33=vcki45_3;
/*37º*/double[] vcki45_4={1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45};
double[] vcki45_12,vcki45_21,vcki45_24,vcki45_31,vcki45_43;
vcki45_12=vcki45_4;vcki45_21=vcki45_4;vcki45_24=vcki45_4;vcki45_31=vcki45_4;vcki45_43=vcki45_4;
/*41º*/double[] vcki45_6={1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52};
double[] vcki45_9,vcki45_22,vcki45_40,vcki45_42,vcki45_45,vcki45_51;
vcki45_9=vcki45_6;vcki45_22=vcki45_6;vcki45_40=vcki45_6;vcki45_42=vcki45_6;
vcki45_45=vcki45_6;vcki45_51=vcki45_6;
/*40º*/double[] vcki45_8={1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5};
double[] vcki45_11,vcki45_14,vcki45_19,vcki45_30,vcki45_46,vcki45_47;
vcki45_11=vcki45_8;vcki45_14=vcki45_8;vcki45_19=vcki45_8;
vcki45_30=vcki45_8;vcki45_46=vcki45_8;vcki45_47=vcki45_8;
/*42º*/double[] vcki45_10={1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54};
double[]
vcki45_28,vcki45_44,vcki45_20,vcki45_25,vcki45_35,vcki45_36,vcki45_38,vcki45_39,vcki45_49,vcki45_52;
vcki45_28=vcki45_10;vcki45_44=vcki45_10;vcki45_20=vcki45_10;vcki45_25=vcki45_10;
vcki45_35=vcki45_10;vcki45_36=vcki45_10;vcki45_38=vcki45_10;vcki45_39=vcki45_10;
vcki45_49=vcki45_10;vcki45_52=vcki45_10;
132
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
/*36º*/double[] vcki45_15={1.34,1.23,1.1,0.97,0.87,0.87,0.84,0.87,0.98,1.14,1.32,1.44,1.43};
/*35º*/double[] vcki45_32={1.33,1.22,1.09,0.96,0.86,0.82,0.86,0.97,1.13,1.3,1.42,1.41};
/*28º*/double[] vcki45_37={1.23,1.14,1.01,0.89,0.79,0.75,0.79,0.89,1.04,1.2,1.3,1.3};
double[]vcki45_41=vcki45_37;
/*Inclinación 50º-----------------------------------------------------------------------------*/
/*43º*/double[] vcki50_1={1.46,1.33,1.17,1.02,0.91,0.87,0.91,1.03,1.23,1.46,1.61,1.58};
double[] vcki50_5,vcki50_13,vcki50_18,vcki50_23,vcki50_27,vcki50_29,vcki50_34,vcki50_50;
vcki50_5=vcki50_1;vcki50_13=vcki50_1;vcki50_18=vcki50_1;vcki50_23=vcki50_1;
vcki50_27=vcki50_1;vcki50_29=vcki50_1;vcki50_34=vcki50_1;vcki50_50=vcki50_1;
/*39º*/double[] vcki50_2={1.39,1.26,1.12,0.97,0.86,0.82,0.86,0.98,1.16,1.37,1.51,1.5};
double[] vcki50_7,vcki50_16,vcki50_48;
vcki50_7=vcki50_2;vcki50_16=vcki50_2;vcki50_48=vcki50_2;
/*38º*/double[] vcki50_3={1.37,1.25,1.1,0.96,0.85,0.81,0.85,0.97,1.15,1.35,1.49,1.48};
double[] vcki50_17,vcki50_26,vcki50_33;
vcki50_17=vcki50_3;vcki50_26=vcki50_3;vcki50_33=vcki50_3;
/*37º*/double[] vcki50_4={1.35,1.24,1.09,0.94,0.84,0.8,0.84,0.95,1.13,1.33,1.47,1.46};
double[] vcki50_12,vcki50_21,vcki50_24,vcki50_31,vcki50_43;
vcki50_12=vcki50_4;vcki50_21=vcki50_4;vcki50_24=vcki50_4;vcki50_31=vcki50_4;
vcki50_43=vcki50_4;
/*41º*/double[] vcki50_6={1.42,1.3,1.14,0.99,0.88,0.84,0.88,1.01,1.19,1.41,1.41,1.56,1.54};
double[] vcki50_9,vcki50_22,vcki50_40,vcki50_42,vcki50_45,vcki50_51;
vcki50_9=vcki50_6;vcki50_22=vcki50_6;vcki50_40=vcki50_6;vcki50_42=vcki50_6;
vcki50_45=vcki50_6;vcki50_51=vcki50_6;
/*40º*/double[] vcki50_8={1.41,1.28,1.13,0.98,0.87,0.83,0.87,0.99,1.18,1.39,1.54,1.52};
double[] vcki50_11,vcki50_14,vcki50_19,vcki50_30,vcki50_46,vcki50_47;
vcki50_11=vcki50_8;vcki50_14=vcki50_8;vcki50_19=vcki50_8;
vcki50_30=vcki50_8;vcki50_46=vcki50_8;vcki50_47=vcki50_8;
/*42º*/double[] vcki50_10={1.44,1.31,1.16,1,0.89,0.86,0.9,1.02,1.21,1.44,1.59,1.56};
double[] vcki50_28,vcki50_44,vcki50_20,vcki50_25,vcki50_35,vcki50_36,vcki50_38,vcki50_39,vcki50_49,
vcki50_52;
vcki50_28=vcki50_10;vcki50_44=vcki50_10;vcki50_20=vcki50_10;vcki50_25=vcki50_10;
vcki50_35=vcki50_10;vcki50_36=vcki50_10;vcki50_38=vcki50_10;vcki50_39=vcki50_10;
vcki50_49=vcki50_10;vcki50_52=vcki50_10;
/*36º*/double[] vcki50_15={1.34,1.22,1.08,0.93,0.82,0.78,0.82,0.94,1.12,1.31,1.45,1.44};
/*35º*/double[] vcki50_32={1.32,1.21,1.07,0.92,0.81,0.77,0.81,0.93,1.1,1.3,1.43,1.42};
/*28º*/double[] vcki50_37={1.22,1.12,0.98,0.73,0.69,0.73,0.84,1,1.18,1.3,1.3};
double[]vcki50_41=vcki50_37;
/*inclinación 55º--------------------------------------------------------------------------------*/
/*43º*/double[] vcki55_1={1.46,1.32,1.15,0.98,0.86,0.82,0.86,1,1.21,1.45,1.62,1.59};
double[] vcki55_5,vcki55_13,vcki55_18,vcki55_23,vcki55_27,vcki55_29,vcki55_34,vcki55_50;
vcki55_5=vcki55_1;vcki55_13=vcki55_1;vcki55_18=vcki55_1;vcki55_23=vcki55_1;
vcki55_27=vcki55_1;vcki55_29=vcki55_1;vcki55_34=vcki55_1;vcki55_50=vcki55_1;
133
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
/*39º*/double[] vcki55_2={1.38,1.25,1.09,0.93,0.81,0.77,0.81,0.94,1.13,1.36,1.51,1.5};
double[] vcki55_7,vcki55_16,vcki55_48;
vcki55_7=vcki55_2;vcki55_16=vcki55_2;vcki55_48=vcki55_2;
/*38º*/double[] vcki55_3={1.36,1.23,1.07,0.91,0.8,0.75,0.8,0.92,1.12,1.34,1.49,1.48};
double[] vcki55_17,vcki55_26,vcki55_33;
vcki55_17=vcki55_3;vcki55_26=vcki55_3;vcki55_33=vcki55_3;
/*37º*/double[] vcki55_4={1.35,1.22,1.06,0.9,0.78,0.74,0.78,0.91,1.1,1.32,1.47,1.45};
double[] vcki55_12,vcki55_21,vcki55_24,vcki55_31,vcki55_43;
vcki55_12=vcki55_4;vcki55_21=vcki55_4;vcki55_24=vcki55_4;vcki55_31=vcki55_4;
vcki55_43=vcki55_4;
/*41º*/double[] vcki55_6={1.42,1.28,1.12,0.95,0.83,0.79,0.84,0.97,1.17,1.41,1.57,1.54};
double[] vcki55_9,vcki55_22,vcki55_40,vcki55_42,vcki55_45,vcki55_51;
vcki55_9=vcki55_6;vcki55_22=vcki55_6;vcki55_40=vcki55_6;vcki55_42=vcki55_6;
vcki55_45=vcki55_6;vcki55_51=vcki55_6;
/*40º*/double[] vcki55_8={1.4,1.27,1.1,0.94,0.82,0.78,0.82,0.95,1.15,1.38,1.54,1.52};
double[] vcki55_11,vcki55_14,vcki55_19,vcki55_30,vcki55_46,vcki55_47;
vcki55_11=vcki55_8;vcki55_14=vcki55_8;vcki55_19=vcki55_8;
vcki55_30=vcki55_8;vcki55_46=vcki55_8;vcki55_47=vcki55_8;
/*42º*/double[] vcki55_10={1.44,1.3,1.13,0.97,0.85,0.8,0.85,0.98,1.19,1.43,1.59,1.57};
double[] vcki55_28,vcki55_44,vcki55_20,vcki55_25,vcki55_35,vcki55_36,vcki55_38,vcki55_39,
vcki55_49,vcki55_52;
vcki55_28=vcki55_10;vcki55_44=vcki55_10;vcki55_20=vcki55_10;vcki55_25=vcki55_10;
vcki55_35=vcki55_10;vcki55_36=vcki55_10;vcki55_38=vcki55_10;vcki55_39=vcki55_10;
vcki55_49=vcki55_10;vcki55_52=vcki55_10;
/*36º*/double[] vcki55_15={1.33,1.2,1.05,0.89,0.77,0.73,0.77,0.9,1.08,1.3,1.44,1.43};
/*35º*/double[] vcki55_32={1.31,1.19,1.03,0.87,0.76,0.72,0.76,0.88,1.07,1.28,1.42,1.41};
/*28º*/double[] vcki55_37={1.2,1.09,0.94,0.79,0.68,0.63,0.67,0.79,0.96,1.15,1.28,1.28};
double[]vcki55_41=vcki55_37;
/*inclinación 60º--------------------------------------------------------------------------------*/
/*43º*/double[] vcki60_1={1.45,1.3,1.12,0.94,0.81,0.76,0.81,0.95,1.17,1.44,1.62,1.59};
double[] vcki60_5,vcki60_13,vcki60_18,vcki60_23,vcki60_27,vcki60_29,vcki60_34,vcki60_50;
vcki60_5=vcki60_1;vcki60_13=vcki60_1;vcki60_18=vcki60_1;vcki60_23=vcki60_1;
vcki60_27=vcki60_1;vcki60_29=vcki60_1;vcki60_34=vcki60_1;vcki60_50=vcki60_1;
/*39º*/double[] vcki60_2={1.37,1.22,1.05,0.88,0.75,0.71,0.75,0.89,1.1,1.34,1.51,1.49};
double[] vcki60_7,vcki60_16,vcki60_48;
vcki60_7=vcki60_2;vcki60_16=vcki60_2;vcki60_48=vcki60_2;
/*38º*/double[] vcki60_3={1.35,1.21,1.04,0.86,0.74,0.69,0.74,0.87,1.08,1.32,1.48,1.47};
double[] vcki60_17,vcki60_26,vcki60_33;
vcki60_17=vcki60_3;vcki60_26=vcki60_3;vcki60_33=vcki60_3;
/*37º*/double[] vcki60_4={1.33,1.19,1.02,0.85,0.73,0.68,0.73,0.86,1.06,1.3,1.45,1.44};
double[] vcki60_12,vcki60_21,vcki60_24,vcki60_31,vcki60_43;
vcki60_12=vcki60_4;vcki60_21=vcki60_4;vcki60_24=vcki60_4;vcki60_31=vcki60_4;vcki60_43=vcki60_4;
/*41º*/double[] vcki60_6={1.41,1.26,1.08,0.91,0.78,0.73,0.78,0.92,1.14,1.39,1.56,1.54};
double[] vcki60_9,vcki60_22,vcki60_40,vcki60_42,vcki60_45,vcki60_51;
134
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
vcki60_9=vcki60_6;vcki60_22=vcki60_6;vcki60_40=vcki60_6;vcki60_42=vcki60_6;
vcki60_45=vcki60_6;vcki60_51=vcki60_6;
/*40º*/double[] vcki60_8={1.39,1.24,1.07,0.89,0.77,0.72,0.77,0.9,1.12,1.36,1.53,1.51};
double[] vcki60_11,vcki60_14,vcki60_19,vcki60_30,vcki60_46,vcki60_47;
vcki60_11=vcki60_8;vcki60_14=vcki60_8;vcki60_19=vcki60_8;
vcki60_30=vcki60_8;vcki60_46=vcki60_8;vcki60_47=vcki60_8;
/*42º*/double[] vcki60_10={1.43,1.28,1.1,0.92,0.79,0.75,0.8,0.93,1.15,1.41,1.59,1.57};
double[]
vcki60_28,vcki60_44,vcki60_20,vcki60_25,vcki60_35,vcki60_36,vcki60_38,vcki60_39,vcki60_49,vcki60_52;
vcki60_28=vcki60_10;vcki60_44=vcki60_10;vcki60_20=vcki60_10;vcki60_25=vcki60_10;
vcki60_35=vcki60_10;vcki60_36=vcki60_10;vcki60_38=vcki60_10;vcki60_39=vcki60_10;
vcki60_49=vcki60_10;vcki60_52=vcki60_10;
/*36º*/double[] vcki60_15={1.31,1.17,1.01,0.84,0.71,0.67,0.71,0.84,1.05,1.27,1.43,1.42};
/*35º*/double[] vcki60_32={1.29,1.16,0.99,0.82,0.7,0.66,0.7,0.83,1.03,1.25,1.41,1.4};
/*28º*/double[] vcki60_37={1.18,1.05,0.9,0.73,0.61,0.57,0.61,0.73,0.92,1.12,1.26,1.26};
double[]vcki60_41=vcki60_37;
/*-------------------------------------------------------------------------------------------------*/
//Vector de vectores, cada uno corresponde a un lugar
double[] vck[]={vck1,vck2,vck3,vck4,vck5,vck6,vck7,vck8,vck9,vck10,
vck11,vck12,vck13,vck14,vck15,vck16,vck17,vck18,vck19,vck20,
vck21,vck22,vck23,vck24,vck25,vck26,vck27,vck28,vck29,vck30,
vck31,vck32,vck33,vck34,vck35,vck36,vck37,vck38,vck39,vck40,
vck41,vck42,vck43,vck44,vck45,vck46,vck47,vck48,vck49,vck50,vck51,vck52};
//Vector de vectores para inclinación de 35º
double[] v35[]={vcki35_1,vcki35_2,vcki35_3,vcki35_4,vcki35_5,vcki35_6,vcki35_7,vcki35_8,vcki35_9,
vcki35_10,vcki35_11,vcki35_12,vcki35_13,vcki35_14,vcki35_15,vcki35_16,vcki35_17,vcki35_18,
vcki35_19,vcki35_20,vcki35_21,vcki35_22,vcki35_23,vcki35_24,vcki35_25,vcki35_26,vcki35_27,
vcki35_28,vcki35_29,vcki35_30,vcki35_31,vcki35_32,vcki35_33,vcki35_34,vcki35_35,vcki35_36,
vcki35_37,vcki35_38,vcki35_39,vcki35_40,vcki35_41,vcki35_42,vcki35_43,vcki35_44,vcki35_45,
vcki35_46,vcki35_47,vcki35_48,vcki35_49,vcki35_50,vcki35_51,vcki35_52};
//Vector de vectores para inclinación de 40º
double[] v40[]={vcki40_1,vcki40_2,vcki40_3,vcki40_4,vcki40_5,vcki40_6,vcki40_7,vcki40_8,vcki40_9,
vcki40_10,vcki40_11,vcki40_12,vcki40_13,vcki40_14,vcki40_15,vcki40_16,vcki40_17,vcki40_18,
vcki40_19,vcki40_20,vcki40_21,vcki40_22,vcki40_23,vcki40_24,vcki40_25,vcki40_26,vcki40_27,
vcki40_28,vcki40_29,vcki40_30,vcki40_31,vcki40_32,vcki40_33,vcki40_34,vcki40_35,vcki40_36,
vcki40_37,vcki40_38,vcki40_39,vcki40_40,vcki40_41,vcki40_42,vcki40_43,vcki40_44,vcki40_45,
vcki40_46,vcki40_47,vcki40_48,vcki40_49,vcki40_50,vcki40_51,vcki40_52};
//Vector de vectores para inclinación de 45º
double[] v45[]={vcki45_1,vcki45_2,vcki45_3,vcki45_4,vcki45_5,vcki45_6,vcki45_7,vcki45_8,vcki45_9,
vcki45_10,vcki45_11,vcki45_12,vcki45_13,vcki45_14,vcki45_15,vcki45_16,vcki45_17,vcki45_18,
vcki45_19,vcki45_20,vcki45_21,vcki45_22,vcki45_23,vcki45_24,vcki45_25,vcki45_26,vcki45_27,
vcki45_28,vcki45_29,vcki45_30,vcki45_31,vcki45_32,vcki45_33,vcki45_34,vcki45_35,vcki45_36,
vcki45_37,vcki45_38,vcki45_39,vcki45_40,vcki45_41,vcki45_42,vcki45_43,vcki45_44,vcki45_45,
vcki45_46,vcki45_47,vcki45_48,vcki45_49,vcki45_50,vcki45_51,vcki45_52};
135
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
//Vector de vectores para inclinación de 50º
double[] v50[]={vcki50_1,vcki50_2,vcki50_3,vcki50_4,vcki50_5,vcki50_6,vcki50_7,vcki50_8,vcki50_9,
vcki50_10,vcki50_11,vcki50_12,vcki50_13,vcki50_14,vcki50_15,vcki50_16,vcki50_17,vcki50_18,
vcki50_19,vcki50_20,vcki50_21,vcki50_22,vcki50_23,vcki50_24,vcki50_25,vcki50_26,vcki50_27,
vcki50_28,vcki50_29,vcki50_30,vcki50_31,vcki50_32,vcki50_33,vcki50_34,vcki50_35,vcki50_36,
vcki50_37,vcki50_38,vcki50_39,vcki50_40,vcki50_41,vcki50_42,vcki50_43,vcki50_44,vcki50_45,
vcki50_46,vcki50_47,vcki50_48,vcki50_49,vcki50_50,vcki50_51,vcki50_52};
//Vector de vectores para inclinación de 55º
double[] v55[]={vcki55_1,vcki55_2,vcki55_3,vcki55_4,vcki55_5,vcki55_6,vcki55_7,vcki55_8,vcki55_9,
vcki55_10,vcki55_11,vcki55_12,vcki55_13,vcki55_14,vcki55_15,vcki55_16,vcki55_17,vcki55_18,
vcki55_19,vcki55_20,vcki55_21,vcki55_22,vcki55_23,vcki55_24,vcki55_25,vcki55_26,vcki55_27,
vcki55_28,vcki55_29,vcki55_30,vcki55_31,vcki55_32,vcki55_33,vcki55_34,vcki55_35,vcki55_36,
vcki55_37,vcki55_38,vcki55_39,vcki55_40,vcki55_41,vcki55_42,vcki55_43,vcki55_44,vcki55_45,
vcki55_46,vcki55_47,vcki55_48,vcki55_49,vcki55_50,vcki55_51,vcki55_52};
//Vector de vectores para inclinación de 60º
double[] v60[]={vcki60_1,vcki60_2,vcki60_3,vcki60_4,vcki60_5,vcki60_6,vcki60_7,vcki60_8,vcki60_9,
vcki60_10,vcki60_11,vcki60_12,vcki60_13,vcki60_14,vcki60_15,vcki60_16,vcki60_17,vcki60_18,
vcki60_19,vcki60_20,vcki60_21,vcki60_22,vcki60_23,vcki60_24,vcki60_25,vcki60_26,vcki60_27,
vcki60_28,vcki60_29,vcki60_30,vcki60_31,vcki60_32,vcki60_33,vcki60_34,vcki60_35,vcki60_36,
vcki60_37,vcki60_38,vcki60_39,vcki60_40,vcki60_41,vcki60_42,vcki60_43,vcki60_44,vcki60_45,
vcki60_46,vcki60_47,vcki60_48,vcki60_49,vcki60_50,vcki60_51,vcki60_52};
/*Inclinacion=inclina;
if(Inclinacion==40){for(int i=0;i<52;i++){vck[i]=v40[i];}}
if(Inclinacion==45){for(int i=0;i<52;i++){vck[i]=v45[i];}}
if(Inclinacion==50){for(int i=0;i<52;i++){vck[i]=v50[i];}}*/
if(inclina==35){System.arraycopy(v35, 0, vck, 0, 52);}
if(inclina==40){System.arraycopy(v40, 0, vck, 0, 52);}
if(inclina==45){System.arraycopy(v45, 0, vck, 0, 52);}
if(inclina==50){System.arraycopy(v50, 0, vck, 0, 52);}
if(inclina==55){System.arraycopy(v55, 0, vck, 0, 52);}
if(inclina==60){System.arraycopy(v60, 0, vck, 0, 52);}
double[] vTr[]={vTr1,vTr2,vTr3,vTr4,vTr5,vTr6,vTr7,vTr8,vTr9,vTr10,
vTr11,vTr12,vTr13,vTr14,vTr15,vTr16,vTr17,vTr18,vTr19,vTr20,
vTr21,vTr22,vTr23,vTr24,vTr25,vTr26,vTr27,vTr28,vTr29,vTr30,
vTr31,vTr32,vTr33,vTr34,vTr35,vTr36,vTr37,vTr38,vTr39,vTr40,
vTr41,vTr42,vTr43,vTr44,vTr45,vTr46,vTr47,vTr48,vTr49,vTr50,vTr51,vTr52};
double[] vh[]={vh1,vh2,vh3,vh4,vh5,vh6,vh7,vh8,vh9,vh10,
vh11,vh12,vh13,vh14,vh15,vh16,vh17,vh18,vh19,vh20,
vh21,vh22,vh23,vh24,vh25,vh26,vh27,vh28,vh29,vh30,
vh31,vh32,vh33,vh34,vh35,vh36,vh37,vh38,vh39,vh40,
vh41,vh42,vh43,vh44,vh45,vh46,vh47,vh48,vh49,vh50,vh51,vh52};
double[] vTa[]={vTa1,vTa2,vTa3,vTa4,vTa5,vTa6,vTa7,vTa8,vTa9,vTa10,
vTa11,vTa12,vTa13,vTa14,vTa15,vTa16,vTa17,vTa18,vTa19,vTa20,
vTa21,vTa22,vTa23,vTa24,vTa25,vTa26,vTa27,vTa28,vTa29,vTa30,
vTa31,vTa32,vTa33,vTa34,vTa35,vTa36,vTa37,vTa38,vTa39,vTa40,
vTa41,vTa42,vTa43,vTa44,vTa45,vTa46,vTa47,vTa48,vTa49,vTa50,vTa51,vTa52};
String provincia[]={"Álava","Albacete","Alicante","Almería","Asturias","Ávila","Badajoz","Baleares"
,"Barcelona","Burgos","Cáceres","Cádiz","Cantabria","Castellón","Ceuta","Ciudad Real","Córdoba"
,"La Coruña","Cuenca","Gerona","Granada","Guadalajara","Guipúzcoa","Huelva","Huesca","Jaén"
,"León","Lérida","Lugo","Madrid","Málaga","Melilla","Murcia","Navarra","Orense","Palencia"
136
APÉNDICE II. CÓDIGOS. JAVA. LocalizacionACS.java
,"Las Palmas","Pontevedra","La Rioja","Salamanca","Tenerife","Segovia","Sevilla","Soria"
,"Tarragona","Teruel","Toledo","Valencia","Valladolid","Vizcaya","Zamora","Zaragoza"};
if(sitio.equals("")){
for(int i=0;i<52;i++){if (Nombre.equals(provincia[i])){
vTred=vTr[i];vH=vh[i];vCork=vck[i];vTamb=vTa[i];}}}
else{{
for(int i=0;i<52;i++){if (Nombre.equals(provincia[i])){
vCork_MasMenos=vck[i];}}
}
}
}
public void BuscaDatosLatitud(){
String provincia[]={"Álava","Albacete","Alicante","Almería","Asturias","Ávila","Badajoz","Baleares"
,"Barcelona","Burgos","Cáceres","Cádiz","Cantabria","Castellón","Ceuta","Ciudad Real","Córdoba"
,"La Coruña","Cuenca","Gerona","Granada","Guadalajara","Guipúzcoa","Huelva","Huesca","Jaén"
,"León","Lérida","Lugo","Madrid","Málaga","Melilla","Murcia","Navarra","Orense","Palencia"
,"Las Palmas","Pontevedra","La Rioja","Salamanca","Tenerife","Segovia","Sevilla","Soria"
,"Tarragona","Teruel","Toledo","Valencia","Valladolid","Vizcaya","Zamora","Zaragoza"};
double altitud[]={542,686,7,65,232,1126,186,28,95,929,459,28,69,27,206,628,128,54,949,
95,775,685,181,4,488,586,908,323,465,667,40,47,42,449,139,734,6,19,
380,803,37,1002,30,1063,60,915,540,10,694,32,649,200};
double latitud[]={42.9,39,38.4,36.9,43.4,40.7,38.9,39.6,41.4,42.3,39.5,36.5,43.5,40,
35.9,39,37.9,43.4,40.1,42,37.2,40.6,43.3,37.3,42.1,37.8,42.6,41.7,
43,40.4,36.7,35.3,38,42.8,42.3,42,28.2,42.4,42.5,41,28.5,41,37.4,
41.8,41.1,40.4,39.9,39.5,41.7,43.3,41.5,41.7};
double TempMinHis[]={-18,-23,-5,-1,-11,-21,-6,-4,-20,-18,-6,-2,-4,-8,-1,-10,-6,-9,-21,
-11,-13,-14,-12,-6,-14,-8,-18,-11,-8,-16,-4,-1,-5,-16,-8,-14,+6,
-4,-12,-16,+3,-17,-6,-16,-7,-14,-9,-8,-16,-8,-14,-11};
for(int i=0;i<52;i++){if (Nombre.equals(provincia[i])){
Altitud=altitud[i];
Latitud=latitud[i];
TempMinHistorica=TempMinHis[i];}}
}
}
137
APÉNDICE II. CÓDIGOS. JAVA. HistogramaACS.java
1.3. Clase HistogramaACS.java
package paquete;
/**
*
* @author Eduardo
*/
import graficos.clasesgraficas.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
public class HistogramaACS {
//variables globales
JPanel panelg;//Lienzo lienzo ;
double[] valores;
Color[] colores;
//constructor
public HistogramaACS(){
panelg=new JPanel();
valores=new double[12];
colores=new Color[12];
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Métodos de la clase HistogramaACS
public void Dibuja_Histograma(double[] val,Color[] col, JPanel pan){
// El lienzo
JPanel panel=new JPanel();
panel.setSize(330,310);
Lienzo lienzo = new Lienzo();
lienzo.setPreferredSize(new Dimension(330,300));
lienzo.setBackground(Color.white);
// Una escala grafica
InterfaceEscalaGrafica escala = new EscalaGraficaCartesiana();
escala.tomaExtremos (0, 0, 12, 11);
lienzo.tomaEscala (escala);
VisorRaton visorX = new VisorRaton (VisorRaton.VISOR_X);
visorX.setColumns(20);
VisorRaton visorY = new VisorRaton (VisorRaton.VISOR_Y);
visorY.setColumns(20);
lienzo.anhadeObservadorRaton(visorX);
138
APÉNDICE II. CÓDIGOS. JAVA. HistogramaACS.java
lienzo.anhadeObservadorRaton(visorY);
panel.setLayout(new BorderLayout());
panel.add (lienzo, BorderLayout.CENTER);
pan.setLayout(new BorderLayout());
pan.add (panel, BorderLayout.CENTER);
// El histograma
/**/
Histograma histograma = new Histograma (val, col);
lienzo.tomaObjetoGrafico(histograma);
// La escala grafica para inicializar el lienzo.
escala.tomaExtremos (0.0, 0.0, 12,105);
lienzo.tomaEscala (escala);
// Un editor de coordenada x
VisorRaton visor = new VisorRaton(VisorRaton.VISOR_X);
visor.setColumns(20);
lienzo.anhadeObservadorRaton(visor);
// Una rejilla para el Lienzo
RejillaFija rejilla = new RejillaFija (21,0);
lienzo.tomaObjetoGrafico(rejilla);
//para que lo muestre al pulsar un botón
panel.validate();
}
public void Dibuja_Histograma2(double[] val1,double[] val2,Color[] col1,Color[] col2, JPanel pan){
// El lienzo
JPanel panel=new JPanel();
panel.setSize(330,310);
Lienzo lienzo = new Lienzo();
lienzo.setPreferredSize(new Dimension(330,300));
lienzo.setBackground(Color.white);
// Una escala grafica
InterfaceEscalaGrafica escala = new EscalaGraficaCartesiana();
escala.tomaExtremos (0, 0, 12, 11);
lienzo.tomaEscala (escala);
VisorRaton visorX = new VisorRaton (VisorRaton.VISOR_X);
visorX.setColumns(20);
VisorRaton visorY = new VisorRaton (VisorRaton.VISOR_Y);
visorY.setColumns(20);
139
APÉNDICE II. CÓDIGOS. JAVA. HistogramaACS.java
lienzo.anhadeObservadorRaton(visorX);
lienzo.anhadeObservadorRaton(visorY);
// Se añade todo en el panel que queramos
panel.setLayout(new BorderLayout());
panel.add (lienzo, BorderLayout.CENTER);
pan.setLayout(new BorderLayout());
pan.add (panel, BorderLayout.CENTER);
// El histograma
/**/
Histograma histograma1 = new Histograma (val1, col1);
lienzo.tomaObjetoGrafico(histograma1);
Histograma histograma2 = new Histograma (val2, col2);
lienzo.tomaObjetoGrafico(histograma2);
// La escala grafica para inicializar el lienzo.
escala.tomaExtremos (0.0, 0.0, 12,105);
lienzo.tomaEscala (escala);
// Un editor de coordenada x
VisorRaton visor = new VisorRaton(VisorRaton.VISOR_X);
visor.setColumns(20);
lienzo.anhadeObservadorRaton(visor);
// Una rejilla para el Lienzo
RejillaFija rejilla = new RejillaFija (21,0);
lienzo.tomaObjetoGrafico(rejilla);
//para que lo muestre al pulsar un botón
panel.validate();
}
public void Dibuja_Histograma3(double[] val1,Color[] col, JPanel pan){
// El lienzo
JPanel panel=new JPanel();
panel.setSize(330,310);
Lienzo lienzo = new Lienzo();
lienzo.setPreferredSize(new Dimension(330,300));
lienzo.setBackground(Color.white);
// Una escala grafica
InterfaceEscalaGrafica escala = new EscalaGraficaCartesiana();
escala.tomaExtremos (0, 0, 24, 11);
lienzo.tomaEscala (escala);
VisorRaton visorX = new VisorRaton (VisorRaton.VISOR_X);
visorX.setColumns(20);
VisorRaton visorY = new VisorRaton (VisorRaton.VISOR_Y);
visorY.setColumns(20);
lienzo.anhadeObservadorRaton(visorX);
140
APÉNDICE II. CÓDIGOS. JAVA. HistogramaACS.java
lienzo.anhadeObservadorRaton(visorY);
// Se añade todo en el panel que queramos
panel.setLayout(new BorderLayout());
panel.add (lienzo, BorderLayout.CENTER);
pan.setLayout(new BorderLayout());
pan.add (panel, BorderLayout.CENTER);
// El histograma
/**/
Histograma histograma1 = new Histograma (val1, col);
lienzo.tomaObjetoGrafico(histograma1);
// La escala grafica para inicializar el lienzo.
escala.tomaExtremos (0.0, 0.0, 12,105);
lienzo.tomaEscala (escala);
// Un editor de coordenada x
VisorRaton visor = new VisorRaton(VisorRaton.VISOR_X);
visor.setColumns(20);
lienzo.anhadeObservadorRaton(visor);
// Una rejilla para el Lienzo
RejillaFija rejilla = new RejillaFija (21,0);
lienzo.tomaObjetoGrafico(rejilla);
//para que lo muestre al pulsar un botón
panel.validate();
}
public void Dibuja_Histograma2_escalado(double referencia,double[] val1,double[] val2,Color[] col1,Color[]
col2, JPanel pan){
// El lienzo
JPanel panel=new JPanel();
panel.setSize(330,310);
Lienzo lienzo = new Lienzo();
lienzo.setPreferredSize(new Dimension(330,300));
lienzo.setBackground(Color.white);
// Una escala grafica
InterfaceEscalaGrafica escala = new EscalaGraficaCartesiana();
escala.tomaExtremos (0, 0, 12, 11);
lienzo.tomaEscala (escala);
VisorRaton visorX = new VisorRaton (VisorRaton.VISOR_X);
visorX.setColumns(20);
VisorRaton visorY = new VisorRaton (VisorRaton.VISOR_Y);
visorY.setColumns(20);
lienzo.anhadeObservadorRaton(visorX);
lienzo.anhadeObservadorRaton(visorY);
// Se añade todo en el panel que queramos
panel.setLayout(new BorderLayout());
panel.add (lienzo, BorderLayout.CENTER);
141
APÉNDICE II. CÓDIGOS. JAVA. HistogramaACS.java
pan.setLayout(new BorderLayout());
pan.add (panel, BorderLayout.CENTER);
// El histograma
/**/
Histograma histograma1 = new Histograma (val1, col1);
lienzo.tomaObjetoGrafico(histograma1);
Histograma histograma2 = new Histograma (val2, col2);
lienzo.tomaObjetoGrafico(histograma2);
// La escala grafica para inicializar el lienzo.
double extremoymaximo=referencia*1.05;
escala.tomaExtremos (0.0, 0.0, 12,extremoymaximo);
lienzo.tomaEscala (escala);
// Un editor de coordenada x
VisorRaton visor = new VisorRaton(VisorRaton.VISOR_X);
visor.setColumns(20);
lienzo.anhadeObservadorRaton(visor);
// Una rejilla para el Lienzo
RejillaFija rejilla = new RejillaFija (21,0);
lienzo.tomaObjetoGrafico(rejilla);
//para que lo muestre al pulsar un botón
panel.validate();
}
public void Dibuja_Histograma3_escalado(double referencia,double[] val1,Color[] col, JPanel pan){
// El lienzo
JPanel panel=new JPanel();
panel.setSize(330,310);
Lienzo lienzo = new Lienzo();
lienzo.setPreferredSize(new Dimension(330,300));
lienzo.setBackground(Color.white);
// Una escala grafica
InterfaceEscalaGrafica escala = new EscalaGraficaCartesiana();
escala.tomaExtremos (0, 0, 24, 11);
lienzo.tomaEscala (escala);
VisorRaton visorX = new VisorRaton (VisorRaton.VISOR_X);
visorX.setColumns(20);
VisorRaton visorY = new VisorRaton (VisorRaton.VISOR_Y);
visorY.setColumns(20);
lienzo.anhadeObservadorRaton(visorX);
lienzo.anhadeObservadorRaton(visorY);
// Se añade todo en el panel que queramos
142
APÉNDICE II. CÓDIGOS. JAVA. HistogramaACS.java
panel.setLayout(new BorderLayout());
panel.add (lienzo, BorderLayout.CENTER);
pan.setLayout(new BorderLayout());
pan.add (panel, BorderLayout.CENTER);
// El histograma
/**/
Histograma histograma1 = new Histograma (val1, col);
lienzo.tomaObjetoGrafico(histograma1);
// La escala grafica para inicializar el lienzo.
double extremoymaximo=referencia*1.05;
escala.tomaExtremos (0.0, 0.0, 12,extremoymaximo);
lienzo.tomaEscala (escala);
// Un editor de coordenada x
VisorRaton visor = new VisorRaton(VisorRaton.VISOR_X);
visor.setColumns(20);
lienzo.anhadeObservadorRaton(visor);
// Una rejilla para el Lienzo
RejillaFija rejilla = new RejillaFija (21,0);
lienzo.tomaObjetoGrafico(rejilla);
//para que lo muestre al pulsar un botón
panel.validate();
}
}
143
APÉNDICE II. CÓDIGOS. JAVA. Grafica_fchart_ACS.java
1.4. Clase Grafica_fchart_ACS.java
package paquete;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import graficos.clasesgraficas.*;
/**
*
* @author Eduardo
*/
public class Grafica_fchart_ACS {
JPanel panelg;
Color col;
public Grafica_fchart_ACS(){
panelg=new JPanel();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Métodos de la clase Grafica_fchart_ACS
public void Dibuja_grafica_fchart(double mini,double maxi, double[] valores,double[] valores2,Color
col,Color col2,JPanel pan){
// El lienzo
JPanel panel=new JPanel();
panel.setSize(330,310);
Lienzo lienzo = new Lienzo();
lienzo.setPreferredSize(new Dimension(300,300));
lienzo.setBackground(Color.WHITE);
// Una escala grafica
InterfaceEscalaGrafica escala = new EscalaGraficaCartesiana();
escala.tomaExtremos (0, 0, 12, 2);
lienzo.tomaEscala (escala);
// La botoneria de zoom
BotoneriaZoom zoom = new BotoneriaZoom (escala);
// VisorRaton visorX = new VisorRaton (VisorRaton.VISOR_X);
// visorX.setColumns(20);
VisorRaton visorY = new VisorRaton (VisorRaton.VISOR_Y);
visorY.setColumns(20);
// zoom.add (visorX);
zoom.add (visorY);
// lienzo.anhadeObservadorRaton(visorX);
lienzo.anhadeObservadorRaton(visorY);
// Se añade todo en el applet
144
APÉNDICE II. CÓDIGOS. JAVA. Grafica_fchart_ACS.java
panel.setLayout(new BorderLayout());
panel.add (lienzo, BorderLayout.CENTER);
panel.add(zoom, BorderLayout.SOUTH);
pan.setLayout(new BorderLayout());
pan.add (panel, BorderLayout.CENTER);
GraficoFuncionPorPuntos grafi=new GraficoFuncionPorPuntos(mini,maxi,valores);//grafica linea
grafi.setColor(col);
lienzo.tomaObjetoGrafico(grafi);
GraficoFuncionPorPuntos grafi2=new GraficoFuncionPorPuntos(mini,maxi,valores2);//grafica linea
grafi2.setColor(col2);
lienzo.tomaObjetoGrafico(grafi2);
// La escala grafica para inicializar el lienzo.
escala.tomaExtremos (0.0, 0.0, 12,1.1);
lienzo.tomaEscala (escala);
// Una rejill para el Lienzo
RejillaFija rejilla = new RejillaFija (11,12);
rejilla.tomaColores(Color.BLACK, Color.BLUE);
lienzo.tomaObjetoGrafico(rejilla);
//para que lo muestre al pulsar un botón
panel.validate();
pan.validate();
}
public void Dibuja_grafica_linea(double mini,double maxi, double[] valores,Color col,JPanel pan){
// El lienzo
JPanel panel=new JPanel();
panel.setSize(330,310);
Lienzo lienzo = new Lienzo();
lienzo.setPreferredSize(new Dimension(300,300));
lienzo.setBackground(Color.WHITE);
// Una escala grafica
InterfaceEscalaGrafica escala = new EscalaGraficaCartesiana();
escala.tomaExtremos (0, 0, 12, 2);
lienzo.tomaEscala (escala);
// La botoneria de zoom
BotoneriaZoom zoom = new BotoneriaZoom (escala);
VisorRaton visorY = new VisorRaton (VisorRaton.VISOR_Y);
visorY.setColumns(20);
// zoom.add (visorX);
zoom.add (visorY);
// lienzo.anhadeObservadorRaton(visorX);
lienzo.anhadeObservadorRaton(visorY);
// Se añade todo en el applet
panel.setLayout(new BorderLayout());
panel.add (lienzo, BorderLayout.CENTER);
panel.add(zoom, BorderLayout.SOUTH);
pan.setLayout(new BorderLayout());
pan.add (panel, BorderLayout.CENTER);
145
APÉNDICE II. CÓDIGOS. JAVA. Grafica_fchart_ACS.java
GraficoFuncionPorPuntos grafi=new GraficoFuncionPorPuntos(mini,maxi,valores);//grafica linea
grafi.setColor(col);
lienzo.tomaObjetoGrafico(grafi);
// La escala grafica para inicializar el lienzo.
escala.tomaExtremos (0.0, 0.0, 12,1.1);
lienzo.tomaEscala (escala);
// Una rejill para el Lienzo
RejillaFija rejilla = new RejillaFija (11,12);
rejilla.tomaColores(Color.BLACK, Color.BLUE);
lienzo.tomaObjetoGrafico(rejilla);
//para que lo muestre al pulsar un botón
panel.validate();
pan.validate();
}
}
146
APÉNDICE. CÓDIGOS. JAVA. Grafica_JFC.java
1.5. Clase Grafica_JFC.java
package paquete;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
/**
*
* @author Eduardo
*/
public class Grafica_JFC {
//declara variables "double valores[];"
public Grafica_JFC(){
//inicia variables "valores = new double[12];"
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//métodos public void.....pe
public void Dibuja_Barras_JFree(double[] datosYorigen,JPanel pan,JLabel eti,
String tituloGrafica,String nombreX,String nombreY){
/* datosYorigen origen de los valores Y
pan= panel donde se verá la graafica
eti= etiqueta en el pan que captura la imagen
tituloGrafica nombre arriba
nombreX nombre abajo
nombreY nombre lateral izquierdo*/
JFreeChart barra = null;//objeto grafico que llamaremos "barra"
DefaultCategoryDataset datos;
datos = new DefaultCategoryDataset();//objeto que almacena los valores (y) en la grafica
double[] valores = new double[12];
String[] meses={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"};
for (int i = 0; i < 12; i++) {valores[i] = datosYorigen[i];
//datos.setValue(valores[i],"",meses[i]);//añadimos los valores al conjunto en orden,leyenda null
//valores y,"leyenda los diferencia por colores",valores (x)
if(tituloGrafica.equals("Rendimiento")){if (valores[i] < 50) {
147
APÉNDICE. CÓDIGOS. JAVA. Grafica_JFC.java
datos.setValue(valores[i],"<50%",meses[i]);//estos irán de con color leyenda <50
} else {
datos.setValue(valores[i],">50%",meses[i]);//esto irán de otro con leyenda >50
}
}else{datos.setValue(valores[i],"",meses[i]);}}
barra = ChartFactory.createBarChart(tituloGrafica,
nombreX,nombreY,datos,PlotOrientation.VERTICAL,true,true,true);
//"titulo","nombre valores x,nombre valores y,orientacion,leyenda colores,?,?
//el grafico tomará las dimensiones de la etiqueta donde se dibuja
BufferedImage graficoBarra=barra.createBufferedImage(eti.getWidth(),eti.getHeight());
//eti.setSize(pan);
eti.setIcon(new ImageIcon(graficoBarra));
pan.updateUI();
}
public void Dibuja_2Barras_JFree(double[] datosYorigen1,double[] datosYorigen2,
JPanel pan,JLabel eti,String tituloGrafica,String nombreX,String nombreY,
String leyenda1,String leyenda2){
/* datosYorigen origen de los valores Y
pan= panel donde se verá la graafica
eti= etiqueta en el pan que captura la imagen
tituloGrafica nombre arriba
nombreX nombre abajo
nombreY nombre lateral izquierdo*/
JFreeChart barra = null;//objeto grafico que llamaremos "barra"
DefaultCategoryDataset datos;
datos = new DefaultCategoryDataset();//objeto que almacena los valores (y) en la grafica
double[] valores1 = new double[12];
double[] valores2 = new double[12];
String[] meses={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"};
for (int i = 0; i < 12; i++) {valores1[i] = datosYorigen1[i];
valores2[i] = datosYorigen2[i];
datos.setValue(valores1[i],leyenda1,meses[i]);
datos.setValue(valores2[i],leyenda2,meses[i]);//añadimos los valores al conjunto en orden,leyenda
aportacion
//valores y,"leyenda los diferencia por colores",valores (x)
}
barra = ChartFactory.createBarChart(tituloGrafica,
nombreX,nombreY,datos,PlotOrientation.VERTICAL,true,true,true);
//"titulo","nombre valores x,nombre valores y,orientacion,leyenda colores,?,?
//el grafico tomará las dimensiones de la etiqueta donde se dibuja
//cambiar colores barras
CategoryPlot plot=(CategoryPlot)barra.getPlot();
BarRenderer renderer =(BarRenderer)plot.getRenderer();
renderer.setSeriesPaint(0,Color.orange);
renderer.setSeriesPaint(1,Color.red);
/////fin cambiar colores
BufferedImage graficoBarra=barra.createBufferedImage(eti.getWidth(),eti.getHeight());
//eti.setSize(pan);
eti.setIcon(new ImageIcon(graficoBarra));
pan.updateUI();
}
public void Dibuja_Linea_JFree(double[] datosYorigen1,
JPanel pan,JLabel eti,String tituloGrafica,String nombreX,String nombreY
148
APÉNDICE. CÓDIGOS. JAVA. Grafica_JFC.java
){
JFreeChart linea = null;
DefaultCategoryDataset datos;
datos = new DefaultCategoryDataset();
double[] valores1 = new double[12];
String[] meses={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"};
for (int i = 0; i < 12; i++) {valores1[i] = datosYorigen1[i];
datos.setValue(valores1[i],"",meses[i]);//asi poniendo luego en VERTICA sale bien
linea = ChartFactory.createLineChart(tituloGrafica,nombreX,nombreY,datos, PlotOrientation.VERTICAL, true,
true, true);
BufferedImage graficoLinea=linea.createBufferedImage(eti.getWidth(),
eti.getHeight());
//eti.setSize(pan.getSize());
eti.setIcon(new ImageIcon(graficoLinea));
pan.updateUI();
}}
public void Dibuja_2Lineas_JFree(double[] datosYorigen1,double[] datosYorigen2,
JPanel pan,JLabel eti,String tituloGrafica,String nombreX,String nombreY,
String leyenda1,String leyenda2){
JFreeChart linea = null;
DefaultCategoryDataset datos;
datos = new DefaultCategoryDataset();
double[] valores1 = new double[12];
double[] valores2 = new double[12];
String[] meses={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"};
for (int i = 0; i < 12; i++) {valores1[i] = datosYorigen1[i];
valores2[i]=datosYorigen2[i];
datos.setValue(valores1[i],leyenda1,meses[i]);
datos.setValue(valores2[i],leyenda2,meses[i]);
linea = ChartFactory.createLineChart(tituloGrafica,nombreX,nombreY,datos, PlotOrientation.VERTICAL, true,
true, true);
BufferedImage graficoLinea=linea.createBufferedImage(eti.getWidth(),
eti.getHeight());
//eti.setSize(pan.getSize());
eti.setIcon(new ImageIcon(graficoLinea));
pan.updateUI();
}}
public void Guarda_grafica_enArchivo(JLabel eti,String nombre){
File fichero = new File("Graficas/"+nombre+".bmp");
String formato = "bmp";
// Creamos la imagen para dibujar en ella.
BufferedImage imagenpanel = new BufferedImage(eti.getWidth(),eti.getHeight(),
BufferedImage.TYPE_INT_RGB);
// Hacemos el dibujo
Graphics g = imagenpanel.getGraphics();
149
APÉNDICE. CÓDIGOS. JAVA. Grafica_JFC.java
eti.paint(g);
// Escribimos la imagen en el archivo.
try {
ImageIO.write(imagenpanel, formato, fichero);
} catch (IOException e) {
System.out.println("Error de escritura");
}
}
public void Dibuja_Variaciones2Lineas_JFree(Statement sentencia,String columnaX,JPanel pan,JLabel eti){
int i;
int n;//contador de filas
try{
//extraemos los datos de la BD
String consulta="select * from variacionesFchartAnual order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
r.first();int n0=r.getInt("Numero");
r.last();int n1=r.getInt("Numero");
n=n1-n0+1;
consulta="select * from variacionesFchartAnual order by "+columnaX;
r=sentencia.executeQuery(consulta);
r.first();
String temp[]=new String[n];
JFreeChart linea = null;
DefaultCategoryDataset datos;
datos = new DefaultCategoryDataset();
Double v1[]=new Double[n];
Double v2[]=new Double[n];
//busca extremos
Double vmin=1000.0;Double vmax=0.0;
//
for(i=0;i<temp.length;i++){temp[i]=r.getString(columnaX);//nuevo
v1[i]=Double.parseDouble(r.getString("aportacion"));
v2[i]=Double.parseDouble(r.getString("CSA"))*100;
r.next();
datos.setValue(v1[i],"aportación",temp[i]);
datos.setValue(v2[i],"CSA F-chart",temp[i]);
//busca extremos
if(v1[i]>vmax){vmax=v1[i];}
if(v2[i]>vmax){vmax=v2[i];}
if(v1[i]<vmin){vmin=v1[i];}
if(v2[i]<vmin){vmin=v2[i];}
//
linea = ChartFactory.createLineChart("variaciones",columnaX,"CSA - Aportación",datos,
PlotOrientation.VERTICAL, true, true, true);
//rango valoresY enfunción de los valores extremos
CategoryPlot plot=(CategoryPlot)linea.getPlot();
plot.getRangeAxis().setRange(vmin-1.0,vmax+1.0);
//
BufferedImage graficoLinea=linea.createBufferedImage(eti.getWidth(),
eti.getHeight());
//eti.setSize(pan.getSize());
eti.setIcon(new ImageIcon(graficoLinea));
pan.updateUI();}
150
APÉNDICE. CÓDIGOS. JAVA. Grafica_JFC.java
}
catch(Exception e){}
}
public void Dibuja_4Barras_JFree(Statement sentencia,JPanel pan,JLabel eti,String columna){
int i;
int n;//contador de filas
try{
//extraemos los datos de la BD
String consulta="select * from resultadosACS order by Numero";
ResultSet r=sentencia.executeQuery(consulta);
r.first();
JFreeChart barra = null;//objeto grafico que llamaremos "barra"
DefaultCategoryDataset datos;
datos = new DefaultCategoryDataset();//objeto que almacena los valores (y) en la grafica
double[] valores1 = new double[52];
double[] valores2 = new double[52];
double[] valores3 = new double[52];
double[] valores4 = new double[52];
String[] meses={"Álava", "Albacete", "Alicante", "Almería", "Asturias", "Ávila",
"Badajoz", "Baleares", "Barcelona", "Burgos", "Cáceres", "Cádiz", "Cantabria",
"Castellón", "Ceuta", "Ciudad Real", "Córdoba", "La Coruña", "Cuenca", "Gerona",
"Granada", "Guadalajara", "Guipúzcoa", "Huelva", "Huesca", "Jaén", "León",
"Lérida", "Lugo", "Madrid", "Málaga", "Melilla", "Murcia", "Navarra", "Orense",
"Palencia", "Las Palmas", "Pontevedra", "La Rioja", "Salamanca", "Tenerife",
"Segovia", "Sevilla", "Soria", "Tarragona", "Teruel", "Toledo", "Valencia",
"Valladolid", "Vizcaya", "Zamora", "Zaragoza"};
//busca extremos
Double vmin=1000000.0;Double vmax=0.0;
//
for(i=0;i<valores1.length;i++){
valores2[i]=Double.parseDouble(r.getString(columna));
r.next();
datos.setValue(valores2[i],columna,meses[i]);
if(valores2[i]>vmax){vmax=valores2[i];}
if(valores2[i]<vmin){vmin=valores2[i];}
barra = ChartFactory.createBarChart("", "Localización","",datos,PlotOrientation.HORIZONTAL,true,true,true);
//rango valoresY
CategoryPlot plot=(CategoryPlot)barra.getPlot();
plot.getRangeAxis().setRange(0.90*vmin,vmax*1.1);
//
BufferedImage graficoBarra=barra.createBufferedImage(eti.getWidth(),eti.getHeight());
eti.setIcon(new ImageIcon(graficoBarra));
pan.updateUI();}
}
catch(Exception e){}
}
////////////////////////////////////////////////////////////
public void Dibuja_10Lineas_JFree(double[] datosY[],int numlineas,
JPanel pan,JLabel eti,String tituloGrafica,String nombreX,String nombreY
,String ley[]){
151
APÉNDICE. CÓDIGOS. JAVA. Grafica_JFC.java
JFreeChart linea = null;
DefaultCategoryDataset datos;
datos = new DefaultCategoryDataset();
String[] meses={"Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"};
if (numlineas==1){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);}}
if (numlineas==2){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);}}
if (numlineas==3){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);}}
if (numlineas==4){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);
datos.setValue(datosY[3][i],ley[3],meses[i]);}}
if (numlineas==5){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);
datos.setValue(datosY[3][i],ley[3],meses[i]);
datos.setValue(datosY[4][i],ley[4],meses[i]);}}
if (numlineas==6){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);
datos.setValue(datosY[3][i],ley[3],meses[i]);
datos.setValue(datosY[4][i],ley[4],meses[i]);
datos.setValue(datosY[5][i],ley[5],meses[i]);}}
if (numlineas==7){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);
datos.setValue(datosY[3][i],ley[3],meses[i]);
datos.setValue(datosY[4][i],ley[4],meses[i]);
datos.setValue(datosY[5][i],ley[5],meses[i]);
datos.setValue(datosY[6][i],ley[6],meses[i]);}}
if (numlineas==8){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);
datos.setValue(datosY[3][i],ley[3],meses[i]);
datos.setValue(datosY[4][i],ley[4],meses[i]);
datos.setValue(datosY[5][i],ley[5],meses[i]);
datos.setValue(datosY[6][i],ley[6],meses[i]);
datos.setValue(datosY[7][i],ley[7],meses[i]);}}
if (numlineas==9){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);
datos.setValue(datosY[3][i],ley[3],meses[i]);
datos.setValue(datosY[4][i],ley[4],meses[i]);
datos.setValue(datosY[5][i],ley[5],meses[i]);
152
APÉNDICE. CÓDIGOS. JAVA. Grafica_JFC.java
datos.setValue(datosY[6][i],ley[6],meses[i]);
datos.setValue(datosY[7][i],ley[7],meses[i]);
datos.setValue(datosY[8][i],ley[8],meses[i]);}}
if (numlineas==10){
for (int i = 0; i < 12; i++) {datos.setValue(datosY[0][i],ley[0],meses[i]);
datos.setValue(datosY[1][i],ley[1],meses[i]);
datos.setValue(datosY[2][i],ley[2],meses[i]);
datos.setValue(datosY[3][i],ley[3],meses[i]);
datos.setValue(datosY[4][i],ley[4],meses[i]);
datos.setValue(datosY[5][i],ley[5],meses[i]);
datos.setValue(datosY[6][i],ley[6],meses[i]);
datos.setValue(datosY[7][i],ley[7],meses[i]);
datos.setValue(datosY[8][i],ley[8],meses[i]);
datos.setValue(datosY[9][i],ley[9],meses[i]);}}
linea = ChartFactory.createLineChart(tituloGrafica,nombreX,nombreY,datos, PlotOrientation.VERTICAL, true,
true, true);
BufferedImage graficoLinea=linea.createBufferedImage(eti.getWidth(),
eti.getHeight());
//eti.setSize(pan.getSize());
eti.setIcon(new ImageIcon(graficoLinea));
pan.updateUI();
}
}
153
APÉNDICE II. CÓDIGOS. JAVA. Imagen_panel.java
1.6. Clase Imagen_panel.java
package paquete;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
*
* @author Eduardo
*/
public class Imagen_panel {
//declara variables
public Imagen_panel(){//inicia variabels
}
//métodos de la clase
public void Archiva_Imagem_jpg(String nomFichero,JPanel pan){
//dibuja panel_datos en eti_graf_paneles
File fichero = new File("Graficas/"+nomFichero+".jpg");
String formato = "jpg";
// Creamos la imagen para dibujar en ella.
BufferedImage imagenpanel = new BufferedImage(pan.getWidth(),
pan.getHeight(), BufferedImage.TYPE_INT_RGB);
// Hacemos el dibujo
Graphics g = imagenpanel.getGraphics();
pan.paint(g);
// Escribimos la imagen en el archivo.
try {
ImageIO.write(imagenpanel, formato, fichero);
} catch (IOException e) {
System.out.println("Error de escritura");
}}
public void Pinta_arcivo_enJLabel(String nomFichero,JLabel eti){
//carga imagen del archivo que tenemos y lo pinta en la JLabel eti_graf_paneles
File fichero = new File("Graficas/"+nomFichero+".jpg");
BufferedImage imagen;
ImageIcon img=null;
try {
imagen=ImageIO.read(fichero);
//eti_graf_paneles.setSize(new Dimension(imagen.getWidth(),imagen.getHeight()));
img=new ImageIcon(imagen);
eti.setIcon(img);
//repaint();
} catch (Exception e) {e.printStackTrace();}
}
}
154
APÉNDICE II. CÓDIGOS. HTML. ACSenJS.html
2.1.1. Archivo ACSenJS.html
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
<!DOCTYPE html>
<!-To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
Código HTML, archivo: ACSenJS.html
Author : Eduardo Gajardo
-->
<html>
<head>
<title>Simulación cálculo nºcsp para ACS</title>
<meta charset="UTF-8">
<meta name="description" content="programación en JavaScript para
cálculos de energia solar termica para ACS" />
<link rel="stylesheet" href="css/estilo_0_1.css"/>
</head>
<body>
<div id="cotenedor">
<div id="cabecera">
<label id="local">Localizacion</label>
<label id="altitud" >Altitud:</label>
<label id="latitud" >Latitud:</label>
<label id="tempminhis" >Temperatura mínima histórica:</label>
</div> <!--cabecera-->
<div id="navegacion">
<table id="tituCombos" border>
<tr id="fila1">
<th >Provincia</th>
<th title="Temperatura de uso ºC" >Temp ACS</th>
<th title="inclinacion de los paneles respecto a la
horizontal">Inclinación</th>
<th >Nº de paneles calculado</th>
<th >Nº de paneles proyecto</th>
<th title="m2 de superficie útil de paneles">Superficie m2</th>
<th >litros acumulador calculado</th>
<th title="depósito acumulador de agua">Volumen proyecto</th>
<th title="% usuarios">% ocupación</th>
<th title="consumo estimado por usuario">litros día</th>
<th >Nº usuarios</th>
<th title="superficie útil de un colector solar plano">área csp m2</th>
</tr>
<tr id="fila2">
<th ><select name="prov" id="pro" title="provincia" >
<option>provincia</option></select></th>
155
APÉNDICE II. CÓDIGOS. HTML. ACSenJS.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<th ><select name="tuso" id="comboTuso" title="temperatura de uso" >
<option>Tuso</option></select></th>
<th ><select name="inc" id="comboinclina" title="inclinacion">
<option>inclinación</option></select></th>
<th > <input type="text" id="npa" placeholder="nº paneles" /></th>
<th > <select name="numpa" id="combopaneles" title="nº de paneles">
<option>inclinación</option></select></th>
<th > <input type="text" id="sup" placeholder="superficie m2"/></th>
<th > <input type="text" id="vol"
placeholder="litros acumulador calculado"/></th>
<th ><select name="vol" id="comboacumula" title="volumen proyecto">
<option>inclinación</option></select></th>
<th > <select name="ocu" id="combovariaocu" title="%ocupacion">
<option>% ocupación</option></select></th>
<th ><select name="lit" id="combovariaLD" title="Litrosdia">
<option>Litros día</option></select></th>
<th > <select name="numsu" id="combovariaNU" title="Nºusuarios">
<option>Nº usuarios</option></select></th>
<th > <select name="acol" id="combovariaAcol"
title="Área colector solar plano">
<option>área csp</option></select></th>
</tr>
</table>
<table id="tablafila2" border>
<tr id="fila3">
<th title="factor b de los paneles">bcol</th>
<th title="factor m de los paneles">mcol</th>
<th title="factor de corrección de H">CorH</th>
<th title="factor de corrección de b">Cor b</th>
<th >Pérdidas globales</th>
<th >Desviación NS</th>
<th title="calor específico del agua">Calor específico</th>
<th >factor ángulo incidencia</th>
<th >factor intercambiador</th>
<th title="temperatura mínima de uso del agua"> Temperatura mínima</th>
</tr>
<tr id="fila4">
<th > <select name="bcol" id="combovariaBcol"
title="b csp,factor de eficiencia óptica">
<option>b csp</option></select></th>
<th > <select name="mcol" id="combovariaMcol"
title="m csp, coeficiente global de pérdidas">
<option>m csp</option></select></th>
<th > <select name="corh" id="combovariaCorH"
title="factor corrección de H, atmófera limpia 1.05,
contaminada 0.95">
<option>atmósfera limpia</option></select></th>
<th > <select name="corb" id="combovariaCorb"
156
APÉNDICE II. CÓDIGOS. HTML. ACSenJS.html
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
title="factor corrección de b">
<option>corrección b</option></select></th>
<th > <select name="pg" id="combovariaPG" title="coef pérdidas global">
<option>coef pérdidas</option></select></th>
<th > <select name="dns" id="combovariaDNS" title="desviación NS">
<option>desviación NS</option></select></th>
<th > <select name="ce" id="combovariaCE" title="calor específico">
<option>Ce</option></select></th>
<th > <select name="mai" id="combovariaMAI"
title="modificación ángulo de incidencia">
<option>factor ángulo incidencia</option></select></th>
<th > <select name="fci" id="combovariaFCCI"
title="factor intercambiador">
<option>factor intercambiador</option></select></th>
<th > <select name="tm" id="combovariaTmin"
title="temperatura mínima de uso">
<option>Temp mínima</option></select></th>
</tr>
</table>
</div><!--navegacion-->
<table id="var1" ></table>
<div id="lateralDerecha" >
<h2 class="titlat">cálculos d-a</h2>
<div id="resume1">
<ul>
<li>Demanda anual: <label id="resumeDA"></label></li>
<li>energía anual/m2:<label id="resumeEAm2"></label></li>
<li>Superficie m2: <label id="resumeSUP"></label></li>
<li>Nº colectores: <label id="resumeNC"></label></li>
<li>ACS m3/año: <label id="resumeCACS"></label></li>
</ul>
</div><!--/*resume1*/-->
<div id="resume2">
<ul>
<li>Aportación solar % :<label id="resumeApor"></label></li>
<li>Déficit de energía:<label id="resumeDef"></label></li>
</ul>
</div><!--/*resume2*/-->
<div id="resume3">
<ul>
<li>Coste energía anual :<label id="resumeCos"></label></li>
<li>Coste auxiliar anual :<label id="resumeCosDef"></label></li>
<li>Ahorro anual : <label id="resumeAho"></label></li>
</ul>
</div><!--/*resume3*/-->
<h2 class="titlat">cálculos f-chart</h2>
<div id="resume4">
157
APÉNDICE II. CÓDIGOS. HTML. ACSenJS.html
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<ul>
<li>CSA f-chart : <label id="resumeCSA"></label></li>
</ul>
</div><!--/*resume4*/-->
<h2 class="titlat">diseño</h2>
<div id="resume5">
<ul>
<li>Superficie final m2 :<label id="resumeSupfinal"></label></li>
<li>Acumulador litros :<label id="resumeAcu"></label></li>
</ul>
</div><!--/*resume5*/-->
<div id="resume6">
b:
<label id="resumebcol" > </label>
| m:
<label id="resumemcol"> </label>
| FCCI:
<label id="resumeFCCI"> </label>
</div> <!--/*resume6*/-->
<div id="resume7">
<ul>
<li>V/M : <label id="resumeVMprueba"
title="0.8<vol teórico/vol proyecto<1.2"></label></li>
<li>C/A : <label id="resumeCAprueba"
title="60<litrosACSdia/m2csp<100"></label></li>
<li>M/A : <label id="resumeMAprueba"
title="37.5<kg acumulador/m2csp<300"></label></li>
</ul>
</div><!--/*resume7*/-->
<h2 class="titlat">consulta datos y resultados</h2>
<div id="resume8">
<ul>
<li><a href="#dm">Datos mensuales</a></li>
<li><a href="#rm">Resultados mensuales</a></li>
<li><a href="#ran">Resultados anuales</a></li>
<li><a href="#rf">Resultados fchart</a></li>
<li><a href="#Rgrande">Ver gráficas</a></li>
</ul>
</div><!--/*resume8*/-->
<input id="btnImprime" type="button" value="Imprimir todo"
title ="Imprimir todo" />
</div><!--tabla lateralDerecha-->
158
APÉNDICE II. CÓDIGOS. HTML. ACSenJS.html
193
<div id="lateralIzquierda">
194
<div id="graficaDAyF">
195
<div id="DA" > </div>
<div id="fchart"></div>
196
197
</div>
198
</div><!--lateralIzquierda-->
199
200
<div id="RAP"> </div>
201
202
<hr >
203
<table style="width: 800px; height: 210px;" ></table><!--espacio en blanco-->
204
205
<h1 id="dm">Datos mensuales</h1>
<a class="flecha" href="#cabecera"><img src="flecharriba.gif" title="volver"/></a>
206
207
<table id="datosmes" ></table>
208
<h1 id="rm">Resultados mensuales</h1>
209
210
<a class="flecha" href="#cabecera"><img src="flecharriba.gif" title="volver"/></a>
211
<table id="resultadosmes"></table>
212
213
<h1 id="ran">Resultados anuales</h1>
214
<a class="flecha" href="#cabecera"><img src="flecharriba.gif" title="volver"/></a>
215
<table id="resultadosanuales"></table>
216
217
<table style="width: 800px; height: 50px;" ></table> <!--espacio en blanco-->
<br>
218
219
<div >
<h1 id="rf" >Calculos fchart</h1>
220
221
<a class="flecha" href="#cabecera"><img src="flecharriba.gif" title="volver"/></a>
222
</div>
223
<p id="formuFchart">
224
f=1.029*D<sub>1</sub>-0.065*D<sub>2</sub>-0.245
225
*D<sub>1</sub><sup>2</sup>+0.0018*D<sub>2</sub><sup>2</sup>
226
+0.0215*D<sub>1</sub><sup>3</sup></p>
227
<table id="DatyResf"></table>
<div id="resf">
228
229
<label id="csa" title="Cobertura solar anual">CSA:</label>
230
<label id="k1">K1:</label>
231
<label id="pk1" >pruebak1:</label>
</div>
232
233
<br><br><br><br><br> <br><br><hr>
234 <!--///////////////////////////////////////////////////////////// -->
235
<img src="logedu.jpg"/>
236
<hr>
237
238
<a class="flecha" href="#cabecera"><img src="flecharriba.gif" title="volver"/></a>
239
<div id="Rgrande"></div>
240
<div id="Agrande"></div>
241
<div id="Pgrande"></div>
159
APÉNDICE II. CÓDIGOS. HTML. ACSenJS.html
242
</div><!--contenedor-->
243
<!--////////////////////////////////////////////////////////////// -->
244
<script src="js/localizacionjs_ACSenJS_correjido.js"></script>
<script src="js/fchart_ACSenJS.js"></script>
245
246
<script src="js/Graficas_ACSenJS_1.js"></script>
247
<script src="js/grafica-lineal-visor_ACSenJS.js"></script>
248
<script src="js/imprimir.js"></script>
249 </body>
250 </html>
160
APÉNDICE II. CÓDIGOS. CSS. estilo_0_1.css
2.2.1. Archivo estilo_0_1.css
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
/* Hoja de estilos
Código CSS archivo: estilo_0_1.css
Author : Eduardo Gajardo
*/
*{margin:0px;padding:0px;border:0px;background:none;}
body{font: 8pt Verdana, Geneva, Arial, Helvetica, sans-serif;
width:800px;margin:4px auto;text-align: center;}
#cabecera{background-color: lightgreen;padding: 5px;
border-top-left-radius: 10px;border-top-right-radius: 10px;}
#local{font-size: 1.5em; font-weight: bold;padding-right: 10px;}
#latitud,#altitud,#tempminhis{padding:0px 5px 0px 5px;}
#navegacion{background-color:gray}
#fila1>th{width:70px;background-color: lavender;}
#fila2>th{ background-color: powderblue; }
#fila2>th>select,input{width: 60px;}
#fila3>th{width:106px;background-color: lavender;}
#fila4>th{background-color: powderblue;}
#fila2>th>select{width: 60px;}
#fila4>th>select{width: 60px;}
#lateralIzquierda{float: right;}
#var1{ width: 800px; border: 1px black solid;border-radius: 10px;
background: goldenrod;margin-right: 4px;}
#btnImprime{border: 1px black solid;border-radius: 3px;
margin: 5px;background:gray;width: 80px;}
.flecha{float: right;}
#datosmes td{font-size: 80%;border-right: 1px black solid;padding: 5px;}
#datosmes th{font-size: 80%;padding: 0px 5px 0px 5px;border-bottom:1px aquamarine solid;}
#datosmes{border: 1px black solid;}
#resultadosmes td{font-size: 80%;border-right: 1px black solid;padding: 5px;}
#resultadosmes th{font-size: 80%;padding: 0px 5px 0px 5px;border-bottom:1px aquamarine
solid;}
43 #resultadosmes{border: 1px black solid;}
44
161
APÉNDICE II. CÓDIGOS. CSS. estilo_0_1.css
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
77
78
79
80
#resultadosanuales td{font-size: 80%;border-right: 1px black solid;padding: 5px;}
#resultadosanuales th{font-size: 80%;padding: 0px 5px 0px 5px;
border-bottom:1px aquamarine solid;}
#resultadosanuales{border: 1px black solid;}
#DatyResf th{font-size: 75%;border-right: 1px black solid;padding:0px 3px 0px 3px;
border-bottom:1px aquamarine solid;}
#DatyResf td{font-size: 75%;padding:3px;}
#DatyResf{border: 2px black solid;}
#csa{padding: 3px 10px 0px 5px;background: lightgrey;float: left;width: 100px;}
#k1{padding: 0px 10px 0px 5px;background: lightgrey;float: left;width: 290px;}
#pk1{padding: 3px 10px 0px 5px;background: lightgrey;float: left;width: 314px;}
#resf{height: 23px;background: lightgrey;width: 749px;}
#lateralDerecha{float: right;text-align: left;//margin-top: 100px;border: 1px black solid;
border-radius: 5px;background: lightgray;width: 180px;//height: 580px;}
#lateralDerecha div{border-bottom: 2px blue solid;}
#lateralDerecha a{margin-left: 3px;}
#lateralDerecha ul{list-style: none;}
#lateralDerecha li label{ float:right;}
#lateralDerecha li,#resume6 {height: 1.5em; border-bottom: 1px black solid;}
.titlat{
background-color: #68729E;
color: #ffffff;
font-size: 8pt;
text-transform: uppercase;
padding: 7px 3px 7px 8px;
font-weight: normal;
letter-spacing: 2px;
margin: 0px 0px 8px 0px;}
#RAP{border: 1px black solid;border-radius: 5px;background: lightgray;width: 200px;}
162
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
2.3.1. Archivo localizacionjs_ACSenJS.js
1
//Código JavaScript para cálculos de energía solar térmica por el método D-A para ACS
2
3
4
5
/*
Código JavaScript, archivo: localizacionjs_ACSenJS.js
Author : Eduardo Gajardo
*/
6
7
8
9
// VARIABLES GLOBALES
var etilocal=document.getElementById("local");
var provincia=new Array("Álava","Albacete","Alicante","Almería","Asturias","Ávila","Badajoz","Baleares"
,"Barcelona","Burgos","Cáceres","Cádiz","Cantabria","Castellón","Ceuta","Ciudad Real","Córdoba"
,"La Coruña","Cuenca","Gerona","Granada","Guadalajara","Guipúzcoa","Huelva","Huesca","Jaén"
,"León","Lérida","Lugo","Madrid","Málaga","Melilla","Murcia","Navarra","Orense","Palencia"
,"Las Palmas","Pontevedra","La Rioja","Salamanca","Tenerife","Segovia","Sevilla","Soria"
,"Tarragona","Teruel","Toledo","Valencia","Valladolid","Vizcaya","Zamora","Zaragoza");
var contaprovincia=0;
var inclina=new Array(45,35,40,45,50,55,60);
var vTuso=new Array(45,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90);
var vectorlitro=[40,5,10,15,20,22,25,30,35,40,45,50,55,60,65,70,75,80];
var vectornus=[32,1,2,4,5,6,8,10,15,20,25,30,40,50,60,70,80,90,100,150,200,300];
var vectorAcol=[2.01,1,1.5,3,3.5,4,1.90];
var vectorBcol=[0.83,0.75,0.76,0.77,0.78,0.79,0.80,0.81,0.82,0.83,0.84,0.85,0.86,0.87,0.88,0.89,0.90];
var vectorMcol=[4.8,4.5,4.6,4.56,4.70,4.75,4.8,4.85,4.9,4.95,5,5.05,5.1,5.2];
var vectorCorH=[1.05,0.95];
var vectorCorb=[0.94];
var vectorPG=[0.15,0.10,0.05,0.01,0,0.2];
var vectorDNS=[0];
var vectorCE=[4184];//calor específico
var vectorMAI=[0.96,0.97,0.98,0.99,1,0.95,0.94,0.93,0.92,0.91,0.9];
var vectorFCCI=[0.95,0.96,0.97,0.98,0.99,1,0.94,0.93,0.92,0.91,0.9];
var vectorTmin=[45,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90];
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
var comboprov=document.getElementById("pro");
var lista=document.getElementById("pro");
var vPaneles=new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23);
var vVolacu=new Array(100,200,300,400,500,600,700,800,900,1000,1500,2000,2500,3000,3500,4000,4500,5000);
var txtnpa=document.getElementById("npa");
var txtsup=document.getElementById("sup");
var txtvol=document.getElementById("vol");
var etinpaneles=document.getElementById("npaneles");//para las variaciones
var altitud=document.getElementById("altitud");
var latitud=document.getElementById("latitud");
var tempminhis=document.getElementById("tempminhis");
var vDias = [31,28,31,30,31,30,31,31,30,31,30,31];
var LitrosDia;
var NumUsu;
var vOcupacion=new Array(12);
var vConsumo=new Array(12);
var lugar,Altitud,Latitud,TemperaturaMinHistorica;
163
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
var tabladatosmes=document.getElementById("datosmes");
var tablaresultadosmes=document.getElementById("resultadosmes");
var tablaresultadosmes2=document.getElementById("resultadosmes2");
var tablaresultadosanuales=document.getElementById("resultadosanuales");
var vTamb,vTred,vH,VCork,Inclinacion;
var vTr1,vTr2,vTr3,vTr4,vTr5,vTr6,vTr7,vTr8,vTr9,vTr10,
vTr11,vTr12,vTr13,vTr14,vTr15,vTr16,vTr17,vTr18,vTr19,vTr20,
vTr21,vTr22,vTr23,vTr24,vTr25,vTr26,vTr27,vTr28,vTr29,vTr30,
vTr31,vTr32,vTr33,vTr34,vTr35,vTr36,vTr37,vTr38,vTr39,vTr40,
vTr41,vTr42,vTr43,vTr44,vTr45,vTr46,vTr47,vTr48,vTr49,vTr50,vTr51,vTr52;
var vh1,vh2,vh3,vh4,vh5,vh6,vh7,vh8,vh9,vh10,
vh11,vh12,vh13,vh14,vh15,vh16,vh17,vh18,vh19,vh20,
vh21,vh22,vh23,vh24,vh25,vh26,vh27,vh28,vh29,vh30,
vh31,vh32,vh33,vh34,vh35,vh36,vh37,vh38,vh39,vh40,
vh41,vh42,vh43,vh44,vh45,vh46,vh47,vh48,vh49,vh50,vh51,vh52;
var vTa1,vTa2,vTa3,vTa4,vTa5,vTa6,vTa7,vTa8,vTa9,vTa10,
vTa11,vTa12,vTa13,vTa14,vTa15,vTa16,vTa17,vTa18,vTa19,vTa20,
vTa21,vTa22,vTa23,vTa24,vTa25,vTa26,vTa27,vTa28,vTa29,vTa30,
vTa31,vTa32,vTa33,vTa34,vTa35,vTa36,vTa37,vTa38,vTa39,vTa40,
vTa41,vTa42,vTa43,vTa44,vTa45,vTa46,vTa47,vTa48,vTa49,vTa50,vTa51,vTa52;
var vck1,vck2,vck3,vck4,vck5,vck6,vck7,vck8,vck9,vck10,
vck11,vck12,vck13,vck14,vck15,vck16,vck17,vck18,vck19,vck20,
vck21,vck22,vck23,vck24,vck25,vck26,vck27,vck28,vck29,vck30,
vck31,vck32,vck33,vck34,vck35,vck36,vck37,vck38,vck39,vck40,
vck41,vck42,vck43,vck44,vck45,vck46,vck47,vck48,vck49,vck50,vck51,vck52;
var vcki35p1,vcki35p2,vcki35p3,vcki35p4,vcki35p5,vcki35p6,vcki35p7,vcki35p8,vcki35p9,vcki35p10,
vcki35p11,vcki35p12,vcki35p13,vcki35p14,vcki35p15,vcki35p16,vcki35p17,vcki35p18,vcki35p19,
vcki35p20,vcki35p21,vcki35p22,vcki35p23,vcki35p24,vcki35p25,vcki35p26,vcki35p27,vcki35p28,
vcki35p29,vcki35p30,vcki35p31,vcki35p32,vcki35p33,vcki35p34,vcki35p35,vcki35p36,vcki35p37,
vcki35p38,vcki35p39,vcki35p40,vcki35p41,vcki35p42,vcki35p43,vcki35p44,vcki35p45,vcki35p46,
vcki35p47,vcki35p48,vcki35p49,vcki35p50,vcki35p51,vcki35p52;
var vcki40p1,vcki40p2,vcki40p3,vcki40p4,vcki40p5,vcki40p6,vcki40p7,vcki40p8,vcki40p9,vcki40p10,
vcki40p11,vcki40p12,vcki40p13,vcki40p14,vcki40p15,vcki40p16,vcki40p17,vcki40p18,vcki40p19,
vcki40p20,vcki40p21,vcki40p22,vcki40p23,vcki40p24,vcki40p25,vcki40p26,vcki40p27,vcki40p28,
vcki40p29,vcki40p30,vcki40p31,vcki40p32,vcki40p33,vcki40p34,vcki40p35,vcki40p36,vcki40p37,
vcki40p38,vcki40p39,vcki40p40,vcki40p41,vcki40p42,vcki40p43,vcki40p44,vcki40p45,vcki40p46,
vcki40p47,vcki40p48,vcki40p49,vcki40p50,vcki40p51,vcki40p52;
var vcki45p1,vcki45p2,vcki45p3,vcki45p4,vcki45p5,vcki45p6,vcki45p7,vcki45p8,vcki45p9,vcki45p10,
vcki45p11,vcki45p12,vcki45p13,vcki45p14,vcki45p15,vcki45p16,vcki45p17,vcki45p18,vcki45p19,
vcki45p20,vcki45p21,vcki45p22,vcki45p23,vcki45p24,vcki45p25,vcki45p26,vcki45p27,vcki45p28,
vcki45p29,vcki45p30,vcki45p31,vcki45p32,vcki45p33,vcki45p34,vcki45p35,vcki45p36,vcki45p37,
vcki45p38,vcki45p39,vcki45p40,vcki45p41,vcki45p42,vcki45p43,vcki45p44,vcki45p45,vcki45p46,
vcki45p47,vcki45p48,vcki45p49,vcki45p50,vcki45p51,vcki45p52;
var vcki50p1,vcki50p2,vcki50p3,vcki50p4,vcki50p5,vcki50p6,vcki50p7,vcki50p8,vcki50p9,vcki50p10,
164
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
vcki50p11,vcki50p12,vcki50p13,vcki50p14,vcki50p15,vcki50p16,vcki50p17,vcki50p18,vcki50p19,
vcki50p20,vcki50p21,vcki50p22,vcki50p23,vcki50p24,vcki50p25,vcki50p26,vcki50p27,vcki50p28,
vcki50p29,vcki50p30,vcki50p31,vcki50p32,vcki50p33,vcki50p34,vcki50p35,vcki50p36,vcki50p37,
vcki50p38,vcki50p39,vcki50p40,vcki50p41,vcki50p42,vcki50p43,vcki50p44,vcki50p45,vcki50p46,
vcki50p47,vcki50p48,vcki50p49,vcki50p50,vcki50p51,vcki50p52;
var vcki55p1,vcki55p2,vcki55p3,vcki55p4,vcki55p5,vcki55p6,vcki55p7,vcki55p8,vcki55p9,vcki55p10,
vcki55p11,vcki55p12,vcki55p13,vcki55p14,vcki55p15,vcki55p16,vcki55p17,vcki55p18,vcki55p19,
vcki55p20,vcki55p21,vcki55p22,vcki55p23,vcki55p24,vcki55p25,vcki55p26,vcki55p27,vcki55p28,
vcki55p29,vcki55p30,vcki55p31,vcki55p32,vcki55p33,vcki55p34,vcki55p35,vcki55p36,vcki55p37,
vcki55p38,vcki55p39,vcki55p40,vcki55p41,vcki55p42,vcki55p43,vcki55p44,vcki55p45,vcki55p46,
vcki55p47,vcki55p48,vcki55p49,vcki55p50,vcki55p51,vcki55p52;
var vcki60p1,vcki60p2,vcki60p3,vcki60p4,vcki60p5,vcki60p6,vcki60p7,vcki60p8,vcki60p9,vcki60p10,
vcki60p11,vcki60p12,vcki60p13,vcki60p14,vcki60p15,vcki60p16,vcki60p17,vcki60p18,vcki60p19,
vcki60p20,vcki60p21,vcki60p22,vcki60p23,vcki60p24,vcki60p25,vcki60p26,vcki60p27,vcki60p28,
vcki60p29,vcki60p30,vcki60p31,vcki60p32,vcki60p33,vcki60p34,vcki60p35,vcki60p36,vcki60p37,
vcki60p38,vcki60p39,vcki60p40,vcki60p41,vcki60p42,vcki60p43,vcki60p44,vcki60p45,vcki60p46,
vcki60p47,vcki60p48,vcki60p49,vcki60p50,vcki60p51,vcki60p52;
//---------------------------//Álava1 42.9
vTr1=[5,6,8,10,11,12,13,12,11,10,8,5];
vh1=[4.6,6.9,11.2,13,14.8,16.6,18.1,17.3,14.3,9.5,5.5,4.1];
vh1=[4.6,6.9,11.2,13,14.8,16.6,18.1,17.3,14.3,9.5,5.5,4.1];
vck1=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa1=[7,7,11,12,15,19,21,21,19,15,10,7];
//Albacete2 39
vTr2=[5,6,8,10,11,12,13,12,11,10,8,5];
vh2=[6.5,10.5,15,19.2,21.2,25.1,26.7,23.2,18.8,12.4,8.4,6.4];
vck2=[1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48];
vTa2=[6,8,11,13,17,22,26,26,22,16,11,7];
//Alicante3 38.4
vTr3=[8,9,11,13,14,15,16,15,14,13,11,8];
vh3=[8.5,12,16.3,18.9,23.1,24.8,25.8,22.5,18.3,13.6,9.8,7.6];
vck3=[1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47];
vTa3=[13,14,16,18,21,25,28,28,26,21,17,14];
//Almeria4 36.9
vTr4=[8,9,11,13,14,15,16,15,14,13,11,8];
vh4=[8.9,12.2,16.4,19.6,23.1,24.6,25.3,22.5,18.5,13.9,10,8];
vck4=[1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45];
vTa4=[15,15,16,18,21,24,27,28,26,22,18,16];
//Asturias5 43
vTr5=[6,7,9,11,12,13,14,13,12,11,9,6];
vh5=[5.3,7.7,10.6,12.2,15,15.2,16.8,14.8,12.4,9.8,5.9,4.6];
vck5=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa5=[9,10,11,12,15,18,20,20,19,16,12,10];
//Ávila6 40.7
vTr6=[4,5,7,9,10,11,12,11,10,9,7,4];
vh6=[6,9.1,13.5,17.7,19.4,22.3,26.3,25.3,18.8,11.2,6.9,5.2];
vck6=[1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52];
vTa6=[4,5,8,11,14,18,22,22,18,13,8,5];
//Badajoz7 38.9
165
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
vTr7=[6,7,9,11,12,13,14,13,12,11,9,6];
vh7=[6.50,10,13.60,18.70,21.80,24.60,25.90,23.80,17.90,12.30,8.20,6.20];
vck7=[1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48];
vTa7=[11,12,15,17,20,25,28,28,25,20,15,11];
//Baleares8 39.6
vTr8=[8,9,11,13,14,15,16,15,14,13,11,8];
vh8=[7.2,10.7,14.4,16.2,21,22.7,24.2,20.6,16.4,12.1,8.5,6.5];
vck8=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5];
vTa8=[12,13,14,17,19,23,26,27,25,20,16,14];
//Barcelona9 41.4 42
vTr9=[8,9,11,13,14,15,16,15,14,13,11,8];
vh9=[6.5,9.5,12.9,16.1,18.6,20.3,21.6,18.1,14.6,10.8,7.2,5.8];
vck9=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa9=[11,12,14,17,20,24,26,26,24,20,16,12];
//Burgos10 42.3
vTr10=[4,5,7,9,10,11,12,11,10,9,7,4];
vh10=[5.1,7.9,12.4,16,18.7,21.5,23,20.7,16.7,10.1,6.5,4.5];
vck10=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa10=[5,10,9,11,14,18,21,21,18,13,9,5];
//Cáceres11 39.5
vTr11=[6,7,9,11,12,13,14,13,12,11,9,6];
vh11=[6.8,10,14.7,19.6,22.1,25.1,28.1,25.4,19.7,12.7,8.9,6.6];
vck11=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.54,1.52];
vTa11=[10,11,14,16,19,25,28,28,25,19,14,10];
//Cádiz12 36.5
vTr12=[8,9,11,13,14,15,16,15,14,13,11,8];
vh12=[8.1,11.5,15.7,18.5,22.2,23.8,25.9,23,18.1,14.2,10,7.4];
vck12=[1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45];
vTa12=[13,15,17,19,21,24,27,27,25,22,18,15];
//Cantabria13 43.5
vTr13=[8,9,11,13,14,15,16,15,14,13,11,8];
vh13=[5,7.4,11,13,16.1,17,18.4,15.5,13,9.5,5.8,4.5];
vck13=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vck13=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa13=[11,11,14,14,16,19,21,21,20,17,14,12];
//Castellón14 40
vTr14=[8,9,11,13,14,15,16,15,14,13,11,8];
vh14=[8,12.2,15.5,17.4,20.6,21.4,23.9,19.5,16.6,13.1,8.6,7.3];
vck14=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5];
vTa14=[13,13,15,17,20,24,26,27,25,21,16,13];
//Ceuta15 35.9
vTr15=[8,9,10,12,13,13,14,13,13,12,11,8];
vh15=[8.9,13.1,18.6,21,24.3,26.7,26.8,24.3,19.1,14.2,11,8.6];
vck15=[1.34,1.23,1.1,0.97,0.87,0.87,0.84,0.87,0.98,1.14,1.32,1.44,1.43];
vTa15=[15,15,16,17,19,23,25,26,24,21,18,16];
//Ciudad Real16 39
vTr16=[5,6,8,10,11,12,13,12,11,10,8,5];
vh16=[7,10.1,15,18.7,21.4,23.7,25.3,23.2,18.8,12.5,8.7,6.5];
vck16=[1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48];
vTa16=[7,9,12,15,18,23,28,27,20,17,11,8];
//Córdoba17 37.9
vTr17=[6,7,9,11,12,13,14,13,12,11,9,6];
vh17=[7.2,10.1,15.1,18.5,21.8,25.9,28.5,25.1,19.9,12.6,8.6,6.9];
166
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
225
259
260
261
262
vck17=[1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47];
vTa17=[11,13,16,18,21,26,30,30,26,21,16,12];
//La Coruña18 43.4
vTr18=[8,9,11,13,14,15,16,15,14,13,11,8];
vh18=[5.4,8,11.4,12.4,15.4,16.2,17.4,15.3,13.9,10.9,6.4,5.1];
vck18=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa18=[12,12,14,14,16,19,20,21,20,17,14,12];
//Cuenca19 40.1
vTr19=[4,5,7,9,10,11,12,11,10,9,7,4];
vh19=[5.9,8.8,12.9,17.4,18.7,22,25.5,22.3,17.5,11.2,7.2,5.5];
vck19=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5];
vTa19=[5,6,9,12,15,20,24,23,20,14,9,6];
//Gerona20 42
vTr20=[6,7,9,11,12,13,14,13,12,11,9,6];
vh20=[7.1,10.5,14.2,15.9,18.7,19,22.3,18.5,14.9,11.7,7.8,6.6];
vck20=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa20=[9,10,13,15,19,23,26,25,23,18,13,10];
//Granada21 37.2
vTr21=[6,7,9,11,12,13,14,13,12,11,9,6];
vh21=[7.8,10.8,15.2,18.5,21.9,24.8,26.7,23.6,18.8,12.9,9.6,7.1];
vck21=[1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45];
vTa21=[9,10,13,16,18,24,27,27,24,18,13,9];
//Guadalajara22 40.6
vTr22=[6,7,9,11,12,13,14,13,12,11,9,6];
vh22=[6.5,9.2,14,17.9,19.4,22.7,25,23.2,17.8,11.7,7.8,5.6];
vck22=[1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52];
vTa22=[7,8,12,14,18,22,26,26,22,16,10,8];
//Guipúzcoa23 43.3
vTr23=[8,9,11,13,14,15,16,15,14,13,11,8];
vh23=[5.5,7.7,11,.3,11.7,14.6,16.2,16.1,13.6,12.7,10.3,6.2,5];
vck23=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa23=[10,10,13,14,16,19,21,21,20,17,13,10];
//Huelva24 37.3
vTr24=[8,9,11,13,14,15,16,15,14,13,11,8];
vh24=[7.6,11.3,16,19.5,24.1,25.6,28.7,25.6,21.2,14.5,9.2,7.5];
vck24=[1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45];
vTa24=[13,14,16,20,21,24,27,27,25,21,17,14];
//Huesca25 42.1
vTr25=[5,6,8,10,11,12,13,12,11,10,8,5];
vh25=[6.1,9.6,14.3,18.7,20.3,22.1,23.1,20.9,16.9,11.3,7.2,5.1];
vck25=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa25=[7,8,12,15,18,22,25,25,21,16,11,7];
//Jaén26 37.8
vTr26=[8,9,11,13,14,15,17,16,14,13,11,7];
vh26=[6.7,10.1,14.4,18,20.3,24.4,26.7,24.1,19.2,11.9,8.1,6.5];
vck26=[1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47];
vTa26=[11,11,14,17,21,26,30,29,25,19,15,10];
//León27 42.6
vTr27=[4,5,7,9,10,11,12,11,10,9,7,4];
vh27=[5.8,8.7,13.8,17.2,19.5,22.1,24.2,20.9,17.2,10,4,7,4.8];
167
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
vck27=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa27=[5,6,10,12,15,19,22,22,19,14,9,6];
//Lérida28 41.7
vTr28=[5,6,8,10,11,12,13,12,11,10,8,5];
vh28=[6,9.9,10,18.8,20.9,22.6,23.8,21.3,16.8,12.1,7.2,4.8];
vck28=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa28=[7,10,14,15,21,24,27,27,23,18,11,8];
//Lugo29 43
vTr29=[6,7,9,11,12,13,14,13,12,11,9,6];
vh29=[5.1,7.6,11.7,15.2,17.1,19.5,20.2,18.4,15,9.9,6.2,4.5];
vck29=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa29=[8,9,11,13,15,18,20,21,19,15,11,8];
//Madrid30 40.4
vTr30=[6,7,9,11,12,13,14,13,12,11,9,6];
vh30=[6.7,10.6,13.6,18.8,20.9,23.5,26,23.1,16.9,11.4,7.5,5.9];
vck30=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5];
vTa30=[6,8,11,13,18,23,28,26,21,15,11,7];
//Málaga31 36.7
vTr31=[8,9,11,13,14,15,16,15,14,13,11,8];
vh31=[8.3,12,15.5,18.5,23.2,24.5,26.5,23.2,19,13.6,9.3,8];
vck31=[1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45];
vTa31=[15,15,17,19,21,25,27,28,26,22,18,15];
//Melilla32 35.3
vTr32=[8,9,11,13,14,15,16,15,14,13,11,8];
vh32=[9.4,12.6,17.2,20.3,23,24.8,24.8,22.6,18.3,14.2,10.9,8.7];
vck32=[1.33,1.22,1.09,0.96,0.86,0.82,0.86,0.97,1.13,1.3,1.42,1.41];
vTa32=[15,15,16,18,21,25,27,28,26,22,18,16];
//Murcia33 38
vTr33=[8,9,11,13,14,15,16,15,14,13,11,8];
vh33=[10.1,14.8,16.6,20.4,24.2,25.6,27.7,23.5,18.6,13.9,9.8,8.1];
vck33=[1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47];
vTa33=[12,12,15,17,21,25,28,28,25,20,16,12];
//Navarra34 42.8
vTr34=[5,6,8,10,11,12,13,12,11,10,8,5];
vh34=[5,7.4,12.3,14.5,17.1,18.9,20.5,18.2,16.2,10.2,6,4.5];
vck34=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa34=[7,7,11,13,16,20,22,23,20,15,10,8];
//Orense35 42.3
vTr35=[5,7,9,11,12,13,14,13,12,11,9,6];
vh35=[4.7,7.3,11.3,14,16.2,17.6,18.3,16.6,14.3,9.4,5.6,4.3];
vck35=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa35=[9,9,13,15,18,21,24,23,21,16,12,9];
//Palencia36 42
vTr36=[5,6,8,10,11,12,13,12,11,10,8,5];
vh36=[5.3,9,13.2,17.5,19.7,21.8,24.1,21.6,17.1,10.9,6.6,4.6];
vck36=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa36=[5,7,10,13,16,20,23,23,20,14,9,6];
//Las Palmas37 28.2
vTr37=[8,9,11,13,14,15,16,15,14,13,11,8];
vh37=[11.2,14.2,17.8,19.6,21.7,22.5,24.3,21.9,19.8,15.1,12.3,10.7];
vck37=[1.23,1.14,1.01,0.89,0.79,0.75,0.79,0.89,1.04,1.2,1.3,1.3];
vTa37=[20,20,21,22,23,24,25,25,26,25,23,21];
//Pontevedra38 42.4
vTr38=[8,9,11,13,14,15,16,15,14,13,11,8];
vh38=[5.5,8.2,13,15.7,17.5,20.4,22,18.9,15.1,11.3,6.8,5.5];
vck38=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
168
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
vTa38=[11,12,14,16,18,20,22,23,20,17,14,12];
//La Rioja39 42.5
vTr39=[6,7,9,11,12,13,14,13,12,11,9,6];
vh39=[5.6,8.8,13.7,16.6,19.2,21.4,23.3,20.8,16.2,10.7,6.8,4.8];
vck39=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa39=[7,9,12,14,18,21,24,24,21,16,11,8];
//Salamanca40 41
vTr40=[5,6,8,10,11,12,13,12,11,10,8,5];
vh40=[6.1,9.5,13.5,17.1,19.7,22.8,24.6,22.6,17.5,11.3,7.4,5.2];
vck40=[1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52];
vTa40=[6,7,10,13,16,20,24,23,20,14,9,6];
//Sta.C.Tenerife41 28.5
vTr41=[8,9,11,13,14,15,16,15,14,13,11,8];
vh41=[10.7,13.3,18.1,21.5,25.7,26.5,29.3,26.6,21.2,16.2,10.8,9.3];
vck41=[1.23,1.14,1.01,0.89,0.79,0.75,0.79,0.89,1.04,1.2,1.3,1.3];
vTa41=[19,20,20,21,22,24,26,27,26,25,23,20];
//Segovia42 41
vTr42=[4,5,7,9,10,11,12,11,10,9,7,4];
vh42=[5.7,8.8,13.4,18.4,20.4,22.6,25.7,24.9,18.8,11.4,6.8,5.1];
vck42=[1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52];
vTa42=[4,6,10,12,15,20,24,23,20,14,9,5];
//Sevilla43 37.4
vTr43=[8,9,11,13,14,15,16,15,14,13,11,8];
vh43=[7.3,10.6,14.4,19.2,22.4,24.3,24.9,23,17.9,12.3,8.8,6.9];
vck43=[1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45];
vTa43=[11,13,14,17,21,25,29,29,24,20,16,12];
//Soria44 41.8
vTr44=[4,5,7,9,10,11,12,11,10,9,7,4];
vh44=[5.9,8.7,12.8,17.1,19.7,21.8,24.1,22.3,17.5,11.1,7.6,5.6];
vck44=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa44=[4,6,9,11,14,19,22,22,18,13,8,5];
//Tarragona45 41.1
vTr45=[6,7,9,11,12,13,14,13,12,11,9,6];
vh45=[7.3,10.7,14.9,17.6,20.2,22.5,23.8,20.5,16.4,12.3,8.8,6.3];
vck45=[1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52];
vTa45=[11,12,14,16,19,22,25,26,23,20,15,12];
//Teruel46 40.4
vTr46=[4,5,7,9,10,11,12,11,10,9,7,4];
vh46=[6.1,8.8,12.9,16.7,18.4,20.6,21.8,20.7,16.9,11,7.1,5.3];
vck46=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5];
vTa46=[5,6,9,12,16,20,23,24,19,14,9,6];
//Toledo47 39.9
vTr47=[6,7,9,11,12,13,14,13,12,11,9,6];
vh47=[6.2,9.5,14,19.3,21,24.4,27.2,24.5,18.1,11.9,7.6,5.6];
vck47=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5];
vTa47=[7,9,13,15,19,24,28,27,23,17,12,8];
//Valencia48 39.5 39
vTr48=[8,9,11,13,14,15,16,15,14,13,11,8];
vh48=[7.2,10.6,14.9,18.1,20.6,22.8,23.8,20.7,16.7,12,8.7,6.6];
vck48=[1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48];
vTa48=[12,13,15,17,20,23,26,27,24,20,16,13];
//Valladolid49 41.7
vTr49=[5,6,8,10,11,12,13,12,11,10,8,5];
vh49=[5.5,8.8,13.9,17.2,19.9,22.6,25.1,23,18.3,11.2,6.9,4.2];
169
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
vck49=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa49=[4,6,9,12,17,21,24,23,18,13,8,4];
//Vizcaya50 43.3
vTr50=[6,7,9,11,12,13,14,13,12,11,9,6];
vh50=[5,7.1,10.8,12.7,15.5,16.7,17.9,15.7,13.1,9.3,6,4.6];
vck50=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vTa50=[10,11,12,13,16,20,22,22,20,16,13,18];
//Zamora51 41.5
vTr51=[5,6,8,10,11,12,13,12,11,10,8,5];
vh51=[5.4,8.9,13.2,17.3,22.2,21.6,23.5,22,17.2,11.1,6.7,4.6];
vck51=[1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52];
vTa51=[6,7,11,13,16,21,24,23,20,15,10,6];
//Zaragoza52 41.7
vTr52=[5,6,8,10,11,12,13,12,11,10,8,5];
vh52=[6.3,9.8,15.2,18.3,21.8,24.2,25.1,23.4,18.3,12.1,7.4,5.7];
vck52=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vTa52=[8,10,13,16,19,23,26,26,23,17,12,9];
//---------------------------/*inclinación 35º--------------------------------------------------------------------------------*/
/*43º*/ vcki35p1=[1.41,1.31,1.2,1.09,1.01,0.98,1.01,1.1,1.25,1.42,1.52,1.5];
vcki35p5=vcki35p1;vcki35p13=vcki35p1;vcki35p18=vcki35p1;vcki35p23=vcki35p1;
vcki35p27=vcki35p1;vcki35p29=vcki35p1;vcki35p34=vcki35p1;vcki35p50=vcki35p1;
/*39º*/vcki35p2=[1.35,1.27,1.16,1.05,0.97,0.94,0.98,1.06,1.2,1.35,1.45,1.43];
vcki35p7=vcki35p2;vcki35p16=vcki35p2;vcki35p48=vcki35p2;
/*38º*/vcki35p3=[1.34,1.25,1.15,1.04,0.96,0.94,0.97,1.05,1.19,1.34,1.43,1.42];
vcki35p17=vcki35p3;vcki35p26=vcki35p3;vcki35p33=vcki35p3;
/*37º*/vcki35p4=[1.33,1.24,1.14,1.03,0.96,0.93,0.96,1.04,1.17,1.32,1.42,1.41];
vcki35p12=vcki35p4;vcki35p21=vcki35p4;vcki35p24=vcki35p4;vcki35p31=vcki35p4;
vcki35p43=vcki35p4;
/*41º*/ vcki35p6=[1.38,1.29,1.18,1.07,0.99,0.96,0.99,1.08,1.22,1.38,1.49,1.47];
vcki35p9=vcki35p6;vcki35p22=vcki35p6;vcki35p40=vcki35p6;vcki35p42=vcki35p6;
vcki35p45=vcki35p6;vcki35p51=vcki35p6;
/*40º*/ vcki35p8=[1.37,1.28,1.17,1.06,0.98,0.95,0.98,1.07,1.21,1.37,1.47,1.45];
vcki35p11=vcki35p8;vcki35p14=vcki35p8;vcki35p19=vcki35p8;
vcki35p30=vcki35p8;vcki35p46=vcki35p8;vcki35p47=vcki35p8;
/*42º*/vcki35p10=[1.39,1.3,1.19,1.08,1,0.97,1,1.09,1.23,1.4,1.51,1.48];
vcki35p28=vcki35p10;vcki35p44=vcki35p10;vcki35p20=vcki35p10;vcki35p25=vcki35p10;
vcki35p35=vcki35p10;vcki35p36=vcki35p10;vcki35p38=vcki35p10;vcki35p39=vcki35p10;
vcki35p49=vcki35p10;vcki35p52=vcki35p10;
/*36º*/vcki35p15=[1.32,1.23,1.13,1.02,0.95,0.92,0.95,1.03,1.16,1.31,1.4,1.39];
/*35º*/vcki35p32=[1.31,1.22,1.12,1.02,0.94,0.91,0.94,1.02,1.15,1.29,1.39,1.38];
/*28º*/ vcki35p37=[1.23,1.16,1.06,0.96,0.88,0.85,0.88,0.96,1.08,1.21,1.29,1.29];
vcki35p41=vcki35p37;
/*inclinación 40º--------------------------------------------------------------------------------*/
/*43º*/vcki40p1=[1.43,1.33,1.2,1.07,0.98,0.95,0.98,1.09,1.25,1.44,1.56,1.54];
vcki40p5=vcki40p1;vcki40p13=vcki40p1;vcki40p18=vcki40p1;vcki40p23=vcki40p1;
vcki40p27=vcki40p1;vcki40p29=vcki40p1;vcki40p34=vcki40p1;vcki40p50=vcki40p1;
/*39º*/vcki40p2=[1.37,1.27,1.15,1.03,0.94,0.91,0.94,1.04,1.19,1.37,1.48,1.46];
vcki40p7=vcki40p2;vcki40p16=vcki40p2;vcki40p48=vcki40p2;
/*38º*/vcki40p3=[1.36,1.26,1.14,1.02,0.93,0.9,0.93,1.03,1.18,1.35,1.46,1.45];
vcki40p17=vcki40p3;vcki40p26=vcki40p3;vcki40p33=vcki40p3;
/*37º*/vcki40p4=[1.35,1.25,1.13,1.01,0.92,0.89,0.92,1.02,1.17,1.34,1.44,1.43];
170
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
vcki40p12=vcki40p4;vcki40p21=vcki40p4;vcki40p24=vcki40p4;vcki40p31=vcki40p4;
vcki40p43=vcki40p4;
/*41º*/vcki40p6=[1.4,1.3,1.18,1.05,0.96,0.93,0.96,1.06,1.22,1.4,1.52,1.5];
vcki40p9=vcki40p6;vcki40p22=vcki40p6;vcki40p40=vcki40p6;vcki40p42=vcki40p6;
vcki40p45=vcki40p6;vcki40p51=vcki40p6;
/*40º*/vcki40p8=[1.39,1.29,1.16,1.04,0.95,0.92,0.95,1.05,1.21,1.39,1.5,1.48];
vcki40p11=vcki40p8;vcki40p14=vcki40p8;vcki40p19=vcki40p8;
vcki40p30=vcki40p8;vcki40p46=vcki40p8;vcki40p47=vcki40p8;
/*42º*/vcki40p10=[1.42,1.31,1.19,1.06,0.97,0.94,0.97,1.08,1.24,1.42,1.54,1.52];
vcki40p28=vcki40p10;vcki40p44=vcki40p10;vcki40p20=vcki40p10;vcki40p25=vcki40p10;
vcki40p35=vcki40p10;vcki40p36=vcki40p10;vcki40p38=vcki40p10;vcki40p39=vcki40p10;
vcki40p49=vcki40p10;vcki40p52=vcki40p10;
/*36º*/vcki40p15=[1.33,1.24,1.12,1,0.91,0.88,0.91,1.01,1.16,1.32,1.43,1.41];
/*35º*/vcki40p32=[1.32,1.23,1.11,0.99,0.9,0.87,0.9,1,1.14,1.3,1.41,1.4];
/*28º*/ vcki40p37=[1.24,1.15,1.04,0.92,0.85,0.8,0.84,0.93,1.06,1.21,1.3,1.3];
vcki40p41=vcki40p37;
/*Inclinación 45º---------------------------------------------------------------------------*/
/*43º*/ vcki45p1=[1.45,1.33,1.19,1.05,0.95,0.91,0.95,1.06,1.24,1.45,1.59,1.57];
vcki45p5=vcki45p1;vcki45p13=vcki45p1;vcki45p18=vcki45p1;vcki45p23=vcki45p1;
vcki45p27=vcki45p1;vcki45p29=vcki45p1;vcki45p34=vcki45p1;vcki45p50=vcki45p1;
/*39º*/ vcki45p2=[1.38,1.27,1.14,1,0.9,0.87,0.9,1.01,1.18,1.37,1.5,1.48];
vcki45p7=vcki45p2;vcki45p16=vcki45p2;vcki45p48=vcki45p2;
/*38º*/ vcki45p3=[1.37,1.26,1.13,0.99,0.89,0.86,0.89,1,1.17,1.36,1.48,1.47];
vcki45p17=vcki45p3;vcki45p26=vcki45p3;vcki45p33=vcki45p3;
/*37º*/ vcki45p4=[1.35,1.25,1.11,0.98,0.88,0.85,0.88,0.99,1.15,1.34,1.46,1.45];
vcki45p12=vcki45p4;vcki45p21=vcki45p4;vcki45p24=vcki45p4;vcki45p31=vcki45p4;
vcki45p43=vcki45p4;
/*41º*/ vcki45p6=[1.42,1.3,1.16,1.03,0.93,0.89,0.93,1.04,1.21,1.41,1.55,1.52];
vcki45p9=vcki45p6;vcki45p22=vcki45p6;vcki45p40=vcki45p6;vcki45p42=vcki45p6;
vcki45p45=vcki45p6;vcki45p51=vcki45p6;
/*40º*/ vcki45p8=[1.4,1.29,1.15,1.01,0.91,0.88,0.92,1.03,1.2,1.39,1.52,1.5];
vcki45p11=vcki45p8;vcki45p14=vcki45p8;vcki45p19=vcki45p8;
vcki45p30=vcki45p8;vcki45p46=vcki45p8;vcki45p47=vcki45p8;
/*42º*/ vcki45p10=[1.43,1.32,1.18,1.04,0.94,0.9,0.94,1.05,1.23,1.43,1.57,1.54];
vcki45p28=vcki45p10;vcki45p44=vcki45p10;vcki45p20=vcki45p10;vcki45p25=vcki45p10;
vcki45p35=vcki45p10;vcki45p36=vcki45p10;vcki45p38=vcki45p10;vcki45p39=vcki45p10;
vcki45p49=vcki45p10;vcki45p52=vcki45p10;
/*36º*/ vcki45p15=[1.34,1.23,1.1,0.97,0.87,0.87,0.84,0.87,0.98,1.14,1.32,1.44,1.43];
/*35º*/ vcki45p32=[1.33,1.22,1.09,0.96,0.86,0.82,0.86,0.97,1.13,1.3,1.42,1.41];
/*28º*/ vcki45p37=[1.23,1.14,1.01,0.89,0.79,0.75,0.79,0.89,1.04,1.2,1.3,1.3];
vcki45p41=vcki45p37;
/*Inclinación 50º-----------------------------------------------------------------------------*/
/*43º*/ vcki50p1=[1.46,1.33,1.17,1.02,0.91,0.87,0.91,1.03,1.23,1.46,1.61,1.58];
vcki50p5=vcki50p1;vcki50p13=vcki50p1;vcki50p18=vcki50p1;vcki50p23=vcki50p1;
vcki50p27=vcki50p1;vcki50p29=vcki50p1;vcki50p34=vcki50p1;vcki50p50=vcki50p1;
/*39º*/ vcki50p2=[1.39,1.26,1.12,0.97,0.86,0.82,0.86,0.98,1.16,1.37,1.51,1.5];
vcki50p7=vcki50p2;vcki50p16=vcki50p2;vcki50p48=vcki50p2;
/*38º*/ vcki50p3=[1.37,1.25,1.1,0.96,0.85,0.81,0.85,0.97,1.15,1.35,1.49,1.48];
171
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
vcki50p17=vcki50p3;vcki50p26=vcki50p3;vcki50p33=vcki50p3;
/*37º*/ vcki50p4=[1.35,1.24,1.09,0.94,0.84,0.8,0.84,0.95,1.13,1.33,1.47,1.46];
vcki50p12=vcki50p4;vcki50p21=vcki50p4;vcki50p24=vcki50p4;vcki50p31=vcki50p4;
vcki50p43=vcki50p4;
/*41º*/ vcki50p6=[1.42,1.3,1.14,0.99,0.88,0.84,0.88,1.01,1.19,1.41,1.41,1.56,1.54];
vcki50p9=vcki50p6;vcki50p22=vcki50p6;vcki50p40=vcki50p6;vcki50p42=vcki50p6;
vcki50p45=vcki50p6;vcki50p51=vcki50p6;
/*40º*/ vcki50p8=[1.41,1.28,1.13,0.98,0.87,0.83,0.87,0.99,1.18,1.39,1.54,1.52];
vcki50p11=vcki50p8;vcki50p14=vcki50p8;vcki50p19=vcki50p8;
vcki50p30=vcki50p8;vcki50p46=vcki50p8;vcki50p47=vcki50p8;
/*42º*/ vcki50p10=[1.44,1.31,1.16,1,0.89,0.86,0.9,1.02,1.21,1.44,1.59,1.56];
vcki50p28=vcki50p10;vcki50p44=vcki50p10;vcki50p20=vcki50p10;vcki50p25=vcki50p10;
vcki50p35=vcki50p10;vcki50p36=vcki50p10;vcki50p38=vcki50p10;vcki50p39=vcki50p10;
vcki50p49=vcki50p10;vcki50p52=vcki50p10;
/*36º*/ vcki50p15=[1.34,1.22,1.08,0.93,0.82,0.78,0.82,0.94,1.12,1.31,1.45,1.44];
/*35º*/ vcki50p32=[1.32,1.21,1.07,0.92,0.81,0.77,0.81,0.93,1.1,1.3,1.43,1.42];
/*28º*/ vcki50p37=[1.22,1.12,0.98,0.73,0.69,0.73,0.84,1,1.18,1.3,1.3];
vcki50p41=vcki50p37;
/*inclinación 55º--------------------------------------------------------------------------------*/
/*43º*/ vcki55p1=[1.46,1.32,1.15,0.98,0.86,0.82,0.86,1,1.21,1.45,1.62,1.59];
vcki55p5=vcki55p1;vcki55p13=vcki55p1;vcki55p18=vcki55p1;vcki55p23=vcki55p1;
vcki55p27=vcki55p1;vcki55p29=vcki55p1;vcki55p34=vcki55p1;vcki55p50=vcki55p1;
/*39º*/ vcki55p2=[1.38,1.25,1.09,0.93,0.81,0.77,0.81,0.94,1.13,1.36,1.51,1.5];
vcki55p7=vcki55p2;vcki55p16=vcki55p2;vcki55p48=vcki55p2;
/*38º*/ vcki55p3=[1.36,1.23,1.07,0.91,0.8,0.75,0.8,0.92,1.12,1.34,1.49,1.48];
vcki55p17=vcki55p3;vcki55p26=vcki55p3;vcki55p33=vcki55p3;
/*37º*/ vcki55p4=[1.35,1.22,1.06,0.9,0.78,0.74,0.78,0.91,1.1,1.32,1.47,1.45];
vcki55p12=vcki55p4;vcki55p21=vcki55p4;vcki55p24=vcki55p4;vcki55p31=vcki55p4;
vcki55p43=vcki55p4;
/*41º*/ vcki55p6=[1.42,1.28,1.12,0.95,0.83,0.79,0.84,0.97,1.17,1.41,1.57,1.54];
vcki55p9=vcki55p6;vcki55p22=vcki55p6;vcki55p40=vcki55p6;vcki55p42=vcki55p6;
vcki55p45=vcki55p6;vcki55p51=vcki55p6;
/*40º*/ vcki55p8=[1.4,1.27,1.1,0.94,0.82,0.78,0.82,0.95,1.15,1.38,1.54,1.52];
vcki55p11=vcki55p8;vcki55p14=vcki55p8;vcki55p19=vcki55p8;
vcki55p30=vcki55p8;vcki55p46=vcki55p8;vcki55p47=vcki55p8;
/*42º*/ vcki55p10=[1.44,1.3,1.13,0.97,0.85,0.8,0.85,0.98,1.19,1.43,1.59,1.57];
vcki55p28=vcki55p10;vcki55p44=vcki55p10;vcki55p20=vcki55p10;vcki55p25=vcki55p10;
vcki55p35=vcki55p10;vcki55p36=vcki55p10;vcki55p38=vcki55p10;vcki55p39=vcki55p10;
vcki55p49=vcki55p10;vcki55p52=vcki55p10;
/*36º*/ vcki55p15=[1.33,1.2,1.05,0.89,0.77,0.73,0.77,0.9,1.08,1.3,1.44,1.43];
/*35º*/ vcki55p32=[1.31,1.19,1.03,0.87,0.76,0.72,0.76,0.88,1.07,1.28,1.42,1.41];
/*28º*/ vcki55p37=[1.2,1.09,0.94,0.79,0.68,0.63,0.67,0.79,0.96,1.15,1.28,1.28];
vcki55p41=vcki55p37;
/*inclinación 60º--------------------------------------------------------------------------------*/
/*43º*/ vcki60p1=[1.45,1.3,1.12,0.94,0.81,0.76,0.81,0.95,1.17,1.44,1.62,1.59];
vcki60p5=vcki60p1;vcki60p13=vcki60p1;vcki60p18=vcki60p1;vcki60p23=vcki60p1;
vcki60p27=vcki60p1;vcki60p29=vcki60p1;vcki60p34=vcki60p1;vcki60p50=vcki60p1;
/*39º*/ vcki60p2=[1.37,1.22,1.05,0.88,0.75,0.71,0.75,0.89,1.1,1.34,1.51,1.49];
vcki60p7=vcki60p2;vcki60p16=vcki60p2;vcki60p48=vcki60p2;
172
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
/*38º*/ vcki60p3=[1.35,1.21,1.04,0.86,0.74,0.69,0.74,0.87,1.08,1.32,1.48,1.47];
vcki60p17=vcki60p3;vcki60p26=vcki60p3;vcki60p33=vcki60p3;
/*37º*/ vcki60p4=[1.33,1.19,1.02,0.85,0.73,0.68,0.73,0.86,1.06,1.3,1.45,1.44];
vcki60p12=vcki60p4;vcki60p21=vcki60p4;vcki60p24=vcki60p4;vcki60p31=vcki60p4;
vcki60p43=vcki60p4;
/*41º*/ vcki60p6=[1.41,1.26,1.08,0.91,0.78,0.73,0.78,0.92,1.14,1.39,1.56,1.54];
vcki60p9=vcki60p6;vcki60p22=vcki60p6;vcki60p40=vcki60p6;vcki60p42=vcki60p6;
vcki60p45=vcki60p6;vcki60p51=vcki60p6;
/*40º*/vcki60p8=[1.39,1.24,1.07,0.89,0.77,0.72,0.77,0.9,1.12,1.36,1.53,1.51];
vcki60p11=vcki60p8;vcki60p14=vcki60p8;vcki60p19=vcki60p8;
vcki60p30=vcki60p8;vcki60p46=vcki60p8;vcki60p47=vcki60p8;
/*42º*/vcki60p10=[1.43,1.28,1.1,0.92,0.79,0.75,0.8,0.93,1.15,1.41,1.59,1.57];
vcki60p28=vcki60p10;vcki60p44=vcki60p10;vcki60p20=vcki60p10;vcki60p25=vcki60p10;
vcki60p35=vcki60p10;vcki60p36=vcki60p10;vcki60p38=vcki60p10;vcki60p39=vcki60p10;
vcki60p49=vcki60p10;vcki60p52=vcki60p10;
/*36º*/vcki60p15=[1.31,1.17,1.01,0.84,0.71,0.67,0.71,0.84,1.05,1.27,1.43,1.42];
/*35º*/ vcki60p32=[1.29,1.16,0.99,0.82,0.7,0.66,0.7,0.83,1.03,1.25,1.41,1.4];
/*28º*/ vcki60p37=[1.18,1.05,0.9,0.73,0.61,0.57,0.61,0.73,0.92,1.12,1.26,1.26];
vcki60p41=vcki60p37;
//-----------------------------
var vTr=[vTr1,vTr2,vTr3,vTr4,vTr5,vTr6,vTr7,vTr8,vTr9,vTr10,
vTr11,vTr12,vTr13,vTr14,vTr15,vTr16,vTr17,vTr18,vTr19,vTr20,
vTr21,vTr22,vTr23,vTr24,vTr25,vTr26,vTr27,vTr28,vTr29,vTr30,
vTr31,vTr32,vTr33,vTr34,vTr35,vTr36,vTr37,vTr38,vTr39,vTr40,
vTr41,vTr42,vTr43,vTr44,vTr45,vTr46,vTr47,vTr48,vTr49,vTr50,vTr51,vTr52];
var vh=[vh1,vh2,vh3,vh4,vh5,vh6,vh7,vh8,vh9,vh10,
vh11,vh12,vh13,vh14,vh15,vh16,vh17,vh18,vh19,vh20,
vh21,vh22,vh23,vh24,vh25,vh26,vh27,vh28,vh29,vh30,
vh31,vh32,vh33,vh34,vh35,vh36,vh37,vh38,vh39,vh40,
vh41,vh42,vh43,vh44,vh45,vh46,vh47,vh48,vh49,vh50,vh51,vh52];
var vTa=[vTa1,vTa2,vTa3,vTa4,vTa5,vTa6,vTa7,vTa8,vTa9,vTa10,
vTa11,vTa12,vTa13,vTa14,vTa15,vTa16,vTa17,vTa18,vTa19,vTa20,
vTa21,vTa22,vTa23,vTa24,vTa25,vTa26,vTa27,vTa28,vTa29,vTa30,
vTa31,vTa32,vTa33,vTa34,vTa35,vTa36,vTa37,vTa38,vTa39,vTa40,
vTa41,vTa42,vTa43,vTa44,vTa45,vTa46,vTa47,vTa48,vTa49,vTa50,vTa51,vTa52];
//Vector de vectores, cada uno corresponde a un lugar
var vck=[vck1,vck2,vck3,vck4,vck5,vck6,vck7,vck8,vck9,vck10,
vck11,vck12,vck13,vck14,vck15,vck16,vck17,vck18,vck19,vck20,
vck21,vck22,vck23,vck24,vck25,vck26,vck27,vck28,vck29,vck30,
vck31,vck32,vck33,vck34,vck35,vck36,vck37,vck38,vck39,vck40,
vck41,vck42,vck43,vck44,vck45,vck46,vck47,vck48,vck49,vck50,vck51,vck52];
//Vector de vectores para inclinación de 35º
var v35=[vcki35p1,vcki35p2,vcki35p3,vcki35p4,vcki35p5,vcki35p6,vcki35p7,vcki35p8,vcki35p9,
vcki35p10,vcki35p11,vcki35p12,vcki35p13,vcki35p14,vcki35p15,vcki35p16,vcki35p17,vcki35p18,
vcki35p19,vcki35p20,vcki35p21,vcki35p22,vcki35p23,vcki35p24,vcki35p25,vcki35p26,vcki35p27,
vcki35p28,vcki35p29,vcki35p30,vcki35p31,vcki35p32,vcki35p33,vcki35p34,vcki35p35,vcki35p36,
173
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
vcki35p37,vcki35p38,vcki35p39,vcki35p40,vcki35p41,vcki35p42,vcki35p43,vcki35p44,vcki35p45,
vcki35p46,vcki35p47,vcki35p48,vcki35p49,vcki35p50,vcki35p51,vcki35p52];
//Vector de vectores para inclinación de 40º
var v40=[vcki40p1,vcki40p2,vcki40p3,vcki40p4,vcki40p5,vcki40p6,vcki40p7,vcki40p8,vcki40p9,
vcki40p10,vcki40p11,vcki40p12,vcki40p13,vcki40p14,vcki40p15,vcki40p16,vcki40p17,vcki40p18,
vcki40p19,vcki40p20,vcki40p21,vcki40p22,vcki40p23,vcki40p24,vcki40p25,vcki40p26,vcki40p27,
vcki40p28,vcki40p29,vcki40p30,vcki40p31,vcki40p32,vcki40p33,vcki40p34,vcki40p35,vcki40p36,
vcki40p37,vcki40p38,vcki40p39,vcki40p40,vcki40p41,vcki40p42,vcki40p43,vcki40p44,vcki40p45,
vcki40p46,vcki40p47,vcki40p48,vcki40p49,vcki40p50,vcki40p51,vcki40p52];
//Vector de vectores para inclinación de 45º
var v45=[vcki45p1,vcki45p2,vcki45p3,vcki45p4,vcki45p5,vcki45p6,vcki45p7,vcki45p8,vcki45p9,
vcki45p10,vcki45p11,vcki45p12,vcki45p13,vcki45p14,vcki45p15,vcki45p16,vcki45p17,vcki45p18,
vcki45p19,vcki45p20, vcki45p21,vcki45p22,vcki45p23,vcki45p24,vcki45p25,vcki45p26, vcki45p27,
vcki45p28,vcki45p29,vcki45p30,vcki45p31,vcki45p32,vcki45p33,vcki45p34,vcki45p35, vcki45p36,
vcki45p37,vcki45p38,vcki45p39,vcki45p40,vcki45p41,vcki45p42,vcki45p43,vcki45p44, vcki45p45,
vcki45p46,vcki45p47,vcki45p48,vcki45p49,vcki45p50,vcki45p51,vcki45p52];
//Vector de vectores para inclinación de 50º
var v50=[vcki50p1,vcki50p2,vcki50p3,vcki50p4,vcki50p5,vcki50p6,vcki50p7,vcki50p8,vcki50p9,
vcki50p10,vcki50p11,vcki50p12,vcki50p13,vcki50p14,vcki50p15,vcki50p16,vcki50p17,vcki50p18,
vcki50p19,vcki50p20,vcki50p21,vcki50p22,vcki50p23,vcki50p24,vcki50p25,vcki50p26,vcki50p27,
vcki50p28,vcki50p29,vcki50p30,vcki50p31,vcki50p32,vcki50p33,vcki50p34,vcki50p35,vcki50p36,
vcki50p37,vcki50p38,vcki50p39,vcki50p40,vcki50p41,vcki50p42,vcki50p43,vcki50p44,vcki50p45,
vcki50p46,vcki50p47,vcki50p48,vcki50p49,vcki50p50,vcki50p51,vcki50p52];
//Vector de vectores para inclinación de 55º
var v55=[vcki55p1,vcki55p2,vcki55p3,vcki55p4,vcki55p5,vcki55p6,vcki55p7,vcki55p8,vcki55p9,
vcki55p10,vcki55p11,vcki55p12,vcki55p13,vcki55p14,vcki55p15,vcki55p16,vcki55p17,vcki55p18,
vcki55p19,vcki55p20,vcki55p21,vcki55p22,vcki55p23,vcki55p24,vcki55p25,vcki55p26,vcki55p27,
vcki55p28,vcki55p29,vcki55p30,vcki55p31,vcki55p32,vcki55p33,vcki55p34,vcki55p35,vcki55p36,
vcki55p37,vcki55p38,vcki55p39,vcki55p40,vcki55p41,vcki55p42,vcki55p43,vcki55p44,vcki55p45,
vcki55p46,vcki55p47,vcki55p48,vcki55p49,vcki55p50,vcki55p51,vcki55p52];
//Vector de vectores para inclinación de 60º
var v60=[vcki60p1,vcki60p2,vcki60p3,vcki60p4,vcki60p5,vcki60p6,vcki60p7,vcki60p8,vcki60p9,
vcki60p10,vcki60p11,vcki60p12,vcki60p13,vcki60p14,vcki60p15,vcki60p16,vcki60p17,vcki60p18,
vcki60p19,vcki60p20,vcki60p21,vcki60p22,vcki60p23,vcki60p24,vcki60p25,vcki60p26,vcki60p27,
vcki60p28,vcki60p29,vcki60p30,vcki60p31,vcki60p32,vcki60p33,vcki60p34,vcki60p35,vcki60p36,
vcki60p37,vcki60p38,vcki60p39,vcki60p40,vcki60p41,vcki60p42,vcki60p43,vcki60p44,vcki60p45,
vcki60p46,vcki60p47,vcki60p48,vcki60p49,vcki60p50,vcki60p51,vcki60p52];
//-----------------var vSalto=new Array(12);var Tuso;
var vDemandaTermiasmes=new Array(12);
var vDemandaMJmes=new Array(12);
var vHcor=new Array(12);
var CorH;//CorH 1.05 para atmósfera muy limpias//CorH 0.95 para atmósfera contaminada
var vE=new Array(12);
var vI=new Array(12);
var vRendimiento=new Array(12);
var Corb;var bcol;var mcol;
var DesNS;//no interviene pero la indicamos
/*DesNS=0;CorH=1.05;PerdGlo=0.15;NumUsu=32;LitrosDia=40;
174
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
Acol=2.01;bcol=0.83;mcol=4.8;Tuso=45;Corb=0.94;Preciokwh=0.12;*/
var vAportacion=new Array(12);
var ASR=new Array(12);
var vENDdia=new Array(12); var PerdGlo; var vENDmes=new Array(12);
var ENDanualM2;var DemandaAnual;
var SCteorica;var NCteorico; var Acol;var SCresultante; var NCrecomendado;
var vENTotalmes=new Array(12);
var vSustitucion=new Array(12);
var vDeficit=new Array(12);
var vCobertura=new Array(12);
var deficitEnergeticoAnual;
var aportacionAnual;
var vCEmes=new Array(12); var Preciokwh=0.12;var CEanual;//coste total de la demanda
var vCAuxmes=new Array(12);var CAuxAnual;//coste de la energía auxiliar
var vAhorromes=new Array(12);var AhorroAnual;
var ConsumoanualACSm3;var NumDiasAnual;
var ConsumoanualACSm3;var NumDiasAnual;
var VolAcuM2;var VolAcuTeorico;var PruebaSC;var VolAcuProyecto;var PruebaVolAcu;
var CSC;var CVA;//comprobaciones superficie y volumen
//-------------------------------------------------------------------------
//ELEMENTOS DEL HTML
//combos
var comboinclina=document.getElementById("comboinclina");
var comboTuso=document.getElementById("comboTuso");
var combopaneles=document.getElementById("combopaneles");
var comboacumula=document.getElementById("comboacumula");
var combovariaocu=document.getElementById("combovariaocu");
var combovariaLD=document.getElementById("combovariaLD");
var combovariaNU=document.getElementById("combovariaNU");
var combovariaAcol=document.getElementById("combovariaAcol");
var combovariaBcol=document.getElementById("combovariaBcol");
var combovariaMcol=document.getElementById("combovariaMcol");
var combovariaCorH=document.getElementById("combovariaCorH");
var combovariaCorb=document.getElementById("combovariaCorb");
var combovariaPG=document.getElementById("combovariaPG");
var combovariaDNS=document.getElementById("combovariaDNS");
var combovariaCE=document.getElementById("combovariaCE");
var combovariaMAI=document.getElementById("combovariaMAI");
var combovariaFCCI=document.getElementById("combovariaFCCI");
var combovariaTmin=document.getElementById("combovariaTmin");
//-----------//panel resumen lateral
var resumeDA=document.getElementById("resumeDA");
var resumeEAm2=document.getElementById("resumeEAm2");
var resumeSUP=document.getElementById("resumeSUP");
var resumeNC=document.getElementById("resumeNC");
175
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
var resumeCACS=document.getElementById("resumeCACS");
var resumeApor=document.getElementById("resumeApor");
var resumeDef=document.getElementById("resumeDef");
var resumeCos=document.getElementById("resumeCos");
var resumeCosDef=document.getElementById("resumeCosDef");
var resumeAho=document.getElementById("resumeAho");
var resumeSupfinal=document.getElementById("resumeSupfinal");
var resumeAcu=document.getElementById("resumeAcu");
var resumebcol=document.getElementById("resumebcol");
var resumemcol=document.getElementById("resumemcol");
var resumeFCCI=document.getElementById("resumeFCCI");
var resumeVMprueba=document.getElementById("resumeVMprueba");
var resumeCAprueba=document.getElementById("resumeCAprueba");
//--------------------------------------------------------------//FUNCIONES
function llenarCombo(){
var i=0;var j=0;
var listado="";
for(i=0;i<provincia.length;i++){
np=i;
listado+="<option value='"+np+"'>"+provincia[i]+"</option>";
}comboprov.innerHTML=listado;
var inclinaciones="";
for(j=0;j<inclina.length;j++){
ni=j;
inclinaciones+="<option value='"+ni+"'>"+inclina[j]+"</option>";
}comboinclina.innerHTML=inclinaciones;
var temperaturas="";
for(j=0;j<vTuso.length;j++){
nt=j;
temperaturas+="<option value='"+nt+"'>"+vTuso[j]+"</option>";
}comboTuso.innerHTML=temperaturas;
var pan="";
for(j=0;j<vPaneles.length;j++){
np=j;
pan+="<option value='"+np+"'>"+vPaneles[j]+"</option>";
}combopaneles.innerHTML=pan;
var Voa="";
for(j=0;j<vVolacu.length;j++){
nv=j;
Voa+="<option value='"+nv+"'>"+vVolacu[j]+"</option>";
}comboacumula.innerHTML=Voa;
var LD="";
for(j=0;j<vectorlitro.length;j++){
nl=j;
LD+="<option value='"+nl+"'>"+vectorlitro[j]+"</option>";
}combovariaLD.innerHTML=LD;
var OCU="";
var vectorocu=[100,90,80,75,70,60,50,40,30,25,20,10,5];
for(j=0;j<vectorocu.length;j++){
no=j;
176
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
OCU+="<option value='"+no+"'>"+vectorocu[j]+"</option>";
}combovariaocu.innerHTML=OCU;
var NUS="";
for(j=0;j<vectornus.length;j++){
nu=j;
NUS+="<option value='"+nu+"'>"+vectornus[j]+"</option>";
}combovariaNU.innerHTML=NUS;
var ACO="";
for(j=0;j<vectorAcol.length;j++){
nac=j;
ACO+="<option value='"+nac+"'>"+vectorAcol[j]+"</option>";
}combovariaAcol.innerHTML=ACO;
var bCO="";
for(j=0;j<vectorBcol.length;j++){
nbc=j;
bCO+="<option value='"+nbc+"'>"+vectorBcol[j]+"</option>";
}combovariaBcol.innerHTML=bCO;
var mCO="";
for(j=0;j<vectorMcol.length;j++){
nmc=j;
mCO+="<option value='"+nmc+"'>"+vectorMcol[j]+"</option>";
}combovariaMcol.innerHTML=mCO;
var cH="";
for(j=0;j<vectorCorH.length;j++){
ch=j;
cH+="<option value='"+ch+"'>"+vectorCorH[j]+"</option>";
}combovariaCorH.innerHTML=cH;
var cB="";
for(j=0;j<vectorCorb.length;j++){ cb=j;
cB+="<option value='"+cb+"'>"+vectorCorb[j]+"</option>";
}combovariaCorb.innerHTML=cB;
var PG="";
for(j=0;j<vectorPG.length;j++){
pg=j;
PG+="<option value='"+pg+"'>"+vectorPG[j]+"</option>";
}combovariaPG.innerHTML=PG;
var DNS="";
for(j=0;j<vectorDNS.length;j++){
dns=j;
DNS+="<option value='"+dns+"'>"+vectorDNS[j]+"</option>";
}combovariaDNS.innerHTML=DNS;
var CE="";
for(j=0;j<vectorCE.length;j++){
ce=j;
CE+="<option value='"+ce+"'>"+vectorCE[j]+"</option>";
}combovariaCE.innerHTML=CE;
var mai="";
for(j=0;j<vectorMAI.length;j++){
ma=j;
mai+="<option value='"+ma+"'>"+vectorMAI[j]+"</option>";
}combovariaMAI.innerHTML=mai;
var fci="";
for(j=0;j<vectorFCCI.length;j++){
177
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
fc=j;
fci+="<option value='"+fc+"'>"+vectorFCCI[j]+"</option>";
}combovariaFCCI.innerHTML=fci;
var TM="";
for(j=0;j<vectorTmin.length;j++){
tm=j;
TM+="<option value='"+tm+"'>"+vectorTmin[j]+"</option>";
}combovariaTmin.innerHTML=TM;
}
function selecionaProvincia(){
var texto=lista.options[lista.selectedIndex].text;
lugar=texto;
etilocal.innerHTML="Cálculos para ACS en: "+lugar+" ";
contaprovincia++;
}
function BuscaDatosLatitud(nom){
42,37.2,40.6,43.3,37.3,42.1,37.8,42.6,41.7,43,40.4,36.7,35.3,38,42.8,42.3,42,28.2,42.4,42.5,41,28.5,
41,37.4,41.8,41.1,40.4,39.9,39.5,41.7,43.3,41.5,41.7];
var TempMinHis=[-18,-23,-5,-1,-11,-21,-6,-4,-20,-18,-6,-2,-4,-8,-1,-10,-6,-9,-21,-11,-13,-14,-12,-6,
-14,-8,-18,-11,-8,-16,-4,-1,-5,-16,-8,-14,+6,-11,-13,-14,-12,-6,-14,-8,-18,-11,-8,-16,-4,-1,-5,-16,-8,
-14,+6,-4,-12,-16,+3,-17,-6,-16,-7,-14,-9,-8,-16,-8,-14,-11];
for(var i=0;i<52;i++){if (nom===provincia[i]){
Altitud=altitud[i];
Latitud=latitud[i];
TempMinHistorica=TempMinHis[i];}}
}
function BuscaDatosMensuales(){
var vd=[31,28,31,30,31,30,31,31,30,31,30,31];
var vHSU=[8,9,9,9.5,9.5,9.5,9.5,9.5,9,9,8,7.5];//para latitudes entre +25º y +45º (hemisferio Norte)
vDias=vd;
//selecciona ocupacion
var vectorocu=[100,90,80,75,70,60,50,40,30,25,20,10,5];
var ocusele=combovariaocu.selectedIndex;
for(var i=0;i<12;i++){vOcupacion[i]=vectorocu[ocusele];}
//selecciona inclinacion
var insele=comboinclina.selectedIndex;
Inclinacion=inclina[insele];
//selecciona tuso
var tusele=comboTuso.selectedIndex;
Tuso=vTuso[tusele];
//selecciona volumen proyecto
var vosele=comboacumula.selectedIndex;
VolAcuProyecto=vVolacu[vosele];
//selecciona Litros dia
178
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
var ldsele=combovariaLD.selectedIndex;
LitrosDia=vectorlitro[ldsele];
//selecciona número de usuarios
var nusele=combovariaNU.selectedIndex;
NumUsu=vectornus[nusele];
//selecciona área del panel
var acsele=combovariaAcol.selectedIndex;
Acol=vectorAcol[acsele];
//selecciona bcol y mcol
var bcsele=combovariaBcol.selectedIndex;
bcol=vectorBcol[bcsele];
var mcsele=combovariaMcol.selectedIndex;
mcol=vectorMcol[mcsele];
//selecciona factor de corrección de H
var chsele=combovariaCorH.selectedIndex;
CorH=vectorCorH[chsele];
//selecciona factor de corrección de b
var cbsele=combovariaCorb.selectedIndex;
Corb=vectorCorb[cbsele];
//selecciona factor de corrección de H
var pgsele=combovariaPG.selectedIndex;
DesNS=vectorDNS[dnssele];
//selecciona calor específico, fchart
var csele=combovariaCE.selectedIndex;
Ce=vectorCE[csele];
//selecciona factor ángulo de incidencia, fchart
var masele=combovariaMAI.selectedIndex;
MAI=vectorMAI[masele];
//selecciona factor intercambiador, fchart
var fcsele=combovariaFCCI.selectedIndex;
FCCI=vectorFCCI[fcsele];
//selecciona temperatura mínima, fchart
var tmsele=combovariaTmin.selectedIndex;
var tmsele=combovariaTmin.selectedIndex;
//Tmin=Tuso;
Tmin=vectorTmin[tmsele];// de momento lo dejaremos como Tmin=tuso
vHorasSolUtil=vHSU;
var vI=[v45,v35,v40,v45,v50,v55,v60];
var pro=lista.selectedIndex;
var inc=comboinclina.selectedIndex;
vTred=vTr[pro];vH=vh[pro];vTamb=vTa[pro];
vki=vck[pro];//factor k para inclinacion de 45º
vCork=vI[inc][pro];//factor k corregido por inclinacion
}
900
901
902
903
904
905
906
907
function BuscaDatos_LatitudAltitudyTempMinima() {
BuscaDatosLatitud(lugar);
altitud.innerHTML="Altitud: "+Altitud;
latitud.innerHTML="Latitud: "+Latitud;
tempminhis.innerHTML="Temperatura mínima histórica: "+TempMinHistorica;
}
function Calcula(){
179
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
BuscaDatosMensuales();
// selecionaInclinacion(); en BuscaDatosMensuales //selecionaTuso(); en BuscaDatosMensuales
Calcula_vConsumo();//ACS
CalculavSalto();
Calcula_vDemandaTermiasmes();
Calcula_vDemandaMJmes();
Calcula_vHcor();
Calcula_vE();
Calcula_vI();
Calcula_vRendimiento();
Calcula_vAportacion();
Calcula_Aportacion_Solar_Relativa();
Calcula_vENDmes();
Calcula_SCteorica();
Calcula_NCteorico();
Calcula_SCresultante();
Calcula_vENTotalmes();
Calcula_vSustitucion();
Calcula_vDeficit();
Calcula_vCobertura();
Calcula_DeficitEnergeticoAnual();
Calcula_aportacionAnual();
Calcula_vCosteEmes();
Calcula_vCosteAuxmes();
Calcula_vAhorromes();
Calcula_ConsumoanualACSm3();
Calcula_NumDiasAnual();
Calcula_VolAcuTeorico();
Calcula_PruebaSC();
Calcula_PruebaVolAcu();
ComprobacionSC();
ComprobacionVolAcu();
}
function DatosMensuales(){
Calcula();
var vmes=["enero ","febrero ","marzo ","abril ","mayo ","junio ","julio ","agosto ","septiembre ",
"octubre ","noviembre ","diciembre "];
var datosmesentabla="<tr ><th>mes</th><th>dias</th><th>m3 ACS</th><th>T amb</th>\n\
<th>horas sol</th><th>T red</th><th>T ACS</th>\n\
<th>salto</th><th>termias</th><th>MJ/mes</th><th>k</th>\n\
<th>Inclina</th><th>k'</th><th>H</th>\n\
<th>corH</th><th>H'</th>\n\
<th>E</th><th>I</th></tr>";
var j=0;
180
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
var conACS=new Array(12);
var vtermias=new Array(12);var vMJmes=new Array(12);var vHc=new Array(12);
var vEn=new Array(12);var vIn=new Array(12);
for(j=0;j<12;j++){
conACS[j]=vConsumo[j].toFixed(2);
vtermias[j]=vDemandaTermiasmes[j].toFixed(2);
vMJmes[j]=vDemandaMJmes[j].toFixed(2);
vHc[j]=vHcor[j].toFixed(2);
vEn[j]=vE[j].toFixed(2);
vIn[j]=vI[j].toFixed(2);
datosmesentabla+="<tr ><td>"+vmes[j]+"</td><td>"+vDias[j]+"</td><td>"+vConsumo[j]+"</td>\n\
<td>"+vTamb[j]+"</td><td>"+vHorasSolUtil[j]+"</td><td>"+vTred[j]+"</td>\n\
<td>"+Tuso+"</td><td>"+vSalto[j]+"</td>\n\
<td>"+vtermias[j]+"</td><td>"+vMJmes[j]+"</td>\n\
<td>"+vki[j]+"</td><td>"+Inclinacion+"</td><td>"+vCork[j]+"</td>\n\
<td>"+vH[j]+"</td><td>"+CorH+"</td><td>"+vHc[j]+"</td>\n\
<td>"+vEn[j]+"</td>\n\
<td>"+vIn[j]+"</td></tr>";
}
tabladatosmes.innerHTML=datosmesentabla;
}
function ResultadosMensuales(){
Calcula();
var vmes=["enero ","febrero ","marzo ","abril ","mayo ","junio ","julio ","agosto ","septiembre ",
"octubre ","noviembre ","diciembre "];
var vCd=new Array(12);var vCa=new Array(12);var vAh=new Array(12);//para presentar 2 decimales
var vCd=new Array(12);var vCa=new Array(12);var vAh=new Array(12);//para presentar 2 decimales
var resultamesentabla="<tr><th>mes</th><th>Rendimiento %</th>\n\
<th>Aportación solar</th><th>ASR</th><th>ENDmes</th>\n\
<th>ENTotal mes</th><th>Sustitución</th><th>Déficit</th>\n\
<th>Cobertura</th><th>Coste €</th><th>Coste Aux €</th>\n\
<th>Ahorro €</th></tr>";
var j=0;
//para resultados en pantalla con 2 decimales y que los cálculos sigan con todos los decimales
var vRend=new Array(12);var vApor=new Array(12);var vAs=new Array(12);
var vEneta=new Array(12);var vEtotal=new Array(12);var vSus=new Array(12);
1000
var vDef=new Array(12);var vCob=new Array(12);
1001
1002
1003
for(j=0;j<12;j++){
1004
vRend[j]=vRendimiento[j].toFixed(2);
1005
vApor[j]=vAportacion[j].toFixed(2);
1006
vAs[j]=ASR[j].toFixed(2);
1007
vEneta[j]=vENDmes[j].toFixed(2);
1008
vEtotal[j]=vENTotalmes[j].toFixed(2);
1009
vSus[j]=vSustitucion[j].toFixed(2);
vDef[j]=vDeficit[j].toFixed(2);
1010
vCob[j]=vCobertura[j].toFixed(2);
1011
vCd[j]=vCEmes[j].toFixed(2);
1012
vCa[j]=vCAuxmes[j].toFixed(2);
1013
vAh[j]=vAhorromes[j].toFixed(2);
1014
181
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
resultamesentabla+="<tr><td>"+vmes[j]+"</td><td>"+vRend[j]+"</td><td>"+vApor[j]+"</td>\n\
<td>"+vAs[j]+"</td><td>"+vEneta[j]+"</td><td>"+vEtotal[j]+"</td>\n\
<td>"+vSus[j]+"</td><td>"+vDef[j]+"</td><td>"+vCob[j]+"</td><td>"+vCd[j]+"</td><td>"+vCa[j]+" </td>\n\
<td>"+vAh[j]+"</td></tr>";
}
tablaresultadosmes.innerHTML=resultamesentabla;
}
function ResultadosMensuales2(){
Calcula();
var vmes=["enero ","febrero ","marzo ","abril ","mayo ","junio ","julio ","agosto ","septiembre ",
"octubre ","noviembre ","diciembre "];
var resultamesentabla2="<tr><th>mes</th><th>Coste €</th><th>Coste Aux €</th>\n\
<th>Ahorro €</th></tr>";
var k=0;
var vCd=new Array(12);var vCa=new Array(12);var vAh=new Array(12);//para presentar 2 decimales
for(k=0;k<12;k++){
vCd[k]=vCEmes[k].toFixed(2);
vCa[k]=vCAuxmes[k].toFixed(2);
vAh[k]=vAhorromes[k].toFixed(2);
resultamesentabla2+="<tr><td>"+vmes[k]+"</td><td>"+vCd[k]+"</td><td>"+vCa[k]+"</td>\n\
<td>"+vAh[k]+"</td></tr>";
}
tablaresultadosmes2.innerHTML=resultamesentabla2;
}
function ResultadosAnuales(){
Calcula();
var resultanualentabla="<tr><th>variable</th><th>resultado</th></tr>";
var variable=["nº días","Consumo m3ACS/año","Demanda energía","Superficie necesaria",
"nº csp necesario","Superficie proyecto","Energía disponible/m2",
"Aportació solar","déficit de energía","Coste demanda €","coste aux €",
"ahorro coste €","litros acumulador necesarios","litros proyecto",
"Comprobación superficie","Comprobación acumulador"];
var pruebaS=PruebaSC.toFixed(2)+" "+CSC;
182
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
var pruebaV=PruebaVolAcu.toFixed(2)+" "+CVA;
//con 2 decimales
var nd=NumDiasAnual.toFixed();//sin decimales
var caACS=ConsumoanualACSm3.toFixed(2);
var da=DemandaAnual.toFixed(2);
var sct=SCteorica.toFixed(2);
var nct=NCteorico.toFixed();//sin decimales
var scr=SCresultante.toFixed(2);
var endm2=ENDanualM2.toFixed(2);
var apa=aportacionAnual.toFixed(2);
var dea=deficitEnergeticoAnual.toFixed(2);
var cea=CEanual.toFixed(2);
var caux=CAuxAnual.toFixed(2);
var aha=AhorroAnual.toFixed(2);
var vat=VolAcuTeorico.toFixed();//sin decimales
var vap=VolAcuProyecto.toFixed();//sin decimales
/*var resultado=[NumDiasAnual,ConsumoanualACSm3,DemandaAnual,SCteorica,NCteorico,SCresultante,
ENDanualM2,aportacionAnual,deficitEnergeticoAnual,CEanual,CAuxAnual,AhorroAnual,
VolAcuTeorico,VolAcuProyecto,pruebaS,pruebaV];*/
var resultado=[nd,caACS,da,sct,nct,scr,endm2,apa,dea,cea,caux,aha,vat,vap,pruebaS,pruebaV];
var a=0;
for(a=0;a<variable.length;a++){
resultanualentabla+="<tr><td>"+variable[a]+"</td><td>"+resultado[a]+"</td></tr>";
}
tablaresultadosanuales.innerHTML=resultanualentabla;
resumeDA.innerHTML=da;
resumeEAm2.innerHTML=endm2;
resumeSUP.innerHTML=sct;
resumeNC.innerHTML=nct;
resumeCACS.innerHTML=caACS;
resumeApor.innerHTML=apa;
resumeDef.innerHTML=dea;
resumeCos.innerHTML=cea;
resumeCosDef.innerHTML=caux;
resumeAho.innerHTML=aha;
resumeSupfinal.innerHTML=scr;
resumeAcu.innerHTML=vap;
resumebcol.innerHTML=bcol;
resumemcol.innerHTML=mcol;
resumeFCCI.innerHTML=FCCI;
resumeVMprueba.innerHTML=pruebaV;
resumeCAprueba.innerHTML=pruebaS;
}
function carga(){
llenarCombo();
}
function Calcula_vConsumo(){
for(i=0;i<12;i++){
vConsumo[i]=(LitrosDia*NumUsu*vDias[i]*vOcupacion[i])/100000;
var vmes=["enero ","febrero ","marzo ","abril ","mayo ","junio ","julio ","agosto ","septiembre ",
183
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
"octubre ","noviembre ","diciembre "];
var vCon="<option>"+vmes[0]+vConsumo[0]+" m3</option>";
for(j=1;j<12;j++){vCon+="<option>"+vmes[j]+vConsumo[j]+" m3</option>";}
}
}
function CalculavSalto(){
var temp=comboTuso.options[comboTuso.selectedIndex].text;
var i=0; //Tuso=temp;
for(i=0;i<12;i++){vSalto[i]=Tuso-vTred[i];}
}
function Calcula_vDemandaTermiasmes(){
var i=0;
for(i=0;i<12;i++){
vSalto[i]=Tuso-vTred[i];
vConsumo[i]=(LitrosDia*NumUsu*vDias[i]*vOcupacion[i])/100000;}
for(i=0;i<12;i++){vDemandaTermiasmes[i]=vConsumo[i]*vSalto[i];//Termias/mes}
}
function Calcula_vDemandaMJmes(){
var i=0;var da=0;
for(i=0;i<12;i++){
vConsumo[i]=(LitrosDia*NumUsu*vDias[i]*vOcupacion[i])/100000;
vSalto[i]=Tuso-vTred[i];
vDemandaMJmes[i]=vConsumo[i]*vSalto[i]*4.184;//MJ/mes
da+=vDemandaMJmes[i];}
DemandaAnual=da;
}
function Calcula_vHcor(){
var i=0;
for(i=0;i<12;i++){
vHcor[i]=vH[i]*CorH; } //CorH 1.05 para atmósfera muy limpias//CorH 0.95 atmósfera contaminada
}
function Calcula_vE(){
Calcula_vHcor();
var i=0;
for(i=0;i<12;i++){
vE[i]=0.94*vCork[i]*vHcor[i];
}
//vE[i]=Corb*vCork[i]*vHcor[i];
//no es corb aunque tenga el mismo valor, el corrección de E al
//considerar perdidas de 6%, factor experimental, por momentos
//en que la intensidad es menor que el valor umbral de de 200w/m2,
}
function Calcula_vI(){
//Calcula_vE();
var i=0;
for(i=0;i<12;i++){
vI[i]=277.778*vE[i]/vHorasSolUtil[i];
}
184
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
}
function Calcula_vRendimiento(){
//Calcula_vI();//con esto calcula I
var i=0;
for(i=0;i<12;i++){
vRendimiento[i]=100*Corb*bcol-100*mcol*(Tuso-vTamb[i])/vI[i];
// if(vRendimiento[i]<20){vRendimiento[i]=0;}
if(vRendimiento[i]<0){vRendimiento[i]=0;}
}
}
function Calcula_vAportacion(){
//Calcula_vRendimiento();//con esto calcula I que calcula E
var i=0;
for(i=0;i<12;i++){
if(vOcupacion[i]>0){vAportacion[i]=vE[i]*vRendimiento[i]/100;}// hemos añadido /100
else{vAportacion[i]=0;}
}
}
function Calcula_Aportacion_Solar_Relativa(){
//Calcula_vAportacion();
var i=0;;var maxApor=0;//var Apor=new Array[12];
for(i=0;i<12;i++){
if(vAportacion[i]>maxApor){maxApor=vAportacion[i];}else{}}
for(i=0;i<12;i++){
ASR[i]=(100*vAportacion[i])/maxApor;}
}
function Calcula_vENDmes(){
var i=0;var anual=0;
for(i=0;i<12;i++){
vENDdia[i]=vAportacion[i]*(1-PerdGlo);}
for(i=0;i<12;i++){
vENDmes[i]=vENDdia[i]*vDias[i];
anual+=vENDmes[i]; }
//anual
ENDanualM2=anual;
}
function Calcula_SCteorica(){
//Calcula_DemandaAnual();//Calcula_ENDanualM2();
SCteorica=DemandaAnual/ENDanualM2;
if(combopaneles.options[0].selected){txtsup.setAttribute("value",SCteorica.toFixed(2));}
}
function Calcula_NCteorico(){
NCteorico=SCteorica/Acol;
var p=combopaneles.options.length;
var i=0;
185
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1225
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
if(combopaneles.options[0].selected){
for(i=0;i<p;i++){
if(combopaneles.options[i].text===NCteorico.toFixed()){combopaneles.options[i].selected=true;}
}}
txtnpa.setAttribute("value",NCteorico.toFixed(2));
}
function Calcula_SCresultante(){
NCrecomendado=combopaneles.options[combopaneles.selectedIndex].text;
//NCrecomendado=SCteorica/Acol;
SCresultante=NCrecomendado*Acol;
txtsup.setAttribute("value",SCresultante.toFixed(2));
}
function Calcula_vENTotalmes(){
//Calcula_vENDmes();//Calcula_SCresultante();
var i=0;
for(i=0;i<12;i++){
vENTotalmes[i]=vENDmes[i]*SCresultante;
}
}
function Calcula_vSustitucion(){
//Calcula_vDemandaMJmes();//Calcula_vENTotalmes();
var i=0;
for(i=0;i<12;i++){
if(vOcupacion[i]===0){vSustitucion[i]=0;}
else{vSustitucion[i]=vENTotalmes[i]/vDemandaMJmes[i];}}}
function Calcula_vDeficit(){
//Calcula_vDemandaMJmes();//Calcula_vENTotalmes();
var i=0;
for(i=0;i<12;i++){
vDeficit[i]=vDemandaMJmes[i]-vENTotalmes[i];
}
}
function Calcula_vCobertura(){
//Calcula_vDeficit();
var i=0;
for(i=0;i<12;i++){
vCobertura[i]=100*(1-vDeficit[i]/vDemandaMJmes[i]);
}
}
function Calcula_DeficitEnergeticoAnual(){
var defi=0;var i=0;
//Calcula_vDeficit();
for(i=0;i<12;i++){
if(vDeficit[i]<0){}else{defi+=vDeficit[i];}
}
deficitEnergeticoAnual=defi;
}
function Calcula_aportacionAnual(){
//Calcula_DemandaAnual();//Calcula_DeficitEnergeticoAnual();
186
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
aportacionAnual=100*(DemandaAnual-deficitEnergeticoAnual)/DemandaAnual;
}
function Calcula_vCosteEmes(){
//Calcula_vDemandaMJmes();//Calcula_vDemandaMJmes();
var i=0;
for(i=0;i<12;i++){
vCEmes[i]=(Preciokwh/3.6)*vDemandaMJmes[i];
}
//anual
CEanual=Preciokwh/3.6*DemandaAnual;
}
function Calcula_vCosteAuxmes(){
//Calcula_vDeficit();
var i=0;
for(i=0;i<12;i++){
if(vDeficit[i]>0){vCAuxmes[i]=Preciokwh/3.6*vDeficit[i];}
else{vCAuxmes[i]=0;}
}
//anual
CAuxAnual=0;
for(i=0;i<12;i++){
CAuxAnual+=vCAuxmes[i];}
}
function Calcula_vAhorromes(){
//Calcula_vCosteEmes();//Calcula_vCosteAuxmes();
var i=0;
for(i=0;i<12;i++){
vAhorromes[i]=vCEmes[i]-vCAuxmes[i];}
AhorroAnual=0;
for(i=0;i<12;i++){AhorroAnual+=vAhorromes[i];}}
function Calcula_ConsumoanualACSm3(){
//Calcula_vConsumo();
ConsumoanualACSm3=0;
var i=0;
for(i=0;i<12;i++){
ConsumoanualACSm3=ConsumoanualACSm3+vConsumo[i];
}
}
function Calcula_NumDiasAnual(){
NumDiasAnual=0;var i=0;
for(i=0;i<12;i++){
NumDiasAnual+=vDias[i]*vOcupacion[i]/100;
}
}
function Calcula_VolAcuTeorico(){
VolAcuM2=70;
//Calcula_SCresultante();//
VolAcuTeorico=SCresultante*VolAcuM2;
txtvol.setAttribute("value",VolAcuTeorico.toFixed(2));
}
187
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
function Calcula_PruebaSC(){
//Calcula_ConsumoanualACSm3();//Calcula_NumDiasAnual();//Calcula_SCresultante();
PruebaSC=1000*ConsumoanualACSm3/(NumDiasAnual*SCresultante);
}
function Calcula_PruebaVolAcu(){
/*if(comboacumula.options[0].selected){
VolAcuProyecto=VolAcuTeorico;}
else{VolAcuProyecto=comboacumula.options[comboacumula.selectedIndex].text;} */
//volAcuProyecto=2000;
//Calcula_VolAcuTeorico();
PruebaVolAcu=VolAcuTeorico/VolAcuProyecto;
}
function ComprobacionSC(){
//Calcula_PruebaSC();
if(PruebaSC<60){CSC="No cumple";}
else{if(PruebaSC>100){CSC="No cumple";}else{CSC="Cumple";}}
var pruebaS=PruebaSC.toFixed(2)+" "+CSC;
//txtps.setAttribute("value",pruebaS);
return CSC;
}
function ComprobacionVolAcu(){
//Calcula_PruebaVolAcu();
if(PruebaVolAcu<0.8){CVA="No cumple";}
else{if(PruebaVolAcu>1.2){CVA="No cumple";}else{CVA="Cumple";}}
//txtpv.setAttribute("value",CVA);
return CVA;
var resu=PruebaVolAcu+" "+CVA;
//txtpv.setAttribute("value",resu);
}
//--------------------------------------------------------------------------// AGRUPA FUNCIONES
function calcula_CasiTodo(){
if(contaprovincia<1){ var texto=lista.options[0].text; //si comenzamos sin seleccionar la provincia
lugar=texto;//selecciona por defecto la opción 0 (Álava)
etilocal.innerHTML="Cálculos para ACS en: "+lugar+" ";
BuscaDatos_LatitudAltitudyTempMinima();} else{}
Calcula();
DatosMensuales();
ResultadosMensuales();
// ResultadosMensuales2();//la hemos metido en ResultadosMensuales
ResultadosAnuales();
}
//--------------------------------------------------------------------------------------// ELEMENTO-EVENTO-FUNCIÓN
188
APÉDICE II. CÓDIGOS. JAVASCRIPT. localizacionjs_ACSenJS
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
//--------------------------------------------------------------------------------------// ELEMENTO-EVENTO-FUNCIÓN
//evento inicial
window.addEventListener("load",carga);
lista.addEventListener("change",selecionaProvincia);
lista.addEventListener("change",BuscaDatos_LatitudAltitudyTempMinima);
lista.addEventListener("change",calcula_CasiTodo);
//-------------------------------------------------------------------comboTuso.addEventListener("change",calcula_CasiTodo);
comboinclina.addEventListener("change",calcula_CasiTodo);
comboacumula.addEventListener("change",calcula_CasiTodo);
combopaneles.addEventListener("change",calcula_CasiTodo);
combovariaocu.addEventListener("change",calcula_CasiTodo);
combovariaLD.addEventListener("change",calcula_CasiTodo);
combovariaNU.addEventListener("change",calcula_CasiTodo);
combovariaAcol.addEventListener("change",calcula_CasiTodo);
combovariaBcol.addEventListener("change",calcula_CasiTodo);
combovariaMcol.addEventListener("change",calcula_CasiTodo);
combovariaCorH.addEventListener("change",calcula_CasiTodo);
combovariaCorb.addEventListener("change",calcula_CasiTodo);
combovariaPG.addEventListener("change",calcula_CasiTodo);
combovariaDNS.addEventListener("change",calcula_CasiTodo);
combovariaCE.addEventListener("change",calcula_CasiTodo);//no hace falta????
combovariaMAI.addEventListener("change",calcula_CasiTodo);//no hace falta
combovariaFCCI.addEventListener("change",calcula_CasiTodo);//no hace falta
combovariaTmin.addEventListener("change",calcula_CasiTodo);//no hace falta
189
APÉNDICE II. CÓDIGOS. JAVASCRIPT. fchart_ACSenJS
2.3.2. fchart_ACSenJS.js
1
//Código JavaScript para cálculos de energía solar térmica por el método FChart para ACS
2
3
4
5
/*
Código JavaScript, archivo: fchart_ACSenJS.js
Author : Eduardo Gajardo
*/
6
7
8
9
//carga
var nveces=0;
var vfcarga=new Array(12);
var Ce;var N;var C;var tac;var consufQa;
//absorbida
var vEabsorbida=new Array(12);
var Fadim;var Corb;var FEO;var MAI;var FCCI;
var fSc;
//FprUL
var FprUL;var CGP;
var vDt=new Array(12);
//K
var ka1;var K1;var KgA=VolAcuProyecto;
var vK2=new Array(12);
var Tmin;
//Eperdida
var vEperdida=new Array(12);
//D1,D2
var vD1=new Array(12);
var vD2=new Array(12);
//fchart
var vf=new Array(12);
//Eutil captada
var vEutilc=new Array(12);
//cobertura
var CSA;
var vCSA=new Array(12);//para la gráfica
//comprueba k1
var pruebak1;
var compruebak1="";var compruebak1_1="";
//tablas
var tablaDatyResf=document.getElementById("DatyResf");
var eticsa=document.getElementById("csa");
var etik1=document.getElementById("k1");
var etipruebak1=document.getElementById("pk1");
///////////////////////////////////////////////////////////////////
//combos
var lista=document.getElementById("pro");
var comboinclina=document.getElementById("comboinclina");
var comboTuso=document.getElementById("comboTuso");
var combopaneles=document.getElementById("combopaneles");
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
190
APÉNDICE II. CÓDIGOS. JAVASCRIPT. fchart_ACSenJS
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var comboacumula=document.getElementById("comboacumula");
var combovariaocu=document.getElementById("combovariaocu");
var combovariaLD=document.getElementById("combovariaLD");
var combovariaNU=document.getElementById("combovariaNU");
var combovariaAcol=document.getElementById("combovariaAcol");
var combovariaBcol=document.getElementById("combovariaBcol");
var combovariaMcol=document.getElementById("combovariaMcol");
var combovariaCorH=document.getElementById("combovariaCorH");
var combovariaCorb=document.getElementById("combovariaCorb");
var combovariaPG=document.getElementById("combovariaPG");
var combovariaDNS=document.getElementById("combovariaDNS");
var combovariaCE=document.getElementById("combovariaCE");
var combovariaMAI=document.getElementById("combovariaMAI");
var combovariaFCCI=document.getElementById("combovariaFCCI");
var combovariaTmin=document.getElementById("combovariaTmin");
var resumeCSA=document.getElementById("resumeCSA");
var resumeAcu=document.getElementById("resumeAcu");
var resumeSupfinal=document.getElementById("resumeSupfinal");
var resumebcol=document.getElementById("resumebcol");
var resumemcol=document.getElementById("resumemcol");
var resumeFCCI=document.getElementById("resumeFCCI");
var resumeVMprueba=document.getElementById("resumeVMprueba");
var resumeVMprueba=document.getElementById("resumeVMprueba");
var resumeMAprueba=document.getElementById("resumeMAprueba");
var resumeCAprueba=document.getElementById("resumeCAprueba");
//------------------------//FUNCIONES
function carga_fvaloresIniciales(){
KgA=VolAcuProyecto; fSc=SCresultante;
CGP=mcol;//coeficiente global de pérdidas
FEO=bcol;//factor de eficiencia óptica
//MAI=0.96; definida en BuscaDatosMensuales en localizacionjs
//FCCI=0.95; definida en BuscaDatosMensuales en localizacionjs
//Ce=4184; definida en BuscaDatosMensuales en localizacionjs
N=NumUsu; C=LitrosDia; tac=Tuso;
//Tmin=Tuso; //lo ponemos fuera de Calcula_fchart para poder calcular f variando sus valores
}
function Calcula_fchart(){
Calcula_vfcarga();
Calcula_Fadim();
Calcula_vEabsorbidaf();
Calcula_FprUL();
Calcula_vDt();
Calcula_K1();
Calcula_vK2();
Calcula_vEperdidaf();
Calcula_D1();
191
APÉNDICE II. CÓDIGOS. JAVASCRIPT. fchart_ACSenJS
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Calcula_D2();
Calcula_f();
Calcula_vEutilcaptada();
Calcula_CoberturaSA();
Comprueba_K1_fchart();
}
function Calcula_vfcarga(){
var i=0;
for(i=0;i<12;i++){ vfcarga[i]=(Ce*N*C*vDias[i]*(tac-vTred[i]))/Math.pow(10,6); //MJ/mes}
consufQa =N * C;
}
function Calcula_Fadim(){
Fadim=FEO*MAI*FCCI;
}
function Calcula_vEabsorbidaf(){
//Calcula_vE();//Calcula_Fadim();
var i=0;
for(i=0;i<12;i++){//vEabsorbida[i]=fSc*Fadim*vH[i]*vDias[i];//Mj/mes
vEabsorbida[i]=fSc*Fadim*vE[i]*vDias[i]; }//////////////Cambio
}
function Calcula_FprUL(){
FprUL=CGP*FCCI;
}
function Calcula_vDt(){
var i=0;
for(i=0;i<12;i++){vDt[i]=vDias[i]*24*3600;}
}
function Calcula_K1(){
ka1=(KgA/(75*fSc));
K1=Math.pow(ka1,-0.25);
}
function Calcula_vK2(){
var i=0;
for(i=0;i<12;i++){vK2[i]=(11.6+1.18*Tmin+3.86*vTred[i]-2.32*vTamb[i])/(100-vTamb[i]);}
}
function Calcula_vEperdidaf(){
var i=0;
//Calcula_vDt();//Calcula_FprUL();//Calcula_K1();//Calcula_vK2();
for(i=0;i<12;i++){//vEperdida[i]=fSc*CGP*0.95*(100-vTamb[i])*vDt[i]/1000000;//Mj/mes
vEperdida[i]=fSc*FprUL*(100-vTamb[i])*vDt[i]*K1*vK2[i]/1000000;//Mj/mes
}
}
192
APÉNDICE II. CÓDIGOS. JAVASCRIPT. fchart_ACSenJS
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
function Calcula_D1(){
var i=0;
//Calcula_vfcarga();//Calcula_vEabsorbidaf();
for(i=0;i<12;i++){
vD1[i]=vEabsorbida[i]/vfcarga[i];
}
}
function Calcula_D2(){
var i=0;
//Calcula_vfcarga();//Calcula_vEperdidaf();//Calcula_K1();// Calcula_vK2();
for(i=0;i<12;i++){//vD2[i]=vEperdida[i]*K1*vK2[i]/vfcarga[i];
vD2[i]=vEperdida[i]/vfcarga[i];
}
}
function Calcula_f(){
var i=0;
//Calcula_D1();//Calcula_D2();
for(i=0;i<12;i++){
vf[i]=1.029*vD1[i]-0.065*vD2[i]0.245*Math.pow(vD1[i],2)+0.0018*Math.pow(vD2[i],2)+0.0215*Math.pow(vD1[i],3);
//if(vf[i]>1){vf[i]=1;}
vf[i]=vf[i]*100;
}
}
function Calcula_vEutilcaptada(){
var i=0;
//Calcula_vfcarga();//Calcula_fchart();
for(i=0;i<12;i++){
vEutilc[i]=vfcarga[i]*vf[i]/100;
}
}
function Calcula_CoberturaSA(){
var i=0;
//Calcula_vfcarga();Calcula_vEutilcaptada();
var sumaQu=0;var sumaQa=0;
for(i=0;i<12;i++){
sumaQu=sumaQu+vEutilc[i];
sumaQa=sumaQa+vfcarga[i];
}
CSA=sumaQu/sumaQa;
CSA=CSA*100;
CSA=CSA*100;
for(var i=0;i<12;i++){vCSA[i]=CSA;}
}
193
APÉNDICE II. CÓDIGOS. JAVASCRIPT. fchart_ACSenJS
193 function Comprueba_K1_fchart(){
pruebak1=KgA/fSc;
194
var pru=pruebak1.toFixed(2);
195
if(pruebak1<37.5){compruebak1=""+pru+" No cumple";
196
compruebak1_1="No cumple: Kg Acumulacion/Sc= "+pru+" <37.5";}
if(pruebak1>300){compruebak1=""+pru+" No cumple";
compruebak1_1="No cumple: Kg Acumulacion/Sc= "+pru+" >300";}
if(pruebak1>37.5&&pruebak1<300){compruebak1=""+pru+" Cumple";
compruebak1_1="Cumple: 37.5< Kg Acumulacion/Sc= "+pru+" <300";}
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
}
//Representacion en tablas
function DatosYResultados_fchart(){
// carga_fvaloresIniales();//Calcula_fchart();
var vtitucol=["mes","enero ","febrero ","marzo ","abril ","mayo ","junio ","julio ","agosto",
"septiembre ","octubre ","noviembre ","diciembre "];
var titufil = ["tr(ºC)", "Qa", "Ri(MJ/m2)", "Ea", "Dt(s)", "k2", "Ep", "D1=Ea/Qa", "D2=Ep/Qa", "f",
"Qu=f*Qa"];
var datosentabla="<tr><th>mes</th><th>enero</th><th>febrero</th><th>marzo</th>\n\
<th>abril</th><th>mayo</th><th>junio</th>\n\
<th>julio</th><th>agosto</th><th>septiembre</th><th>octubre</th>\n\
<th>noviembre</th><th>diciembre</th></tr>";
var j=0; //var fila1=titufil1+Tr1+Tr2+Tr3
//para resultados, en pantalla con 2 decimales y que los cálculos sigan con todos los decimales
var vt=new Array(12);var vqa=new Array(12);var vri=new Array(12);var vea=new Array(12);
var vdt=new Array(12);var vka2=new Array(12);var vep=new Array(12);var vde1=new Array(12);
var vde2=new Array(12);var vfch=new Array(12);var veu=new Array(12);
for(j=0;j<12;j++){
vt[j]=vTred[j];
vqa[j]=vfcarga[j].toFixed(2);
vri[j]=vH[j].toFixed(2);
vea[j]=vEabsorbida[j].toFixed(2);
vdt[j]=vDt[j].toFixed();
vka2[j]=vK2[j].toFixed(2);
vep[j]=vEperdida[j].toFixed(2);
vde1[j]=vD1[j].toFixed(2);
vde2[j]=vD2[j].toFixed(2);
vfch[j]=vf[j].toFixed(2);
veu[j]=vEutilc[j].toFixed(2);
}
var fila0="<tr><th title='temperatura de red ºC'>"+titufil[0]+"</th>";
for(j=0;j<12;j++){fila0+="<th >"+vt[j]+"</th>";}fila0+="</tr>";
var fila1="<tr><th title='Cargas caloríficas J'>"+titufil[1]+"</th>";
for(j=0;j<12;j++){fila1+="<th>"+vqa[j]+"</th>";}fila1+="</tr>";
var fila2="<tr><th title='MJ/m2'>"+titufil[2]+"</th>";
for(j=0;j<12;j++){fila2+="<th>"+vri[j]+"</th>";}fila2+="</tr>";
var fila3="<tr><th title='Energía absorbida J'>"+titufil[3]+"</th>";
for(j=0;j<12;j++){fila3+="<th>"+vea[j]+"</th>";}fila3+="</tr>";
var fila4="<tr><th title='segundos'>"+titufil[4]+"</th>";
for(j=0;j<12;j++){fila4+="<th>"+vdt[j]+"</th>";}fila4+="</tr>";
194
APÉNDICE II. CÓDIGOS. JAVASCRIPT. fchart_ACSenJS
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
225
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
var fila5="<tr><th title='k2=11.6+1.18TmínimaACS+3.86tr-2.32Tambiente/(100Tambiente)'>"+titufil[5]+"</th>";
for(j=0;j<12;j++){fila5+="<th>"+vka2[j]+"</th>";}fila5+="</tr>";
var fila6="<tr><th title='Energía perdida '>"+titufil[6]+"</th>";
for(j=0;j<12;j++){fila6+="<th>"+vep[j]+"</th>";}fila6+="</tr>";
var fila7="<tr><th>"+titufil[7]+"</th>";
for(j=0;j<12;j++){fila7+="<th>"+vde1[j]+"</th>";}fila7+="</tr>";
var fila8="<tr><th>"+titufil[8]+"</th>";
for(j=0;j<12;j++){fila8+="<th>"+vde2[j]+"</th>";}fila8+="</tr>";
var fila9="<tr><th title='f'>"+titufil[9]+"</th>";
for(j=0;j<12;j++){fila9+="<th>"+vfch[j]+"</th>";}fila9+="</tr>";
var fila10="<tr><th title='Energía útil'>"+titufil[10]+"</th>"; // ...sigue
///...continuación
for(j=0;j<12;j++){fila10+="<th>"+veu[j]+"</th>";}fila10+="</tr>";
var filas=[fila0,fila1,fila2,fila3,fila4,fila5,fila6,fila7,fila8,fila9,fila10];
for(i=0;i<filas.length;i++){datosentabla+=filas[i];}
tablaDatyResf.innerHTML=datosentabla;
var cosoa=CSA.toFixed(2);
var ka1=K1.toFixed(2);
eticsa.innerHTML="CSA: "+cosoa+" ";
etik1.innerHTML="K1=[kg acumulacion/(75*Sc)]<sup>-0.25</sup>= "+ka1;
etipruebak1.innerHTML=compruebak1_1;
resumeCSA.innerHTML=cosoa;
resumeAcu.innerHTML=KgA;
resumeMAprueba.innerHTML=compruebak1;
var supfinal=fSc.toFixed(2);
resumeSupfinal.innerHTML=supfinal;
resumebcol.innerHTML=bcol;
resumemcol.innerHTML=mcol;
resumeFCCI.innerHTML=FCCI;
var pruebaS=PruebaSC.toFixed(2)+" "+CSC;
var pruebaV=PruebaVolAcu.toFixed(2)+" "+CVA;
resumeVMprueba.innerHTML=pruebaV;
resumeCAprueba.innerHTML=pruebaS;
}
///////AGRUPA FUNCIONES
function Calcula_CasiTodo_fchart(){
carga_fvaloresIniciales();
Calcula_fchart();
DatosYResultados_fchart();
}
////////ASIGNA FUNCIONES A COMBOS
lista.addEventListener("change",Calcula_CasiTodo_fchart);
comboinclina.addEventListener("change",Calcula_CasiTodo_fchart);
comboTuso.addEventListener("change",Calcula_CasiTodo_fchart);
combopaneles.addEventListener("change",Calcula_CasiTodo_fchart);
comboacumula.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaocu.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaLD.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaNU.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaAcol.addEventListener("change",Calcula_CasiTodo_fchart);
195
APÉNDICE II. CÓDIGOS. JAVASCRIPT. fchart_ACSenJS
289
290
291
292
293
294
295
296
297
298
combovariaBcol.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaMcol.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaCorH.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaCorb.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaPG.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaDNS.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaCE.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaMAI.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaFCCI.addEventListener("change",Calcula_CasiTodo_fchart);
combovariaTmin.addEventListener("change",Calcula_CasiTodo_fchart);
196
APÉNDICE II. CÓDIGOS.JAVASCRIPT. imprimir.js
2.3.3. Archivo imprimir.js
1
2
3
4
5
6
7
8
/*
Código JavaScript, archivo: imprimir.js
Author : Eduardo Gajardo
*/
var btnImprime=document.getElementById("btnImprime");
function imprimePagina(){window.print();}
btnImprime.addEventListener("click",imprimePagina);
//////////////////////////////////////
197
433
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
2.3.4. Archivo Graficas_ACSenJS_1.js
1
/*
2
3
4
5
Código JavaScript para gráficas de cálculos de energía solar térmica
por el método D-A y por el método F-Chart para ACS
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
Código JavaScript, archivo: Graficas_ACSenJS_1.js
Author : Eduardo Gajardo
*/
// VARIABLES GLOBALES
var divRAP=document.getElementById("RAP");
var divRgrande=document.getElementById("Rgrande");
var divAgrande=document.getElementById("Agrande");
var divPgrande=document.getElementById("Pgrande");
var divfchart=document.getElementById("fchart");
var divDA= document.getElementById("DA");
var etinpaneles=document.getElementById("npaneles");//variaciones
var tablaVariaciones1=document.getElementById("var1");
//combos
var lista=document.getElementById("pro");
var comboinclina=document.getElementById("comboinclina");
var comboTuso=document.getElementById("comboTuso");
var combopaneles=document.getElementById("combopaneles");
var comboacumula=document.getElementById("comboacumula");
var combovariaocu=document.getElementById("combovariaocu");
var combovariaLD=document.getElementById("combovariaLD");
var combovariaNU=document.getElementById("combovariaNU");
var combovariaAcol=document.getElementById("combovariaAcol");
var combovariaBcol=document.getElementById("combovariaBcol");
var combovariaMcol=document.getElementById("combovariaMcol");
var combovariaCorH=document.getElementById("combovariaCorH");
var combovariaCorb=document.getElementById("combovariaCorb");
var combovariaPG=document.getElementById("combovariaPG");
var combovariaDNS=document.getElementById("combovariaDNS");
var combovariaCE=document.getElementById("combovariaCE");
var combovariaMAI=document.getElementById("combovariaMAI");
var combovariaFCCI=document.getElementById("combovariaFCCI");
var combovariaTmin=document.getElementById("combovariaTmin");
var nrap=0;var nfchart=0;var nDA=0;
var vdem=new Array(12);
var vapo=new Array(12);
var da=0;
for(da=0;da<12;da++){vdem[da]=vDemandaMJmes[da]/100;vapo[da]=vENTotalmes[da]/100;}
var Visor = Visor || {};
var wxG, wxGL;
//----------------------
198
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Visor.datosGraficas = {
graficaRendimiento: {//esto va en una div de id="grafica1" y class="grafica-lineal"
xy: {
titulo: "Rendimiento",
udsTramoDiv: 25,
categoriasEntreTramos: true,
columnasSeries: 2,
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["E","F","M","A","M","J","J","A","S","O","N","D"],
series: [{
titulo: "Rendimiento csp",
colorLinea: "blue",
valores:vRendimiento
}]
},
x: {
titulo: "Meses",
longitud: 125
},
y: {
titulo: "Uds",
longitud: 55,
numTramosSubDiv: 5,
topLeft: true,
invertir: true,
decimales: 1
},
css: {
grafica: "border: black solid 0px;",//"border: black solid 1px;",
rotuloValorEmergente: "color: white;"
}
},
graficaRendimientoGrande: {// va en una div de id="grafica1" y class="grafica-lineal"
: xy: {
titulo: "Rendimiento",
udsTramoDiv: 25,
categoriasEntreTramos: true,
columnasSeries: 2,
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["ene ","feb ","mar ","abr ","may ","jun ","jul ","ago ","sep ","oct ",
199
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
"nov ","dic "],
series: [{
titulo: "Rendimiento csp",
colorLinea: "blue",
valores:vRendimiento
}]
},
x: {
titulo: "Meses",
longitud: 350
},
y: {
titulo: "Uds",
longitud: 200,
numTramosSubDiv: 5,
topLeft: true,
invertir: true,
decimales: 1
},
css: {
grafica: "border: black solid 1px;",
rotuloValorEmergente: "color: white;"
}
},
graficaASR:{
xy: {
titulo: "Aportación solar relativa",
tipoGrafica: "lineas",
udsTramoDiv: 25,
categoriasEntreTramos: true,
columnasSeries: 2,
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["E","F","M","A","M","J","J","A","S","O","N","D"],
series: [{
titulo: "ARS",
colorLinea: "blue",
valores: ASR
}]
},
x: {
titulo: "Meses",
longitud: 115//125
},
y: {
titulo: "Uds",
longitud: 55,
numTramosSubDiv: 5,
topLeft: true,
200
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
invertir: true,
decimales: 1
},
css: {
grafica: "border: black solid 0px;",//"border: black solid 1px;",
rotuloValorEmergente: "color: white;"
}
},
graficaASRGrande:{
xy: {
titulo: "Aportación solar relativa",
tipoGrafica: "lineas",
udsTramoDiv: 25,
categoriasEntreTramos: true,
columnasSeries: 2,
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["ene ","feb ","mar ","abr ","may ","jun ","jul ","ago ","sep ","oct ",
"nov ","dic "],
series: [{
titulo: "ARS",
colorLinea: "blue",
valores: ASR
}]
},
x: {
titulo: "Meses",
longitud: 350
},
y: {
titulo: "Uds",
longitud: 200,
numTramosSubDiv: 5,
topLeft: true,
invertir: true,
decimales: 1
},
css: {
grafica: "border: black solid 1px;",
rotuloValorEmergente: "color: white;"
}
},
graficaSustitucion:{
xy: {
titulo: "Sustitución",
tipoGrafica: "lineas",
udsTramoDiv: 0.1,
201
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
categoriasEntreTramos: true,
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["E","F","M","A","M","J","J","A","S","O","N","D"],
series: [{titulo: "Sustitución ", colorLinea: "blue", valores:vSustitucion},
{ titulo: "100% ", colorLinea: "orange", valores:[1,1,1,1,1,1,1,1,1,1,1,1]}
]
},
x: {
titulo: "Meses",
longitud: 120
},
y: {
titulo: "Uds",
longitud: 60,
numTramosSubDiv: 3,
topLeft: true,
invertir: true,
decimales: 2
},
css: {
grafica: "border: black solid 0px;",//"border: black solid 1px;",
rotuloValorEmergente: "color: white;"
}
},
graficaSustitucionGrande:{
xy: {
titulo: "Sustitución",
tipoGrafica: "lineas",
udsTramoDiv: 0.1,
categoriasEntreTramos: true,
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["ene ","feb ","mar ","abr ","may ","jun ","jul ","ago ","sep ","oct ",
"nov ","dic "],
series: [{titulo: "Sustitución ", colorLinea: "blue", valores:vSustitucion},
{ titulo: "100% ", colorLinea: "orange", valores:[1,1,1,1,1,1,1,1,1,1,1,1]}
]
},
x: {
titulo: "Meses",
longitud: 350
},
y: {
titulo: "Uds",
longitud: 200,
202
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
252
253
254
255
256
257
225
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
longitud: 200,
numTramosSubDiv: 5,
topLeft: true,
invertir: true,
decimales: 2
},
css: {
grafica: "border: black solid 1px;",
rotuloValorEmergente: "color: white;"
}
},
graficaFchart:{
xy: {
titulo: "f-chart",
tipoGrafica: "lineas",
udsTramoDiv: 10,
categoriasEntreTramos: true,
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["En","Fe","Ma","Ab","My","Jn","Jl","Ag","Se","Oc","No","Di"],
series: [{titulo: "f ", colorLinea: "blue", valores:vf },
{ titulo: "CSA ", colorLinea: "red", valores:vCSA}
]
},
x: {
titulo: "Meses",
longitud: 329//longitud: 200
},
y: {
titulo: "Uds",
longitud: 200,
numTramosSubDiv: 2,
topLeft: true,
invertir: true,
decimales: 2
},
css: {
grafica: "border: black solid 0px;",//"border: black solid 1px;",
rotuloValorEmergente: "color: white;"
}
},
graficaDA: {
xy: {
titulo: "D - A",
udsTramoDiv: 500,
categoriasEntreTramos: true,
columnasSeries: 2,
203
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
margenBarras: 2,
tamanyoFuenteTituloGrafica: 12,
tamanyoFuenteTituloEje: 11,
leyendasSeries: true,
categorias: ["En","Fe","Ma","Ab","My","Jn","Jl","Ag","Se","Oc","No","Di"],
series: [{titulo: "Demanda", colorLinea: "red", valores: vDemandaMJmes},
{ titulo: "Aportación", colorLinea: "blue", formaPunto: "circulo", valores: vENTotalmes}
]
},
x: { titulo: "Meses", longitud: 320//longitud: 200},
y: { titulo: "MJ/mes", longitud: 220, numTramosSubDiv: 2,
topLeft: true, invertir: true, decimales: 1},
css: { grafica: "border: black solid 0px;", rotuloValorEmergente: "color: white;"}
}
};//-----------------------------------------------------------------------------function Grafica(){
wxG = Visor.general;
wxG.cargarModulos(["conector-visor.js", "grafica-lineal-visor.js"]);
wxG.prefijarCss(["transform","transform-origin"]);
wxG.dotarVpCss();
wxGL = Visor.iniciarGraficaLineal();
};
function dibujaRAP(){
nrap++;
if(nfchart>0){
divfchart.innerHTML="";//para borrar la anterior
divfchart.innerHTML=
"<div class='grafica-lineal' id='graficaFchart' style='display: inline-block;'></div>";
}
if(nDA>0){
divDA.innerHTML="";//para borrar la anterior
divDA.innerHTML=
"<div class='grafica-lineal' id='graficaDA' style='display: inline-block;'></div>";
}
divRAP.innerHTML="";//para borrar la anterior
divRAP.innerHTML=
"<div class='grafica-lineal' id='graficaRendimiento' style='display: inline-block;'></div>\n\
<div class='grafica-lineal' id='graficaASR' style='display: inline-block;'></div>\n\
<div class='grafica-lineal' id='graficaSustitucion' style='display: inline-block;'></div>";
divRgrande.innerHTML="";
divRgrande.innerHTML="<div
class='grafica-lineal' id='graficaRendimientoGrande' style='display: inline-block;'></div>";
divAgrande.innerHTML="";
divAgrande.innerHTML=
"<div class='grafica-lineal' id='graficaASRGrande' style='display: inline-block;'></div>";
204
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
354
355 divPgrande.innerHTML="";
356 divPgrande.innerHTML="<div
357
class='grafica-lineal' id='graficaSustitucionGrande' style='display: inline- block;'></div>";
358
359 Grafica();
360 }
361
362
363
364
365
366
367
368
369
370
371 function dibujaFchart(){
372 nfchart++;
373 if(nrap>0){
374
divRAP.innerHTML="";//para borrar la anterior
375
divRAP.innerHTML=
376
"<div class='grafica-lineal' id='graficaRendimiento' style='display: inline-block;'></div>\n\
377
<div class='grafica-lineal' id='graficaASR' style='display: inline-block;'></div>\n\
378
<div class='grafica-lineal' id='graficaSustitucion' style='display: inline-block;'></div>";
379
380
divRgrande.innerHTML="";
381
divRgrande.innerHTML="<div class='grafica-lineal' id='graficaRendimientoGrande'
382
style='display: inline-block;'></div>";
383
384
divAgrande.innerHTML="";
385
divAgrande.innerHTML="<div class='grafica-lineal' id='graficaASRGrande'
386
style='display: inline-block;'></div>";
387
388
divPgrande.innerHTML="";
389
divPgrande.innerHTML="<div class='grafica-lineal' id='graficaSustitucionGrande'
390
style='display: inline- block;'></div>";
391 }
392 if(nDA>0){
393
divDA.innerHTML="";//para borrar la anterior
394
divDA.innerHTML="<div class='grafica-lineal' id='graficaDA'
395
style='display: inline-block;'></div>";
396 }
397
398 divfchart.innerHTML="";
399 divfchart.innerHTML="<div class='grafica-lineal' id='graficaFchart'
400
style='display: inline-block;'></div>";
401
402
Grafica();
403 }
405
205
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
function dibujaDA(){
nDA++;
if(nrap>0){
divRAP.innerHTML="";//para borrar la anterior
divRAP.innerHTML="
<div class='grafica-lineal' id='graficaRendimiento' style='display: inline-block;'></div>\n\
<div class='grafica-lineal' id='graficaASR' style='display: inline-block;'></div>\n\
<div class='grafica-lineal' id='graficaSustitucion' style='display: inline-block;'></div>";
divRgrande.innerHTML="";
divRgrande.innerHTML="<div class='grafica-lineal' id='graficaRendimientoGrande'
style='display: inline-block;'></div>";
divAgrande.innerHTML="";
divAgrande.innerHTML="<div class='grafica-lineal' id='graficaASRGrande'
style='display: inline-block;'></div>";
divPgrande.innerHTML="";
divPgrande.innerHTML="<div class='grafica-lineal' id='graficaSustitucionGrande'
style='display: inline-block;'></div>";
}
if(nfchart>0){
divfchart.innerHTML="";//para borrar la anterior
divfchart.innerHTML="<div class='grafica-lineal' id='graficaFchart'
style='display: inline-block;'></div>";
}
divDA.innerHTML="";
divDA.innerHTML="<div class='grafica-lineal' id='graficaDA'
style='display: inline-block;'></div>";
Grafica();
}
//
//--------------------------------------------206
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478 function Variaciones1(){
479 //var temp=comboTuso.options[comboTuso.selectedIndex].text;
480 var vtuso=new Array(12);var voc=new Array(12);
481 var vlitrosdia=new Array(12);var vinclinacion=new Array(12);
482 for(var i =0;i<12;i++){ voc[i]=vOcupacion[i]; vtuso[i]=Tuso;
483
vlitrosdia[i]=LitrosDia; vinclinacion[i]=Inclinacion;}
484 var titufil = ["%Ocupación", "Tuso", "LitrosDia", "Inclinación"];
485 var datosentabla="<tr><th> </th><th>ene</th><th>feb</th><th>mar</th>\n\
486
<th>abr</th><th>may</th><th>jun</th>\n\
487
<th>jul</th><th>ago</th><th>sep</th><th>oct</th>\n\
488
<th>nov</th><th>dic</th></tr>";
489
490 var j=0;
491 var fila0="<tr><th>"+titufil[0]+"</th>";
492 for(j=0;j<12;j++){fila0+="<th>"+voc[j]+"</th>";}fila0+="</tr>";
493
494 var fila1="<tr><th>"+titufil[1]+"</th>";
495 for(j=0;j<12;j++){fila1+="<th>"+vtuso[j]+"</th>";}fila1+="</tr>";
496
497 var fila2="<tr><th>"+titufil[2]+"</th>";
498 for(j=0;j<12;j++){fila2+="<th>"+vlitrosdia[j]+"</th>";}fila2+="</tr>";
499
500
var fila3="<tr><th>"+titufil[3]+"</th>";
501
for(j=0;j<12;j++){fila3+="<th>"+vinclinacion[j]+"</th>";}fila3+="</tr>";
502
503
504
505
506
507
var filas=[fila0,fila1,fila2,fila3];
for(i=0;i<filas.length;i++){datosentabla+=filas[i];}
tablaVariaciones1.innerHTML=datosentabla;
207
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
508 }
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
//----------- ELEMENTO-EVENTO-FUNCIÓN
//ACTUALIZA Y DIBUJA GRÁFICAS AL CAMBIAR VALORES EN LOS SELECTS
lista.addEventListener("change",Variaciones1);
comboinclina.addEventListener("change",Variaciones1);
comboTuso.addEventListener("change",Variaciones1);
combopaneles.addEventListener("change",Variaciones1);
comboacumula.addEventListener("change",Variaciones1);
combovariaocu.addEventListener("change",Variaciones1);
combovariaLD.addEventListener("change",Variaciones1);
combovariaNU.addEventListener("change",Variaciones1);
combovariaAcol.addEventListener("change",Variaciones1);
combovariaBcol.addEventListener("change",Variaciones1);
combovariaMcol.addEventListener("change",Variaciones1);
combovariaCorH.addEventListener("change",Variaciones1);
combovariaCorb.addEventListener("change",Variaciones1);
combovariaPG.addEventListener("change",Variaciones1);
combovariaDNS.addEventListener("change",Variaciones1);
combovariaCE.addEventListener("change",Variaciones1);
combovariaMAI.addEventListener("change",Variaciones1);
combovariaFCCI.addEventListener("change",Variaciones1);
combovariaTmin.addEventListener("change",Variaciones1);
lista.addEventListener("change",dibujaRAP);
comboinclina.addEventListener("change",dibujaRAP);
comboTuso.addEventListener("change",dibujaRAP);
combopaneles.addEventListener("change",dibujaRAP);
comboacumula.addEventListener("change",dibujaRAP);
combovariaocu.addEventListener("change",dibujaRAP);
combovariaLD.addEventListener("change",dibujaRAP);
combovariaNU.addEventListener("change",dibujaRAP);
combovariaAcol.addEventListener("change",dibujaRAP);
combovariaBcol.addEventListener("change",dibujaRAP);
combovariaMcol.addEventListener("change",dibujaRAP);
combovariaCorH.addEventListener("change",dibujaRAP);
combovariaCorb.addEventListener("change",dibujaRAP);
combovariaPG.addEventListener("change",dibujaRAP);
combovariaDNS.addEventListener("change",dibujaRAP);
combovariaCE.addEventListener("change",dibujaRAP);
combovariaMAI.addEventListener("change",dibujaRAP);
combovariaFCCI.addEventListener("change",dibujaRAP);
combovariaTmin.addEventListener("change",dibujaRAP);
//
lista.addEventListener("change",dibujaDA);
comboinclina.addEventListener("change",dibujaDA);
comboTuso.addEventListener("change",dibujaDA);
combopaneles.addEventListener("change",dibujaDA);
comboacumula.addEventListener("change",dibujaDA);
combovariaocu.addEventListener("change",dibujaDA);
combovariaLD.addEventListener("change",dibujaDA);
combovariaNU.addEventListener("change",dibujaDA);
208
APÉNDICE II. CÓDIGOS. JAVASCRIPT. Graficas_ACSenJS.js
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
combovariaAcol.addEventListener("change",dibujaDA);
combovariaBcol.addEventListener("change",dibujaDA);
combovariaMcol.addEventListener("change",dibujaDA);
combovariaCorH.addEventListener("change",dibujaDA);
combovariaCorb.addEventListener("change",dibujaDA);
combovariaPG.addEventListener("change",dibujaDA);
combovariaDNS.addEventListener("change",dibujaDA);
combovariaDNS.addEventListener("change",dibujaDA);
combovariaCE.addEventListener("change",dibujaDA);
combovariaMAI.addEventListener("change",dibujaDA);
combovariaFCCI.addEventListener("change",dibujaDA);
combovariaTmin.addEventListener("change",dibujaDA);
//
lista.addEventListener("change",dibujaFchart);
comboinclina.addEventListener("change",dibujaFchart);
comboTuso.addEventListener("change",dibujaFchart);
combopaneles.addEventListener("change",dibujaFchart);
comboacumula.addEventListener("change",dibujaFchart);
combovariaocu.addEventListener("change",dibujaFchart);
combovariaLD.addEventListener("change",dibujaFchart);
combovariaNU.addEventListener("change",dibujaFchart);
combovariaAcol.addEventListener("change",dibujaFchart);
combovariaBcol.addEventListener("change",dibujaFchart);
combovariaMcol.addEventListener("change",dibujaFchart);
combovariaCorH.addEventListener("change",dibujaFchart);
combovariaCorb.addEventListener("change",dibujaFchart);
combovariaPG.addEventListener("change",dibujaFchart);
combovariaDNS.addEventListener("change",dibujaFchart);
combovariaCE.addEventListener("change",dibujaFchart);
combovariaMAI.addEventListener("change",dibujaFchart);
combovariaFCCI.addEventListener("change",dibujaFchart);
combovariaTmin.addEventListener("change",dibujaFchart);
//-------------------------------------------------------------------------------------------------
209
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
2.3.5. Archivo grafica-lineal-visor-ACSenJS.js
/* grafica-lineal-visor-nomin.js
* (c) 2013, Andrés de la Paz
* www.wextensible.com
*
* Agrupación no minimizada de los recursos:
* - general.js
* - conector.js
* - grafica-lineal.js
*
* Estos recursos se copian y agrupan en este único archivo. Por lo tanto puede que los
* originales (que se encuentra en /res/inc/) hayan sido modificados y no se reflejen los
* cambios aquí.
*
* La versión minimizada es grafica-lineal-visor.js
*
* Aquí se ha cambiado el espacio de nombres Wextensible por Visor.
*/
//===================================================================
/* general.js
* (c) 2013, Andrés de la Paz
* www.wextensible.com
*/
var Visor = Visor || {};
Visor.general = Visor.general || {};
var wxG = Visor.general;
wxG.cargarModulos = function(arrModulos){
for (var i=0, max=arrModulos.length; i<max; i++) {
var modulo = (arrModulos[i].replace(/[\-\.\/]/g, "_")).toUpperCase();
Visor[modulo]();
}
};
wxG.vendorPrefixesCss = ["-webkit-", "-moz-", "-o-", "-xv-", "-ms-", "-mso-", "-khtml-"];
wxG.vpForCss = {};
wxG.prefijarCss = function(propiedad){
var divtest = document.createElement("div");
//Para IE8 necesitamos ponerlo en el DOM
document.body.appendChild(divtest);
var estilo = null;
//El argumento viene como un array o si viene como string hacemos un array
if (typeof(propiedad) == "string"){
if (propiedad != "") estilo = [propiedad];
} else if (propiedad.length){
estilo = propiedad;
}
if (estilo && (estilo.length>0)){
//Sacamos un objeto de todos los estilos computados
var objEstilo = this.objetoEstiloActual(divtest);
for (var j in estilo){
var cadEst = this.trim(estilo[j]);
210
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
if (cadEst != ""){
//Necesitamos la propiedad con guiones
var estiloCG = this.descambiaGuiones(cadEst);
//Aunque la devolveremos sin guiones
this.vpForCss[cadEst] = this.cambiaGuiones(cadEst);
if (this.propiedadEstiloActual(objEstilo, estiloCG)==null){
this.vpForCss[cadEst] = null;
for (var i in this.vendorPrefixesCss){
var conPrefijo = this.vendorPrefixesCss[i] + estiloCG;
if (this.propiedadEstiloActual(objEstilo, conPrefijo)!=null) {
this.vpForCss[cadEst] = this.cambiaGuiones(conPrefijo);
this.vpForCss[cadEst] = this.cambiaGuiones(conPrefijo);
break;
}}}}}}
//Elimina divtest
document.body.removeChild(divtest);
};
wxG.propiedadEstiloActual = function(objetoEstilo, propiedad){
try {
if (objetoEstilo && (propiedad != "")) {
var prop = propiedad;
if (propiedad.indexOf("-")>-1) prop = wxG.cambiaGuiones(propiedad);
var valor = objetoEstilo[prop];
if ((valor==undefined)||(valor==null)){
if (propiedad == "float") {
//"float" es una palabra reservada de JavaScript y en FF y IE hay que reemplazarla en
//algunos navegadores.
//Para FF
propiedad = "cssFloat";
valor = objetoEstilo[propiedad];
if (valor == null) {
//Para IE
propiedad = "styleFloat";
valor = objetoEstilo[propiedad];
}
} else {
valor = objetoEstilo[propiedad];
}
if ((valor==undefined)||(valor==null)){
return null;
} else {
return valor;
}
} else {
return valor;
}
} else {
return null;
}
} catch(e){
return null;
}
};
211
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
wxG.objetoEstiloActual = function(elemento){
try {
if (elemento != null) {
if (document.defaultView.getComputedStyle) {//FF, OP, CH, SA
return document.defaultView.getComputedStyle(elemento, null);
} else {
return null;
}
} else {
return null;
}
} catch(e){
//IE8 no soporta getComputedStyle y da error, salimos por aquí
//devolviendo el currentStyle. Este estilo debió ser anteriormente
//declarado en CSS para que IE pueda recuperarlo aquí
try {
return elemento.currentStyle;
} catch(e){}
return null;
}
};
wxG.dotarVpCss = function(){
var todos = document.body.getElementsByTagName("*");
var todos = document.body.getElementsByTagName("*")
getElementsByTagName("*");
//No usar for(var inod in todos) porque FF extrae inod como número e inod
//como string (2 veces)
for (var inod=0, maxinod=todos.length; inod<maxinod; inod++){
if (todos[inod].getAttribute && todos[inod].getAttribute("data-vpforcss")){
var listaProps = wxG.trim(todos[inod].getAttribute("data-vpforcss"));
if (listaProps != ""){
var estiloLinea = todos[inod].getAttribute("style");
var arrEl = estiloLinea.split(";");
var objEst = null;
for (var iael in arrEl){
var arrPar = arrEl[iael].split(":");
if (arrPar.length == 2){
var nombre = wxG.trim(arrPar[0]);
var valor = "";
if (nombre != ""){
if (!objEst) objEst = new Object;
valor = wxG.trim(arrPar[1]);
objEst[nombre] = valor;
}
}
}
if (objEst){
var props = listaProps.split(",");
for (var ip in props){
var propiedad = wxG.trim(props[ip]);
if ((propiedad != "") &&
objEst[propiedad] &&
wxG.vpForCss[propiedad] &&
212
var
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
(wxG.vpForCss[propiedad] != wxG.cambiaGuiones(propiedad))){
todos[inod].style[wxG.vpForCss[propiedad]] = objEst[propiedad];
}}}}}}
};
wxG.redondear = function(numero, decimales){
try {
if (isNaN(numero)) numero = 0;
if (decimales==null) decimales = 0;
if (isNaN(decimales)) decimales = 0;
if (decimales<0) decimales = 0;
var base = Math.pow(10, decimales);
return Math.round(numero*base)/base;
} catch(e) {
return 0;
}
};
wxG.cambiaGuiones = function (cadena){
try {
var temp = "";
if (cadena.indexOf("-")>-1){
for (var i=0; i<cadena.length; i++) {
var car = cadena.substring(i,i+1);
if (car == "-"){
var carSgte = cadena.substring(i+1,i+2);
temp += carSgte.toUpperCase();
i++;
} else {
temp += car;
}
}
temp = temp.replace(/\-/g, "");
} else {
temp = cadena;
}
return temp;
} catch (e) {
return cadena;
return cadena;
}
};
wxG.trim = function (cadena){
try{
if (cadena != "") {
cadena = cadena.replace(/^[ \s]+|[ \s]+$/, "");
}
} catch (e) {}
return cadena;
};
wxG.arrayClassName = function (nombreClase, elemento){
try {
function recorreDom(el, arr){
if (el.className == nombreClase) arr.push(el);
var hijos = el.childNodes;
213
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
for (var i=0; i<hijos.length; i++){
recorreDom(hijos[i], arr);
}
return arr;
}
var nodo = document.body;
if (elemento != null) nodo = elemento;
if (document.getElementsByClassName){ //FF
return nodo.getElementsByClassName(nombreClase);
} else { //IE
var arr = new Array;
return recorreDom(nodo, arr);
}
} catch (e) {
return null;
}
};
wxG.nodoPadre = function (nodo) {
try {
if (nodo == null) {
return null;
} else if (nodo.parentElement) {//IE
return nodo.parentElement;
} else {//FF
return nodo.parentNode;
}
} catch(e){
return null;
}
};
wxG.descambiaGuiones = function (cadena){
try {
var mayus = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var temp = "";
for (var i=0; i<cadena.length; i++) {
var car = cadena.substring(i,i+1);
if (mayus.indexOf(car) > -1){
temp += "-" + car.toLowerCase();
} else {
temp += car;
}
}
return temp;
} catch (e) {
return cadena;
}
};
wxG.setInnerText = function (elemento, texto) {
try{
if (elemento != null){
if (elemento.innerText != undefined) {//IE,OP,SA
elemento.innerText = texto;
elemento.innerText = texto;
214
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
} else if (elemento.textContent != undefined) {//FF
elemento.textContent = texto;
} else if (elemento.innerHTML != undefined) {
//si no hay otra posibilidad lo ponemos con
//innerHTML que si lo ejecutan IE, OP, SA y FF
elemento.innerHTML = texto;
} else if (elemento.text != undefined) {
elemento.text = texto;
} else {
var nodoTexto = elemento.selectSingleNode("text()");
if (nodoTexto != null) {
nodoTexto.nodeValue = texto;
} else {
return null;
}
}
}
return elemento;
} catch(e){
return null;
}
};
wxG.recogeEvento = function (event){
try {
var evt = event || window.event;
var objeto = new Object;
objeto.event = evt;
objeto.element = evt.srcElement || evt.target;
objeto.keyAscii = evt.charCode || evt.keyCode;
//relativo al elemento
objeto.x = evt.offsetX || evt.layerX;
objeto.y = evt.offsetY || evt.layerY;
//relativo a la página
if (evt.pageX) {
//CH,SA,FF,OP,...
objeto.pagx = evt.pageX;
objeto.pagy = evt.pageY;
} else {
//IE8
var position = wxG.estiloActual(objeto.element, "position");
if (((wxG.estiloActual(objeto.element, "display")!="block")&&(position=="static"))||
(position=="fixed")) {
//Para fixed, el padre en el DOM tiene que ser static. En otro caso no se
//corrigen los valores que resulten.
objeto.pagx = evt.x;
objeto.pagy = evt.y;
} else {
objeto.pagx = evt.offsetX + objeto.element.offsetLeft;
objeto.pagy = evt.offsetY + objeto.element.offsetTop;
if (objeto.element.offsetParent) {
objeto.pagx += objeto.element.offsetParent.offsetLeft;
objeto.pagy += objeto.element.offsetParent.offsetTop;
}
215
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
}
}
return objeto;
} catch (e){
return null;
}
};
//==========================================================================
====================
/* conector.js
* Conectores
* (c) 2013, Andrés de la Paz
* www.wextensible.com
*
*/
//Asignación inicial a un objeto literal vacío o a si mismo
//si ya fue creado previamente.
//si ya fue creado previamente.
var Visor = Visor || {};
//Envolvemos el módulo en el espacio de nombres que se enviará al cargador
Visor.CONECTOR_VISOR_JS = function(){
Visor.Conector = (function(){
//Un acortador para el módulo general
var wxG = Visor.general;
//Este objeto gestiona funciones comunes de todos los conectores
Visor.conectores = {
//Estilos para borde y fondo al seleccionar
colorBordeConector: "orange",
colorFondoConector: "rgba(255, 255, 0, 0.3)",
//Para IE8 que no soporta rgba
colorFondoConectorOpaco: "rgb(255, 255, 200)",
//Valores iniciales para crear nuevo
tamanyoCursorDefault: 7,
anchoBordeDefault: 2,
colorBordeDefault: "black",
estiloBordeDefault: "solid none none",
formaIniDefault: "ninguna",
formaFinDefault: "flecha",
scaleXDefault: 1,
scaleYDefault: 1,
//Redondear decimales al trabajar con los ángulos
dec: 3,
//La pantalla siempre tendrá que estar 1 por encima de los conectores, pero también por encima
//del zIndexBase del selectArea (select-area.js en caso de usarse el componente) (que tiene valor 100000,
//pero comprobar si no ha sido modificado).
zIndexPantalla: 110001,
//Selección
seleccionado: null,
ejecutaSeleccion: false,
ejecutarSelecionar: function(){},
ejecutaDesSeleccion: false,
ejecutarDesSelecionar: function(){},
//Crear un nuevo conector con inicio en (x1,y1) y fin en (x2,y2).
216
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
//Con el argumento polar = true (x2, y2)=(radio, angulo).
//Con el argumento fijos = null o false podemos moverlos como en diagramas.js. Pero en
//graficas-lin.js los conectores no deben moverse ni seleccionarse.
crearConector: function(idLienzo, x1, y1, x2, y2, fijos, polar) {
if (polar) {
var radio = x2, angulo = y2;
x2 = x1 + radio * Math.cos(angulo);
y2 = y1 + radio * Math.sin(angulo);
}
return new Visor.Conector(idLienzo, x1, y1, x2, y2, fijos);
},
eliminarConector: function(conector){
//recuperamos la pantalla (un div)
var pantalla = conector.objeto.pantalla;
//eliminamos la pantalla
wxG.nodoPadre(pantalla).removeChild(pantalla);
//Quitamos el objeto del conector (¿posible memory leak?)
conector. objeto = null;
//eliminamos el conector (un div) con sus cursores hijos (dives)
wxG.nodoPadre(conector).removeChild(conector);
},
quitarSeleccion: function(){
var dives = wxG.arrayClassName("conector");
for (var i=0, max=dives.length; i<max; i++) {
dives[i].style.outline = "none";
dives[i].style.backgroundColor = "transparent";
}
if (this.ejecutaDesSeleccion) this.ejecutarDesSeleccionar();
},
seleccionarConector: function(event) {
var evento = event || window.event;
this.quitarSeleccion();
if (this.seleccionado) {
if (this.seleccionado) {
this.seleccionado.style.outline = this.colorBordeConector + " dashed 1px";
try {
this.seleccionado.style.backgroundColor = this.colorFondoConector;
} catch(e) {
//IE no soporta rgba
this.seleccionado.style.backgroundColor = this.colorFondoConectorOpaco;
}
}
if (this.ejecutaSeleccion) this.ejecutarSeleccionar(evento);
}
};
//Constructor del conector
var tempConstructor = function(idLienzo, x1, y1, x2, y2, fijos){
wxCS = Visor.conectores;
this.lienzo = document.getElementById(idLienzo);
if (!this.lienzo) {
alert("No hay un 'idLienzo' donde construir un conector.");
return;
}
217
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
if (!fijos) {
this.lienzo.addEventListener("mouseup",
function (event){
var evento = event || window.event;
if (evento.button == 2) return;
wxCS.seleccionado = null;
wxCS.seleccionarConector();
}, false);
}
//coordenadas y ángulo de giro del conector
this.x1 = 100;
if (x1!=null) this.x1 = x1;
this.y1 = 100;
if (y1!=null) this.y1 = y1;
this.x2 = 200;
if (x2!=null) this.x2 = x2;
this.y2 = 100;
if (y2!=null) this.y2 = y2;
this.angulo = 0;
//Estilo del borde
this.anchoBorde = wxCS.anchoBordeDefault;
this.colorBorde = wxCS.colorBordeDefault;
this.estiloBorde = wxCS.estiloBordeDefault;
//Tamaño del cursor
this.tamanyoCursor = wxCS.tamanyoCursorDefault;
//Al hacer click sobre un cursor se determina cual es el que se está activando. Será uno
//de los dos cursores con class="conector-cursor-ini" o class="conector-cursor-fin"
this.cursorActivo = null;
//El tipo de cursor que está activo, "conector-cursor-ini" o "conector-cursor-fin" o también con
//"ff" ("fin-fijo") y "if" ("ini-fijo") para fijar la cabeza o la flecha con las conexiones
this.tipoCursorActivo = "";
//formas del cursor
this.formaIni = wxCS.formaIniDefault;
this.formaFin = wxCS.formaFinDefault;
//Escalado de la flecha para hacerla más puntiaguda con (1.5, 0.7) por ejemplo
this.scaleX = 1,
this.scaleY = 1,
//Eventos
this.eventoPosicionar = false;
this.ejecutarAlPosicionar = function(){};
//Variable temporal para pasar en los manejadores de eventos
var that = this;
//CREACIÓN DEL CUERPO DEL CONECTOR ..............................................
this.conector = document.createElement("div");
this.conector.setAttribute("class", "conector");
this.conector.style.height = "0px";
//Ajuste para conectores fijos, para ajustar el grosor del borde, como cuando
//se usan en gráficas lineales. En conectores que se mueven no es necesario hacer
//este ajuste.
this.ancb = 0;
if (fijos) this.ancb = this.anchoBorde/2;
this.conector.style.left = (this.x1-this.ancb) + "px";
this.conector.style.top = (this.y1-this.ancb) + "px";
218
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
this.conector.style.top = (this.y1-this.ancb) + "px";
this.conector.style[wxG.vpForCss["transform-origin"]] = this.ancb + "px " + this.ancb + "px";
this.conector.style.paddingBottom = this.tamanyoCursor + "px";
this.conector.style.position = "absolute";
this.conector.style.borderStyle = this.estiloBorde;
this.conector.style.borderWidth = this.anchoBorde + "px";
this.conector.style.borderColor = this.colorBorde;
this.conector.style.zIndex = this.lienzo.style.zIndex + wxCS.zIndexPantalla - 1;
if (!fijos) {
wxG.agregarEventListener(null, [[this.conector, "outer"]]);
this.conector.addEventListener("click",
function(event){
var evento = event || window.event;
if (evento.button == 2) return;
if (wxCS.seleccionado != that.conector) {
wxCS.seleccionado = that.conector;
wxCS.seleccionarConector(evento);
}
}, false);
}
//CREACIÓN DEL CURSOR INICIAL DEL CONECTOR
this.cursorIni = document.createElement("div");
this.cursorIni.setAttribute("class", "conector-cursor-ini");
this.cursorIni.style.position = "relative";
if (!fijos) {
this.cursorIni.style.cursor = "pointer";
wxG.agregarEventListener(null, [[this.cursorIni, "outer"]]);
this.cursorIni.addEventListener("mousedown", function(event){
if (that.cursorActivo==null) {
that.presentarPantalla(event);
}
}, false);
}
//CREACIÓN DEL CURSOR FINAL DEL CONECTOR
this.cursorFin = document.createElement("div");
this.cursorFin.setAttribute("class", "conector-cursor-fin");
this.cursorFin.style.position = "relative";
if (!fijos) {
this.cursorFin.style.cursor = "sw-resize";
wxG.agregarEventListener(null, [[this.cursorFin, "outer"]]);
this.cursorFin.addEventListener("mousedown", function(event){
var evento = event || window.event;
that.presentarPantalla(evento);
}, false);
}
//CREACIÓN DEL TEXTO EN EL CONECTOR
this.texto = document.createElement("div");
this.texto.setAttribute("class", "conector-texto");
this.texto.style.marginTop = "-" + (2*this.tamanyoCursor) + "px";
//ANEXAR AL DOM
this.conector.appendChild(this.cursorFin);
this.conector.appendChild(this.cursorIni);
this.conector.appendChild(this.texto);
219
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
this.lienzo.appendChild(this.conector);
//Después del appendChild para tener conector.offsetWidth disponible
this.formatearCursor("Ini");
this.formatearCursor("Fin");
if (!fijos) {
//El conector de pantalla se crea independiente para cada conector
this. pantalla = document.createElement("div");
this.pantalla.setAttribute("class", "conector-pantalla");
this.pantalla.style.display = "none";
this.pantalla.style.position = "absolute";
this.pantalla.style.width = this.lienzo.offsetWidth + "px";
this.pantalla.style.height = this.lienzo.offsetHeight + "px";
this.pantalla.style.zIndex = parseInt(this.lienzo.style.zIndex) + wxCS.zIndexPantalla;
this.pantalla.style.cursor = "pointer";
//IE8 no permite rgba y da error. Podíamos poner "transparente" pero el evento mouseup más abajo
//no es detectado por IE8 en capas transparentes.
try {
this.pantalla.style.backgroundColor = "rgba(0,0,0,0)";
}catch(e) {
//En IE8 el opacity es en porcentaje de 0% a 100% (sin el signo %). Le ponemos un 0.1% que
//es a todos los efectos transparentes pero así sí detecta el mouseup
//es a todos los efectos transparentes pero así sí detecta el mouseup
this.pantalla.style.backgroundColor = "black";
this.pantalla.style.filter = "alpha(opacity=0.1)";
}
wxG.agregarEventListener(null, [[this.pantalla, "outer"]]);
this.pantalla.addEventListener("mousemove",
function(event){
var evento = event || window.event;
that.controlarCursor(evento);
}, false);
this.pantalla.addEventListener("mouseup",
function(event){
var evento = event || window.event;
that.controlarCursor(evento);
}, false);
//Anexar la pantalla al DOM
this.lienzo.appendChild(this.pantalla);
}
//Apuntamos una referencia al propio objeto en la referencia conector
this.conector.objeto = this;
//Finalizamos posicionando el cursor final
this.tipoCursorActivo = "conector-cursor-fin";
this.posicionar(x2,y2);
};
//Formatear el cursor. El argumento iniFin será "Ini" o "Fin"
tempConstructor.prototype. formatearCursor = function(iniFin){
var forma = "";
if (iniFin == "Ini") {
forma = this.formaIni;
} else {
forma = this.formaFin;
}
220
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
//Para todos
this["cursor" + iniFin].style.top = Math.round(-this.tamanyoCursor-this.anchoBorde/2) + "px";
if (iniFin == "Fin") {
this["cursor" + iniFin].style.marginTop = "0px";
this["cursor" + iniFin].style.marginRight = "0px";
//ubica el cursor final en su centro
this["cursor" + iniFin].style.marginLeft = (this.conector.offsetWidth-this.tamanyoCursor) + "px";
} else {
this["cursor" + iniFin].style.marginTop = (-2*this.tamanyoCursor) + "px";
this["cursor" + iniFin].style.marginRight = "0px";
this["cursor" + iniFin].style.marginLeft = (-this.tamanyoCursor) + "px";
}
//Seleccionando
if (forma == "flecha") {
//sólo para flecha
this["cursor" + iniFin].style.width = 0;
this["cursor" + iniFin].style.height = 0;
this["cursor" + iniFin].style.borderStyle = "solid";
this["cursor" + iniFin].style.borderWidth = this.tamanyoCursor + "px";
this["cursor" + iniFin].style.borderColor = "transparent";
if (iniFin == "Fin") {
this["cursor" + iniFin].style.borderLeftColor = this.colorBorde;
} else {
this["cursor" + iniFin].style.borderRightColor = this.colorBorde;
}
this["cursor" + iniFin].style.backgroundColor = "transparent";
this["cursor" + iniFin].style.borderRadius = 0;
this["cursor" + iniFin].style[wxG.vpForCss["transform"]] = "scale(" +
this.scaleX + ", " + this.scaleY + ")";
} else {
//comunes para el resto que no sean flecha
this["cursor" + iniFin].style.width = (2*this.tamanyoCursor) + "px";
this["cursor" + iniFin].style.height = (2*this.tamanyoCursor) + "px";
this["cursor" + iniFin].style.borderStyle = "none";
this["cursor" + iniFin].style.borderWidth = 0;
this["cursor" + iniFin].style.borderColor = "transparent";
this["cursor" + iniFin].style.borderLeftColor = "transparent";
this["cursor" + iniFin].style.borderRightColor = "transparent";
//específicas
if (forma == "ninguna") {
this["cursor" + iniFin].style.backgroundColor = "transparent";
this["cursor" + iniFin].style.backgroundColor = "transparent";
this["cursor" + iniFin].style.borderRadius = 0;
} else if (forma == "cuadrado") {
this["cursor" + iniFin].style.backgroundColor = this.colorBorde;
this["cursor" + iniFin].style.borderRadius = 0;
} else if (forma == "circulo") {
this["cursor" + iniFin].style.backgroundColor = this.colorBorde;
this["cursor" + iniFin].style.borderRadius = (this.tamanyoCursor) + "px";
}
}
//Estos data son para cuando guardemos el html
this.conector.setAttribute("data-tamanyo-cursor", this.tamanyoCursor);
221
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
this.conector.setAttribute("data-forma-ini", this.formaIni);
this.conector.setAttribute("data-forma-fin", this.formaFin);
this.conector.setAttribute("data-scalex", this.scaleX);
this.conector.setAttribute("data-scaley", this.scaleY);
};
//Presentar la pantalla del conector para moverlo
tempConstructor.prototype. presentarPantalla = function(event){
var evento = event || window.event;
var objEvento = wxG.recogeEvento(evento);
this.cursorActivo = objEvento.element;
this.tipoCursorActivo = this.cursorActivo.className;
this.cursorActivo.style.outline = "red dotted 1px";
this.pantalla.style.display = "block";
};
//Controlar el cursor que se está moviendo
tempConstructor.prototype. controlarCursor = function(evento) {
if (evento.type == "mousemove") {
var objEvento = wxG.recogeEvento(evento);
var x = objEvento.pagx - this.lienzo.offsetLeft;
var y = objEvento.pagy - this.lienzo.offsetTop;
this.posicionar(x,y);
} else if (evento.type == "mouseup") {
this.pantalla.style.display = "none";
this.cursorActivo.style.outline = "none";
this.cursorActivo = null;
}
};
//Posicionar el cursor en un punto
tempConstructor.prototype. posicionar = function(x, y){
if (this.tipoCursorActivo == "conector-cursor-fin") {
//Sólo los conectores fijos entran aquí la primera vez que se construye el
//conector. Los conectores móviles entran aquí y en las otras alternativas.
//El ajuste this.ancb será cero para los conectores móviles.
var w = Math.sqrt(Math.pow(x-this.x1, 2)+Math.pow(y-this.y1, 2));
this.angulo = Math.atan2(y-this.y1, x-this.x1);
this.conector.style.width = Math.floor(w+2*this.ancb) + "px";
this.conector.style[wxG.vpForCss["transform"]] = "rotate(" +
wxG.redondear(this.angulo,wxCS.dec) + "rad)";
this.x2 = this.x1+w*Math.cos(this.angulo);
this.y2 = this.y1+w*Math.sin(this.angulo);
} else if (this.tipoCursorActivo == "conector-cursor-ini") {
this.conector.style.left = x + "px";
this.conector.style.top = y + "px";
this.x1 = x;
this.y1 = y;
var w = this.conector.offsetWidth;
this.x2 = x+w*Math.cos(this.angulo);
this.y2 = y+w*Math.sin(this.angulo);
} else if (this.tipoCursorActivo == "ff"){
//La flecha se fija y se mueve sólo el inicio. (x,y) portan incrementos.
this.x1 += x;
this.y1 += y;
this.conector.style.left = this.x1 + "px";
222
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
this.conector.style.top = this.y1 + "px";
this.angulo = Math.atan2(this.y2-this.y1, this.x2-this.x1);
var w = Math.sqrt(Math.pow(this.x2-this.x1, 2) + Math.pow(this.y2-this.y1, 2));
this.conector.style.width = Math.round(w) + "px";
this.conector.style.width = Math.round(w) + "px";
this.conector.style[wxG.vpForCss["transform"]] = "rotate(" + wxG.redondear(this.angulo,wxCS.dec) +
"rad)";
} else if (this.tipoCursorActivo == "if"){
//El inicio se fija y se mueve la flecha. (x,y) portan incrementos
this.x2 += x;
this.y2 += y;
this.angulo = Math.atan2(this.y2-this.y1, this.x2-this.x1);
var w = Math.sqrt(Math.pow(this.x2-this.x1, 2) + Math.pow(this.y2-this.y1, 2));
this.conector.style.width = Math.round(w) + "px";
this.conector.style[wxG.vpForCss["transform"]] = "rotate(" + wxG.redondear(this.angulo,wxCS.dec) +
"rad)";
}
//Ubica el cursor final en su centro
this.cursorFin.style.marginLeft = (this.conector.offsetWidth-this.tamanyoCursor) + "px";
if (this.eventoPosicionar) this.ejecutarAlPosicionar();
};
//Prefijamos estas propiedades por si hay navegadores que no las soporten sin prefijo
wxG.prefijarCss(["transform", "transform-origin"]);
//RETORNAMOS EL CONSTRUCTOR
return tempConstructor;
})();
}; //cierra el módulo
//==========================================================================
====================
/* grafica-lineal.js
* (c) 2013, Andrés de la Paz
* http://www.wextensible.com
*/
//Asignación inicial del espacio de nombres
var Visor = Visor || {};
//Envoltura para el cargador de módulos
Visor.GRAFICA_LINEAL_VISOR_JS = function(){
//Módulos cargados previamente
var wxG = Visor.general;
var wxCS = Visor.conectores;
//Módulo del tipo inicializador
Visor.iniciarGraficaLineal = (function(){
Visor.graficaLineal = {
//Variables obtenidas de los datos de usuario
xy: {},
x: {},
y: {},
css: {},
//Variables temporales de proceso
minimoTramoSubDiv: 5,
minimo: 0,
escala: 1,
anchoIniX: 0,
223
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
anchoFinX: 0,
altoFinX: 0,
maxAnchoY: 0,
dat: {
x: {tramoDiv:0, tramoSubDiv:0, longitudActual:0},
y: {tramoDiv:0, tramoSubDiv:0, longitudActual:0}
},
sumaValores: 0,
cacheRotulos: {},
coloresCategoriasDefault: ["aquamarine", "lemonchiffon", "greenyellow",
"pink", "lightcyan", "gold", "beige",
"springgreen", "mistyrose", "plum",
"honeydew", "coral", "khaki",
"lightskyblue", "peachpuff", "yellowgreen",
"moccasin", "turquoise", "whitesmoke",
"seashell", "lightyellow", "mintcream" ],
"seashell", "lightyellow", "mintcream" ],
coloresDefault: ["red", "green", "blue", "maroon", "purple", "olive", "teal", "gray",
"orange", "fuchsia", "lime", "cyan", "yellow", "silver"],
/* Los valores iniciales son los predeterminados, pues en los datos de usuario
* no tienen porqué venir todos. Así esos datos ocuparán menos volumen pero
* es importante no modificar los valores iniciales en este módulo una vez la aplicación
* esté en uso para asegurar la compatibilidad con versiones anteriores.
*/
valoresIni: {
//Estos valores son para wxGL.xy (área trazado y valores, es decir, propiedades
//generales de la gráfica)
general: {
titulo: "",
tipoGrafica: "barras",
udsTramoDiv: 100,
minUdsTramoDiv: 0,
textoVertical: false,
noWrap: false,
categoriasEntreTramos: false,
intercambiarEjes: false,
columnasSeries: 1,
margenBarras: 2,
colorTitulos: "black",
familiaFuenteTitulos: "Arial, sans-serif",
tamanyoFuenteTituloGrafica: "16",
tamanyoFuenteTituloEje: "16",
colorFondoGrafica: "transparent",
colorFondoAreaTrazado: "transparent",
colorBordeAreaTrazado: "transparent",//"black",
gruesoBordeAreaTrazado: 0,//1,
estiloBordeAreaTrazado: "none",
rotulosValores: "val",
rotulosValoresEmergentes: "cat-val-por",
leyendasSeries: true,
colorFondoLeyendasSeries: "transparent",
categorias: [],
usarColoresDefault: true,
224
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
coloresCategorias: [],
series: [
{
titulo: "",
colorLinea: "blue",
gruesoLinea: 1,
estiloLinea: "solid",
formaPunto: "cuadrado",
//tamanyoPunto: 4,
tamanyoPunto: 1,
rotulosSeries: "none",
valores: []
}
]
},
//Estos valores sirven para los dos ejes wxGL.x, wxGL.y
eje: {
titulo: "",
longitud: 200,
numTramosSubDiv: 1,
lineasDiv: true,
lineasSubDiv: false,
topLeft: false,
interior: false,
invertir: false,
decimales: 0,
miles: false,
colorLinea: "gray",
colorNumero: "gray",
familiaFuenteNumero: "Arial, sans-serif",
longDiv: 12,
longSubDiv: 5
},
},
//Estilo CSS adicional en algunos elementos que pueden agregarse
//aparte de los anteriores. Estos sobrescriben los anteriores, pero
//es útil para dar otros estilos que los anteriores no recogen.
css: {
grafica: "border: gray solid 1px;",
tituloGrafica: "",
tituloTop: "",
tituloBottom: "",
areaTrazado: "",
leyendasSeries: "",
rotulosSeries: "",
rotuloValor: "",
rotuloValorEmergente: "",
valorCategoriaX: "",
valorCategoriaY: ""
}
},
/* Función principal para crear la gráfica. El proceso es el siguiente:
* 1. construirArea() de trazado
225
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
* 1.1 prepararDatos() de usuario
* 1.2 crear HTML para títulos, área trazado, leyendas series, rótulos y ejes.
* 2. trazarGraficaLineas(), ...Barras() o ...Circular() sobre y alrededor del área de trazado
* 3. ajustarGrafica()
* 4. bordearAreaTrazado()
* 5. agregarCssAdicional()
*/
crearGrafica: function(idGrafica){
var areaTrazado = wxGL.construirArea(idGrafica);
if (wxGL.xy.tipoGrafica=="lineas") {
wxGL.trazarGraficaLineas(idGrafica, areaTrazado);
} else if (wxGL.xy.tipoGrafica=="barras") {
wxGL.trazarGraficaBarras(idGrafica, areaTrazado);
} else {
wxGL.trazarGraficaCircular(idGrafica, areaTrazado);
}
wxGL.ajustarGrafica(areaTrazado);
if (wxGL.xy.tipoGrafica!="circular") {
wxGL.ubicarTitulosEjes(idGrafica);
}
wxGL.bordearAreaTrazado(areaTrazado);
wxGL.agregarCssAdicional(idGrafica);
},
/* Esta es una forma alternativa de crear una gráfica a partir de un tabla tabulada en formato
* string "DATOS\rTIPO\rANCHO\rALTO", donde "DATOS" son los propios datos tabulados:
* - Primera fila con títulos: "TG|TX|TY S1 S2 ..."
* - Siguientes filas con categorias: "C1 N1 N2 ..."
* Las filas están separadas por una salto de línea "\n", mientras que " " representa un
* caracter tabulador "\t". La cadena TG|TX|TY son los títulos de la gráfica, eje X y ejeY,
* separados por una barra vertical. El tipo de gráfica, ancho y alto también pueden ser
* pasados en los argumentos. El resto de datos se toman desde los iniciales.
*/
cargarGraficaString: function(idGrafica, datosString, tipoGrafica, ancho, alto){
datosString = datosString.replace(/\r\n/g, "\n");
var w,h,t;
if (tipoGrafica) {
t = tipoGrafica;
} else {
t = wxGL.valoresIni.general.tipoGrafica;
}
if (ancho) {
w = ancho;
} else {
w = wxGL.valoresIni.eje.longitud;
}
if (alto) {
h = alto;
} else {
} else {
h = wxGL.valoresIni.eje.longitud;
}
Visor.datosGraficas[idGrafica] = datosString + "\r" + t + "\r" + w + "\r" + h;
wxGL.crearGrafica(idGrafica);
226
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
},
/* Todo se construirá en el contenedor idGrafica que se pasa en el argumento. La
* estructura del html final será:
* <div id="[idGrafica]">
* <div class="glin-titulo-grafica">...</div>
* <div class="glin-titulo-top">...</div>
* <div class="glin-contenedor-trazado"><div class="glin-area-trazado"> trazado">...</div></div>
</* <div class="glin-titulo-bottom">...</div>
* <div class="glin-leyendas">...</div>
* </div>
* Todos los div primeros hijos de idGrafica se posicionan de forma estática. Sólo el
* área de trazado (glin-area-trazado) tiene posición relativa, para posicionar de forma
* absoluta el contenido de la gráfica (ejes, líneas, puntos, etc).
*/
construirArea: function(idGrafica){
var areaTrazado;
var grafica = document.getElementById(idGrafica);
if (grafica) {
wxGL.prepararDatos(idGrafica);
grafica.style.padding = "16px";
grafica.style.backgroundColor = wxGL.xy.colorFondoGrafica;
grafica.style.webkitPrintColorAdjust = "exact";
//El título de la gráfica
var tituloGrafica = document.createElement("div");
tituloGrafica.id = idGrafica + "-tituloGrafica";
tituloGrafica.className = "glin-titulo-grafica";
tituloGrafica.style.color = wxGL.xy.colorTitulos;
tituloGrafica.style.fontFamily = wxGL.xy.familiaFuenteTitulos;
tituloGrafica.style.fontSize = wxGL.xy.tamanyoFuenteTituloGrafica + "px";
tituloGrafica.style.fontWeight = "bold";
tituloGrafica.style.textAlign = "center";
tituloGrafica.innerHTML = wxGL.xy.titulo;
grafica.appendChild(tituloGrafica);
//El título de la parte superior (título Y)
if (wxGL.xy.tipoGrafica != "circular") {
var tituloTop = document.createElement("div");
tituloTop.id = idGrafica + "-tituloTop";
tituloTop.className = "glin-titulo-top";
tituloTop.style.color = wxGL.xy.colorTitulos;
tituloTop.style.fontFamily = wxGL.xy.familiaFuenteTitulos;
tituloTop.style.fontSize = wxGL.xy.tamanyoFuenteTituloEje + "px";
tituloTop.style.lineHeight = wxGL.xy.tamanyoFuenteTituloEje + "px";
tituloTop.style.fontWeight = "bold";
grafica.appendChild(tituloTop);
}
//Este contenedor alberga los títulos de los ejes y el contenedor Trazado. Sirve
//para girar todo la gráfica completa e intercambiar ejes sin necesidad de repintarlos
var contenedorGrafica = document.createElement("div");
contenedorGrafica.id = idGrafica + "-contenedorGrafica";
contenedorGrafica.className = "glin-contenedor-grafica";
grafica.appendChild(contenedorGrafica);
//Este contenedor alberga el área de trazado
var contenedorTrazado = document.createElement("div");
227
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
//dejar este borde transparente
contenedorTrazado.style.border = "transparent solid 1px";
contenedorTrazado.id = idGrafica + "-contenedorTrazado";
contenedorTrazado.className = "glin-contenedor-trazado";
contenedorTrazado.style.overflow = "visible";
contenedorGrafica.appendChild(contenedorTrazado);
//El área de trazado tiene posición relativa para dibujan líneas de
//división y puntos con posicionamiento absoluto.
//Se devolverá la referencia para tenerla externamente y trazar puntos
areaTrazado = document.createElement("div");
areaTrazado.id = idGrafica + "-areaTrazado";
areaTrazado.className = "glin-area-trazado";
areaTrazado.style.position = "relative";
/*areaTrazado.style.width = wxGL.dat.x.longitudActual + "px";
/*areaTrazado.style.width = wxGL.dat.x.longitudActual + "px";
areaTrazado.style.height = wxGL.dat.y.longitudActual + "px";*/
areaTrazado.style.width = wxGL.dat.x.longitudActual + "px";
areaTrazado.style.height = wxGL.dat.y.longitudActual + "px";
areaTrazado.style.backgroundColor = wxGL.xy.colorFondoAreaTrazado;
contenedorTrazado.appendChild(areaTrazado);
//Título de eje en parte inferior (eje X)
if (wxGL.xy.tipoGrafica != "circular") {
var tituloBottom = document.createElement("div");
tituloBottom.id = idGrafica + "-tituloBottom";
tituloBottom.className = "glin-titulo-bottom";
tituloBottom.style.color = wxGL.xy.colorTitulos;
tituloBottom.style.fontFamily = wxGL.xy.familiaFuenteTitulos;
tituloBottom.style.fontSize = wxGL.xy.tamanyoFuenteTituloEje + "px";
tituloBottom.style.lineHeight = wxGL.xy.tamanyoFuenteTituloEje + "px";
tituloBottom.style.fontWeight = "bold";
grafica.appendChild(tituloBottom);
}
//Lleyendas de series
wxGL.crearLeyendasSeries(grafica);
//Contenedor para rótulos de valores emergentes
var rotuloValorEmergente = document.createElement("div");
rotuloValorEmergente.id = idGrafica + "-rotuloValorEmergente";
rotuloValorEmergente.className = "glin-rotulo-valor-emergente";
rotuloValorEmergente.style.position = "absolute";
rotuloValorEmergente.style.display = "none";
rotuloValorEmergente.style.zIndex = wxCS.zIndexPantalla + 800;
rotuloValorEmergente.style.color = wxGL.xy.colorTitulos;
rotuloValorEmergente.style.fontFamily = wxGL.xy.familiaFuenteTitulos;
rotuloValorEmergente.style.fontSize = wxGL.xy.tamanyoFuenteTituloEje + "px";
rotuloValorEmergente.style.padding = "5px";
rotuloValorEmergente.style.fontWeight = "bold";
rotuloValorEmergente.style.whiteSpace = "nowrap";
rotuloValorEmergente.style.backgroundColor = "white";
//Estos tamaños de bordes se tienen en cuenta en establecerEventoRotuloCircular()
rotuloValorEmergente.style.border = wxGL.xy.colorTitulos + " solid 1px";
rotuloValorEmergente.style.borderRadius = "5px";
rotuloValorEmergente.style.boxShadow = "gray 3px 3px";
areaTrazado.appendChild(rotuloValorEmergente);
228
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
//Creamos ejes
if (wxGL.xy.tipoGrafica != "circular") wxGL.crearEjes(areaTrazado);
}
//Devolvemos la referencia al área de trazado para acciones externas
return areaTrazado;
},
/* Los datos de usuario vienen en Visor.datosGraficas y los tenemos que pasar a wxGL. Previamente
* reiniciamos valores con lo que wxGL tendrá los valores predeterminados obtenidos de
wxGL.valoresIni.
* El objeto Visor.datosGraficas contiene tantas entradas como gráficas se vayan a crear en
* una página. Su estructura esquemática es:
* Visor.datosGraficas: {
* ID1: {
* xy: {titulo: "ggg",
* ...,
* categorias: ["c1", "c2", "c3", ...],
* coloresCategorias: ["red", "blue", "green", ...],
* series: [{titulo: "S1", ..., valores: [n1, n2, n3, ...]}, {...}, ...]
* },
* x: {titulo: "xxx", ...},
* y: {titulo: "yyy", ...},
* css: {...}
* },
* ID2: {...},
* ID3: "STRING",
* ...
*}
* Los ID son los de los contenedores donde se crearán las gráficas. Alguna entrada puede ser un string
* a modo de tabla de valores. Al final los datos para construir la gráfica van a parar a wxGL.xy, wxGL.x,
* wxGL.y, wxGL.css en el momento de crear cada gráfica, por lo que sirven sólo de almacén temporal
* para el proceso de creación. Al crear la siguiente gráfica se machacan los datos pues una vez creada
* no tiene utilidad conservarlos (no hay procesos posteriores que los usen).
*/
prepararDatos: function(: idGrafica){
var datUser;
var esString = (typeof Visor.datosGraficas[idGrafica] == "string");
if (esString) {
//Será un string con 1 a 4 posibles partes "DATOS\rTIPO\rANCHO\rALTO" separadas por "\r".
//DATOS sólo contiene valores en una tabla con la primera fila de títulos:
//TG|TX|TY tituloSerie1 tituloSerie2 ...
//separado por "\t" y filas separadas por "\n". Luego las siguientes filas son los
//títulos de categorías y los valores. Los títulos TG|TX|TY son los de la gráfica y ejes,
//separados por una barra vertical.
var ancho = wxGL.valoresIni.eje.longitud;
var alto = wxGL.valoresIni.eje.longitud;
var tipoGraf = wxGL.valoresIni.general.tipoGrafica;
var dgStr = Visor.datosGraficas[idGrafica];
var arrDg = dgStr.split("\r");
var dg = arrDg[0];
if (arrDg.length>1) {
tipoGraf = arrDg[1];
}
if (arrDg.length>2) {
229
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
ancho = arrDg[2];
}
if (arrDg.length>3) {
alto = arrDg[3];
}
//Creamos una nueva entrada de gráfica con valores iniciales.
Visor.datosGraficas[idGrafica] = {
xy:{
tipoGrafica: tipoGraf,
categorias:[],
series:[]
},
x:{
longitud: ancho
},
y:{
longitud: alto,
invertir: true,
topLeft: true
},
css:{}
};
//Parseamos la tabla para obtener los datos tabulados
var filas = dg.split("\n");
for (var i=0, maxI=filas.length; i<maxI; i++) {
var cols = filas[i].split("\t");
for (var j=0, maxJ=cols.length; j<maxJ; j++) {
if (i==0) {
if (j==0) {
var arr = cols[0].split("|");
if (arr.length>0) {
Visor.datosGraficas[idGrafica].xy.titulo = arr[0];
}
if (arr.length>1) {
Visor.datosGraficas[idGrafica].x.titulo = arr[1];
}
if (arr.length>2) {
Visor.datosGraficas[idGrafica].y.titulo = arr[2];
}
} else {
Visor.datosGraficas[idGrafica].xy.series[j-1] = {};
Visor.datosGraficas[idGrafica].xy.series[j-1].titulo = cols[j];
var colorLinea = "blue";
if ((j-1)<wxGL.coloresDefault.length) {
colorLinea = wxGL.coloresDefault[j-1];
}
Visor.datosGraficas[idGrafica].xy.series[j-1].colorLinea = colorLinea;
Visor.datosGraficas[idGrafica].xy.series[j-1].valores = [];
}
} else {
if (j==0) {
Visor.datosGraficas[idGrafica].xy.categorias[i-1] = cols[j];
} else {
230
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
Visor.datosGraficas[idGrafica].xy.series[j-1].valores[i-1] = cols[j];
}
}
}
}
} else {
//Si algúna parte no viene se toma vacío y luego se ponen valores iniciales
Visor.datosGraficas[idGrafica].xy = Visor.datosGraficas[idGrafica].xy || {};
Visor.datosGraficas[idGrafica].x = Visor.datosGraficas[idGrafica].x || {};
Visor.datosGraficas[idGrafica].y = Visor.datosGraficas[idGrafica].y || {};
Visor.datosGraficas[idGrafica].css = Visor.datosGraficas[idGrafica].css || {};
}
//Temporalmente almacenamos en datUser los datos de usuario
datUser = Visor.datosGraficas[idGrafica];
//Reiniciamos valores wxGL.xy, wxGL.x, wxGL.y, wxGL.css a partir de wxGL.valoresIni
wxGL.reiniciarValores();
//Extraemos datos de usuario GENERALES (xy)
for (var i in datUser.xy) {
if (i=="series") {
//Iteramos por todas las series que nos vienen en los datos datUser
for (var j=0; j<datUser.xy.series.length; j++) {
if (j>0) {
//El primer array ya está iniciado. Los siguientes los
//copiamos de valoresIni
wxGL.xy.series[j] = {};
for (var k in wxGL.valoresIni.general.series[0]) {
wxGL.xy.series[j][k] = wxGL.valoresIni.general.series[0][k];
}
}
//Pasamos los datos al objeto actual wxGL.xy.series
for (var k in datUser.xy.series[j]) {
//sólo llenamos los datos que vengan, los que no se usarán los
//predeterminados.
wxGL.xy.series[j][k] = datUser.xy.series[j][k];
}
}
} else {
wxGL.xy[i] = datUser.xy[i];
}
}
if (wxGL.xy.tipoGrafica=="barras") {
wxGL.xy.categoriasEntreTramos = true;
}
//Extraemos datos de usuario EJE X
for (var i in datUser.x) {
wxGL.x[i] = datUser.x[i];
}
//Extraemos datos de usuario EJE Y
for (var i in datUser.y) {
wxGL.y[i] = datUser.y[i];
}
//Extraemos datos de usuario para CSS ADICIONAL
for (var i in datUser.css) {
231
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
wxGL.css[i] = datUser.css[i];
}
//La variable temporal wxGL.dat contiene algunos datos que pueden ser modificados
//tras el proceso de construir el área de trazado
wxGL.dat.x.longitudActual = wxGL.x.longitud;
wxGL.dat.y.longitudActual = wxGL.y.longitud;
//Aquí se procesan el ancho y alto de la gráfica que pueden modificarse para
//adaptarse a la longitud de los tramos de divisiones
if (wxGL.xy.tipoGrafica != "circular") {
//Recopilamos todos los valores Y de todas las series en un único array
//para obtener el máximo y mínimo
var valores = [];
for (var i=0; i<wxGL.xy.series.length; i++) {
var arr = wxGL.xy.series[i].valores;
for (var j=0; j<arr.length; j++) {
valores[valores.length] = arr[j];
}
}
wxGL.minimo = Math.min.apply(Math, valores);
//Condicionar el mínimo de uds en Y con este mínimo
if (wxGL.minimo < wxGL.xy.minUdsTramoDiv) {
wxGL.xy.minUdsTramoDiv = wxGL.minimo;
} else {
wxGL.minimo = wxGL.xy.minUdsTramoDiv;
}
var max = Math.max.apply(Math, valores);
//Para string adaptamos udsTramoDiv a 1/10
if (esString) {
wxGL.xy.udsTramoDiv = Math.round(max/10);
wxGL.y.numTramosSubDiv = 5;
wxGL.x.numTramosSubDiv = 1;
}
//Calculamos temporalmente la escala (podrá ser recalculada después)
wxGL.escala = (max-wxGL.minimo)/wxGL.y.longitud;
wxGL.xy.udsTramoDiv = Math.abs(wxGL.xy.udsTramoDiv);
if (wxGL.xy.udsTramoDiv > (max-wxGL.minimo)) wxGL.xy.udsTramoDiv = (max-wxGL.minimo);
var nv = (max-wxGL.minimo)/wxGL.xy.udsTramoDiv;
var numValores = Math.round(nv);
wxGL.validarNumTramosSubDiv("y");
var subTramos = numValores * wxGL.y.numTramosSubDiv;
wxGL.dat.y.tramoSubDiv = Math.round(wxGL.y.longitud/subTramos);
wxGL.dat.y.tramoDiv = wxGL.y.numTramosSubDiv * wxGL.dat.y.tramoSubDiv;
wxGL.dat.y.longitudActual = subTramos * wxGL.dat.y.tramoSubDiv;
var tramoRectif = (numValores - nv)*wxGL.dat.y.tramoDiv;
var longRectif = wxGL.dat.y.longitudActual - tramoRectif;
wxGL.escala = (max-wxGL.minimo)/longRectif;
if (tramoRectif < 0) {
var diferMmax = max/wxGL.escala-wxGL.dat.y.longitudActual;
var numSubTramos = Math.ceil(diferMmax/wxGL.dat.y.tramoSubDiv);
wxGL.dat.y.longitudActual += numSubTramos * wxGL.dat.y.tramoSubDiv; //wxGL.dat.y.tramoDiv;
}
numValores = wxGL.xy.categorias.length;
if (wxGL.xy.categoriasEntreTramos) numValores++;
232
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
wxGL.validarNumTramosSubDiv("x");
subTramos = (numValores-1) * wxGL.x.numTramosSubDiv;
wxGL.dat.x.tramoSubDiv = Math.round(wxGL.x.longitud/subTramos);
wxGL.dat.x.tramoDiv = wxGL.x.numTramosSubDiv * wxGL.dat.x.tramoSubDiv;
wxGL.dat.x.longitudActual = subTramos * wxGL.dat.x.tramoSubDiv;
}
},
/* Esta función se llama para el eje X y eje Y, por lo que la extraemos para
* no duplicar código.
*/
validarNumTramosSubDiv: function(eje){
var numTramos = wxGL[eje].numTramosSubDiv;
if (isNaN(numTramos)) numTramos = 1;
numTramos = parseInt(numTramos);
if (numTramos<1) numTramos = 1;
if (numTramos>100) numTramos = 50;
wxGL[eje].numTramosSubDiv = numTramos;
},
/* Los datos para crear la gráfica está en wxGL.xy, wxGL.x, wxGL.y, pero inicialmente
* están vacios. Los rellenamos con los wxGL.valoresIni. La ventaja de hacerlo así es que la
* estructura de los dos ejes (wxGL.x, wxGL.y) son iguales y podemos guardar los valores
* iniciales en un único sito wxGL.valoresIni.eje.
*/
reiniciarValores: function(){
for (var i in wxGL.valoresIni.general) {
if (i=="series") {
wxGL.xy.series = [{}];
for (var j in wxGL.valoresIni.general.series[0]) {
wxGL.xy.series[0][j] = wxGL.valoresIni.general.series[0][j];
}
} else {
wxGL.xy[i] = wxGL.valoresIni.general[i];
}
}
for (var i in wxGL.valoresIni.eje) {
wxGL.x[i] = wxGL.valoresIni.eje[i];
wxGL.y[i] = wxGL.valoresIni.eje[i];
}
for (var i in wxGL.valoresIni.css) {
wxGL.css[i] = wxGL.valoresIni.css[i];
}
},
/* Leyendas de series y también de categorías para gráfica circular.
*/
crearLeyendasSeries: function(grafica){
if (wxGL.xy.leyendasSeries) {
var leyendas = document.createElement("div");
leyendas.className = "glin-leyendas-series";
leyendas.id = grafica.id + "-leyendasSeries";
leyendas.style.textAlign = "center";
leyendas.style.backgroundColor = wxGL.xy.colorFondoLeyendasSeries;
var fsize = wxGL.xy.tamanyoFuenteTituloEje;
leyendas.style.fontSize = fsize + "px";
233
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
leyendas.style.fontFamily = wxGL.xy.familiaFuenteTitulos;
var fsizeM = Math.round(fsize/2);
var fsize54 = Math.round(fsize*5/4);
var serCat = [];
var colores = [];
if (wxGL.xy.tipoGrafica=="circular") {
serCat = wxGL.xy.categorias;
if (wxGL.xy.usarColoresDefault) {
for (var j=0, maxJ=wxGL.xy.categorias.length; j<maxJ; j++) {
var color = "white";
if (j<wxGL.coloresCategoriasDefault.length) {
color = wxGL.coloresCategoriasDefault[j];
}
colores[j] = color;
}
} else {
colores= wxGL.xy.coloresCategorias;
}
} else {
serCat = wxGL.xy.series;
for (var j=0, maxJ=wxGL.xy.series.length; j<maxJ; j++) {
colores[j] = wxGL.xy.series[j].colorLinea;
}
}
var html = "";
if (wxGL.xy.tipoGrafica=="circular") {
//Ponemos el título del eje X en las gráficas circulares
var ttlo = wxGL.x.titulo;
if (wxGL.x.miles) ttlo += " (miles)";
html += '<div class="glin-circ-leyenda" style="display: inline-block; ' +
'color:' + wxGL.xy.colorTitulos + '; ' +
'font-weight: bold; ">' + ttlo + '</div><br />';
}
for (var i=0; i<serCat.length; i++) {
var colorLinea, colorLineaOpuesto, estiloLinea, formaPunto;
if (wxGL.xy.tipoGrafica=="lineas") {
colorLinea = colores[i];
colorLineaOpuesto = "transparent";
estiloLinea = serCat[i].estiloLinea;
formaPunto = serCat[i].formaPunto;
} else if (wxGL.xy.tipoGrafica=="barras") {
colorLineaOpuesto = colores[i];
colorLinea = "transparent";
estiloLinea = serCat[i].estiloLinea;
formaPunto = "";
} else {
colorLineaOpuesto = colores[i];
colorLinea = "transparent";
estiloLinea = "solid";
formaPunto = "";
}
//Un contenedor para cada serie
html += '<div class="glin-item-leyenda" style="display: inline-block; ' +
234
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
''+
'">';
//Un inline-block que cruza una línea horizontal en el tipo gráfica líneas. En el resto es
//transparente. Dentro de este se pone la forma de punto
html += '<div class="glin-item2-leyenda" style="display: inline-block; margin-left: 16px; ';
var ww = 0;
if (wxGL.xy.tipoGrafica=="lineas") {
ww = 3*fsize;
} else {
ww = 2*fsize;
}
html += 'width: ' + ww + 'px; height: ' + fsizeM + 'px; ';
var mpx = "1px";
if (estiloLinea == "double") mpx = "3px";
html += 'border-top-width: ' + mpx + '; ' +
'border-top-style: ' + estiloLinea + '; border-top-color: ' + colorLinea + '; ' +
'">';
//Forma de punto cuadradro, círculo o flecha
html += '<div class="glin-punto-leyenda" style="position: relative; ';
if (formaPunto != "flecha") {
html += 'left: ' + fsize + 'px; ' +
'margin-top: -' + fsizeM + 'px; ';
} else {
html += 'left: ' + fsize54 + 'px; ' +
'margin-top: -' + fsizeM + 'px; ';
}
if (formaPunto == "cuadrado") {
//html += 'width: ' + (fsize-1) + 'px; height: ' + (fsize-1) + 'px; ' +
html += 'width: ' + (1) + 'px; height: ' + (1) + 'px; ' +
'border: transparent solid 0px; ' +
'background-color: ' + colorLinea + '; ';
} else if (formaPunto == "circulo") {
html += 'width: ' + (fsize-1)+ 'px; height: ' + (fsize-1) + 'px; ' +
'background-color: ' + colorLinea + '; ' +
'border: transparent solid 0px; ' +
'border-radius: ' + (fsize-1) + 'px; ';
} else if (formaPunto == "flecha") {
html += 'width: 0; height: 0; ' +
'background-color: transparent; ' +
'border-width: ' + fsizeM + 'px; ' +
'border-style: solid; ' +
'border-color: transparent transparent transparent ' + colorLinea + '; ';
} else {
var borde= "";
if (wxGL.xy.tipoGrafica=="circular") {
borde = "border: gray solid 1px; ";
}
html += 'width: ' + (fsize-1) + 'px; height: ' + (fsize-1) + 'px; ' +
'background-color: ' + colorLineaOpuesto + '; ' + borde;
}
html += '"></div>' +
'</div>';
//Luego va el título (también un inline-block)
235
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
var titulo = "";
if (wxGL.xy.tipoGrafica=="circular") {
var num = serCat[i];
if (!isNaN(num)) {
if (wxGL.x.miles) num = num/1000;
num = parseFloat(num).toFixed(wxGL.x.decimales);
}
titulo = num;
} else {
titulo = serCat[i].titulo;
}
html += '<div class="glin-linea-leyenda" style="position: relative; ' +
'display: inline-block; margin-left: 5px; vertical-align:' + Math.round(fsize/8) + 'px; ' +
'color: ' + wxGL.xy.colorTitulos + '; ' +
'">' +
titulo +
'</div>' +
'</div>';
'</div>';
}
leyendas.innerHTML = html;
grafica.appendChild(leyendas);
}
},
/* Crea el HTML de los ejes X, Y
*/
crearEjes: function(areaTrazado){
var ejes = ["x", "y"];
for (var ie=0; ie<2; ie++) {
var eje = ejes[ie];
var medida, contramedida, lt, wh, lti, whi;
if (eje=="x"){
medida = areaTrazado.offsetWidth;
contramedida = areaTrazado.offsetHeight;
lt = "left";
wh = "width";
lti = "top";
whi = "height";
} else {
medida = areaTrazado.offsetHeight;
contramedida = areaTrazado.offsetWidth;
lt = "top";
wh = "height";
lti = "left";
whi = "width";
}
var fragmento = document.createDocumentFragment();
var arrCat = [];
if ((eje=="x") && (wxGL.xy.categorias.length>0)) {
if (wxGL.x.invertir) {
for (var i=wxGL.xy.categorias.length-1; i>-1; i--) {
arrCat[arrCat.length] = wxGL.xy.categorias[i];
}
236
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
} else {
for (var i=0; i<wxGL.xy.categorias.length; i++) {
arrCat[arrCat.length] = wxGL.xy.categorias[i];
}
}
}
//Entre categorías agregamos una vacía
if (wxGL.xy.categoriasEntreTramos) arrCat.push("");
var itemValores = -1;
for (var i=0; i<=medida; i++) {
//El ajuste en X siempre es perfecto para tramoDiv y tramoSubDiv, pero no pasa lo mismo en Y.
//Si no es así no se dibujará la lína horizontal de la máxima medida (en el bottom del
//área de trazado. En ese caso lo forzamos para que la dibuje.
// && (i % wxGL.dat[eje].tramoSubDiv != 0));
var jim, lineaCeroY;
if (wxGL[eje].invertir) {
jim = medida-i;
var lineaCeroY = ((eje=="y") && (i==0));
} else {
jim = i;
var lineaCeroY = ((eje=="y") && (i==medida));
}
if ((jim % wxGL.dat[eje].tramoSubDiv == 0) || lineaCeroY) {
var graduacion = document.createElement("div");
graduacion.className = "glin-graduacion-" + eje;
graduacion.style.position = "absolute";
graduacion.style.fontSize = wxGL[eje].longDiv + "px";
graduacion.style.fontFamily = wxGL[eje].familiaFuenteNumero;
graduacion.style.color = wxGL[eje].colorLinea;
graduacion.style[wxG.cambiaGuiones("border-" + lt)] = wxGL[eje].colorLinea + " solid 1px";
wxGL.pintarLinea(eje, areaTrazado, graduacion, wxGL[eje].lineasSubDiv,
wxGL[eje].longSubDiv,
contramedida, lti, whi);
graduacion.style[lt] = (i-1) + "px";
if ((jim % wxGL.dat[eje].tramoDiv == 0) || lineaCeroY){
graduacion.style[wh] = wxGL.dat[eje].tramoDiv + "px";
wxGL.pintarLinea(eje, areaTrazado, graduacion, wxGL[eje].lineasDiv,
wxGL[eje].longDiv,
wxGL[eje].longDiv,
contramedida, lti, whi);
var valorCategoria = document.createElement("div");
valorCategoria.className = "glin-valor-categoria-" + eje;
valorCategoria.style.position = "absolute";
valorCategoria.style.zIndex = wxCS.zIndexPantalla + 900;
valorCategoria.style.fontSize = wxGL[eje].longDiv + "px";
valorCategoria.style.fontFamily = wxGL[eje].familiaFuenteNumero;
valorCategoria.style.color = wxGL[eje].colorNumero;
if (eje == "y") {
var paddingTop = (wxGL.dat.y.tramoDiv/2-wxGL.y.longDiv/2);
valorCategoria.style.paddingTop = paddingTop + "px";
valorCategoria.style[wh] = (wxGL.dat[eje].tramoDiv - paddingTop) + "px";
valorCategoria.style.textAlign = "right";
} else {
237
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
valorCategoria.style.lineHeight = wxGL.x.longDiv + "px";
valorCategoria.style[wh] = wxGL.dat[eje].tramoDiv + "px";
valorCategoria.style.textAlign = "center";
}
if ((eje=="x") && wxGL.xy.categoriasEntreTramos) {
valorCategoria.style[lt] = (i-1) + "px";
} else {
valorCategoria.style[lt] = (i-1-wxGL.dat[eje].tramoDiv/2) + "px";
}
if (wxGL[eje].topLeft) {
if (wxGL[eje].interior) {
valorCategoria.style[lti] = (wxGL[eje].longDiv) + "px";
if (eje=="y") {
valorCategoria.style.textAlign = "left";
}
} else {
if (eje=="y") {
valorCategoria.style[lti] = (-wxGL[eje].longDiv) + "px";
} else {
valorCategoria.style[lti] = (-2*wxGL[eje].longDiv) + "px";
}
}
} else {
if (wxGL[eje].interior) {
if (eje=="y") {
valorCategoria.style[lti] = (contramedida-wxGL[eje].longDiv) + "px";
} else {
valorCategoria.style[lti] = (contramedida-2*wxGL[eje].longDiv) + "px";
}
} else {
valorCategoria.style[lti] = (contramedida+wxGL[eje].longDiv) + "px";
if (eje=="y") {
valorCategoria.style.textAlign = "left";
}
}
}
if ((eje=="x") && wxGL.xy.textoVertical) {
var align = "left";
var angulo = 90;
if (wxGL.x.topLeft) {
angulo = -90;
} else if (wxGL.xy.intercambiarEjes) {
angulo = -90;
align = "right";
}
valorCategoria.style[wxG.vpForCss["transform"]] = "rotate(" + angulo + "deg)";
if (wxGL.x.topLeft) {
valorCategoria.style.top = (-wxGL.dat.x.tramoDiv/2-wxGL.x.longDiv*3/2) + "px";
} else {
valorCategoria.style.top = (contramedida+wxGL.dat.x.tramoDiv/2+wxGL.x.longDiv/2) + "px";
}
valorCategoria.style.textAlign = align;
}
238
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
var valor = i;
var num = "";
if (eje=="x") {
itemValores++;
//En X siempre tendrá que haber alguna categoría pero, por si hay algún error
//no esperado sacamos como número el valor del pixel
//no esperado sacamos como número el valor del pixel
if (arrCat.length==0) {
num = valor;
} else if (itemValores < arrCat.length) {
num = arrCat[itemValores];
}
if ((wxG.trim(num) != "")&&(!isNaN(num))) {
if (wxGL[eje].miles) num = num/1000;
num = parseFloat(num).toFixed(wxGL[eje].decimales);
}
} else {
if (wxGL[eje].invertir) valor = medida - valor;
var val = valor*wxGL.escala+wxGL.minimo;
if (wxGL[eje].miles) val = val/1000;
num = parseFloat(val).toFixed(wxGL[eje].decimales);
}
if ((eje=="y") && (!wxGL.y.topLeft)) {
num = " " + num;
}
var nowrap = "";
if ((eje=="x") && wxGL.xy.noWrap) {
nowrap = "white-space: nowrap; ";
}
var valorHtml = '<div class="glin-valor-eje-' + eje + '" style="display: inline-block; ' +
nowrap + '">' + num + '</div>';
valorCategoria.innerHTML = valorHtml;
fragmento.appendChild(valorCategoria);
}
fragmento.appendChild(graduacion);
}
}
areaTrazado.appendChild(fragmento);
wxGL.ajustarAreaTrazado(areaTrazado, eje);
}
},
//Función que traza líneas de división para evitar esta ejecución repetida en crearEjes()
pintarLinea: function(eje, areaTrazado, graduacion, lineas, longitud, contramedida, lti, whi){
if (lineas) {
if (wxGL[eje].interior) {
graduacion.style[whi] = contramedida + "px";
} else {
graduacion.style[whi] = (longitud+contramedida) + "px";
}
} else {
graduacion.style[whi] = longitud + "px";
}
if (wxGL[eje].topLeft) {
239
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
if (!wxGL[eje].interior) {
graduacion.style[lti] = (-longitud) + "px";
}
} else {
if (lineas) {
graduacion.style[lti] = (0) + "px";
} else {
if (wxGL[eje].interior) {
graduacion.style[lti] = (contramedida-longitud) + "px";
} else {
graduacion.style[lti] = contramedida + "px";
}
}
}
},
/* Ajustes finales del área de trazado: se miden los anchos y altos de los textos de los valores
* de los ejes para reajustar la posición del área del trazado. Los elementos "valorCategorias" son los
* div todos de igual anchura. El texto se mete a su vez en un div interior que es sobre el que
* medimos el ancho. Este div interior tiene overflow visible y por tanto el texto puede sobresalir.
*/
ajustarAreaTrazado: function(areaTrazado, eje){
var valorCategorias = wxG.arrayClassName("glin-valor-categoria-" + eje, areaTrazado);
var maxAncho = 0;
var maxAlto = 0;
var maxAlto = 0;
for (var i=0; i<valorCategorias.length; i++) {
var hijoTexto = valorCategorias[i].firstChild;
var ancho = hijoTexto.offsetWidth;
if (ancho>maxAncho) maxAncho = ancho;
var alto = hijoTexto.offsetHeight;
if (alto>maxAlto) maxAlto = alto;
if (eje=="x") {
//El eje X se pinta antes que el Y. Guardamos el ancho de la primera y última
//categoría para más abajo ajustar los contenedores
if (i==0) wxGL.anchoIniX = ancho/2;
if (i==(valorCategorias.length-1)) {
if (!wxGL.xy.noWrap) {
//Si el texto no salta de línea, el ancho será la mitad pues el
//texto está centrado
wxGL.anchoFinX = ancho/2;
} else {
wxGL.anchoFinX = ancho - wxGL.dat.x.tramoDiv/2;
}
wxGL.altoFinX = alto;
}
} else {
wxGL.maxAnchoY = maxAncho;
if (wxGL.y.topLeft && !wxGL.y.interior) {
valorCategorias[i].style.left = (valorCategorias[i].offsetLeft-ancho) + "px";
}
}
}
//Empezamos con los ajustes del área de trazado. La variable relleno acumulará
240
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
//un marginLeft para el área de trazado.
var relleno = 0;
if (eje == "x") {
relleno = wxGL.x.longDiv;
if (wxGL.xy.textoVertical) {
relleno += maxAncho;
} else {
relleno += maxAlto;
}
if (wxGL.x.topLeft) {
areaTrazado.style.marginBottom = wxGL.y.longDiv + "px";
areaTrazado.style.marginTop = relleno + "px";
} else {
areaTrazado.style.marginTop = wxGL.y.longDiv + "px";
areaTrazado.style.marginBottom = relleno + "px";
}
//Reajusta las categorias
if (wxGL.xy.textoVertical || wxGL.x.topLeft){
for (var i=0; i<valorCategorias.length; i++) {
var top;
if (wxGL.xy.textoVertical) {
top = valorCategorias[i].offsetTop valorCategorias[i].offsetHeight/2+wxGL.x.longDiv/2;
} else {
top = valorCategorias[i].offsetTop valorCategorias[i].offsetHeight + wxGL.x.longDiv;
}
valorCategorias[i].style.top = top + "px";
}
}
//le ponemos un ancho de 1px al elemento DIV de la última columna de la derecha
//que no contiene datos pero sirve para dibujar el borde izquierdo de la última
//categoría. Le damos un ancho de 16px que es el especificado en construirArea().
var catx = wxG.arrayClassName("glin-graduacion-x", areaTrazado);
if (catx.length) catx[catx.length-1].style.width = "1em";
catx = wxG.arrayClassName("glin-valor-categoria-x", areaTrazado);
if (catx.length) catx[catx.length-1].style.width = "16px";
} else {
relleno = 0;
if (wxGL.xy.textoVertical) {
if (wxGL.y.topLeft) {
relleno = maxAncho+wxGL.y.longDiv;
} else {
relleno = wxGL.x.longDiv/2;
}
}
} else {
if (wxGL.y.topLeft) {
relleno = maxAncho+wxGL.y.longDiv;
if (!wxGL.xy.noWrap) {
if (relleno < wxGL.anchoIniX) relleno = wxGL.anchoIniX;
} else {
if (relleno < (wxGL.dat.x.tramoDiv/2)) relleno = wxGL.dat.x.tramoDiv/2;
241
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
}
} else {
if (!wxGL.xy.noWrap) {
relleno = wxGL.anchoIniX;
} else {
relleno = wxGL.dat.x.tramoDiv/2;
}
}
}
areaTrazado.style.marginLeft = relleno + "px";
}
},
/* Ajustar el ancho del contenedor de la gráfica. Si no se hace este ajuste, el ancho ocupará
* toda la ventana. Con esto se ajusta a lo necesario para albergar todo el conjunto
*/
ajustarGrafica: function(areaTrazado){
var grafica = wxG.nodoPadre(wxG.nodoPadre(wxG.nodoPadre(areaTrazado)));
var longi = areaTrazado.offsetWidth;
var anchoIni = 0, anchoFin = 0;
if (wxGL.xy.tipoGrafica != "circular") {
if (!wxGL.xy.textoVertical) {
if (wxGL.xy.noWrap) {
anchoIni = wxGL.dat.x.tramoDiv/2;
} else {
anchoIni = wxGL.anchoIniX;
}
anchoFin = wxGL.anchoFinX;
} else {
anchoIni = wxGL.x.longDiv/2;
anchoFin = wxGL.altoFinX + wxGL.x.longDiv;
}
if ((!wxGL.y.topLeft) && ((wxGL.maxAnchoY + wxGL.y.longDiv)>anchoFin)) {
anchoFin = wxGL.maxAnchoY + wxGL.y.longDiv;
}
if (wxGL.y.topLeft && ((wxGL.maxAnchoY + wxGL.y.longDiv)>anchoIni)) {
anchoIni = wxGL.maxAnchoY + wxGL.y.longDiv;
}
}
grafica.style.width = Math.round(longi + anchoIni + anchoFin) + "px";
if (wxGL.xy.intercambiarEjes) {
//rotamos el contenedor de trazado
wxG.nodoPadre(areaTrazado).style[wxG.vpForCss["transform"]] = "rotate(90deg)";
//cacheamos
var ww = wxG.nodoPadre(areaTrazado).offsetWidth;
var hh = wxG.nodoPadre(areaTrazado).offsetHeight;
//ajustamos el contenedor de la gráfica
wxG.nodoPadre(wxG.nodoPadre(areaTrazado)).style.width = hh + "px";
wxG.nodoPadre(wxG.nodoPadre(areaTrazado)).style.height = ww + "px";
grafica.style.width = hh + "px";
}
},
/* El borde del área de trazado no se puede dibujar sobre ese contenedor pues se dibuja exteriormente
* y encima de las marcas de los ejes. Aunque aún es posible poner borde al área de trazado con el
242
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
* CSS adicional, en las opciones generales podemos definir un borde INTERNO del área de trazado
* para lo cual creamos otro contenedor que montamos encima cuando finalicemos todo el
* pintado de la gráfica
*/
bordearAreaTrazado: function(areaTrazado){
var divBorde;
var bordeador = wxG.arrayClassName("glin-bordeador", areaTrazado);
if (bordeador && (bordeador.length>0)) {
divBorde = bordeador[0];
} else {
} else {
divBorde = document.createElement("div");
divBorde.setAttribute("class", "glin-bordeador");
divBorde.style.position = "absolute";
divBorde.style.left = (wxGL.xy.gruesoBordeAreaTrazado-2*wxGL.xy.gruesoBordeAreaTrazado) + "px";
divBorde.style.top = (wxGL.xy.gruesoBordeAreaTrazado-2*wxGL.xy.gruesoBordeAreaTrazado) + "px";
divBorde.style.width = (areaTrazado.offsetWidth-wxGL.xy.gruesoBordeAreaTrazado) + "px";
divBorde.style.height = (areaTrazado.offsetHeight-wxGL.xy.gruesoBordeAreaTrazado) + "px";
divBorde.style.zIndex = 10;
areaTrazado.appendChild(divBorde);
}
divBorde.style.border = wxGL.xy.colorBordeAreaTrazado + " " + wxGL.xy.estiloBordeAreaTrazado + "
"+
wxGL.xy.gruesoBordeAreaTrazado + "px";
},
/* Según la disposición wxGL.x.topLeft, wxGL.y.topLeft ubicamos los títulos X e Y:
* x.topLeft y.topLeft título X título Y
* ----------------------------------------------------------------* false false abajo-izquierda arriba-derecha
* false true abajo-derecha arriba-izquierda
* true false arriba-izquierda abajo-derecha
* true true arriba-derecha abajo-izquierda
*/
ubicarTitulosEjes: function(idGrafica) {
var eje, contraEje, divTitulo, contraDivTitulo;
if (wxGL.xy.intercambiarEjes) {
eje = "y";
contraEje = "x";
divTitulo = document.getElementById(idGrafica + "-tituloBottom");
contraDivTitulo = document.getElementById(idGrafica + "-tituloTop");
} else {
eje = "x";
contraEje = "y";
divTitulo = document.getElementById(idGrafica + "-tituloTop");
contraDivTitulo = document.getElementById(idGrafica + "-tituloBottom");
}
var titulo = {x:"", y:""};
titulo[eje] = wxGL[eje].titulo;
if (wxGL[eje].miles) titulo[eje] += " (miles)";
titulo[contraEje] = wxGL[contraEje].titulo;
if (wxGL[contraEje].miles) titulo[contraEje] += " (miles)";
//Reubicamos títulos de los ejes
var t1, t2, a1, a2;
243
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
if (wxGL[eje].topLeft) {
if (wxGL.xy.intercambiarEjes) {
t1 = titulo[contraEje]; t2 = titulo[eje];
} else {
t1 = titulo[eje]; t2 = titulo[contraEje];
}
if (wxGL[contraEje].topLeft) {
a1 = "right"; a2 = "left";
} else {
a1 = "left"; a2 = "right";
}
} else {
if (wxGL.xy.intercambiarEjes) {
t1 = titulo[eje]; t2 = titulo[contraEje];
} else {
t1 = titulo[contraEje]; t2 = titulo[eje];
}
if (wxGL[contraEje].topLeft) {
a1 = "left"; a2 = "right";
} else {
a1 = "right"; a2 = "left";
}
}
divTitulo.innerHTML = t1;
contraDivTitulo.innerHTML = t2;
if (wxGL[contraEje].topLeft) {
divTitulo.style.textAlign = a1;
contraDivTitulo.style.textAlign = a2;
} else {
divTitulo.style.textAlign = a1;
divTitulo.style.textAlign = a1;
contraDivTitulo.style.textAlign = a2;
}
},
/* Tras crear y trazar una gráfica se finaliza agregando CSS adicional que hubiera declarado
* el usuario para algunos elementos.
*/
agregarCssAdicional: function(idGrafica){
var grafica = document.getElementById(idGrafica);
for(var clave in wxGL.css) {
var css = wxG.trim(wxGL.css[clave]);
if (css != "") {
if ((clave=="valorCategoriaX")||(clave=="valorCategoriaY")||(clave=="rotulosSeries")||
(clave=="rotuloValor")||(clave=="rotuloValorEmergente")) {
var clase = "glin-" + wxG.descambiaGuiones(clave);
var vc = wxG.arrayClassName(clase, grafica);
for (var i=0; i<vc.length; i++) {
vc[i].style.cssText += css;
}
} else {
var item = "";
if (clave != "grafica") item = "-" + clave;
var elemento = document.getElementById(idGrafica + item);
244
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
if (elemento && (css!="")) {
elemento.style.cssText += css;
}
}
}
}
},
/* Trazado de GRÁFICA DE LÍNEAS
*/
trazarGraficaLineas: function(idGrafica, areaTrazado){
var idAreaTrazado = areaTrazado.id;
wxCS.dec = 10;
var dxIni = 0;
var signo = 1;
if (wxGL.x.invertir) {
dxIni = wxGL.dat.x.longitudActual;
if (wxGL.xy.categoriasEntreTramos) {
dxIni -= wxGL.dat.x.tramoDiv;
}
signo = -1;
}
if (wxGL.xy.categoriasEntreTramos) {
dxIni += wxGL.dat.x.tramoDiv/2;
}
for (var serie=0; serie<wxGL.xy.series.length; serie++) {
wxCS.colorBordeDefault = wxGL.xy.series[serie].colorLinea;
wxCS.anchoBordeDefault = wxGL.xy.series[serie].gruesoLinea;
wxCS.estiloBordeDefault = wxGL.xy.series[serie].estiloLinea + " none none";
wxCS.formaFinDefault = wxGL.xy.series[serie].formaPunto;
wxCS.tamanyoCursorDefault = wxGL.xy.series[serie].tamanyoPunto;
var dx = dxIni;
var valores = wxGL.xy.series[serie].valores;
var numValores = valores.length;
var medio = Math.floor((numValores-1)/2);
wxGL.sumaValores = 0;
for (var i=0;i<numValores; i++) {
wxGL.sumaValores += Math.abs(valores[i]);
}
for (var i=0; i<(numValores-1); i++) {
var x1 = dx;
var y1 = (valores[i]-wxGL.minimo)/wxGL.escala;
if (wxGL.y.invertir) y1 = wxGL.dat.y.longitudActual - y1;
dx = x1 + signo * wxGL.dat.x.tramoDiv;
var x2 = dx;
var y2 = ((valores[i+1]-wxGL.minimo)/wxGL.escala);
if (wxGL.y.invertir) y2 = wxGL.dat.y.longitudActual - y2;
if ((i==0)&&(wxCS.formaFinDefault != "flecha")) {
wxCS.formaIniDefault = wxCS.formaFinDefault;
wxCS.formaIniDefault = wxCS.formaFinDefault;
} else {
wxCS.formaIniDefault = "ninguno";
}
var obj = wxCS.crearConector(idAreaTrazado, x1, y1, x2, y2, true);
245
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
//Para evitar que un conector tape otro aunque tengan color fondo
//transparente ponemos altura 1px (tiene overflow visible para ver texto).
//El alto quedará entonces condicionado por el alto del punto que será
//en su caso mayor de 1px.
obj.conector.style.height = "1px";
//Agrega rótulos de título de serie
var posicion = wxGL.xy.series[serie].rotulosSeries;
if ((wxGL.xy.series[serie].rotulosSeries != "none") && (
((i==0)&&(posicion=="left"))||
((i==(numValores-2))&&(posicion=="right"))||
((i==medio)&&(posicion=="center"))
)) {
var texto = obj.conector.lastChild;
var spanTexto = document.createElement("span");
spanTexto.className = "glin-rotulos-series";
wxG.setInnerText(spanTexto, wxGL.xy.series[serie].titulo);
spanTexto.style.paddingLeft = "3px";
spanTexto.style.paddingRight = "3px";
texto.style.color = wxGL.xy.series[serie].colorLinea;
texto.style.fontFamily = wxGL.xy.familiaFuenteTitulos;
texto.style.fontSize = wxGL.xy.tamanyoFuenteTituloEje + "px";
texto.style.fontWeight = "bold";
texto.style.textAlign = "center";
texto.appendChild(spanTexto);
}
//Agrega rótulos de valores
if (wxGL.xy.rotulosValores != "no") {
var divTexto = wxGL.crearRotuloValor(areaTrazado, x1, y1, serie, i);
if (i==(numValores-2)) {
divTexto = wxGL.crearRotuloValor(areaTrazado, x2, y2, serie, i+1);
}
}
//Agrega evento para abrir rótulos de valores en cada punto
//Este es el cursor inicial del conector
if (wxGL.xy.rotulosValoresEmergentes != "no") {
var punto = obj.conector.firstChild.nextSibling;
punto.style.cursor = "pointer";
//No he podido hacerlo con addEventListener
var num = valores[i];
var cat = wxGL.xy.categorias[i];
var porcen = valores[i]/wxGL.sumaValores;
wxGL.establecerEventoRotulo(punto, "mouseover", idGrafica,
wxGL.xy.series[serie].colorLinea, x1, y1, serie, cat, num, porcen,
wxGL.xy.rotulosValoresEmergentes, wxGL.y.miles, wxGL.y.decimales);
wxGL.establecerEventoRotulo(punto, "mouseout", idGrafica);
if (i==(numValores-2)) {
//para el último punto se dibuja también el cursor final
var punto2 = obj.conector.firstChild;
punto2.style.cursor = "pointer";
num = valores[i+1];
cat = wxGL.xy.categorias[i+1];
porcen = valores[i+1]/wxGL.sumaValores;
wxGL.establecerEventoRotulo(punto2, "mouseover", idGrafica,
246
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
wxGL.xy.series[serie].colorLinea, x2, y2, serie, cat, num, porcen,
wxGL.xy.rotulosValoresEmergentes, wxGL.y.miles, wxGL.y.decimales);
wxGL.establecerEventoRotulo(punto2, "mouseout", idGrafica);
}
}
}
}
},
/* Trazado de GRÁFICA DE BARRAS
*/
trazarGraficaBarras: function(idGrafica, areaTrazado){
var margenBar = wxGL.xy.margenBarras;
if (wxGL.xy.series.length==1) margenBar = 0;
var anchoBar = Math.round((wxGL.dat.x.tramoDiv / wxGL.xy.series.length)*0.75);
if (anchoBar<1) anchoBar = 1;
if (anchoBar<1) anchoBar = 1;
var dxIni = Math.floor(margenBar+(
wxGL.dat.x.tramoDivanchoBar*
wxGL.xy.series.lengthmargenBar*(
wxGL.xy.series.length-1)
)/2);
var signo = 1;
if (wxGL.x.invertir) {
dxIni = wxGL.dat.x.longitudActual-wxGL.dat.x.tramoDiv+dxIni;
signo = -1;
}
for (var serie=0; serie<wxGL.xy.series.length; serie++) {
var dx = dxIni + (serie-1)*margenBar;
var valores = wxGL.xy.series[serie].valores;
var numValores = valores.length;
wxGL.sumaValores = 0;
for (var i=0;i<numValores; i++) {
wxGL.sumaValores += Math.abs(valores[i]);
}
for (var i=0; i<numValores; i++) {
var x = dx;
var y = 1+(valores[i]-wxGL.minimo)/wxGL.escala;
var barra = document.createElement("div");
barra.className = "glin-barra";
barra.style.position = "absolute";
barra.style.zIndex = wxCS.zIndexPantalla + 1;
barra.style.backgroundColor = wxGL.xy.series[serie].colorLinea;
barra.style.width = anchoBar + "px";
barra.style.height = Math.round(y) + "px";
var left = x + serie * anchoBar;
barra.style.left = Math.round(left) + "px";
var top = "-1";
if (wxGL.y.invertir) {
top = wxGL.dat.y.longitudActual-y;
}
barra.style.top = Math.round(top) + "px";
//Agrega rótulos valorese emergentes
if (wxGL.xy.rotulosValoresEmergentes != "no") {
247
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
var num = valores[i];
var cat = wxGL.xy.categorias[i];
var porcen = valores[i]/wxGL.sumaValores;
wxGL.establecerEventoRotulo(barra, "mouseover", idGrafica,
wxGL.xy.series[serie].colorLinea,
left, top, serie, cat, num, porcen,
wxGL.xy.rotulosValoresEmergentes, wxGL.y.miles, wxGL.y.decimales);
wxGL.establecerEventoRotulo(barra, "mouseout", idGrafica);
}
areaTrazado.appendChild(barra);
//Agrega rótulos de valores
if (wxGL.xy.rotulosValores != "no") {
var divTexto = wxGL.crearRotuloValor(areaTrazado, left, y, serie, i, anchoBar);
}
dx = x + signo * wxGL.dat.x.tramoDiv;
}
}
},
/* Trazado de GRÁFICA CIRCULAR
*/
trazarGraficaCircular: function(idGrafica, areaTrazado){
//En esta variable almacenamos algunos datos de la gráfica que necesitaremos posteriomente
//con los rótulos de valores emergentes. Cuando se crean varias gráficas en una página se
//reutilizan los objetos de datos wxGL.xy, wxGL.x, wxGL.y, wxGL.css, por lo que hay que
//almacenar algunos valores de una gráfica circular.
wxGL.cacheRotulos[idGrafica] = {};
if (wxGL.xy.rotulosValoresEmergentes != "no") {
wxGL.cacheRotulos[idGrafica].angulos = [];
wxGL.cacheRotulos[idGrafica].series = wxGL.xy.series;
wxGL.cacheRotulos[idGrafica].categorias = wxGL.xy.categorias;
wxGL.cacheRotulos[idGrafica].rotulosValoresEmergentes = wxGL.xy.rotulosValoresEmergentes;
wxGL.cacheRotulos[idGrafica].miles = wxGL.y.miles;
wxGL.cacheRotulos[idGrafica].decimales = wxGL.y.decimales;
wxGL.cacheRotulos[idGrafica].decimales = wxGL.y.decimales;
}
//Construimos un predeterminado de colores de categorías
var coloresCategorias = [];
if (wxGL.xy.usarColoresDefault) {
for (var j=0, maxJ=wxGL.xy.categorias.length; j<maxJ; j++) {
var color = "white";
if (j<wxGL.coloresCategoriasDefault.length) {
color = wxGL.coloresCategoriasDefault[j];
}
coloresCategorias[j] = color;
}
} else {
coloresCategorias = wxGL.xy.coloresCategorias;
}
//La altura del área de trazado se ajustará automáticamente a las tartas
areaTrazado.style.height = "auto";
var separaTarta = 4;
//Proceso de iteración por series
for (var serie=0; serie<wxGL.xy.series.length; serie++) {
248
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
var medida = Math.floor((areaTrazado.offsetWidth2*wxGL.xy.columnasSeries*separaTarta)/wxGL.xy.columnasSeries);
//Para conseguir un ajuste correcto esta medida debe ser par
if (medida % 2 != 0) medida--;
var medidaArco = medida/2;
var medidaBordeFinal = medida-2*wxGL.xy.series[serie].gruesoLinea;
var valores = wxGL.xy.series[serie].valores;
var numValores = valores.length;
wxGL.sumaValores = 0;
for (var i=0;i<numValores; i++) {
wxGL.sumaValores += Math.abs(valores[i]);
}
//Por cada serie creamos un contenedorTarta del tipo inline-block para que se
//ubique en línea o salte de línea si no cabe en el ancho. El título de la serie
//y la tarta las metemos dentro de este contenedor para cada serie.
var contenedorTarta = document.createElement("div");
contenedorTarta.id = idGrafica + "-contenedor-tarta-" + serie;
contenedorTarta.style.display = "inline-block";
contenedorTarta.style.position = "relative";
contenedorTarta.style.width = (medida+2*separaTarta) + "px";
var tituloSerie = document.createElement("div");
tituloSerie.style.color = wxGL.xy.colorTitulos;
tituloSerie.style.fontFamily = wxGL.xy.familiaFuenteTitulos;
tituloSerie.style.fontSize = wxGL.xy.tamanyoFuenteTituloEje + "px";
tituloSerie.style.fontWeight = "bold";
tituloSerie.style.textAlign = "center";
var ttlo = wxG.trim(wxGL.xy.series[serie].titulo);
if (ttlo != "") ttlo += " - " + wxGL.y.titulo;
if (wxGL.y.miles) ttlo += " (miles)";
wxG.setInnerText(tituloSerie, ttlo);
contenedorTarta.appendChild(tituloSerie);
//Seguimos con la tarta, la propia gráfica circular
var zIndexBase = 10;
var zIndex = zIndexBase;
var tarta = document.createElement("div");
tarta.id = idGrafica + "-tarta-" + serie;
tarta.style.position = "relative";
tarta.style.width = medida + "px";
tarta.style.height = medida + "px";
tarta.style.margin = separaTarta + "px";
var bordeBase = wxGL.xy.series[serie].colorLinea + " solid " + wxGL.xy.series[serie].gruesoLinea +
"px";
var bordeTransp = "transparente solid " + wxGL.xy.series[serie].gruesoLinea + "px";
var anguloAcumulado = 0;
var arrAngulos = [];
//Creación de los sectores de la tarta tantos como categorías y valores en la series
for (var i=0; i<numValores; i++) {
var bordeColor = coloresCategorias[i] + " solid " + wxGL.xy.series[serie].gruesoLinea + "px";
var esteAngulo = 360*Math.abs(valores[i])/wxGL.sumaValores;
var numArcos = parseInt(esteAngulo/90);
var anguloResto = esteAngulo % 90;
var angulo = 0;
var subangulo = 0;
249
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
//Cuando un sector es mayor de 90º, solapamos las porciones un poco antes para evitar la
//Cuando un sector es mayor de 90º, solapamos las porciones un poco antes para evitar la
//unión entre sectores del mismo arco (queda un espacio no bien rematado). Este ajuste lo
//corregimos en el último arco del sector.
var anguloAjuste = 2;
var ajustes = 0;
//Cada sector se compone de dos DIV. Uno es el arco, un cuadrado cuyos lados son de la
//misma longitud que el radio de la tarta. Los border superior y derecho forman un arco
//de círculo de 90 grados. Tiene color transparente. Se van rotando en su lugar para
//formar los distintos ángulos de los sectores. Si un sector tiene menos de 90º, el
//siguiente sector se monta encima del anterior cubriendo el ángulo que sobra. Si tiene
//más de 90º usamos tantos arcos de 90 como hagan falta.
//Dentro de cada arco ponemos un subarco que lleva el color de fondo. El arco tiene
//overflow hidden y recorta lo que sobra.
for (var j=0; j<(numArcos+1); j++) {
var arco = document.createElement("div");
arco.style.position = "absolute";
arco.style.left = (medidaArco+1) + "px";
arco.style.width = medidaArco + "px";
arco.style.height = medidaArco + "px";
arco.style.borderTopLeftRadius = 0;
arco.style.borderTopRightRadius = medidaArco + "px";
arco.style.borderBottomRightRadius = 0;
arco.style.borderBottomLeftRadius = 0;
arco.style.backgroundColor = "transparent";
arco.style.overflow = "hidden";
var subarco = document.createElement("div");
subarco.style.width = medidaArco + "px";
subarco.style.height = medidaArco + "px";
//No haría falta poner borde redondo al subarco porque estará metido dentro
//del arco, pero en OP y SA no recorta lo que sobresale, aunque FF y CH si lo recorta
subarco.style.borderTopLeftRadius = 0;
subarco.style.borderTopRightRadius = medidaArco + "px";
subarco.style.borderBottomRightRadius = 0;
subarco.style.borderBottomLeftRadius = 0;
subarco.style.backgroundColor = coloresCategorias[i];
if (j==0) {
angulo = anguloAcumulado;
subangulo = 0;
if (numArcos==0) {
subangulo = anguloResto-90;
}
} else if (j==numArcos) {
angulo += 90-anguloAjuste;
subangulo = anguloResto-90+(ajustes+1)*anguloAjuste;
} else {
ajustes++;
angulo += 90-anguloAjuste;
subangulo = 0;
}
subarco.style[wxG.vpForCss["transform-origin"]] = "left bottom";
subarco.style[wxG.vpForCss["transform"]] = "rotate(" +
(subangulo) + "deg)";
250
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
arco.style[wxG.vpForCss["transform-origin"]] = "left bottom";
arco.style[wxG.vpForCss["transform"]] = "rotate(" +
(angulo) + "deg)";
arco.appendChild(subarco);
tarta.appendChild(arco);
}
anguloAcumulado += esteAngulo;
arrAngulos[arrAngulos.length] = anguloAcumulado;
}
//Finalizado el pintado de sectores dibujamos un círculo encima de toda la tarta con
//fondo transparente. Nos servirá para rematar el borde y tener un elemento sobre el
//que declarar eventos para mostrar rótulos de valores emergentes.
var bordeFinal = document.createElement("div");
bordeFinal.className = "glin-circular-borde-final";
bordeFinal.style.position = "relative";
bordeFinal.style.width = (medidaBordeFinal) + "px";
bordeFinal.style.height = (medidaBordeFinal) + "px";
bordeFinal.style.border = wxGL.xy.series[serie].colorLinea + " " +
wxGL.xy.series[serie].estiloLinea + " " +
wxGL.xy.series[serie].gruesoLinea + "px";
bordeFinal.style.borderRadius = (medidaBordeFinal) + "px";
bordeFinal.style.zIndex = wxCS.zIndexPantalla + 700;
bordeFinal.style.zIndex = wxCS.zIndexPantalla + 700;
//Los rótulos de valores emergentes usar wxGL.cacheRotulos que almacenamos en la entrada
//de la función actual. Este evento hay que ponerlo sobre el bordeFinal pues es más complejo
//ponerlo sobre los arcos, pues entre otras razones un sector puede tener más de un arco-subarco y
//habría que poner declaraciones a todos los sectores. Así aquí sólo hacemos una declaración en
//este elemento y manejaremos para detectar el ángulo y de ahí obtener la categoría-valor
if (wxGL.xy.rotulosValoresEmergentes != "no") {
var numCacheAngulos = wxGL.cacheRotulos[idGrafica].angulos.length;
wxGL.cacheRotulos[idGrafica].angulos[numCacheAngulos] = arrAngulos;
bordeFinal.setAttribute("onmousemove", "wxGL.establecerEventoRotuloCircular(event, '" + idGrafica +
"', '" + wxGL.xy.series[serie].colorLinea + "', " + numCacheAngulos + ")");
bordeFinal.setAttribute("onmouseout", "wxGL.establecerEventoRotuloCircular(event, '" + idGrafica +
"')");
}
tarta.appendChild(bordeFinal);
//Agregamos la tarta al contenedor...
contenedorTarta.appendChild(tarta);
//... y el contenedor al área de trazado
areaTrazado.appendChild(contenedorTarta);
//Dibujamos los radios de los sectores usando conector.js. También en este proceso
//creamos los rótulos de valores
wxCS.colorBordeDefault = wxGL.xy.series[serie].colorLinea;
wxCS.anchoBordeDefault = wxGL.xy.series[serie].gruesoLinea;
wxCS.estiloBordeDefault = wxGL.xy.series[serie].estiloLinea + " none none";
wxCS.formaFinDefault = wxGL.xy.series[serie].formaPunto;
wxCS.tamanyoCursorDefault = wxGL.xy.series[serie].tamanyoPunto;
var tamanyoTitulos = wxGL.y.longDiv;
//Hacemos un ajuste (ver this.ancb en conector.js)
var r = medidaArco-wxGL.xy.series[serie].gruesoLinea;
var x = medidaArco;
var y = medidaArco;
251
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
for (var i=0; i<numValores; i++) {
var angi = arrAngulos[i];
if (angi==90) angi += 0.000001;
//Si la difer. angulo es exactamente cero no pinta bien el conector
var angulo = (angi-90)*2*Math.PI/360;
var obj = wxCS.crearConector(idGrafica + "-tarta-" + serie, x, y, r, angulo, true, true);
if (wxGL.xy.rotulosValores != "no") {
//Al crear el conector obtenemos acceso a objeto.conector que es el DIV del conector.
//Su último hijo es un DIV donde podemos agregar texto.
var texto = obj.conector.lastChild;
texto.style.paddingLeft = "16px";
var divTexto = document.createElement("div");
divTexto.style.display = "inline-block";
divTexto.className = "glin-rotulo-valor";
divTexto.style.textAlign = "right";
divTexto.style.paddingLeft = (3*wxGL.xy.series[serie].gruesoLinea) + "px";
divTexto.style.paddingRight = (3*wxGL.xy.series[serie].gruesoLinea) + "px";
//Ajustamos por el mínimo el fontSize al perímetro de cada sector. Por ejemplo, si la
//fuente de partida (wxGL.y.longDiv es la misma que la que se usa para el tamaño de
//fuente de ejes) es de 16px y un sector tiene un perímetro menor entonces la fuente
//se ajusta para que quepa en esa longitud.
var fsize, valor;
if (i<(numValores-1)) {
fsize = (arrAngulos[i+1]-arrAngulos[i])*medidaArco*2*Math.PI/360;
valor = valores[i+1];
} else {
fsize = arrAngulos[0]*medidaArco*2*Math.PI/360;
valor = valores[0];
}
var porcentaje = valor /wxGL.sumaValores ;
var categoria = "";
if (i<(numValores-1)) {
categoria = wxGL.xy.categorias[i+1];
} else {
categoria = wxGL.xy.categorias[0];
}
var miles = wxGL.y.miles;
var decimales = wxGL.y.decimales;
var conten = wxGL.formatearRotuloValor(wxGL.xy.rotulosValores, categoria, valor,
porcentaje, miles, decimales);
wxG.setInnerText(divTexto, conten);
if (fsize>wxGL.y.longDiv) {
fsize = wxGL.y.longDiv;
fsize = wxGL.y.longDiv;
} else if (fsize<6) {
fsize = 6;
}
var altoFsize = fsize;
divTexto.style.fontSize = Math.round(fsize) + "px";
//El texto en el conector se debe desplazar 2 veces el tamaño del punto
//para que quede junto al conector. Luego subimos media fuente para
//centrarlo encima del conector (y luego girarlo)
texto.style.marginTop = Math.round(-2*wxGL.xy.series[serie].tamanyoPunto-altoFsize/2) + "px";
252
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
texto.style.lineHeight = Math.round(altoFsize) + "px";
divTexto.style.fontFamily = wxGL.y.familiaFuenteNumero;
texto.style.color = wxGL.y.colorNumero;
texto.style.textAlign = "right"; //posRotulo;
texto.style[wxG.vpForCss["transform-origin"]] = "left " + Math.round(altoFsize/2) + "px";
var ang = 0;
if (i<(numValores-1)) {
ang = (arrAngulos[i+1]-arrAngulos[i])/2;
} else {
ang = arrAngulos[0]/2;
}
texto.style[wxG.vpForCss["transform"]] = "rotate(" + ang + "deg)";
if (((arrAngulos[i]+ang)>=180)&&((arrAngulos[i]+ang)<360)){
//Giramos el texto interior para que no se vea al revés
divTexto.style[wxG.vpForCss["transform"]] = "rotate(-180deg)";
divTexto.style.textAlign = "left";
}
texto.style.zIndex = wxCS.zIndexPantalla + 100000;
texto.appendChild(divTexto);
}
}
}
},
/* Rótulos de valor sólo para tipos de gráfica LÍNEAS y BARRAS, no para circular, que se crean en
* trazarGraficaCircular()
*/
crearRotuloValor: function(areaTrazado, x, y, serie, numCategoria, anchoBar){
/*
var existeValor = false;
if (anchoBar == null) {
for (var i=0; i<serie; i++) {
if (wxGL.xy.series[i].valores[numCategoria] == wxGL.xy.series[serie].valores[numCategoria]) {
existeValor = true;
break;
}
}
}
if (!existeValor) {
var divTexto = document.createElement("div");
divTexto.className = "glin-rotulo-valor";
divTexto.style.position = "absolute";
divTexto.style.zIndex = wxCS.zIndexPantalla + 100;
divTexto.style.fontFamily = wxGL.y.familiaFuenteNumero;
divTexto.style.fontSize = wxGL.y.longDiv + "px";
divTexto.style.color = wxGL.xy.series[serie].colorLinea;
var xx = x;
var yy = y;
if (anchoBar == null) {
//gráfica líneas
if (wxGL.xy.series[serie].formaPunto != "ninguno"){
xx += wxGL.xy.series[serie].tamanyoPunto/2;
yy -= wxGL.xy.series[serie].tamanyoPunto/2;
}
253
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
} else {
//gráfica barras
if (wxGL.y.invertir) {
yy = wxGL.dat.y.longitudActual-y;
}
xx += anchoBar/2;
divTexto.style.textAlign = "left";
//divTexto.style.border = "green solid 1px";
divTexto.style.whiteSpace = "nowrap";
divTexto.style[wxG.vpForCss["transform-origin"]] = "left center";
}
divTexto.style.left = Math.round(xx) + "px";
divTexto.style.top = Math.round(yy) + "px";
var valor = wxGL.xy.series[serie].valores[numCategoria];
var categoria = wxGL.xy.categorias[numCategoria];
var porcentaje = valor/wxGL.sumaValores;
var miles = wxGL.y.miles;
var decimales = wxGL.y.decimales;
var conten = wxGL.formatearRotuloValor(wxGL.xy.rotulosValores, categoria,
valor, porcentaje, miles, decimales);
wxG.setInnerText(divTexto, conten);
areaTrazado.appendChild(divTexto);
if (anchoBar == null) {
//gráficas líneas
if ((divTexto.offsetLeft + divTexto.offsetWidth)>areaTrazado.offsetWidth) {
divTexto.style.left = (areaTrazado.offsetWidth-divTexto.offsetWidth) + "px";
}
if ((divTexto.offsetTop + divTexto.offsetHeight)>areaTrazado.offsetHeight) {
divTexto.style.top = (areaTrazado.offsetHeight-divTexto.offsetHeight) + "px";
} else {
divTexto.style.top = (divTexto.offsetTop - divTexto.offsetHeight) + "px";
}
} else {
//gráficas barras
if (wxGL.y.invertir) {
divTexto.style.top = (divTexto.offsetTop - divTexto.offsetHeight) + "px";
} else {
divTexto.style.top = (divTexto.offsetTop + divTexto.offsetWidth) + "px";
divTexto.style.textAlign = "right";
}
if (wxGL.y.invertir && (divTexto.offsetTop < (divTexto.offsetWidth/2))) {
divTexto.style.left = Math.round(divTexto.offsetLeft - divTexto.offsetWidth/2) + "px";
divTexto.style.top = Math.round(divTexto.offsetTop - divTexto.offsetHeight/4) + "px";
} else if (!wxGL.y.invertir &&
((divTexto.offsetTop + divTexto.offsetWidth/2)>wxGL.dat.y.longitudActual)) {
divTexto.style.left = Math.round(divTexto.offsetLeft - divTexto.offsetWidth/2) + "px";
divTexto.style.top = Math.round(divTexto.offsetTop - 2*divTexto.offsetHeight) + "px";
} else {
divTexto.style[wxG.vpForCss["transform"]] = "rotate(270deg)";
}
}
}
*/
254
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
},
/* Manejador para el evento mouse para presentar el rótulo de valor emergente. No para gráfica circular
* que tiene un manejador aparte establecerEventoRotuloCircular().
*/
establecerEventoRotulo: function(elemento, evento, idGrafica, colorLinea, x, y, serie, categoria, valor,
porcentaje, formato, miles, decimales){
var att = "";
if (evento=="mouseover") {
att = "wxGL.mostrarRotulo(this, '" + idGrafica + "', '" + colorLinea +
"', " + x + ", " + y + ", '" + serie + "', '" + categoria + "', " + valor + ", " +
porcentaje + ", '" + formato + "'," + miles + ","+ decimales + ");";
} else {
att = "wxGL.ocultarRotulo('" + idGrafica + "');";
}
elemento.setAttribute("on" + evento, att);
},
/* El evento del rótulo de valores emergentes para la gráfica circular se dispone en el elemento
* bordeFinal, un círculo con fondo transparente y borde igual que la tarta de sectores. Aquí
* detectamos el ángulo donde se recoge el evento y obtenemos el sector para saber que categoría
* y valor vamos a presentar en el rótulo emergente.
*/
establecerEventoRotuloCircular: function(event, idGrafica, color, numCacheAngulos){
var obj = wxG.recogeEvento(event);
var w = obj.element.offsetWidth;
var h = obj.element.offsetHeight;
if (obj.event.type == "mousemove") {
var x = obj.x-w/2;
var y = h-obj.y-h/2;
var angulo = Math.atan2(y, x);
angulo = Math.PI/2 - angulo;
if (angulo<0) angulo = 3*Math.PI/2+Math.PI/2-Math.abs(angulo);
angulo = angulo*360/(2*Math.PI);
var cacheAngulos = wxGL.cacheRotulos[idGrafica].angulos[numCacheAngulos];
var anguloCategoria = 0;
for (var i=0, max=cacheAngulos.length; i<max; i++) {
if (cacheAngulos[i] > angulo) {
if (i==0) {
anguloCategoria = cacheAngulos[i];
} else {
anguloCategoria = cacheAngulos[i]-cacheAngulos[i-1];
}
break;
}
}
if (i<cacheAngulos.length) {
var rotulo = document.getElementById(idGrafica + "-rotuloValorEmergente");
var dataRotulo = rotulo.getAttribute("data-serie-categoria");
var esteSC = numCacheAngulos + "-" + wxGL.cacheRotulos[idGrafica].categorias[i];
var mostrar = ((rotulo.style.display=="none")||(dataRotulo!=esteSC));
if (mostrar) {
var valor = wxGL.cacheRotulos[idGrafica].series[numCacheAngulos].valores[i];
var areaTrazado = document.getElementById(idGrafica + "-areaTrazado");
var categoria = wxGL.cacheRotulos[idGrafica].categorias[i];
255
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
if (!isNaN(categoria)) {
if (wxGL.cacheRotulos[idGrafica].miles) categoria = categoria/1000;
categoria = parseFloat(categoria).toFixed(wxGL.cacheRotulos[idGrafica].decimales);
}
var porcentaje = anguloCategoria/360;
var formato = wxGL.cacheRotulos[idGrafica].rotulosValoresEmergentes;
wxGL.mostrarRotulo(obj.element,
idGrafica,
color,
obj.pagx-areaTrazado.offsetLeft,
obj.pagy-areaTrazado.offsetTop,
numCacheAngulos,
categoria,
valor,
porcentaje,
formato,
wxGL.cacheRotulos[idGrafica].miles,
wxGL.cacheRotulos[idGrafica].decimales);
}
}
} else {
wxGL.ocultarRotulo(idGrafica);
}
},
/* En mostrarRotulo() mostrarmos los rótulos de valores emergentes, desde donde necesitamos
* formaterar el rótulo según la configuración del usuario para esa gráfica
*/
formatearRotuloValor: function(formato, categoria, valor, porcentaje, miles, decimales){
var conten = "";
if (miles) valor = valor/1000;
var val = parseFloat(valor).toFixed(decimales);
var por = parseFloat(porcentaje*100).toFixed(2);
switch (formato) {
case "cat":
conten = categoria;
break;
case "cat-val":
conten = categoria + ": " + val;
break;
case "cat-val-por":
//conten = categoria + ": " + val + " (" + por + "%)";
conten = categoria + ": " + val ;
break;
case "cat-por":
//conten = categoria + ": "
conten = categoria + ": ";
break;
case "val":
conten = val;
break;
case "val-por":
//conten = val + " (" + por + "%)";
conten = val ;
256
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
break;
case "por":
//conten = por + "%";
conten = "";
break;
default:
conten = val;
}
return conten;
},
/* Mostramos los rótulos de valores emergentes. Realmente el rótulo es un DIV único que se ubica en la
* posición y se le cambia el texto según la categoría-serie donde se mueve el cursor
*/
mostrarRotulo: function(este, idGrafica, color, x, y, serie, categoria, valor, porcentaje, formato, miles,
decimales) {
var rotuloValorEmergente = document.getElementById(idGrafica + "-rotuloValorEmergente");
rotuloValorEmergente.style.backgroundColor = color;
var colorTexto = "white";
if ("orange,fuchsia,lime,cyan,yellow,silver".indexOf(color)>-1) colorTexto = "black";
rotuloValorEmergente.style.color = colorTexto;
//agrega el CSS adicional (que puede sobrescribir el estilo anterior)
var css = wxGL.css["rotuloValorEmergente"];
if (css != "") {
rotuloValorEmergente.style.cssText += css;
}
rotuloValorEmergente.style.display = "block";
var conten = wxGL.formatearRotuloValor(formato, categoria, valor, porcentaje, miles, decimales);
wxG.setInnerText(rotuloValorEmergente, conten);
rotuloValorEmergente.setAttribute("data-serie-categoria", serie + "-" + categoria);
var left = x;
var top = y;
var anchoMas = este.offsetWidth;
if (este.className=="glin-circular-borde-final") {
anchoMas = 5;
}
rotuloValorEmergente.style.left = (Math.round(left)+anchoMas) + "px";
rotuloValorEmergente.style.top = Math.round(top-2*wxGL.y.longDiv) + "px";
if (wxGL.xy.intercambiarEjes) {
rotuloValorEmergente.style[wxG.vpForCss["transform-origin"]] = "left bottom";
rotuloValorEmergente.style[wxG.vpForCss["transform"]] = "rotate(-90deg)";
}
},
/* Ocultar el rótulo de valores emergentes
*/
ocultarRotulo: function(idGrafica){
document.getElementById(idGrafica + "-rotuloValorEmergente").style.display = "none";
}
};
//Una referencia al objeto anterior
var wxGL = Visor.graficaLineal;
/* Función inicializadora del módulo. Recopila todos los elementos con clase "grafica-lineal" de la
* página para crear una gráfica en cada uno.
*/
257
APÉNDICE II. CÓDIGOS. JAVASCRIPT. grafica-lineal-visor-ACSenJS.js
return function() {
//Busca todos los DIV con class="gl-contenedor" para crear las gráficas
var gls = wxG.arrayClassName("grafica-lineal");
for (var i=0, max=gls.length; i<max; i++) {
wxGL.crearGrafica(gls[i].id);
}
//devolvemos la rereferencia a este módulo
return wxGL;
};
})();
};
258
Descargar