📄 audiochartpanel.java
字号:
jPanel4.add(jButton9); jButton10.setText(Config.getResource("reset")); // NOI18N jButton10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton10ActionPerformed(evt); } }); jPanel4.add(jButton10); jLabel3.setText(Config.getResource("AudioChartPanel.numOfBars")); // NOI18N band.setMajorTickSpacing(10); band.setMaximum(40); band.setMinimum(10); band.setMinorTickSpacing(1); band.setPaintLabels(true); band.setPaintTicks(true); band.setSnapToTicks(true); band.setValue(20); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(band, 0, 0, Short.MAX_VALUE) .addComponent(jLabel3)))) .addContainerGap()) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(band, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: Color c = JColorChooser.showDialog(this, Config.getResource("AudioChartPanel.peakColor"), color); if (c != null) { color = c; jButton1.setIcon(Util.createColorIcon(c, width, height)); } }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here:. Color c = JColorChooser.showDialog(this, Config.getResource("AudioChartPanel.topColor"), topColor); if (c != null) { topColor = c; jButton2.setIcon(Util.createColorIcon(c, width, height)); } }//GEN-LAST:event_jButton2ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: Color c = JColorChooser.showDialog(this, Config.getResource("AudioChartPanel.centerColor"), centerColor); if (c != null) { centerColor = c; jButton3.setIcon(Util.createColorIcon(c, width, height)); } }//GEN-LAST:event_jButton3ActionPerformed private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: Color c = JColorChooser.showDialog(this, Config.getResource("AudioChartPanel.bottomColor"), bottomColor); if (c != null) { bottomColor = c; jButton4.setIcon(Util.createColorIcon(c, width, height)); } }//GEN-LAST:event_jButton4ActionPerformed private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed // TODO add your handling code here: Color c = JColorChooser.showDialog(this, Config.getResource("AudioChartPanel.lineColor"), lineColor); if (c != null) { lineColor = c; jButton5.setIcon(Util.createColorIcon(c, width, height)); } }//GEN-LAST:event_jButton5ActionPerformed private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed // TODO add your handling code here: doSave(); }//GEN-LAST:event_jButton9ActionPerformed private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed // TODO add your handling code here: init(); }//GEN-LAST:event_jButton10ActionPerformed private void fpsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fpsStateChanged // TODO add your handling code here: info.setText(fps.getValue() + Config.getResource("AudioChartPanel.ffps")); }//GEN-LAST:event_fpsStateChanged public void init() { Config config = Config.getConfig(); displayMode.setSelectedItem(getStringOfDisplayMode(config.getAudioChartDisplayMode())); fps.setValue(config.getAudioChartfps()); band.setValue(config.getAudioChartBarCount()); info.setText(config.getAudioChartfps() + Config.getResource("AudioChartPanel.ffps")); topColor = config.getAudioChartTopColor(); centerColor = config.getAudioChartCenterColor(); bottomColor = config.getAudioChartbottomColor(); color = config.getAudioChartPeakColor(); lineColor = config.getAudioChartlineColor(); jButton1.setIcon(Util.createColorIcon(color, width, height)); jButton2.setIcon(Util.createColorIcon(topColor, width, height)); jButton3.setIcon(Util.createColorIcon(centerColor, width, height)); jButton4.setIcon(Util.createColorIcon(bottomColor, width, height)); jButton5.setIcon(Util.createColorIcon(lineColor, width, height)); speed.setSelectedItem(getStringOfSpeed(config.getAudioChartDisappearSpeed())); } private int getIntOfDisplayMode(String s) { if (s.equals("频谱分析")) { return AudioChart.DISPLAY_MODE_SPECTRUM_ANALYSER; } else if (s.equals("示波显示")) { return AudioChart.DISPLAY_MODE_SCOPE; } else if (s.equals("不显示")) { return AudioChart.DISPLAY_MODE_OFF; } return AudioChart.DISPLAY_MODE_SPECTRUM_ANALYSER; } private String getStringOfDisplayMode(int mode) { switch (mode) { case AudioChart.DISPLAY_MODE_OFF: return "不显示"; case AudioChart.DISPLAY_MODE_SCOPE: return "示波显示"; case AudioChart.DISPLAY_MODE_SPECTRUM_ANALYSER: return "频谱分析"; } return "频谱分析"; } private int getIntOfSpeed(String s) { if (s.equals("较慢")) { return Config.DISAPPEAR_SLOW; } else if (s.equals("较快")) { return Config.DISAPPEAR_QUICK; } else if (s.equals("普通")) { return Config.DISAPPEAR_NORMAL; } return Config.DISAPPEAR_NORMAL; } private String getStringOfSpeed(int mode) { switch (mode) { case Config.DISAPPEAR_NORMAL: return "普通"; case Config.DISAPPEAR_QUICK: return "较快"; case Config.DISAPPEAR_SLOW: return "较慢"; } return "普通"; } private void doSave() { Config config = Config.getConfig(); config.setAudioChartDisplayMode(getIntOfDisplayMode(displayMode.getSelectedItem().toString())); config.setAudioChartfps(fps.getValue()); config.setAudioChartCenterColor(centerColor); config.setAudioChartTopColor(topColor); config.setAudioChartPeakColor(color); config.setAudioChartlineColor(lineColor); config.setAudioChartbottomColor(bottomColor); config.setAudioChartDisappearSpeed(getIntOfSpeed(speed.getSelectedItem().toString())); config.setAudioChartBarCount(band.getValue()); config.getPlayer().getAudioChart().setPeakColor(color); config.getPlayer().getAudioChart().setScopeColor(lineColor); config.getPlayer().getAudioChart().setSpectrumAnalyserBandCount(band.getValue()); config.getPlayer().getAudioChart().setSpectrumAnalyserColors(Util.getColors(bottomColor, centerColor, topColor, 256)); config.getPlayer().getAudioChart().setDisplayMode(config.getAudioChartDisplayMode()); if (config.isAutoCloseDialogWhenSave()) { config.getOptionDialog().setVisible(false); } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JSlider band; private javax.swing.JComboBox displayMode; private javax.swing.JSlider fps; private javax.swing.JLabel info; private javax.swing.JButton jButton1; private javax.swing.JButton jButton10; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JComboBox speed; // End of variables declaration//GEN-END:variables}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -