Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Add Watermark constructor on every skin, add changeWatermark method in SubstanceLookAndFeel #125

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ www/webstart/*.jar
.classpath
.project
.settings
.nb-gradle
*.zip
gradle
42 changes: 0 additions & 42 deletions README.markdown

This file was deleted.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Customize the excellent substance Look and Feel<br />
Add Watermark in constructor and changeWatermark in SubstanceLookAndFeel<br />
<p>
Create a Skin with Watermark:
<code>
SubstanceSkin skin = new DustSkin(getSubstanceImageWatermark());
SubstanceSkin skin2 = new OfficeBlue2007Skin(getSubstanceImageWatermark());
</code>
</p>

<p>
Change the Watermark:
<code>
SubstanceLookAndFeel.changeWatermark(getSubstanceImageWatermark());
</code>
</p>

Download the archive insubstantial-libraries-7.3-SNAPSHOT.zip:
<ul>
<li><a href="https://www.dropbox.com/sh/3msv90xpsrvbpkz/3fIbgoJWVZ" target="_blank">Dropbox</a></li>
<li><a href="http://pan.baidu.com/s/1oovny" target="_blank">Baidu云网盘</a></li>
</ul>


9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ subprojects {
group = 'com.github.insubstantial'
version = '7.3-SNAPSHOT'
ext.versionKey = "7.3-destroyer"

sourceCompatibility = 1.6
targetCompatibility = 1.6



configurations {
maven { extendsFrom archives }
published { extendsFrom archives, signatures}
Expand Down Expand Up @@ -98,6 +100,11 @@ subprojects {
}
}
}
[compileJava, javadoc, compileTestJava]*.options*.encoding = 'UTF-8'
compileJava.options.encoding = 'UTF-8'
tasks.withType(Compile) {
options.encoding = "UTF-8"
}
}

task githubDist(type: Zip) {
Expand Down
2 changes: 1 addition & 1 deletion flamingo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceSets {

test {
// if we are headless, don't run our tests
enabled = !Boolean.getBoolean("java.awt.headless")
enabled = !Boolean.getBoolean("java.awt.headless")
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.pushingpixels.substance.api.skin.SkinInfo;
import org.pushingpixels.substance.api.tabbed.BaseTabCloseListener;
import org.pushingpixels.substance.api.tabbed.TabCloseCallback;
import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
import org.pushingpixels.substance.internal.contrib.jgoodies.looks.common.ShadowPopupFactory;
import org.pushingpixels.substance.internal.fonts.FontPolicies;
import org.pushingpixels.substance.internal.painter.DecorationPainterUtils;
Expand Down Expand Up @@ -2107,7 +2108,16 @@ public void run() {
* The current Substance skin.
*/
private static SubstanceSkin currentSkin = null;


public static void changeWatermark(SubstanceWatermark watermark) {
SubstanceSkin skin = currentSkin;
if(skin != null) {
SubstanceSkin newSkin = skin.changeWatermark(watermark);
if (newSkin != null) {
setSkin(newSkin);
}
}
}
/**
* Sets the specified skin. If the current look-and-feel is not Substance,
* this method will create a new Substance look-and-feel based on the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@

import java.awt.Component;
import java.awt.Graphics2D;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JTabbedPane;
import javax.swing.UIDefaults;
Expand Down Expand Up @@ -214,7 +218,21 @@ protected SubstanceSkin() {
public final SubstanceWatermark getWatermark() {
return this.watermark;
}


public SubstanceSkin changeWatermark(SubstanceWatermark watermark) {
SubstanceSkin newSkin = null;
try {
Class c = getClass();
Constructor m = c.getConstructor(new Class[]{SubstanceWatermark.class});
if (m != null) {
newSkin = (SubstanceSkin) m.newInstance(new Object[]{watermark});
}
} catch (Exception ex) {
Logger.getLogger(SubstanceSkin.class.getName()).log(Level.SEVERE, null, ex);
}
return newSkin;
}

/**
* Returns the border painter of this skin.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.pushingpixels.substance.api.painter.overlay.BottomLineOverlayPainter;
import org.pushingpixels.substance.api.painter.overlay.TopShadowOverlayPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Autumn</code> skin. This class is part of officially supported API.
*
Expand All @@ -54,7 +54,10 @@ public class AutumnSkin extends SubstanceSkin {
* Overlay painter to paint separator lines on some decoration areas.
*/
private BottomLineOverlayPainter bottomLineOverlayPainter;

public AutumnSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Autumn</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.pushingpixels.substance.api.painter.highlight.ClassicHighlightPainter;
import org.pushingpixels.substance.api.painter.overlay.TopShadowOverlayPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Business Black Steel</code> skin. This class is part of officially
* supported API.
Expand All @@ -56,7 +56,10 @@ public class BusinessBlackSteelSkin extends SubstanceSkin {
* Display name for <code>this</code> skin.
*/
public static final String NAME = "Business Black Steel";

public BusinessBlackSteelSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Business</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.pushingpixels.substance.api.painter.fill.ClassicFillPainter;
import org.pushingpixels.substance.api.painter.highlight.ClassicHighlightPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Business Blue Steel</code> skin. This class is part of officially
* supported API.
Expand All @@ -52,7 +52,10 @@ public class BusinessBlueSteelSkin extends SubstanceSkin {
* Display name for <code>this</code> skin.
*/
public static final String NAME = "Business Blue Steel";

public BusinessBlueSteelSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Business</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.pushingpixels.substance.api.painter.fill.ClassicFillPainter;
import org.pushingpixels.substance.api.painter.highlight.ClassicHighlightPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Business</code> skin. This class is part of officially supported API.
*
Expand All @@ -51,7 +51,10 @@ public class BusinessSkin extends SubstanceSkin {
* Display name for <code>this</code> skin.
*/
public static final String NAME = "Business";

public BusinessSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Business</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.pushingpixels.substance.api.painter.overlay.BottomLineOverlayPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;
import org.pushingpixels.substance.internal.colorscheme.BlendBiColorScheme;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
import java.awt.Color;

/**
Expand All @@ -56,7 +56,10 @@ public class CeruleanSkin extends SubstanceSkin {
* Overlay painter to paint separator lines on some decoration areas.
*/
private BottomLineOverlayPainter bottomLineOverlayPainter;

public CeruleanSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Nebulous</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.pushingpixels.substance.api.painter.fill.GlassFillPainter;
import org.pushingpixels.substance.api.painter.highlight.ClassicHighlightPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Challenger Deep</code> skin. This class is part of officially supported
* API.
Expand All @@ -49,7 +49,10 @@ public class ChallengerDeepSkin extends SubstanceSkin {
* Display name for <code>this</code> skin.
*/
public static final String NAME = "Challenger Deep";

public ChallengerDeepSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Challenger Deep</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.pushingpixels.substance.api.painter.fill.MatteFillPainter;
import org.pushingpixels.substance.api.painter.highlight.ClassicHighlightPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Creme Coffee</code> skin. This class is part of officially supported
* API.
Expand All @@ -52,7 +52,10 @@ public class CremeCoffeeSkin extends SubstanceSkin {
* Display name for <code>this</code> skin.
*/
public static final String NAME = "Creme Coffee";

public CremeCoffeeSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Creme Coffee</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.pushingpixels.substance.api.painter.fill.ClassicFillPainter;
import org.pushingpixels.substance.api.painter.highlight.ClassicHighlightPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Creme</code> skin. This class is part of officially supported API.
*
Expand All @@ -52,7 +52,10 @@ public class CremeSkin extends SubstanceSkin {
* Display name for <code>this</code> skin.
*/
public static final String NAME = "Creme";

public CremeSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Creme</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.pushingpixels.substance.api.SubstanceColorSchemeBundle;
import org.pushingpixels.substance.api.SubstanceSkin;
import org.pushingpixels.substance.api.painter.fill.MatteFillPainter;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Dust Coffee</code> skin. This class is part of officially supported
* API.
Expand All @@ -49,7 +49,10 @@ public class DustCoffeeSkin extends DustSkin {
* Display name for <code>this</code> skin.
*/
public static final String NAME = "Dust Coffee";

public DustCoffeeSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Dust Coffee</code> skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.pushingpixels.substance.api.painter.overlay.BottomLineOverlayPainter;
import org.pushingpixels.substance.api.painter.overlay.TopLineOverlayPainter;
import org.pushingpixels.substance.api.shaper.ClassicButtonShaper;

import org.pushingpixels.substance.api.watermark.SubstanceWatermark;
/**
* <code>Dust</code> skin. This class is part of officially supported API.
*
Expand All @@ -64,7 +64,10 @@ public class DustSkin extends SubstanceSkin {
* Overlay painter to paint a light line along the top edge of the toolbars.
*/
private TopLineOverlayPainter toolbarOverlayPainter;

public DustSkin(SubstanceWatermark watermark) {
this();
this.watermark = watermark;
}
/**
* Creates a new <code>Dust</code> skin.
*/
Expand Down
Loading