first commit
This commit is contained in:
commit
e7bd585b28
40 files changed
+1233
No files matched your search
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>sisPDS</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1680217338092</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,11 @@
|
||||
## SSF - Simulador da Série de Fourier
|
||||
|
||||
Projeto desenvolvido na disciplina de Processamento Digital de Sinais do 8º semestre do curso de Engenharia da Computação do Centro Universitário Católico Salesiano Auxilium no ano de 2015, sob supervisão do professor José Vital Ferraz Leão. Este software simula a construção de ondas quadradas e triangulares através da superposição de ondas senoidais. Implementado em Java.
|
||||
|
||||
Também participaram deste projeto os alunos:
|
||||
|
||||
Claudio Barbosa do Nascimento Neto, David Allan dos Reis Borelli, Guilherme da Silva Oliveira, Jessiclei Ferreira Rodrigues, William Cardoso Simas, Tamiris Ayumi Aoe
|
||||
|
||||
Abaixo, o funcionamento do sistema. Clique na imagem para assistir o vídeo.
|
||||
|
||||
[](https://www.youtube.com/watch?v=D0LzqdL9hyA)
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
//http://docs.oracle.com/javase/7/docs/api/javax/swing/JTextPane.html
|
||||
//http://www.java2s.com/Tutorials/Java/Swing_How_to/JTextPane/Pad_text_in_JTextPane.htm
|
||||
//http://www.java2s.com/Tutorial/Java/0240__Swing/SimpleAttributeBoldItalic.htm
|
||||
//https://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html
|
||||
|
||||
package componentesVisuais;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
import javax.swing.text.Style;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.StyledDocument;
|
||||
|
||||
public class ClsTextPane
|
||||
{
|
||||
private JTextPane tpnTextPane;
|
||||
private Style stlEstilo;
|
||||
private StyledDocument stdDocumento;
|
||||
private SimpleAttributeSet sasAtributos;
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public ClsTextPane(JTextPane pTextPane)
|
||||
{
|
||||
tpnTextPane = pTextPane;
|
||||
stlEstilo = tpnTextPane.addStyle("stlEstilo", null);
|
||||
stdDocumento = tpnTextPane.getStyledDocument();
|
||||
sasAtributos = new SimpleAttributeSet();
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void alinharTextoADireita(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto)
|
||||
{
|
||||
StyleConstants.setAlignment(sasAtributos, StyleConstants.ALIGN_RIGHT);
|
||||
tpnTextPane.getStyledDocument().setParagraphAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, sasAtributos, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void alinharTextoAEsquerda(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto)
|
||||
{
|
||||
StyleConstants.setAlignment(sasAtributos, StyleConstants.ALIGN_LEFT);
|
||||
tpnTextPane.getStyledDocument().setParagraphAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, sasAtributos, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void alinharTextoAoCentro(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto)
|
||||
{
|
||||
StyleConstants.setAlignment(sasAtributos, StyleConstants.ALIGN_CENTER);
|
||||
tpnTextPane.getStyledDocument().setParagraphAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, sasAtributos, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void alinharTextoJustificar(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto)
|
||||
{
|
||||
StyleConstants.setAlignment(sasAtributos, StyleConstants.ALIGN_JUSTIFIED);
|
||||
tpnTextPane.getStyledDocument().setParagraphAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, sasAtributos, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarNegrito(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, boolean pblnAplicar)
|
||||
{
|
||||
StyleConstants.setBold(stlEstilo, pblnAplicar);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarItalico(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, boolean pblnAplicar)
|
||||
{
|
||||
StyleConstants.setItalic(stlEstilo, pblnAplicar);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarSublinhado(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, boolean pblnAplicar)
|
||||
{
|
||||
StyleConstants.setUnderline(stlEstilo, pblnAplicar);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarTamanhoDaFonte(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, int pintTamanho)
|
||||
{
|
||||
StyleConstants.setFontSize(stlEstilo, pintTamanho);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarCorDaFonte(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, Color pclrCor)
|
||||
{
|
||||
StyleConstants.setForeground(stlEstilo, pclrCor);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarCorDaFonteEItalico(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, Color pclrCor)
|
||||
{
|
||||
StyleConstants.setForeground(stlEstilo, pclrCor);
|
||||
StyleConstants.setItalic(stlEstilo, true);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarCorDaFonteENegrito(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, Color pclrCor)
|
||||
{
|
||||
StyleConstants.setForeground(stlEstilo, pclrCor);
|
||||
StyleConstants.setBold(stlEstilo, true);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void formatarFonte(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto, Color pclrCor, boolean pblnNegrito, boolean pblnItalico, boolean pblnSublinhado, int pintTamanho, String strFonte)
|
||||
{
|
||||
StyleConstants.setForeground(stlEstilo, pclrCor);
|
||||
StyleConstants.setBold(stlEstilo, pblnNegrito);
|
||||
StyleConstants.setItalic(stlEstilo, pblnItalico);
|
||||
StyleConstants.setUnderline(stlEstilo, pblnSublinhado);
|
||||
StyleConstants.setFontSize(stlEstilo, pintTamanho);
|
||||
StyleConstants.setFontFamily(stlEstilo, strFonte);
|
||||
stdDocumento.setCharacterAttributes(0, tpnTextPane.getText().length(), stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void removerFormatacao(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto)
|
||||
{
|
||||
StyleConstants.setForeground(stlEstilo, Color.BLACK);
|
||||
StyleConstants.setBold(stlEstilo, false);
|
||||
StyleConstants.setItalic(stlEstilo, false);
|
||||
StyleConstants.setUnderline(stlEstilo, false);
|
||||
StyleConstants.setFontSize(stlEstilo, 12);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarCorDeFundo(Color pclrCor)
|
||||
{
|
||||
tpnTextPane.setBackground(pclrCor);
|
||||
}
|
||||
/*------------------------------------------------------------------------------------------------------------------------*/
|
||||
public void aplicarCorDeFundo(int pintPosicaoInicialDoTexto, int pintPosicaoFinalDoTexto,Color pclrCor)
|
||||
{
|
||||
StyleConstants.setBackground(stlEstilo, pclrCor);
|
||||
stdDocumento.setCharacterAttributes(pintPosicaoInicialDoTexto, pintPosicaoFinalDoTexto, stlEstilo, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
package formularios;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JButton;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.JTextPane;
|
||||
import componentesVisuais.ClsTextPane;
|
||||
|
||||
public class FrmSobre extends JFrame
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel jContentPane = null;
|
||||
private JPanel pnlBotoes = null;
|
||||
private JButton btnFechar = null;
|
||||
private JTextPane tpnSobre = null;
|
||||
|
||||
public FrmSobre()
|
||||
{
|
||||
super();
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize()
|
||||
{
|
||||
this.setSize(566, 466);
|
||||
this.setContentPane(getJContentPane());
|
||||
this.setTitle("Sobre");
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setResizable(false);
|
||||
}
|
||||
|
||||
private JPanel getJContentPane()
|
||||
{
|
||||
if (jContentPane == null)
|
||||
{
|
||||
jContentPane = new JPanel();
|
||||
jContentPane.setLayout(new BorderLayout());
|
||||
jContentPane.add(getPnlBotoes(), BorderLayout.SOUTH);
|
||||
jContentPane.add(getTpnSobre(), BorderLayout.CENTER);
|
||||
}
|
||||
return jContentPane;
|
||||
}
|
||||
|
||||
private JPanel getPnlBotoes()
|
||||
{
|
||||
if (pnlBotoes == null)
|
||||
{
|
||||
pnlBotoes = new JPanel();
|
||||
pnlBotoes.setLayout(new FlowLayout());
|
||||
pnlBotoes.add(getBtnFechar(), null);
|
||||
}
|
||||
return pnlBotoes;
|
||||
}
|
||||
|
||||
private JButton getBtnFechar()
|
||||
{
|
||||
if (btnFechar == null)
|
||||
{
|
||||
btnFechar = new JButton();
|
||||
btnFechar.setText("Fechar");
|
||||
btnFechar.addActionListener(
|
||||
new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnFechar;
|
||||
}
|
||||
|
||||
private JTextPane getTpnSobre()
|
||||
{
|
||||
if (tpnSobre == null)
|
||||
{
|
||||
tpnSobre = new JTextPane();
|
||||
int intPosicaoInicial = 0;
|
||||
ClsTextPane objTextPane = new ClsTextPane(tpnSobre);
|
||||
String strTextoFinal;
|
||||
String strDescricao = "Software desenvolvido na disciplina de Processamento Digital de Sinais(PDS)\n\n";
|
||||
String strCabecalho = "SSF\n" +
|
||||
"Simulador da s�rie de Fourier\n\n";
|
||||
|
||||
String strAutor = "Desenvolvido por:\n" +
|
||||
"\t\t\t\t\t\t\t\t\t\tClaudio Barbosa do Nascimento Neto.\n"+
|
||||
"\t\t\t\t\t\t\t\t\t\tDavid Allan dos Reis Borelli.\n"+
|
||||
"\t\t\t\t\t\t\t\t\t\tGuilherme da Silva Oliveira.\n"+
|
||||
"\t\t\t\t\t\t\t\t\t\tJessiclei Ferreira Rodrigues.\n"+
|
||||
"\t\t\t\t\t\t\t\t\t\tWilliam Cardoso Simas.\n\n"+
|
||||
"\t\t\t\t\t\t\t\t\t\tEngenharia da Computa��o - 8� termo.\n" +
|
||||
"\t\t\t\t\t\t\t\t\t\tCentro Universit�rio Cat�lico Salesiano Auxilium - Ara�atuba(SP).\n\n" +
|
||||
"\t\t\t\t\t\t\t\t\t\tTamiris Ayumi Aoe.\n\n"+
|
||||
"\t\t\t\t\t\t\t\t\t\tEngenharia de Telecomunica��es\n" +
|
||||
"\t\t\t\t\t\t\t\t\t\tCentro Universit�rio Cat�lico Salesiano Auxilium - Ara�atuba(SP).\n\n";
|
||||
String strOrientadores = "Orientado por:\n" +
|
||||
"\t\t\t\t\t\t\t\t\t\tMsc. Jos� Vital Ferraz Le�o.\n"+
|
||||
"\t\t\t\t\t\t\t\t\t\tCentro Universit�rio Cat�lico Salesiano Auxilium - Ara�atuba(SP).\n\n";
|
||||
|
||||
strTextoFinal = strCabecalho + strDescricao + strAutor + strOrientadores;
|
||||
|
||||
tpnSobre.setText(strTextoFinal);
|
||||
|
||||
objTextPane.alinharTextoAoCentro(intPosicaoInicial, strCabecalho.length());
|
||||
objTextPane.aplicarNegrito(intPosicaoInicial, strCabecalho.length(), true);
|
||||
objTextPane.aplicarTamanhoDaFonte(intPosicaoInicial, strCabecalho.length(), 16);
|
||||
|
||||
objTextPane.aplicarCorDaFonte(intPosicaoInicial, strCabecalho.length(), Color.BLACK);
|
||||
|
||||
intPosicaoInicial += strCabecalho.length();
|
||||
objTextPane.alinharTextoAoCentro(intPosicaoInicial, intPosicaoInicial + strAutor.length());
|
||||
objTextPane.aplicarTamanhoDaFonte(intPosicaoInicial, intPosicaoInicial + strAutor.length(), 12);
|
||||
objTextPane.aplicarNegrito(intPosicaoInicial, intPosicaoInicial + strAutor.length(), false);
|
||||
|
||||
intPosicaoInicial += strDescricao.length();
|
||||
objTextPane.alinharTextoJustificar(intPosicaoInicial, intPosicaoInicial + strAutor.length());
|
||||
objTextPane.aplicarTamanhoDaFonte(intPosicaoInicial, intPosicaoInicial + strAutor.length(), 12);
|
||||
objTextPane.aplicarNegrito(intPosicaoInicial, intPosicaoInicial + 3, true);
|
||||
objTextPane.aplicarNegrito(intPosicaoInicial + 18, intPosicaoInicial + strAutor.length(), false);
|
||||
|
||||
intPosicaoInicial += strAutor.length();
|
||||
objTextPane.alinharTextoJustificar(intPosicaoInicial, intPosicaoInicial + strOrientadores.length());
|
||||
objTextPane.aplicarTamanhoDaFonte(intPosicaoInicial, intPosicaoInicial + strOrientadores.length(), 12);
|
||||
objTextPane.aplicarNegrito(intPosicaoInicial, intPosicaoInicial + 14, true);
|
||||
objTextPane.aplicarNegrito(intPosicaoInicial + 15, intPosicaoInicial + strOrientadores.length(), false);
|
||||
|
||||
tpnSobre.setEditable(false);
|
||||
}
|
||||
return tpnSobre;
|
||||
}
|
||||
} // @jve:decl-index=0:visual-constraint="10,10"
|
||||
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
@@ -0,0 +1,717 @@
|
||||
package formularios;
|
||||
|
||||
import grafico.ClsOnda;
|
||||
import grafico.PnlGrafico;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.JButton;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.Font;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.WindowConstants;
|
||||
import java.text.DecimalFormat;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
import java.lang.Object;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class frmPrincipal extends JFrame
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel jContentPane = null;
|
||||
private PnlGrafico pnlGrafico = null;
|
||||
private PnlGrafico pnlGraficoTotal = null;
|
||||
private JPanel pnlGraficos = null;
|
||||
private JPanel pnlControles = null;
|
||||
private JPanel pnlRodape = null;
|
||||
private JButton btnSobre = null;
|
||||
private JButton btnSair = null;
|
||||
private ClsOnda objOndas[];
|
||||
private JLabel lblFourier = null;
|
||||
private JLabel lblOndasSenoidais = null;
|
||||
private int intQtdOndas = 0;
|
||||
ClsOnda objSoma[];
|
||||
private int intAmplitudeInicial = 0;
|
||||
private double dblPeriodoInicial = 0;
|
||||
private float fltZoomSenoidal = 1;
|
||||
private float fltZoomSuperposicao = 1;
|
||||
private boolean blnQuadrada = false;
|
||||
private boolean blnTriangular = false;
|
||||
private JPanel pnlZoomOndasSenoidais = null;
|
||||
private JButton btnZoomMaisOndasSenoidais = null;
|
||||
private JButton btnZoomMenosOndasSenoidais = null;
|
||||
private JButton btnZoomNormalOndasSenoidais = null;
|
||||
private JPanel pnlZoomSuperposicao = null;
|
||||
private JPanel pnlCriacaoOndas = null;
|
||||
private JRadioButton rdbOndaTriangular = null;
|
||||
private JRadioButton rdbOndaQuadrada = null;
|
||||
private JSlider sldQtdOndas = null;
|
||||
private JLabel lblqtdOndas = null;
|
||||
private JButton btnMenosOndas = null;
|
||||
private JButton btnMaisOndas = null;
|
||||
private JScrollPane scrOndas = null;
|
||||
private JTable tblOndas = null;
|
||||
private JLabel lblAmplitude = null;
|
||||
private JTextField txtAmplitude = null;
|
||||
private JLabel lblPeriodo = null;
|
||||
private JTextField txtPeriodo = null;
|
||||
public frmPrincipal()
|
||||
{
|
||||
super();
|
||||
initialize();
|
||||
}
|
||||
|
||||
private Color defineCor(int x)
|
||||
{
|
||||
Color retorno = Color.WHITE;
|
||||
if (x%15 ==1)
|
||||
retorno = Color.RED;
|
||||
if (x%15 ==2)
|
||||
retorno = Color.BLUE;
|
||||
if (x%15 ==3)
|
||||
retorno = Color.BLACK;
|
||||
//retorno = Color.YELLOW;
|
||||
if (x%15 ==4)
|
||||
retorno = Color.GREEN;
|
||||
if (x%15 ==5)
|
||||
retorno = Color.ORANGE;
|
||||
if (x%15 ==6)
|
||||
retorno = new Color(139,0,139);
|
||||
if (x%15 ==7)
|
||||
retorno = new Color(255,20,147);
|
||||
if (x%15 ==8)
|
||||
retorno = new Color(0,206,209);
|
||||
if (x%15 ==9)
|
||||
retorno = new Color(255,140,0);
|
||||
if (x%15 ==10)
|
||||
retorno = new Color(255,215,0);
|
||||
if (x%15 ==11)
|
||||
retorno = new Color(128,128,0);
|
||||
if (x%15 ==12)
|
||||
retorno = new Color(173,255,47);
|
||||
if (x%15 ==13)
|
||||
retorno = new Color(218,165,32);
|
||||
if (x%15 ==14)
|
||||
retorno = new Color(210,105,30);
|
||||
if (x%15 ==0)
|
||||
retorno = new Color(220,20,60);
|
||||
return retorno;
|
||||
}
|
||||
|
||||
private void definirOndas()
|
||||
{
|
||||
objOndas = new ClsOnda[intQtdOndas];
|
||||
Color cor = Color.BLACK;
|
||||
for(int x=1; x<=intQtdOndas; x++)
|
||||
{
|
||||
cor = defineCor(x);
|
||||
int amplitude = 0;
|
||||
double periodo = 0;
|
||||
if(blnQuadrada)
|
||||
{
|
||||
amplitude = (int)(Math.round(1.57 * ((intAmplitudeInicial)/(Math.PI * x))*(1-Math.cos(x*Math.PI))));
|
||||
periodo = (dblPeriodoInicial*Math.PI)/x;
|
||||
}
|
||||
if(blnTriangular)
|
||||
{
|
||||
amplitude = (int)(Math.round(9.9 * (intAmplitudeInicial)/Math.pow(Math.PI, 2)) * ((Math.pow((-1),(x-1)/2))/Math.pow(x, 2)));
|
||||
periodo = (dblPeriodoInicial*Math.PI)/x;
|
||||
}
|
||||
objOndas[x-1] = new ClsOnda(amplitude, periodo, 558, 558, 100, cor, fltZoomSenoidal);
|
||||
}
|
||||
}
|
||||
private void definirSoma()
|
||||
{
|
||||
int X[] = new int[558];
|
||||
double Y[] = new double[558];
|
||||
for(int x=0; x<intQtdOndas; x++)
|
||||
{
|
||||
for(int y=0; y<558; y++)
|
||||
{
|
||||
if(x==0)
|
||||
{
|
||||
Y[y] = 0;
|
||||
}
|
||||
X[y] = y;
|
||||
Y[y] += objOndas[x].obterOrgY()[y];
|
||||
}
|
||||
}
|
||||
objSoma = new ClsOnda[1];
|
||||
objSoma[0] = new ClsOnda(X, Y, Color.RED, 558, 100, fltZoomSuperposicao);
|
||||
}
|
||||
|
||||
private void aplicarZoomSenoidal()
|
||||
{
|
||||
definirOndas();
|
||||
DecimalFormat fmt = new DecimalFormat("0.0");
|
||||
String part[] = fmt.format(fltZoomSenoidal).split("[,]");
|
||||
btnZoomNormalOndasSenoidais.setText(part[0]+ "." +part[1]);
|
||||
pnlGrafico.atualizarTela(intQtdOndas, objOndas, getPnlGrafico().getGraphics());
|
||||
}
|
||||
|
||||
private void alterarQtdOndas()
|
||||
{
|
||||
definirOndas();
|
||||
definirSoma();
|
||||
lblqtdOndas.setText("Qtd Ondas: " + sldQtdOndas.getValue());
|
||||
pnlGrafico.atualizarTela(intQtdOndas, objOndas, getPnlGrafico().getGraphics());
|
||||
pnlGraficoTotal.atualizarTela(1, objSoma, getPnlGraficoTotal().getGraphics());
|
||||
tblOndas.updateUI();
|
||||
}
|
||||
|
||||
private PnlGrafico getPnlGrafico()
|
||||
{
|
||||
definirOndas();
|
||||
if (pnlGrafico == null)
|
||||
{
|
||||
pnlGrafico = new PnlGrafico(intQtdOndas, objOndas);
|
||||
pnlGrafico.setLayout(null);
|
||||
pnlGrafico.setBounds(new Rectangle(0, 28, 560, 200));
|
||||
pnlGrafico.setBackground(Color.WHITE);
|
||||
pnlGrafico.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
}
|
||||
return pnlGrafico;
|
||||
}
|
||||
|
||||
private PnlGrafico getPnlGraficoTotal()
|
||||
{
|
||||
definirSoma();
|
||||
if (pnlGraficoTotal == null)
|
||||
{
|
||||
pnlGraficoTotal = new PnlGrafico(1, objSoma);
|
||||
pnlGraficoTotal.setLayout(null);
|
||||
pnlGraficoTotal.setBounds(new Rectangle(0, 255, 560, 200));
|
||||
pnlGraficoTotal.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
pnlGraficoTotal.setBackground(Color.WHITE);
|
||||
}
|
||||
return pnlGraficoTotal;
|
||||
}
|
||||
|
||||
private JPanel getPnlGraficos()
|
||||
{
|
||||
if (pnlGraficos == null)
|
||||
{
|
||||
lblOndasSenoidais = new JLabel();
|
||||
lblOndasSenoidais.setBounds(new Rectangle(0, 4, 620, 24));
|
||||
lblOndasSenoidais.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblOndasSenoidais.setText("Ondas senoidais");
|
||||
lblOndasSenoidais.setFont(new Font("Dialog", Font.BOLD, 18));
|
||||
lblFourier = new JLabel();
|
||||
lblFourier.setBounds(new Rectangle(0, 229, 620, 24));
|
||||
lblFourier.setFont(new Font("Dialog", Font.BOLD, 18));
|
||||
lblFourier.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblFourier.setText("Superposição");
|
||||
pnlGraficos = new JPanel();
|
||||
pnlGraficos.setBounds(new Rectangle(0, 0, 620, 455));
|
||||
pnlGraficos.setLayout(null);
|
||||
pnlGraficos.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
pnlGraficos.add(getPnlGrafico(), null);
|
||||
pnlGraficos.add(getPnlGraficoTotal(), null);
|
||||
pnlGraficos.add(lblFourier, null);
|
||||
pnlGraficos.add(lblOndasSenoidais, null);
|
||||
pnlGraficos.add(getPnlZoomOndasSenoidais(), null);
|
||||
pnlGraficos.add(getPnlZoomSuperposicao(), null);
|
||||
}
|
||||
return pnlGraficos;
|
||||
}
|
||||
|
||||
private JPanel getPnlControles()
|
||||
{
|
||||
if (pnlControles == null)
|
||||
{
|
||||
pnlControles = new JPanel();
|
||||
pnlControles.setLayout(null);
|
||||
pnlControles.setBounds(new Rectangle(618, 0, 376, 455));
|
||||
pnlControles.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
pnlControles.add(getPnlCriacaoOndas(), null);
|
||||
pnlControles.add(getScrOndas(), null);
|
||||
}
|
||||
return pnlControles;
|
||||
}
|
||||
|
||||
private JPanel getPnlRodape()
|
||||
{
|
||||
if (pnlRodape == null)
|
||||
{
|
||||
pnlRodape = new JPanel();
|
||||
pnlRodape.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
pnlRodape.setBounds(new Rectangle(0, 455, 995, 39));
|
||||
pnlRodape.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
|
||||
pnlRodape.add(getBtnSobre(), null);
|
||||
pnlRodape.add(getBtnSair(), null);
|
||||
}
|
||||
return pnlRodape;
|
||||
}
|
||||
|
||||
private JButton getBtnSobre()
|
||||
{
|
||||
if (btnSobre == null)
|
||||
{
|
||||
btnSobre = new JButton();
|
||||
btnSobre.setText("Sobre...");
|
||||
btnSobre.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
FrmSobre janelaSobre = new FrmSobre();
|
||||
janelaSobre.setVisible(true);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnSobre;
|
||||
}
|
||||
|
||||
private JButton getBtnSair()
|
||||
{
|
||||
if (btnSair == null)
|
||||
{
|
||||
btnSair = new JButton();
|
||||
btnSair.setText("Sair");
|
||||
btnSair.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnSair;
|
||||
}
|
||||
|
||||
private JPanel getPnlZoomOndasSenoidais()
|
||||
{
|
||||
if (pnlZoomOndasSenoidais == null)
|
||||
{
|
||||
pnlZoomOndasSenoidais = new JPanel();
|
||||
pnlZoomOndasSenoidais.setLayout(null);
|
||||
pnlZoomOndasSenoidais.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
pnlZoomOndasSenoidais.setBounds(new Rectangle(558, 28, 62, 200));
|
||||
pnlZoomOndasSenoidais.add(getBtnZoomMaisOndasSenoidais(), null);
|
||||
pnlZoomOndasSenoidais.add(getBtnZoomMenosOndasSenoidais(), null);
|
||||
pnlZoomOndasSenoidais.add(getBtnZoomNormalOndasSenoidais(), null);
|
||||
}
|
||||
return pnlZoomOndasSenoidais;
|
||||
}
|
||||
|
||||
private JButton getBtnZoomMaisOndasSenoidais()
|
||||
{
|
||||
if (btnZoomMaisOndasSenoidais == null)
|
||||
{
|
||||
btnZoomMaisOndasSenoidais = new JButton();
|
||||
btnZoomMaisOndasSenoidais.setBounds(new Rectangle(2, 2, 58, 65));
|
||||
btnZoomMaisOndasSenoidais.setFont(new Font("Dialog", Font.PLAIN, 24));
|
||||
btnZoomMaisOndasSenoidais.setText("+");
|
||||
btnZoomMaisOndasSenoidais
|
||||
.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
fltZoomSenoidal += 0.1;
|
||||
aplicarZoomSenoidal();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnZoomMaisOndasSenoidais;
|
||||
}
|
||||
|
||||
private JButton getBtnZoomMenosOndasSenoidais()
|
||||
{
|
||||
if (btnZoomMenosOndasSenoidais == null)
|
||||
{
|
||||
btnZoomMenosOndasSenoidais = new JButton();
|
||||
btnZoomMenosOndasSenoidais.setBounds(new Rectangle(2, 132, 58, 66));
|
||||
btnZoomMenosOndasSenoidais.setFont(new Font("Dialog", Font.PLAIN, 24));
|
||||
btnZoomMenosOndasSenoidais.setText("-");
|
||||
btnZoomMenosOndasSenoidais
|
||||
.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
if (fltZoomSenoidal > 1)
|
||||
fltZoomSenoidal -= 0.1;
|
||||
aplicarZoomSenoidal();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnZoomMenosOndasSenoidais;
|
||||
}
|
||||
|
||||
private JButton getBtnZoomNormalOndasSenoidais()
|
||||
{
|
||||
if (btnZoomNormalOndasSenoidais == null)
|
||||
{
|
||||
btnZoomNormalOndasSenoidais = new JButton();
|
||||
btnZoomNormalOndasSenoidais.setBounds(new Rectangle(2, 66, 58, 66));
|
||||
btnZoomNormalOndasSenoidais.setFont(new Font("Dialog", Font.PLAIN, 12));
|
||||
btnZoomNormalOndasSenoidais.setText(Double.toString(fltZoomSenoidal));
|
||||
btnZoomNormalOndasSenoidais
|
||||
.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
fltZoomSenoidal = 1;
|
||||
aplicarZoomSenoidal();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnZoomNormalOndasSenoidais;
|
||||
}
|
||||
|
||||
private JPanel getPnlZoomSuperposicao()
|
||||
{
|
||||
if (pnlZoomSuperposicao == null)
|
||||
{
|
||||
pnlZoomSuperposicao = new JPanel();
|
||||
pnlZoomSuperposicao.setLayout(null);
|
||||
pnlZoomSuperposicao.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
pnlZoomSuperposicao.setBounds(new Rectangle(557, 255, 63, 200));
|
||||
pnlZoomSuperposicao.setBackground(Color.GRAY);
|
||||
}
|
||||
return pnlZoomSuperposicao;
|
||||
}
|
||||
|
||||
private JPanel getPnlCriacaoOndas()
|
||||
{
|
||||
if (pnlCriacaoOndas == null)
|
||||
{
|
||||
lblPeriodo = new JLabel();
|
||||
lblPeriodo.setBounds(new Rectangle(200, 43, 126, 16));
|
||||
lblPeriodo.setText("Período (T / s) (\u03c0 rad)");
|
||||
lblAmplitude = new JLabel();
|
||||
lblAmplitude.setBounds(new Rectangle(7, 43, 116, 16));
|
||||
lblAmplitude.setText("Amplitude Inicial (u)");
|
||||
lblqtdOndas = new JLabel();
|
||||
lblqtdOndas.setBounds(new Rectangle(7, 77, 90, 16));
|
||||
lblqtdOndas.setText("Qtd Ondas: 0");
|
||||
pnlCriacaoOndas = new JPanel();
|
||||
pnlCriacaoOndas.setLayout(null);
|
||||
pnlCriacaoOndas.setBounds(new Rectangle(0, 0, 376, 109));
|
||||
pnlCriacaoOndas.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
pnlCriacaoOndas.add(getRdbOndaTriangular(), null);
|
||||
pnlCriacaoOndas.add(getRdbOndaQuadrada(), null);
|
||||
pnlCriacaoOndas.add(getSldQtdOndas(), null);
|
||||
pnlCriacaoOndas.add(lblqtdOndas, null);
|
||||
pnlCriacaoOndas.add(getBtnMenosOndas(), null);
|
||||
pnlCriacaoOndas.add(getBtnMaisOndas(), null);
|
||||
pnlCriacaoOndas.add(lblAmplitude, null);
|
||||
pnlCriacaoOndas.add(getTxtAmplitude(), null);
|
||||
pnlCriacaoOndas.add(lblPeriodo, null);
|
||||
pnlCriacaoOndas.add(getTxtPeriodo(), null);
|
||||
}
|
||||
return pnlCriacaoOndas;
|
||||
}
|
||||
|
||||
private JRadioButton getRdbOndaTriangular()
|
||||
{
|
||||
if (rdbOndaTriangular == null)
|
||||
{
|
||||
rdbOndaTriangular = new JRadioButton();
|
||||
rdbOndaTriangular.setBounds(new Rectangle(42, 5, 115, 21));
|
||||
rdbOndaTriangular.setText("Onda triangular");
|
||||
rdbOndaTriangular.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
rdbOndaTriangular.setSelected(true);
|
||||
rdbOndaQuadrada.setSelected(false);
|
||||
blnQuadrada = false;
|
||||
blnTriangular = true;
|
||||
alterarQtdOndas();
|
||||
definirOndas();
|
||||
definirSoma();
|
||||
pnlGrafico.atualizarTela(intQtdOndas, objOndas, getPnlGrafico().getGraphics());
|
||||
pnlGraficoTotal.atualizarTela(1, objSoma, getPnlGraficoTotal().getGraphics());
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return rdbOndaTriangular;
|
||||
}
|
||||
|
||||
private JRadioButton getRdbOndaQuadrada()
|
||||
{
|
||||
if (rdbOndaQuadrada == null)
|
||||
{
|
||||
rdbOndaQuadrada = new JRadioButton();
|
||||
rdbOndaQuadrada.setBounds(new Rectangle(201, 5, 113, 24));
|
||||
rdbOndaQuadrada.setText("Onda quadrada");
|
||||
rdbOndaQuadrada.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
rdbOndaTriangular.setSelected(false);
|
||||
rdbOndaQuadrada.setSelected(true);
|
||||
blnQuadrada = true;
|
||||
blnTriangular = false;
|
||||
alterarQtdOndas();
|
||||
definirOndas();
|
||||
definirSoma();
|
||||
pnlGrafico.atualizarTela(intQtdOndas, objOndas, getPnlGrafico().getGraphics());
|
||||
pnlGraficoTotal.atualizarTela(1, objSoma, getPnlGraficoTotal().getGraphics());
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return rdbOndaQuadrada;
|
||||
}
|
||||
|
||||
private JSlider getSldQtdOndas()
|
||||
{
|
||||
if (sldQtdOndas == null)
|
||||
{
|
||||
sldQtdOndas = new JSlider();
|
||||
sldQtdOndas.setValue(0);
|
||||
sldQtdOndas.setMaximum(50);
|
||||
sldQtdOndas.setBounds(new Rectangle(100, 77, 162, 16));
|
||||
sldQtdOndas.addChangeListener(new javax.swing.event.ChangeListener()
|
||||
{
|
||||
public void stateChanged(javax.swing.event.ChangeEvent e)
|
||||
{
|
||||
intQtdOndas = sldQtdOndas.getValue();
|
||||
alterarQtdOndas();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return sldQtdOndas;
|
||||
}
|
||||
|
||||
private JButton getBtnMenosOndas()
|
||||
{
|
||||
if (btnMenosOndas == null)
|
||||
{
|
||||
btnMenosOndas = new JButton();
|
||||
btnMenosOndas.setBounds(new Rectangle(277, 74, 45, 20));
|
||||
btnMenosOndas.setText("-");
|
||||
btnMenosOndas.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
sldQtdOndas.setValue(intQtdOndas -1);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnMenosOndas;
|
||||
}
|
||||
|
||||
private JButton getBtnMaisOndas()
|
||||
{
|
||||
if (btnMaisOndas == null)
|
||||
{
|
||||
btnMaisOndas = new JButton();
|
||||
btnMaisOndas.setBounds(new Rectangle(322, 74, 45, 20));
|
||||
btnMaisOndas.setText("+");
|
||||
btnMaisOndas.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
sldQtdOndas.setValue(intQtdOndas + 1);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return btnMaisOndas;
|
||||
}
|
||||
|
||||
private JScrollPane getScrOndas()
|
||||
{
|
||||
if (scrOndas == null)
|
||||
{
|
||||
scrOndas = new JScrollPane();
|
||||
scrOndas.setBounds(new Rectangle(0, 106, 376, 349));
|
||||
scrOndas.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
scrOndas.setViewportView(getTblOndas());
|
||||
}
|
||||
return scrOndas;
|
||||
}
|
||||
|
||||
private JTable getTblOndas()
|
||||
{
|
||||
if (tblOndas == null)
|
||||
{
|
||||
tblOndas = new JTable();
|
||||
tblOndas.setBounds(new Rectangle(0, 11, 375, 65));
|
||||
tblOndas.setModel(new AbstractTableModel()
|
||||
{
|
||||
private static final long serialVersionUID = 2L;
|
||||
private String colunas[] = {"POSIÇÃO", "COR", "AMPLITUDE", "PERÍODO"};
|
||||
public String getColumnName(int num)
|
||||
{
|
||||
return colunas[num];
|
||||
}
|
||||
public int getColumnCount()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
public int getRowCount()
|
||||
{
|
||||
return intQtdOndas;
|
||||
}
|
||||
public Object getValueAt(int row, int col)
|
||||
{
|
||||
String strRetorno = "";
|
||||
switch(col)
|
||||
{
|
||||
case 0:
|
||||
strRetorno = Integer.toString(row + 1) + "ª";
|
||||
break;
|
||||
case 1:
|
||||
strRetorno = "";
|
||||
break;
|
||||
case 2:
|
||||
strRetorno = Integer.toString(objOndas[row].obterAmplitude()) + "u";
|
||||
break;
|
||||
case 3:
|
||||
strRetorno = objOndas[row].obterPeriodoFormatado() + "\u03c0 rad";
|
||||
break;
|
||||
}
|
||||
return strRetorno;
|
||||
}
|
||||
}
|
||||
);
|
||||
tblOndas.setDefaultRenderer(Object.class,
|
||||
new DefaultTableCellRenderer()
|
||||
{
|
||||
private static final long serialVersionUID = 2L;
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)
|
||||
{
|
||||
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
||||
setHorizontalAlignment(CENTER);
|
||||
if (col == 1)
|
||||
{
|
||||
setBackground(objOndas[row].getCor());
|
||||
}
|
||||
else
|
||||
{
|
||||
setBackground(Color.WHITE);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return tblOndas;
|
||||
}
|
||||
|
||||
private JTextField getTxtAmplitude()
|
||||
{
|
||||
if (txtAmplitude == null)
|
||||
{
|
||||
txtAmplitude = new JTextField();
|
||||
txtAmplitude.setBounds(new Rectangle(125, 42, 59, 20));
|
||||
txtAmplitude.addCaretListener(new javax.swing.event.CaretListener()
|
||||
{
|
||||
public void caretUpdate(javax.swing.event.CaretEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
intAmplitudeInicial = Integer.parseInt(txtAmplitude.getText());
|
||||
alterarQtdOndas();
|
||||
}
|
||||
catch(Exception erro)
|
||||
{
|
||||
if (txtAmplitude.getText().equals(""))
|
||||
{
|
||||
intAmplitudeInicial = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
intAmplitudeInicial = (int)(Double.parseDouble(txtAmplitude.getText()));
|
||||
}
|
||||
alterarQtdOndas();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return txtAmplitude;
|
||||
}
|
||||
|
||||
private JTextField getTxtPeriodo()
|
||||
{
|
||||
if (txtPeriodo == null)
|
||||
{
|
||||
txtPeriodo = new JTextField();
|
||||
txtPeriodo.setBounds(new Rectangle(329, 42, 39, 20));
|
||||
txtPeriodo.addCaretListener(new javax.swing.event.CaretListener()
|
||||
{
|
||||
public void caretUpdate(javax.swing.event.CaretEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
dblPeriodoInicial = Double.parseDouble(txtPeriodo.getText());
|
||||
alterarQtdOndas();
|
||||
}
|
||||
catch(Exception erro)
|
||||
{
|
||||
dblPeriodoInicial = 0;
|
||||
alterarQtdOndas();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return txtPeriodo;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
frmPrincipal thisClass = new frmPrincipal();
|
||||
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
thisClass.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void initialize()
|
||||
{
|
||||
this.setContentPane(getJContentPane());
|
||||
this.setTitle("SSF - Simulador da série de Fourier");
|
||||
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
this.setBounds(new Rectangle(0, 0, 1000, 524));
|
||||
this.setResizable(false);
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setVisible(false);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private JPanel getJContentPane()
|
||||
{
|
||||
if (jContentPane == null)
|
||||
{
|
||||
jContentPane = new JPanel();
|
||||
jContentPane.setLayout(null);
|
||||
jContentPane.add(getPnlGraficos(), null);
|
||||
jContentPane.add(getPnlControles(), null);
|
||||
jContentPane.add(getPnlRodape(), null);
|
||||
}
|
||||
return jContentPane;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package grafico;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
public class ClsEixos
|
||||
{
|
||||
public ClsEixos(int eixoXX[], int eixoXY[], int eixoYX[], int eixoYY[], Graphics g, Color cor)
|
||||
{
|
||||
//EIXO X
|
||||
|
||||
g.setColor(cor);
|
||||
g.drawPolyline(eixoXX, eixoXY, 2);
|
||||
|
||||
//EIXO Y
|
||||
|
||||
g.setColor(cor);
|
||||
g.drawPolyline(eixoYX, eixoYY, 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package grafico;
|
||||
import java.awt.Color;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class ClsOnda
|
||||
{
|
||||
private int xValues[];
|
||||
private int yValues[];
|
||||
private double orgY[];
|
||||
private Color cor;
|
||||
private int largura;
|
||||
private int amplitude;
|
||||
private double periodo;
|
||||
|
||||
public ClsOnda(int X[], double Y[], Color cor, int largura, int inicio, double zoom)
|
||||
{
|
||||
this.amplitude = 0;
|
||||
this.periodo = 0;
|
||||
this.largura = largura;
|
||||
this.cor = cor;
|
||||
xValues = X;
|
||||
orgY = Y;
|
||||
yValues = new int[Y.length];
|
||||
for (int x = 0; x < Y.length; x++)
|
||||
{
|
||||
xValues[x] /= zoom;
|
||||
yValues[x] = Math.round(inicio + (int)((orgY[x]) * zoom));
|
||||
}
|
||||
}
|
||||
|
||||
public ClsOnda(int amplitude, double periodo, int largura, int altura, int inicio, Color cor, double zoom)
|
||||
{
|
||||
this.amplitude = amplitude;
|
||||
this.periodo = periodo;
|
||||
this.cor = cor;
|
||||
this.largura = largura;
|
||||
xValues = new int[largura];
|
||||
yValues = new int[largura];
|
||||
orgY = new double[largura];
|
||||
|
||||
for(int x = 0; x < largura/2; x++)
|
||||
{
|
||||
xValues[largura/2 - x] = (int) ((largura/2 - x));
|
||||
yValues[largura/2 - x] = (int) (amplitude * Math.sin(((x * Math.pow((2 *Math.PI),2))/((largura/2) * periodo * zoom)))*zoom + inicio);
|
||||
orgY[largura/2 - x] = (int) (amplitude * Math.sin(((x * Math.pow((2 *Math.PI),2))/((largura/2) * periodo))));
|
||||
|
||||
xValues[x + largura/2] = (int) ((largura/2 + x));
|
||||
yValues[x + largura/2] = (int) (-amplitude * Math.sin(((x * Math.pow((2 *Math.PI),2))/((largura/2) * periodo * zoom)))*zoom + inicio);
|
||||
orgY[x + largura/2] = (int) (-amplitude * Math.sin(((x * Math.pow((2 *Math.PI),2))/((largura/2) * periodo))));
|
||||
}
|
||||
}
|
||||
public Color getCor()
|
||||
{
|
||||
return cor;
|
||||
}
|
||||
|
||||
public int[] obterX()
|
||||
{
|
||||
return xValues;
|
||||
}
|
||||
|
||||
public int[] obterY()
|
||||
{
|
||||
return yValues;
|
||||
}
|
||||
|
||||
public double[] obterOrgY()
|
||||
{
|
||||
return orgY;
|
||||
}
|
||||
public int getLargura()
|
||||
{
|
||||
return largura;
|
||||
}
|
||||
|
||||
public int obterAmplitude()
|
||||
{
|
||||
return Math.abs(amplitude);
|
||||
}
|
||||
public double obterPeriodo()
|
||||
{
|
||||
return (periodo/Math.PI);
|
||||
}
|
||||
public String obterPeriodoFormatado()
|
||||
{
|
||||
DecimalFormat fmt = new DecimalFormat("0.0000");
|
||||
String part[] = fmt.format(periodo/Math.PI).split("[,]");
|
||||
return (part[0] + "." + part[1]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package grafico;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class PnlGrafico extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 0L;
|
||||
private int qtdOndas;
|
||||
private ClsOnda ondas[];
|
||||
|
||||
public PnlGrafico(int qtdOndas, ClsOnda ondas[])
|
||||
{
|
||||
this.qtdOndas = qtdOndas;
|
||||
this.ondas = ondas;
|
||||
}
|
||||
|
||||
public void atualizarTela(int qtdOndas, ClsOnda ondas[], Graphics g)
|
||||
{
|
||||
this.qtdOndas = qtdOndas;
|
||||
this.ondas = ondas;
|
||||
paintAll(g);
|
||||
}
|
||||
|
||||
public void paintAll(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
super.setBorder(BorderFactory.createLineBorder(Color.black, 2));
|
||||
int eixoXX[] = {0, 558};
|
||||
int eixoXY[] = {100, 100};
|
||||
int eixoYX[] = {279, 279};
|
||||
int eixoYY[] = {0, 200};
|
||||
|
||||
ClsEixos eixos = new ClsEixos(eixoXX, eixoXY, eixoYX, eixoYY, g, Color.BLACK);
|
||||
|
||||
for (int x = 0; x < qtdOndas; x++)
|
||||
{
|
||||
g.setColor(ondas[x].getCor());
|
||||
g.drawPolyline(ondas[x].obterX(), ondas[x].obterY(), ondas[x].getLargura());
|
||||
}
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g)
|
||||
{
|
||||
paintAll(g);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
[.ShellClassInfo]
|
||||
InfoTip=Esta pasta está compartilhada on-line.
|
||||
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
|
||||
IconIndex=12
|
||||
|
||||
Reference in new issue
Block a user