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

Commit

Permalink
Bug fixing and license update
Browse files Browse the repository at this point in the history
Issue #34 - fixed inverted preview of vertical sliders in color choosers
Issue #35 - fixed incorrect scaling of glowing icons on title pane
Issue #36 - fixed incorrect rendering of offscreen progress bars

Also updated the year and the footnote of the license
  • Loading branch information
kirill-grouchnikov committed Jul 28, 2017
1 parent 9eb5639 commit fda666b
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 92 deletions.
Binary file modified drop/7.1.00-dev/substance-7.1.00-dev.jar
Binary file not shown.
Binary file modified drop/7.1.00-dev/substance-lite-7.1.00-dev.jar
Binary file not shown.
Binary file modified drop/7.1.00-dev/substance-tools-7.1.00-dev.jar
Binary file not shown.
Binary file modified drop/7.1.00-dev/substance-tst-7.1.00-dev.jar
Binary file not shown.
Binary file modified drop/7.1.00-dev/substance-tst-lite-7.1.00-dev.jar
Binary file not shown.
7 changes: 3 additions & 4 deletions src/Substance.license
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2005-2010, Kirill Grouchnikov and contributors
Copyright (c) 2005-2017, Kirill Grouchnikov and contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -28,6 +28,5 @@ THE POSSIBILITY OF SUCH DAMAGE.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

The original artwork used in the Quaqua color chooser implementation
has been replaced by images from Famfam Silk collection available
under Creative Commons Attribution-ShareAlike 2.5 license and
images created dynamically by the Substance core code.
has been replaced by images transcoded from Material Icons available
under Apache 2.0 license and images created dynamically by the Substance code.
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,12 @@ private void paintColorTrack(Graphics g, int x, int y, int width, int height, in
}

Graphics2D gg = (Graphics2D) g.create();
Color c1 = new Color(colorSliderModel.getInterpolatedRGB(componentIndex, 0.0f),
true);
Color c2 = new Color(colorSliderModel.getInterpolatedRGB(componentIndex, 1.0f));
gg.setPaint(new LinearGradientPaint(x, y, x2, y2, new float[] { 0f, 1.0f },
new Color[] {
new Color(colorSliderModel.getInterpolatedRGB(componentIndex, 0.0f), true),
new Color(colorSliderModel.getInterpolatedRGB(componentIndex, 1.0f)) }));
slider.getOrientation() == JSlider.HORIZONTAL ?
new Color[] { c1, c2 } : new Color[] { c2, c1 }));
gg.fillRect(x, y, width, height);
gg.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public void stateChanged(ChangeEvent e) {

int barRectWidth = progressBar.getWidth() - 2 * margin;
int barRectHeight = progressBar.getHeight() - 2 * margin;
int totalPixels = (progressBar.getOrientation() == JProgressBar.HORIZONTAL) ? barRectWidth
: barRectHeight;
int totalPixels = (progressBar.getOrientation() == JProgressBar.HORIZONTAL) ?
barRectWidth : barRectHeight;
// fix for defect 223 (min and max on the model are the
// same).
int pixelDelta = (span <= 0) ? 0 : (currValue - displayedValue)
Expand All @@ -160,13 +160,15 @@ public void set(Object obj, String fieldName,
AnimationConfigurationManager.getInstance().configureTimeline(
displayTimeline);

// do not animate progress bars used in cell renderers
// Do not animate progress bars used in cell renderers
// since in this case it will most probably be the
// same progress bar used to display different
// values for different cells.
// values for different cells. Also do not animate progress bars
// that are not part of the UI tree.
boolean isInCellRenderer = (SwingUtilities.getAncestorOfClass(
CellRendererPane.class, progressBar) != null);
if (!isInCellRenderer && Math.abs(pixelDelta) > 5) {
boolean hasParent = (progressBar.getParent() != null);
if (hasParent && !isInCellRenderer && Math.abs(pixelDelta) > 5) {
displayTimeline.play();
} else {
displayedValue = currValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.ButtonUI;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.UIResource;
import javax.swing.text.JTextComponent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import javax.swing.*;

import org.pushingpixels.lafwidget.icon.HiDpiAwareIcon;
import org.pushingpixels.lafwidget.icon.IsHiDpiAware;
import org.pushingpixels.substance.api.*;
import org.pushingpixels.substance.internal.animation.StateTransitionTracker;
import org.pushingpixels.substance.internal.animation.TransitionAwareUI;
Expand All @@ -50,7 +51,7 @@
* @author Kirill Grouchnikov
*/
@TransitionAware
public class TransitionAwareIcon implements Icon {
public class TransitionAwareIcon implements Icon, IsHiDpiAware {
/**
* The delegate needs to implement the method in this interface based on the
* provided color scheme. The color scheme is computed based on the
Expand Down Expand Up @@ -146,6 +147,11 @@ public TransitionAwareIcon(
this.iconWidth = markEnabledIcon.getIconWidth();
this.iconHeight = markEnabledIcon.getIconHeight();
}

@Override
public boolean isHiDpiAware() {
return true;
}

/**
* Returns the current icon to paint.
Expand Down
159 changes: 159 additions & 0 deletions src/test/SubstanceBug.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package test;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
import javax.swing.*;

public class SubstanceBug
{
public static void main(String[] args)
{
//This one demos the default Look and Feel handling this
testBug("Default LaF", 0, 0, false);

//Install Substance's Graphite Look and Feel
installLookAndFeel();

//These two demo Substance's Graphite Look and Feel handling this
//This does all kinds of weird stuff
testBug("Substance/Graphite", 0, 1, false);
//This works correctly, but constantly forces the current Look and Feel
testBug("Substance/Graphite (UpdateUI called)", 1, 1, true);

}

private static void testBug(
String title, int xShift, int yShift, boolean updateUI)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(250, 250);
frame.setLocation(275 * xShift, 275 * yShift);

JProgressBar bar = new JProgressBar();
//To give a clear indication of actual value, despite the bug
bar.setStringPainted(true);
//Off-screen components need an explicitly set size
bar.setSize(bar.getPreferredSize());
bar.setValue(50);

//This BufferedImage is what we'll be rendering bar into
BufferedImage image = new BufferedImage(
bar.getWidth(), bar.getHeight(),
BufferedImage.TYPE_INT_ARGB);

//Setup an initial render
paint(bar, image);

JLabel label = new JLabel(new ImageIcon(image));
label.setText(title);
label.setHorizontalTextPosition(JLabel.CENTER);
label.setVerticalTextPosition(JLabel.BOTTOM);
frame.add(label);
frame.setVisible(true);

startUpdating(bar, image, label, updateUI);
}
});
}

private static void startUpdating(JProgressBar bar, BufferedImage image,
JLabel label, boolean updateUI)
{
new Thread(new Runnable()
{
int v = 50;
public void run()
{
while (true)
{
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
}

v++;
if (v > 100)
{
v = 0;
}

try
{
SwingUtilities.invokeAndWait(new Runnable()
{
public void run()
{
//Update the value of progress bar
bar.setValue(v);
//This is the kludgy work-around that seems to get
// this to work properly with substance
if (updateUI)
{
bar.updateUI();
}
//Finally, we can paint it
paint(bar, image);

label.repaint();
}
});
}
catch (InterruptedException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
}
}).start();
}

private static void paint(JComponent jc, BufferedImage image)
{
Graphics g = image.getGraphics();
jc.paint(g);
g.dispose();
}

private static void installLookAndFeel()
{
try
{
//We're waiting to make sure the look and feel is installed before
// moving on to tests
SwingUtilities.invokeAndWait(new Runnable()
{
public void run()
{
try
{
UIManager.setLookAndFeel(
"org.pushingpixels.substance.api.skin."
+ "SubstanceGraphiteLookAndFeel");
}
//Best we can do in the circumstances
catch (ClassNotFoundException
| InstantiationException
| IllegalAccessException
| UnsupportedLookAndFeelException e)
{
System.err.println("Unable to install Look & Feel");
e.printStackTrace(System.err);
}
}
});
}
catch (InterruptedException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
}
77 changes: 0 additions & 77 deletions src/test/TableRowHeight.java

This file was deleted.

1 change: 0 additions & 1 deletion src/test/check/statusbar/FontSizePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;

import test.Check;
import test.check.svg.View_zoom_in;
import test.check.svg.View_zoom_out;

Expand Down

0 comments on commit fda666b

Please sign in to comment.