moved ScaledSVGIcon.java from demo to flatlaf-extras and renamed to FlatSVGIcon.java

This commit is contained in:
Karl Tauber
2019-11-16 22:27:54 +01:00
parent f175c36736
commit 3de329a332
4 changed files with 24 additions and 21 deletions

View File

@@ -23,19 +23,20 @@ plugins {
dependencies { dependencies {
implementation( project( ":flatlaf-core" ) ) implementation( project( ":flatlaf-core" ) )
implementation( project( ":flatlaf-extras" ) )
implementation( "com.miglayout:miglayout-swing:5.2" ) implementation( "com.miglayout:miglayout-swing:5.2" )
implementation( "com.jgoodies:jgoodies-forms:1.9.0" ) implementation( "com.jgoodies:jgoodies-forms:1.9.0" )
implementation( "com.formdev:svgSalamander:1.1.2.1" )
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
} }
tasks { tasks {
jar { jar {
dependsOn( ":flatlaf-core:jar" ) dependsOn( ":flatlaf-core:jar" )
dependsOn( ":flatlaf-extras:jar" )
manifest { manifest {
attributes( "Main-Class" to "com.formdev.flatlaf.demo.FlatLafDemo" ) attributes( "Main-Class" to "com.formdev.flatlaf.demo.FlatLafDemo" )

View File

@@ -20,6 +20,7 @@ import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import com.formdev.flatlaf.demo.intellijthemes.*; import com.formdev.flatlaf.demo.intellijthemes.*;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
/** /**
@@ -273,20 +274,20 @@ class DemoFrame
buttonGroup1.add(radioButtonMenuItem3); buttonGroup1.add(radioButtonMenuItem3);
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
undoMenuItem.setIcon( new ScaledSVGIcon( "icons/undo.svg" ) ); undoMenuItem.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/undo.svg" ) );
redoMenuItem.setIcon( new ScaledSVGIcon( "icons/redo.svg" ) ); redoMenuItem.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/redo.svg" ) );
cutMenuItem.setIcon( new ScaledSVGIcon( "icons/menu-cut.svg" ) ); cutMenuItem.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/menu-cut.svg" ) );
copyMenuItem.setIcon( new ScaledSVGIcon( "icons/copy.svg" ) ); copyMenuItem.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/copy.svg" ) );
pasteMenuItem.setIcon( new ScaledSVGIcon( "icons/menu-paste.svg" ) ); pasteMenuItem.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/menu-paste.svg" ) );
backButton.setIcon( new ScaledSVGIcon( "icons/back.svg" ) ); backButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/back.svg" ) );
forwardButton.setIcon( new ScaledSVGIcon( "icons/forward.svg" ) ); forwardButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/forward.svg" ) );
cutButton.setIcon( new ScaledSVGIcon( "icons/menu-cut.svg" ) ); cutButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/menu-cut.svg" ) );
copyButton.setIcon( new ScaledSVGIcon( "icons/copy.svg" ) ); copyButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/copy.svg" ) );
pasteButton.setIcon( new ScaledSVGIcon( "icons/menu-paste.svg" ) ); pasteButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/menu-paste.svg" ) );
refreshButton.setIcon( new ScaledSVGIcon( "icons/refresh.svg" ) ); refreshButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/refresh.svg" ) );
showToggleButton.setIcon( new ScaledSVGIcon( "icons/show.svg" ) ); showToggleButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/show.svg" ) );
} }
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables

View File

@@ -22,9 +22,10 @@ plugins {
dependencies { dependencies {
implementation( project( ":flatlaf-core" ) ) implementation( project( ":flatlaf-core" ) )
implementation( "com.formdev:svgSalamander:1.1.2.1" )
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
} }

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.formdev.flatlaf.demo; package com.formdev.flatlaf.extras;
import java.awt.Component; import java.awt.Component;
import java.awt.Graphics; import java.awt.Graphics;
@@ -34,14 +34,14 @@ import com.kitfox.svg.app.beans.SVGIcon;
/** /**
* @author Karl Tauber * @author Karl Tauber
*/ */
public class ScaledSVGIcon public class FlatSVGIcon
extends ImageIcon extends ImageIcon
{ {
private final String name; private final String name;
private final SVGIcon svgIcon; private final SVGIcon svgIcon;
private boolean dark; private boolean dark;
public ScaledSVGIcon( String name ) { public FlatSVGIcon( String name ) {
this.name = name; this.name = name;
svgIcon = new SVGIcon(); svgIcon = new SVGIcon();
@@ -69,7 +69,7 @@ public class ScaledSVGIcon
int dotIndex = name.lastIndexOf( '.' ); int dotIndex = name.lastIndexOf( '.' );
name = name.substring( 0, dotIndex ) + "_dark" + name.substring( dotIndex ); name = name.substring( 0, dotIndex ) + "_dark" + name.substring( dotIndex );
} }
return getClass().getResource( name ); return FlatSVGIcon.class.getClassLoader().getResource( name );
} }
@Override @Override