Skip to content
This repository has been archived by the owner on Jul 10, 2018. It is now read-only.

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
* More fixes for #48
* First support for Java 10
* Clean up unused code
* Tweak Javadocs
  • Loading branch information
kirill-grouchnikov committed Feb 27, 2018
1 parent 781a84a commit 0ff612c
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 32 deletions.
Binary file modified drop/8.0.00-dev/substance-8.0.00-dev.jar
Binary file not shown.
Binary file modified drop/8.0.00-dev/substance-lite-8.0.00-dev.jar
Binary file not shown.
Binary file modified drop/8.0.00-dev/trident-1.5.00-dev.jar
Binary file not shown.
Binary file modified lib/trident-1.5.00-dev.jar
Binary file not shown.
21 changes: 12 additions & 9 deletions src/org/pushingpixels/substance/api/SubstanceLookAndFeel.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.KeyboardFocusManager;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
Expand Down Expand Up @@ -61,15 +62,17 @@

/**
* <p>
* Main class for <b>Substance </b> look and feel. There are three options to use Substance in your
* base class for <b>Substance </b> look and feel. There are three options to use Substance in your
* application:
* </p>
*
* <ul>
* <li>Use one of the core skin-based look-and-feels in the
* <li>Use {@link UIManager#setLookAndFeel(javax.swing.LookAndFeel)} or
* {@link UIManager#setLookAndFeel(String)} passing one of the core skin-based look-and-feels in the
* <code>org.pushingpixels.substance.api.skin</code> package.</li>
* <li>Extend this class and pass a skin instance to the
* {@link SubstanceLookAndFeel#SubstanceLookAndFeel(SubstanceSkin)} constructor.</li>
* <li>Extend this class, pass a skin instance to the
* {@link #SubstanceLookAndFeel(SubstanceSkin)} constructor, and then use
* {@link UIManager#setLookAndFeel(javax.swing.LookAndFeel)}.</li>
* <li>Call {@link SubstanceCortex.GlobalScope#setSkin(String)} or
* {@link SubstanceCortex.GlobalScope#setSkin(SubstanceSkin)} static methods. These methods do not
* require Substance to be the current look-and-feel.</li>
Expand Down Expand Up @@ -298,7 +301,6 @@ public void initialize() {
ShadowPopupFactory.install();

SubstanceCortex.GlobalScope.setSkin(this.skin, false);
// setSkin(this.skin, false);

// tracer for memory analysis
String traceFilename = (String) UIManager.get(SubstanceSynapse.TRACE_FILE);
Expand Down Expand Up @@ -404,13 +406,14 @@ public Icon getDisabledIcon(JComponent component, Icon icon) {
float alpha = SubstanceColorSchemeUtilities.getAlpha(component,
ComponentState.DISABLED_UNSELECTED);
if (alpha < 1.0f) {
BufferedImage intermediate = SubstanceCoreUtilities.getBlankImage(icon.getIconWidth(),
BufferedImage intermediate = SubstanceCoreUtilities.getBlankUnscaledImage(icon.getIconWidth(),
icon.getIconHeight());
Graphics2D g2d = intermediate.createGraphics();
g2d.setComposite(AlphaComposite.SrcOver.derive(alpha));
double scaleFactor = UIUtil.getScaleFactor();
g2d.drawImage(result, 0, 0, (int) (result.getWidth() / scaleFactor),
(int) (result.getHeight() / scaleFactor), null);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.drawImage(result, 0, 0, result.getWidth(),
result.getHeight(), null);
g2d.dispose();
result = intermediate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,24 @@
package org.pushingpixels.substance.api;

/**
* This exception is thrown by Substance when it detects violations of Swing UI
* threading rules. See
* <a href="http://www.pushing-pixels.org/2008/07/15/stricter-checks-on-edt-violations-in-substance.html">here</a>
* and
* <a href="http://www.pushing-pixels.org/2010/02/16/your-application-will-be-with-you-momentarily.html">here</a>
* for more information on why Substance throws this exception.
* This exception is thrown by Substance when it detects violations of Swing UI threading rules. See
* <a href=
* "http://www.pushing-pixels.org/2008/07/15/stricter-checks-on-edt-violations-in-substance.html">here</a>
* and <a href=
* "http://www.pushing-pixels.org/2010/02/16/your-application-will-be-with-you-momentarily.html">here</a>
* for more information on why Substance enforces the Swing threading rules and throws this
* exception.
*
* @author Kirill Grouchnikov
*/
public class UiThreadingViolationException extends RuntimeException {
/**
* Creates a new instance of this exception.
*
* @param message
* Message.
*/
public UiThreadingViolationException(String message) {
super(message);
}
/**
* Creates a new instance of this exception.
*
* @param message
* Message.
*/
public UiThreadingViolationException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ private FontUIResource getSubstanceFont(FontUIResource systemFont, boolean toBol
return new FontUIResource(
systemFont.deriveFont((float) (systemFont.getSize() + extraFontSize))
.deriveFont(newStyle));
// return new FontUIResource(systemFont.getFontName(), newStyle,
// systemFont.getSize() + extraFontSize);
}

public FontUIResource getControlFont() {
Expand Down
3 changes: 3 additions & 0 deletions src/org/pushingpixels/substance/api/icon/SubstanceIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

import javax.swing.Icon;
Expand Down Expand Up @@ -102,6 +103,8 @@ public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
int dx = (this.width - this.getInternalWidth()) / 2;
int dy = (this.height - this.getInternalHeight()) / 2;
g2d.translate(x + dx, y + dy);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
if (this.imageSource != null) {
g2d.drawImage(this.imageSource, 0, 0, (int) (this.imageSource.getWidth() / this.factor),
(int) (this.imageSource.getHeight() / this.factor), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

import javax.swing.Icon;
Expand Down Expand Up @@ -106,6 +107,8 @@ public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
int dx = (this.width - this.getInternalWidth()) / 2;
int dy = (this.height - this.getInternalHeight()) / 2;
g2d.translate(x + dx, y + dy);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
if (this.imageSource != null) {
g2d.drawImage(this.imageSource, 0, 0, (int) (this.imageSource.getWidth() / this.factor),
(int) (this.imageSource.getHeight() / this.factor), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.pushingpixels.substance.api.SubstanceSkin;
import org.pushingpixels.substance.api.SubstanceSlices.DecorationAreaType;
import org.pushingpixels.substance.api.colorscheme.SubstanceColorScheme;
import org.pushingpixels.substance.internal.contrib.intellij.UIUtil;
import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;

/**
Expand Down Expand Up @@ -147,9 +146,7 @@ private void paintTitleBackground(Graphics2D graphics, Component comp, int width
rgraphics.setClip(new Rectangle(0, 0, width, height));
rgraphics.draw(mid);

double scaleFactor = UIUtil.getScaleFactor();
graphics.drawImage(rectangular, 0, 0, (int) (rectangular.getWidth() / scaleFactor),
(int) (rectangular.getHeight() / scaleFactor), null);
graphics.drawImage(rectangular, 0, 0, width, height, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static double getScaleFactor(GraphicsDevice device) {
return devicesScaleFactorCacheMap.get(device);
}

double result = LookUtils.IS_JAVA_9 ? getScaleFactorModern(device)
double result = LookUtils.IS_JAVA_9 || LookUtils.IS_JAVA_10 ? getScaleFactorModern(device)
: getScaleFactorLegacy(device);

devicesScaleFactorCacheMap.put(device, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public final class LookUtils {

public static final boolean IS_JAVA_8 = startsWith(JAVA_SPEC_VERSION, "8");
public static final boolean IS_JAVA_9 = startsWith(JAVA_SPEC_VERSION, "9");
public static final boolean IS_JAVA_10 = startsWith(JAVA_SPEC_VERSION, "10");

// Other Properties *******************************************************

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DefaultMacFontPolicy implements FontPolicy {
*/
public FontSet getFontSet(String lafName, UIDefaults table) {
String fontFamily = "Lucida Grande";
if (LookUtils.IS_JAVA_9) {
if (LookUtils.IS_JAVA_9 || LookUtils.IS_JAVA_10) {
if (LookUtils.IS_OS_MAC_EL_CAPITAN_OR_LATER) {
fontFamily = ".SF NS Text";
} else if (LookUtils.IS_OS_MAC_YOSEMITE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,8 @@ public static BufferedImage getColorSchemeImage(Component comp, Icon original,
}
BufferedImage origImage = SubstanceCoreUtilities.getBlankImage(w, h);
Graphics2D g2d = (Graphics2D) origImage.getGraphics().create();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
original.paintIcon(comp, origImage.getGraphics(), 0, 0);
g2d.dispose();

Expand Down

0 comments on commit 0ff612c

Please sign in to comment.