📄 colors.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: Colors.java
package org.gudy.azureus2.ui.swt.mainwindow;
import com.aelitis.azureus.ui.swt.utils.ColorCache;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.ui.swt.Utils;
// Referenced classes of package org.gudy.azureus2.ui.swt.mainwindow:
// HSLColor, SWTThread
public class Colors
implements ParameterListener
{
private class AllocateColor extends AERunnable
{
private String sName;
private RGB rgbDefault;
private Color newColor;
final Colors this$0;
public Color getColor()
{
Utils.execSWTThread(this, false);
return newColor;
}
public void runSupport()
{
if (COConfigurationManager.getBooleanParameter((new StringBuilder()).append("Colors.").append(sName).append(".override").toString()))
{
newColor = ColorCache.getColor(display, COConfigurationManager.getIntParameter((new StringBuilder()).append("Colors.").append(sName).append(".red").toString(), rgbDefault.red), COConfigurationManager.getIntParameter((new StringBuilder()).append("Colors.").append(sName).append(".green").toString(), rgbDefault.green), COConfigurationManager.getIntParameter((new StringBuilder()).append("Colors.").append(sName).append(".blue").toString(), rgbDefault.blue));
} else
{
newColor = ColorCache.getColor(display, rgbDefault.red, rgbDefault.green, rgbDefault.blue);
COConfigurationManager.setRGBParameter((new StringBuilder()).append("Colors.").append(sName).toString(), rgbDefault.red, rgbDefault.green, rgbDefault.blue);
}
}
public AllocateColor(String sName, RGB rgbDefault, Color colorOld)
{
this$0 = Colors.this;
super();
this.sName = sName;
this.rgbDefault = rgbDefault;
}
public AllocateColor(String sName, final Color colorDefault, Color colorOld)
{
this$0 = Colors.this;
super();
this.sName = sName;
Utils.execSWTThread(new AERunnable() {
final Colors val$this$0;
final Color val$colorDefault;
final AllocateColor this$1;
public void runSupport()
{
if (!colorDefault.isDisposed())
rgbDefault = colorDefault.getRGB();
else
rgbDefault = new RGB(0, 0, 0);
}
// JavaClassFileOutputException: Invalid index accessing method local variables table of <init>
}, false);
}
}
private static final LogIDs LOGID;
private static Colors instance = null;
public static final int BLUES_LIGHTEST = 0;
public static final int BLUES_DARKEST = 9;
public static final int BLUES_MIDLIGHT = 2;
public static final int BLUES_MIDDARK = 7;
public static final int FADED_LIGHTEST = 0;
public static final int FADED_DARKEST = 9;
public static Color blues[] = new Color[10];
public static Color faded[] = new Color[10];
public static Color colorProgressBar;
public static Color colorInverse;
public static Color colorShiftLeft;
public static Color colorShiftRight;
public static Color colorError;
public static Color colorErrorBG;
public static Color colorAltRow;
public static Color colorWarning;
public static Color black;
public static Color light_grey;
public static Color blue;
public static Color green;
public static Color fadedGreen;
public static Color grey;
public static Color red;
public static Color fadedRed;
public static Color yellow;
public static Color white;
public static Color background;
public static Color red_ConsoleView;
private static AEMonitor class_mon = new AEMonitor("Colors");
private Display display;
private void allocateBlues()
{
int r = 0;
int g = 128;
int b = 255;
try
{
r = COConfigurationManager.getIntParameter("Color Scheme.red", r);
g = COConfigurationManager.getIntParameter("Color Scheme.green", g);
b = COConfigurationManager.getIntParameter("Color Scheme.blue", b);
boolean bGrayScale = r == b && b == g;
HSLColor hslColor = new HSLColor();
Color colorTables = display.getSystemColor(25);
int tR = colorTables.getRed();
int tG = colorTables.getGreen();
int tB = colorTables.getBlue();
for (int i = 0; i < blues.length; i++)
{
hslColor.initHSLbyRGB(r, g, b);
float blendBy = i != 0 ? 1.0F - (float)i / (float)(blues.length - 1) : 1.0F;
hslColor.blend(tR, tG, tB, blendBy);
blues[i] = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue());
int iSat = hslColor.getSaturation();
int luminence = hslColor.getLuminence();
if (luminence < 20)
{
if (iSat > 10)
{
hslColor.setSaturation(iSat / 2);
hslColor.brighten(1.25F);
} else
if (bGrayScale)
hslColor.brighten(1.2F);
} else
if (iSat > 10)
{
hslColor.setSaturation(iSat / 2);
hslColor.brighten(0.75F);
} else
if (bGrayScale)
hslColor.brighten(0.8F);
faded[i] = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue());
}
if (bGrayScale)
if (b > 200)
b -= 20;
else
b += 20;
hslColor.initHSLbyRGB(r, g, b);
hslColor.reverseColor();
colorInverse = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue());
hslColor.initHSLbyRGB(r, g, b);
hslColor.setHue(hslColor.getHue() + 25);
colorShiftRight = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue());
hslColor.initHSLbyRGB(r, g, b);
hslColor.setHue(hslColor.getHue() - 25);
colorShiftLeft = ColorCache.getColor(display, hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue());
}
catch (Exception e)
{
Logger.log(new LogEvent(LOGID, "Error allocating colors", e));
}
}
private void allocateColorProgressBar()
{
if (display == null || display.isDisposed())
{
return;
} else
{
colorProgressBar = (new AllocateColor("progressBar", colorShiftRight, colorProgressBar)).getColor();
return;
}
}
private void allocateColorErrorBG()
{
if (display == null || display.isDisposed())
{
return;
} else
{
Utils.execSWTThread(new AERunnable() {
final Colors this$0;
public void runSupport()
{
Color colorTables = display.getSystemColor(25);
HSLColor hslColor = new HSLColor();
hslColor.initHSLbyRGB(colorTables.getRed(), colorTables.getGreen(), colorTables.getBlue());
int lum = hslColor.getLuminence();
int sat = hslColor.getSaturation();
lum = (int)(lum <= 127 ? (double)lum * 1.3D : (double)lum * 0.80000000000000004D);
if (sat == 0)
sat = 80;
hslColor.initRGBbyHSL(0, sat, lum);
Colors.colorErrorBG = (new AllocateColor("errorBG", new RGB(hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()), Colors.colorErrorBG)).getColor();
}
{
this$0 = Colors.this;
super();
}
}, false);
return;
}
}
private void allocateColorError()
{
if (display == null || display.isDisposed())
{
return;
} else
{
colorError = (new AllocateColor("error", new RGB(255, 68, 68), colorError)).getColor();
return;
}
}
private void allocateColorWarning()
{
if (display == null || display.isDisposed())
{
return;
} else
{
Utils.execSWTThread(new AERunnable() {
final Colors this$0;
public void runSupport()
{
Color colorTables = display.getSystemColor(25);
HSLColor hslBG = new HSLColor();
hslBG.initHSLbyRGB(colorTables.getRed(), colorTables.getGreen(), colorTables.getBlue());
int lum = hslBG.getLuminence();
HSLColor hslColor = new HSLColor();
hslColor.initRGBbyHSL(25, 200, 128 + (lum >= 160 ? -10 : 10));
Colors.colorWarning = (new AllocateColor("warning", new RGB(hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()), Colors.colorWarning)).getColor();
}
{
this$0 = Colors.this;
super();
}
}, false);
return;
}
}
private void allocateColorAltRow()
{
if (display == null || display.isDisposed())
{
return;
} else
{
Utils.execSWTThread(new AERunnable() {
final Colors this$0;
public void runSupport()
{
Color colorTables = display.getSystemColor(25);
HSLColor hslColor = new HSLColor();
hslColor.initHSLbyRGB(colorTables.getRed(), colorTables.getGreen(), colorTables.getBlue());
int lum = hslColor.getLuminence();
if (lum > 127)
lum -= 16;
else
lum += 30;
hslColor.setLuminence(lum);
Colors.colorAltRow = (new AllocateColor("altRow", new RGB(hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue()), Colors.colorAltRow)).getColor();
}
{
this$0 = Colors.this;
super();
}
}, false);
return;
}
}
private void allocateDynamicColors()
{
if (display == null || display.isDisposed())
{
return;
} else
{
Utils.execSWTThread(new AERunnable() {
final Colors this$0;
public void runSupport()
{
allocateBlues();
allocateColorProgressBar();
allocateColorErrorBG();
}
{
this$0 = Colors.this;
super();
}
}, false);
return;
}
}
private void allocateNonDynamicColors()
{
allocateColorWarning();
allocateColorError();
allocateColorAltRow();
black = ColorCache.getColor(display, 0, 0, 0);
light_grey = ColorCache.getColor(display, 192, 192, 192);
blue = ColorCache.getColor(display, 0, 0, 170);
green = ColorCache.getColor(display, 0, 170, 0);
fadedGreen = ColorCache.getColor(display, 96, 160, 96);
grey = ColorCache.getColor(display, 170, 170, 170);
red = ColorCache.getColor(display, 255, 0, 0);
fadedRed = ColorCache.getColor(display, 160, 96, 96);
yellow = ColorCache.getColor(display, 255, 255, 0);
white = ColorCache.getColor(display, 255, 255, 255);
background = ColorCache.getColor(display, 248, 248, 248);
red_ConsoleView = ColorCache.getColor(display, 255, 192, 192);
}
private Colors()
{
instance = this;
try
{
display = SWTThread.getInstance().getDisplay();
}
catch (Exception e)
{
display = Display.getDefault();
}
allocateDynamicColors();
allocateNonDynamicColors();
addColorsChangedListener(this);
}
public static Colors getInstance()
{
Colors colors;
class_mon.enter();
if (instance == null)
instance = new Colors();
colors = instance;
class_mon.exit();
return colors;
Exception exception;
exception;
class_mon.exit();
throw exception;
}
public void addColorsChangedListener(ParameterListener l)
{
COConfigurationManager.addParameterListener("Color Scheme", l);
COConfigurationManager.addParameterListener("Colors.progressBar.override", l);
COConfigurationManager.addParameterListener("Colors.progressBar", l);
COConfigurationManager.addParameterListener("Colors.error.override", l);
COConfigurationManager.addParameterListener("Colors.error", l);
COConfigurationManager.addParameterListener("Colors.warning.override", l);
COConfigurationManager.addParameterListener("Colors.warning", l);
COConfigurationManager.addParameterListener("Colors.altRow.override", l);
COConfigurationManager.addParameterListener("Colors.altRow", l);
}
public void removeColorsChangedListener(ParameterListener l)
{
COConfigurationManager.removeParameterListener("Color Scheme", l);
COConfigurationManager.removeParameterListener("Colors.progressBar.override", l);
COConfigurationManager.removeParameterListener("Colors.progressBar", l);
COConfigurationManager.removeParameterListener("Colors.error.override", l);
COConfigurationManager.removeParameterListener("Colors.error", l);
COConfigurationManager.removeParameterListener("Colors.warning.override", l);
COConfigurationManager.removeParameterListener("Colors.warning", l);
COConfigurationManager.removeParameterListener("Colors.altRow.override", l);
COConfigurationManager.removeParameterListener("Colors.altRow", l);
}
public void parameterChanged(String parameterName)
{
if (parameterName.equals("Color Scheme"))
allocateDynamicColors();
if (parameterName.startsWith("Colors.progressBar"))
allocateColorProgressBar();
if (parameterName.startsWith("Colors.error"))
allocateColorError();
if (parameterName.startsWith("Colors.warning"))
allocateColorWarning();
if (parameterName.startsWith("Colors.altRow"))
allocateColorAltRow();
}
static
{
LOGID = LogIDs.GUI;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -