Added Gaussion Blur

This commit is contained in:
unknown
2017-01-19 20:33:24 +08:00
parent b36c194f67
commit ed7c52f09f
138 changed files with 1792 additions and 2063 deletions

View File

@@ -18,12 +18,13 @@ package org.jackhuang.hellominecraft.lookandfeel;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.text.ParseException;
import java.util.Map;
import javax.swing.UIDefaults;
import javax.swing.plaf.synth.SynthLookAndFeel;
import org.jackhuang.hellominecraft.util.logging.HMCLog;
import org.jackhuang.hellominecraft.util.NetUtils;
import org.jackhuang.hellominecraft.util.system.IOUtils;
/**
*
@@ -37,7 +38,7 @@ public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
* Creates a new instance of NimbusLookAndFeel
*
* @throws java.text.ParseException error parsing the xml, it must not
* happen.
* happen.
*/
public HelloMinecraftLookAndFeel() throws ParseException {
this(DEFAULT_SETTINGS);
@@ -45,14 +46,18 @@ public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
public HelloMinecraftLookAndFeel(Map<String, String> settings) throws ParseException {
try {
String s = NetUtils.getStreamContent(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml"), "UTF-8");
for (String ss : settings.keySet())
s = s.replace("${" + ss + "}", settings.get(ss));
load(new ByteArrayInputStream(s.getBytes("UTF-8")), HelloMinecraftLookAndFeel.class);
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml")) {
String s = IOUtils.getStreamContent(is, "UTF-8");
for (Map.Entry<String, String> ss : settings.entrySet())
s = s.replace("${" + ss.getKey() + "}", ss.getValue());
load(new ByteArrayInputStream(s.getBytes("UTF-8")), HelloMinecraftLookAndFeel.class);
}
} catch (Throwable ex) {
HMCLog.err("This fucking exception should not happen. Retry backup solution.", ex);
try {
load(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth_backup.xml"), HelloMinecraftLookAndFeel.class);
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth_backup.xml")) {
load(is, HelloMinecraftLookAndFeel.class);
}
} catch (Throwable e) {
HMCLog.err("User fault", e);
}

View File

@@ -42,22 +42,22 @@ import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
public class ButtonPainter extends SynthPainter {
private static final String DEFAULT_NORMAL = "D5D5D5";
private static final Color[] DEFAULT_NORMAL_FG = new Color[] {
private static final Color[] DEFAULT_NORMAL_FG = new Color[]{
GraphicsUtils.getWebColor(DEFAULT_NORMAL),
GraphicsUtils.getWebColor(DEFAULT_NORMAL)
};
private static final String DEFAULT_PRELIGHT = "A9A9A9";
private static final Color[] DEFAULT_PRELIGHT_FG = new Color[] {
private static final Color[] DEFAULT_PRELIGHT_FG = new Color[]{
GraphicsUtils.getWebColor(DEFAULT_PRELIGHT),
GraphicsUtils.getWebColor(DEFAULT_PRELIGHT)
};
private static final String DEFAULT_ACTIVE = "222222";
private static final Color[] DEFAULT_ACTIVE_FG = new Color[] {
private static final Color[] DEFAULT_ACTIVE_FG = new Color[]{
GraphicsUtils.getWebColor(DEFAULT_ACTIVE),
GraphicsUtils.getWebColor(DEFAULT_ACTIVE)
};
private static final Color[] DISABLED_BG = new Color[] {
private static final Color[] DISABLED_BG = new Color[]{
GraphicsUtils.getWebColor("E3EFE9"),
GraphicsUtils.getMidWebColor("E3EFE9", "DFE2E6"),
GraphicsUtils.getWebColor("DFE2E6"),
@@ -68,7 +68,7 @@ public class ButtonPainter extends SynthPainter {
GraphicsUtils.getWebColor("D8DBE1"),
GraphicsUtils.getWebColor("DADDE3")
};
private static final Color[] DISABLED_FG = new Color[] {
private static final Color[] DISABLED_FG = new Color[]{
GraphicsUtils.getWebColor("C9CCD2"),
GraphicsUtils.getWebColor("C9CCD2"),
GraphicsUtils.getWebColor("BCBFC5"),
@@ -106,8 +106,8 @@ public class ButtonPainter extends SynthPainter {
if ((context.getComponentState() & SynthConstants.PRESSED) != 0)
if (context.getComponent() instanceof ConstomButton) {
ConstomButton c = (ConstomButton) context.getComponent();
fg = new Color[] { c.activeFg, c.activeFg };
bg = new Color[] { c.activeFg, c.activeFg };
fg = new Color[]{c.activeFg, c.activeFg};
bg = new Color[]{c.activeFg, c.activeFg};
} else {
fg = DEFAULT_ACTIVE_FG;
bg = DEFAULT_ACTIVE_FG;
@@ -122,8 +122,8 @@ public class ButtonPainter extends SynthPainter {
return;
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
fg = new Color[] { fgs, fgs };
bg = new Color[] { bgs, bgs };
fg = new Color[]{fgs, fgs};
bg = new Color[]{bgs, bgs};
} else {
fg = DEFAULT_PRELIGHT_FG;
bg = DEFAULT_PRELIGHT_FG;
@@ -134,8 +134,8 @@ public class ButtonPainter extends SynthPainter {
return;
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
fg = new Color[] { fgs, fgs };
bg = new Color[] { bgs, bgs };
fg = new Color[]{fgs, fgs};
bg = new Color[]{bgs, bgs};
} else {
fg = DEFAULT_NORMAL_FG;
bg = DEFAULT_NORMAL_FG;
@@ -143,8 +143,8 @@ public class ButtonPainter extends SynthPainter {
else if ((context.getComponentState() & SynthConstants.PRESSED) != 0)
if (context.getComponent() instanceof ConstomButton) {
ConstomButton c = (ConstomButton) context.getComponent();
fg = new Color[] { c.activeFg, c.activeFg };
bg = new Color[] { c.activeFg, c.activeFg };
fg = new Color[]{c.activeFg, c.activeFg};
bg = new Color[]{c.activeFg, c.activeFg};
} else {
fg = DEFAULT_ACTIVE_FG;
bg = DEFAULT_ACTIVE_FG;
@@ -159,12 +159,12 @@ public class ButtonPainter extends SynthPainter {
return;
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
fg = new Color[] { fgs, fgs };
bg = new Color[] { bgs, bgs };
fg = new Color[]{fgs, fgs};
bg = new Color[]{bgs, bgs};
} else if (context.getComponent() instanceof ConstomButton) {
ConstomButton c = (ConstomButton) context.getComponent();
fg = new Color[] { c.prelightFg, c.prelightFg };
bg = new Color[] { c.prelightBg, c.prelightBg };
fg = new Color[]{c.prelightFg, c.prelightFg};
bg = new Color[]{c.prelightBg, c.prelightBg};
} else {
fg = DEFAULT_PRELIGHT_FG;
bg = DEFAULT_PRELIGHT_FG;
@@ -175,8 +175,8 @@ public class ButtonPainter extends SynthPainter {
return;
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
fg = new Color[] { fgs, fgs };
bg = new Color[] { bgs, bgs };
fg = new Color[]{fgs, fgs};
bg = new Color[]{bgs, bgs};
} else {
fg = DEFAULT_NORMAL_FG;
bg = DEFAULT_NORMAL_FG;
@@ -207,21 +207,8 @@ public class ButtonPainter extends SynthPainter {
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Color[] fg, bg;
if ((context.getComponentState() & SynthConstants.DEFAULT) != 0)
if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
fg = DEFAULT_ACTIVE_FG;
bg = DEFAULT_ACTIVE_FG;
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
fg = DISABLED_FG;
bg = DISABLED_BG;
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
fg = DEFAULT_PRELIGHT_FG;
bg = DEFAULT_PRELIGHT_FG;
} else {
fg = DEFAULT_NORMAL_FG;
bg = DEFAULT_NORMAL_FG;
}
else if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
//if ((context.getComponentState() & SynthConstants.DEFAULT) != 0)
if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
fg = DEFAULT_ACTIVE_FG;
bg = DEFAULT_ACTIVE_FG;
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
@@ -234,6 +221,19 @@ public class ButtonPainter extends SynthPainter {
fg = DEFAULT_NORMAL_FG;
bg = DEFAULT_NORMAL_FG;
}
/*else if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
fg = DEFAULT_ACTIVE_FG;
bg = DEFAULT_ACTIVE_FG;
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
fg = DISABLED_FG;
bg = DISABLED_BG;
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
fg = DEFAULT_PRELIGHT_FG;
bg = DEFAULT_PRELIGHT_FG;
} else {
fg = DEFAULT_NORMAL_FG;
bg = DEFAULT_NORMAL_FG;
}*/
g2.setColor(fg[0]);
Rectangle2D fgshape = new Rectangle2D.Float(x, y, w, h);
g2.draw(fgshape);

View File

@@ -18,6 +18,8 @@ import java.awt.Container;
import java.awt.image.BufferedImage;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
/**
* NimbusComboBoxUI
@@ -87,6 +89,13 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
return new Dimension(size);
}
@Override
protected ComboPopup createPopup() {
BasicComboPopup p = new BasicComboPopup(comboBox);
//p.setPopupSize(100, comboBox.getPreferredSize().height);
return p;
}
@Override
protected JButton createArrowButton() {
JButton button = new JButton() {
@@ -101,8 +110,8 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
else if (mouseInside)
img = COMBO_OVER;
g.drawImage(img,
0, 0, getWidth(), getHeight(),
0, 0, img.getWidth(), img.getHeight(), comboBox);
0, 0, getWidth(), getHeight(),
0, 0, img.getWidth(), img.getHeight(), comboBox);
}
}
};
@@ -141,14 +150,14 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
else if (mouseInside)
img = COMBO_OVER;
g.drawImage(img,
bounds.x, bounds.y, bounds.x + 4, bounds.y + bounds.height,
0, 0, 1, 26, comboBox);
bounds.x, bounds.y, bounds.x + 4, bounds.y + bounds.height,
0, 0, 1, 26, comboBox);
g.drawImage(img,
bounds.x + 1, bounds.y, bounds.x + bounds.width - 25, bounds.y + bounds.height,
1, 0, 3, 26, comboBox);
bounds.x + 1, bounds.y, bounds.x + bounds.width - 25, bounds.y + bounds.height,
1, 0, 3, 26, comboBox);
g.drawImage(img,
bounds.x + bounds.width - 25, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
4, 0, 29, 26, comboBox);
bounds.x + bounds.width - 25, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
4, 0, 29, 26, comboBox);
} else {
/*g.setColor(Color.WHITE);
g.fillRect(bounds.x, bounds.y, bounds.width - btnSize.width, bounds.height - 1);
@@ -257,23 +266,25 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
@Override
public void layoutContainer(Container parent) {
JComboBox cb = (JComboBox) parent;
int width = cb.getWidth();
if (parent instanceof JComboBox) {
JComboBox cb = (JComboBox) parent;
int width = cb.getWidth();
Insets insets = getInsets();
Rectangle cvb;
Insets insets = getInsets();
Rectangle cvb;
if (arrowButton != null)
if (cb.getComponentOrientation().isLeftToRight())
arrowButton.setBounds(width - (insets.right + btnSize.width),
insets.top,
btnSize.width, btnSize.height);
else
arrowButton.setBounds(insets.left, insets.top,
btnSize.width, btnSize.height);
if (editor != null) {
cvb = rectangleForCurrentValue();
editor.setBounds(cvb.x, cvb.y, cvb.width, cvb.height);
if (arrowButton != null)
if (cb.getComponentOrientation().isLeftToRight())
arrowButton.setBounds(width - (insets.right + btnSize.width),
insets.top,
btnSize.width, btnSize.height);
else
arrowButton.setBounds(insets.left, insets.top,
btnSize.width, btnSize.height);
if (editor != null) {
cvb = rectangleForCurrentValue();
editor.setBounds(cvb.x, cvb.y, cvb.width, cvb.height);
}
}
}
}

View File

@@ -35,7 +35,7 @@ import java.awt.Graphics;
* @author Created by Jasper Potts (Jan 17, 2007)
* @version 1.0
*/
public class ScrollButton extends MetalScrollButton implements SwingConstants {
public class ScrollButton extends MetalScrollButton {
private final int btnWidth, btnHeight;