⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skin.java

📁 java平台的图形音乐播放器
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * Skin.
 * 
 * JavaZOOM : jlgui@javazoom.net
 *            http://www.javazoom.net
 *
 *-----------------------------------------------------------------------
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as published
 *   by the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */
package javazoom.jlgui.player.amp.skin;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.PixelGrabber;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JSlider;
import javazoom.jlgui.player.amp.PlayerActionEvent;
import javazoom.jlgui.player.amp.equalizer.ui.SplinePanel;
import javazoom.jlgui.player.amp.util.Config;
import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * This class allows to load all skin (2.0 compliant) features. 
 */
public class Skin
{
    private static Log log = LogFactory.getLog(Skin.class);
    public static final String TITLETEXT = "jlGui 3.0 ";
    private Config config = null;
    private String skinVersion = "1"; // 1, 2, for different Volume.bmp
    private String path = null;
    private boolean dspEnabled = true;
    /*-- Window Parameters --*/
    private int WinWidth, WinHeight;
    private String theMain = "main.bmp";
    private Image imMain = null;
    /*-- Text Members --*/
    private int fontWidth = 5;
    private int fontHeight = 6;
    private String theText = "text.bmp";
    private Image imText;
    private String fontIndex = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\"@a  " + "0123456789  :()-'!_+ /[]^&%.=$#" + "   ?*";
    private ActiveFont acFont = null;
    private ActiveJLabel acTitleLabel = null;
    private ActiveJLabel acSampleRateLabel = null;
    private ActiveJLabel acBitRateLabel = null;
    private String sampleRateClearText = "  ";
    private int[] sampleRateLocation = { 156, 43 };
    private String bitsRateClearText = "   ";
    private int[] bitsRateLocation = { 110, 43 };
    private int[] titleLocation = { 111, 27 };
    /*-- Numbers Members --*/
    private int numberWidth = 9;
    private int numberHeight = 13;
    private String theNumbers = "numbers.bmp";
    private String theNumEx = "nums_ex.bmp";
    private Image imNumbers;
    private String numberIndex = "0123456789 ";
    private int[] minuteHLocation = { 48, 26 };
    private int[] minuteLLocation = { 60, 26 };
    private int[] secondHLocation = { 78, 26 };
    private int[] secondLLocation = { 90, 26 };
    private ActiveJNumberLabel acMinuteH = null;
    private ActiveJNumberLabel acMinuteL = null;
    private ActiveJNumberLabel acSecondH = null;
    private ActiveJNumberLabel acSecondL = null;
    /*-- Buttons Panel members --*/
    private String theButtons = "cbuttons.bmp";
    private Image imButtons;
    private ActiveJButton acPrevious, acPlay, acPause, acStop, acNext, acEject;
    private Image imPrevious, imPlay, imPause, imStop, imNext, imEject;
    private Image[] releasedImage = { imPrevious, imPlay, imPause, imStop, imNext, imEject };
    private Image[] pressedImage = { imPrevious, imPlay, imPause, imStop, imNext, imEject };
    private int[] releasedPanel = { 0, 0, 23, 18, 23, 0, 23, 18, 46, 0, 23, 18, 69, 0, 23, 18, 92, 0, 22, 18, 114, 0, 22, 16 };
    private int[] pressedPanel = { 0, 18, 23, 18, 23, 18, 23, 18, 46, 18, 23, 18, 69, 18, 23, 18, 92, 18, 22, 18, 114, 16, 22, 16 };
    private int[] panelLocation = { 16, 88, 39, 88, 62, 88, 85, 88, 108, 88, 136, 89 };
    /*-- EqualizerUI/Playlist/Shuffle/Repeat  --*/
    private String theEPSRButtons = "shufrep.bmp";
    private Image imEPSRButtons;
    private ActiveJToggleButton acEqualizer, acPlaylist, acShuffle, acRepeat;
    private Image[] releasedEPSRImage = { null, null, null, null };
    private Image[] pressedEPSRImage = { null, null, null, null };
    private int[] releasedEPSRPanel = { 0, 61, 23, 12, 23, 61, 23, 12, 28, 0, 47, 15, 0, 0, 28, 15 };
    private int[] pressedEPSRPanel = { 0, 73, 23, 12, 23, 73, 23, 12, 28, 30, 47, 15, 0, 30, 28, 15 };
    private int[] panelEPSRLocation = { 219, 58, 242, 58, 164, 89, 212, 89 };
    /*-- Volume Panel members --*/
    public static final int VOLUMEMAX = 100;
    private String theVolume = "volume.bmp";
    private Image imVolume;
    private ActiveJSlider acVolume = null;;
    private Image[] volumeImage = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null };
    private String fakeIndex = "abcdefghijklmnopqrstuvwxyz01";
    private int[] volumeBarLocation = { 107, 57 };
    private Image[] releasedVolumeImage = { null };
    private Image[] pressedVolumeImage = { null };
    private int[] releasedVolumePanel0 = { 15, 422, 14, 11 };
    private int[] pressedVolumePanel0 = { 0, 422, 14, 11 };
    private int[] releasedVolumePanel1 = { 75, 376, 14, 11 };
    private int[] pressedVolumePanel1 = { 90, 376, 14, 11 };
    /*-- Balance Panel members --*/
    public static final int BALANCEMAX = 5;
    private String theBalance = "balance.bmp";
    private ActiveJSlider acBalance = null;
    private Image imBalance;
    private Image[] balanceImage = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null };
    private Image[] releasedBalanceImage = { null };
    private Image[] pressedBalanceImage = { null };
    private int[] releasedBalancePanel0 = { 15, 422, 14, 11 };
    private int[] pressedBalancePanel0 = { 0, 422, 14, 11 };
    private int[] releasedBalancePanel1 = { 75, 376, 14, 11 };
    private int[] pressedBalancePanel1 = { 90, 376, 14, 11 };
    private int[] balanceBarLocation = { 177, 57 };
    /*-- Title members --*/
    private String theTitleBar = "titlebar.bmp";
    private Image imTitleBar;
    private ActiveJBar acTitleBar = null;
    private Image imTitleB;
    private Image[] releasedTitleIm = { imTitleB };
    private Image[] pressedTitleIm = { imTitleB };
    private int[] releasedTitlePanel = { 27, 0, 264 - 20, 14 }; // -20 for the two button add by me
    private int[] pressedTitlePanel = { 27, 15, 264 - 20, 14 };// -20 for the two button add by me
    private int[] titleBarLocation = { 0, 0 };
    /*-- Exit member --*/
    private ActiveJButton acExit = null;
    private int[] releasedExitPanel = { 18, 0, 9, 9 };
    private int[] pressedExitPanel = { 18, 9, 9, 9 };
    private Image[] releasedExitIm = { null };
    private Image[] pressedExitIm = { null };
    private int[] exitLocation = { 264, 3 };
    /*-- Minimize member --*/
    private ActiveJButton acMinimize = null;
    private int[] releasedMinimizePanel = { 9, 0, 9, 9 };
    private int[] pressedMinimizePanel = { 9, 9, 9, 9 };
    private Image[] releasedMinimizeIm = { null };
    private Image[] pressedMinimizeIm = { null };
    private int[] minimizeLocation = { 244, 3 };
    /*-- Mono/Stereo Members --*/
    private String theMode = "monoster.bmp";
    private Image imMode;
    private int[] activeModePanel = { 0, 0, 28, 12, 29, 0, 27, 12 };
    private int[] passiveModePanel = { 0, 12, 28, 12, 29, 12, 27, 12 };
    private Image[] activeModeImage = { null, null };
    private Image[] passiveModeImage = { null, null };
    private int[] monoLocation = { 212, 41 };
    private int[] stereoLocation = { 239, 41 };
    private ActiveJIcon acMonoIcon = null;
    private ActiveJIcon acStereoIcon = null;
    /*-- PosBar members --*/
    public static final int POSBARMAX = 1000;
    private String thePosBar = "posbar.bmp";
    private Image imPosBar;
    private ActiveJSlider acPosBar = null;
    private Image[] releasedPosIm = { null };
    private Image[] pressedPosIm = { null };
    private int[] releasedPosPanel = { 248, 0, 28, 10 };
    private int[] pressedPosPanel = { 278, 0, 28, 10 };
    private int[] posBarLocation = { 16, 72 };
    /*-- Play/Pause Icons --*/
    private String theIcons = "playpaus.bmp";
    private Image imIcons;
    private Image[] iconsImage = { null, null, null, null, null };
    private int[] iconsPanel = { 0, 0, 9, 9, 9, 0, 9, 9, 18, 0, 9, 9, 36, 0, 3, 9, 27, 0, 2, 9 };
    private int[] iconsLocation = { 26, 28, 24, 28 };
    private ActiveJIcon acPlayIcon = null;
    private ActiveJIcon acTimeIcon = null;
    /*-- Readme --*/
    private String theReadme = "readme.txt";
    private String readme = null;
    /*-- DSP and viscolor --*/
    private String theViscolor = "viscolor.txt";
    private String viscolor = null;
    private int[] visualLocation = { 24, 44 };
    private int[] visualSize = { 76, 15 };
    private SpectrumTimeAnalyzer analyzer = null;
    /*-- EqualizerUI --*/
    private Image imFullEqualizer = null;
    private Image imEqualizer = null;
    private Image imSliders = null;
    private ActiveJSlider[] acSlider = { null, null, null, null, null, null, null, null, null, null, null };
    private Image[] sliderImage = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null };
    private int[][] sliderBarLocation = { { 21, 38 }, { 78, 38 }, { 96, 38 }, { 114, 38 }, { 132, 38 }, { 150, 38 }, { 168, 38 }, { 186, 38 }, { 204, 38 }, { 222, 38 }, { 240, 38 } };
    private Image[] releasedSliderImage = { null };
    private Image[] pressedSliderImage = { null };
    private int[][] sliderLocation = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
    private Image[] releasedPresetsImage = { null };
    private Image[] pressedPresetsImage = { null };
    private int[] panelPresetsLocation = { 217, 18 };
    private ActiveJButton acPresets = null;
    private ActiveJToggleButton acOnOff, acAuto;
    private Image[] releasedOAImage = { null, null };
    private Image[] pressedOAImage = { null, null };
    private int[] panelOALocation = { 15, 18, 39, 18 };
    private SplinePanel spline = null;
    private int[] panelSplineLocation = { 88, 17, 113, 19 };
    private Image splineImage = null;
    private Image splineBarImage = null;
    private ResourceBundle bundle = null;
    /*-- Playlist --*/
    private PlaylistUIDelegate playlist = null;
    private Image imPlaylist = null;
    private String plEdit = null;
    private ActiveJSlider acPlSlider = null;
    private int[] plSliderLocation = { 255, 20 };
    private ActiveJButton acPlUp, acPlDown;
    private ActiveJButton acPlAdd, acPlRemove, acPlSelect, acPlMisc, acPlList;
    private int[] plAddLocation = { 14, 86 };
    private int[] plRemoveLocation = { 14 + 30, 86 };
    private int[] plSelectLocation = { 14 + 60, 86 };
    private int[] plMiscLocation = { 14 + 89, 86 };
    private int[] plListLocation = { 14 + 214, 86 };
    private ActiveJPopup acPlAddPopup, acPlRemovePopup, acPlSelectPopup, acPlMiscPopup, acPlListPopup;
    private int[] plAddPopupArea = { 14, 50, 22, 18 * 3 };
    private int[] plRemovePopupArea = { 14 + 29, 32, 22, 18 * 4 };
    private int[] plSelectPopupArea = { 14 + 58, 50, 22, 18 * 3 };
    private int[] plMiscPopupArea = { 14 + 87, 50, 22, 18 * 3 };
    private int[] plListPopupArea = { 14 + 217, 50, 22, 18 * 3 };

    public Skin()
    {
        super();
        String i18n = "javazoom/jlgui/player/amp/skin/skin";
        bundle = ResourceBundle.getBundle(i18n);
    }

    /**
     * Return I18N value of a given key.
     * @param key
     * @return
     */
    public String getResource(String key)
    {
        String value = null;
        try
        {
            value = bundle.getString(key);
        }
        catch (MissingResourceException e)
        {
            log.debug(e);
        }
        return value;
    }

    /**
     * Return skin path.
     * @return
     */
    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public boolean isDspEnabled()
    {
        return dspEnabled;
    }

    public void setDspEnabled(boolean dspEnabled)
    {
        this.dspEnabled = dspEnabled;
    }

    /**
     * Loads a new skin from local file system.
     * @param skinName
     */
    public void loadSkin(String skinName)
    {
        SkinLoader skl = new SkinLoader(skinName);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -