Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaceable icons set #348

Closed
mgarin opened this issue Nov 13, 2015 · 9 comments
Closed

Replaceable icons set #348

mgarin opened this issue Nov 13, 2015 · 9 comments

Comments

@mgarin
Copy link
Owner

mgarin commented Nov 13, 2015

There is already a huge set of icons used within WebLaF and there is no convenient way to replace them altogether or sometimes there is no way to replace them at all.

This should certainly be addressed along with introduction of the fresh UI icons set based on SVG images in addition to existing PNG images set.

It is also a good opportunity to get rid of some deprecated or/and unused icons within library to reduce its size and make it cleaner overall.

@mgarin mgarin self-assigned this Nov 13, 2015
@mgarin mgarin added this to the v1.30 milestone Nov 13, 2015
@iamchathu
Copy link
Contributor

+1

Great feature

@chaddaniels
Copy link

Have you considered adding something similar to FontAwesomeFX? It is a JavaFX library that allows the use of scalable font characters from FontAwesome as images. If you're unfamiliar, see:
https://bitbucket.org/Jerady/fontawesomefx

@mgarin
Copy link
Owner Author

mgarin commented Nov 20, 2015

I did look into it briefly, but I am pretty sure there are some issues/limitations with fonts in older JDK versions - remember that WebLaF supports JDK 6 update 30 +.

They do have SVG version for the glyphs though which I might actually implement at some point since I am working towards scaleable SVG images as a replacement for non-scaleable raster images because they have a good potential:

  • They can be scaled, recolored and modified in runtime
  • They are stored in readable XML files
  • They work fast when used properly

You can actually already see some SVG icon being used in new demo application from the styling branch and they work pretty well I should say.

Anyway, implementation of FontAwesome and similar things is certainly not something that will be around soon as it will take some significant time and will have to be constantly supported.

@mgarin
Copy link
Owner Author

mgarin commented Feb 8, 2016

This feature will be provided by IconManager basic implementation of which is now available in styling branch. Right now it is simply a sketch of future manager and is not used anywhere.

Also while working on the v1.29 release I got a small idea that might enhance this feature even further - allow providing icons within the skin files. That will be a pretty nice addition to IconManager itself. Basically you will be able to specify icons at any point in the skin XML:

<skin>
    ...
    <SvgIcon id="spinner-up" src="icons/spinner-up.svg" />
    <ImageIcon id="spinner-down" src="icons/spinner-down.png" />
    ....
</skin>

And then use it within the skin description:

<style type="button" id="next" extends="button">
    <component>
        <icon>spinner-up</icon>
    </component>
    ...
</style>

@mgarin mgarin changed the title Easily replaceable icons set Replaceable icons set Feb 8, 2016
@mgarin
Copy link
Owner Author

mgarin commented Aug 5, 2019

First preview of IconManager and IconSets have been added in v1.2.9 update:
https://github.com/mgarin/weblaf/releases/tag/v1.2.9

It will receive major improvements in the next few updates to include most of the features mentioned in this issue.

@mgarin mgarin modified the milestones: v1.3.0, v1.2.11 Nov 22, 2019
@mgarin
Copy link
Owner Author

mgarin commented Nov 22, 2019

Last week I've started looking into IconManager and adjusting some stuff for wiki (by recent request from @mokun) and I've gone into some major internal adjustments across the whole library.

As a result of these changes (that will be going live today):

  • Icons provided through skins and extensions are not added directly into IconManager anymore so they can't be accidentally removed or replaced, but all icons from the active skin and extensions are available through the same IconManager API.

  • All IconSet caches are now properly updated on demand in IconManager allowing proper override of any particular icon by simply providing a new IconSet with an icon that uses existing identifier.

  • IconSets will now have a strict priority order:
    User-added sets > Extensions sets > Skin sets

  • Icons within IconSets will now also have a strict priority order:
    Later added icons > Earlier added icons

  • There are multiple performance and API improvements for IconManager, IconSet, IconData as well as related utilities like ImageUtils and various other classes.

All these changes will basically allow any existing icons from IconSets to be replaced through either custom IconSets added in extensions or at runtime.

@mgarin
Copy link
Owner Author

mgarin commented Nov 22, 2019

I'll be posting more extensive guide on wiki once snapshot versions with these changes are available.

mgarin added a commit that referenced this issue Nov 22, 2019
- IconManager.java - Simplified `IconSet` addition and removal and it is now strict
- IconManager.java - Any `find*` methods can return `null`, while `get*` methods will either return non-`null` value or throw exception
- IconSet.java - Made into a proper base interface for any icon sets and is now used across all related classes instead of `AbstractIconSet`
- XmlIconSet.java - Now uses new `Resource` interface as a source for XML, all path operations were moved into converters
- XmlIconSetConverter.java - New custom converter for `XmlIconSet` that provides necessary context settings for icon converters
- IconSetData.java - Removed as redundant, all icons are read directly into `XmlIconSet`
- AbstractIconDataConverter.java - New custom abstract converter for any kinds of icon data
- XmlUtils.java - Added method for reading various `Resource` types from node attributes for convenience and backward compatibility
- RuntimeIconSet.java - New `IconSet` implementation for convenient runtime icon set creation
- ImageIconData.java, SvgIconData.java - Added various constructors for convenient runtime icon data creation

API
- Resource.java - New interface for any custom resource, provides `InputStream` for reading the resource
- Resource.java - Fully replaced old inconvenient `Resource` (old) class, all related places across the code have been adjusted accordingly
- Resource.java (old), ResourceLocation.java - Removed and replaced by `Resource` interface in API
- UrlResource.java, FileResource.java, ClassResource.java - New `Resource` implementations for most common use cases
- ResourceException.java - Custom `RuntimeException` used for `Resource` implementations exclusively
- DisabledCopySupplier.java - New interface for classes that can return disabled copy of themselves, currently used for complex `Icon`s
- TransparentCopySupplier.java - New interface for classes that can return transparent copy of themselves, currently used for complex `Icon`s

Skins
- WebSkin.java, DarkSkin.java - Renamed to `WebLightSkin` and `WebDarkSkin` accordingly for consistency reasons
- WebLightSkin.java - Moved from `com.alee.skin.web` to `com.alee.skin.light` package for consistency
- web-light-skin.xml - Identifier changed from `weblaf.web.skin` to `weblaf.light.skin` for consistency
- All XML files of different skins and extensions renamed from `skin.xml` and `extension.xml` to more specific names
- Names of placeholder skins like `ModenaSkin` or `FlatSkin` were preserved, but their XML files were renamed

SVG
- SvgIcon.java - Added method for attribute removal
- SvgIcon.java - Will now use separate `SVGUniverse` for each instance
- SvgIconData.java, SvgIconData.xsd - Removed `universe` setting
- AbstractSvgColorAdjustment.java - New abstract adjustment for all `SvgIcon` colors
- SvgColorOpacity.java - New adjustment for `SvgIcon` to change opacity of all colors in the icon
- SvgGrayscale.java - Now based on `SvgColorAdjustment` to simplify code
- SvgOpacity.java - New adjustment for `SvgIcon` to change `opacity` attribute of selected elements
- AbstractSvgAdjustment.java, AbstractSvgAttributeAdjustment.java and other adjustments - Added constructors for convenient usage in code
- pom.xml - Added dependency on SVG Salamander v1.1.2.2 release based on my fork (see https://github.com/mgarin/svgSalamander)

GIF
- GifIcon.java - Now uses `Resource` in constructors instead of hardcoded options
- GifIcon.java - Refactored code and added `@NotNull` and `@Nullable` usage
- GifFrame.java - Moved into separate class for use convenience
- FrameChangeListener.java - Renamed from `RepaintListener` to clarify what kind of events it listens to
- FrameChangeListener.java - Added some basic arguments for usage convenience
- GifDecoder.java - Potential NPE fix and minor code refactoring

NinePatch
- NinePatchIcon.java - Now uses `Resource` in constructors instead of hardcoded options
- NinePatchIcon.java - Replaced static creation method with a proper constructor
- NinePatchIconConverter.java, NinePatchUtils.java - Adjusted for `NinePatchIcon` changes

Icons
- ColorIcon.java - Replaces some old `ImageUtils` methods for creating decorated icon for a specific `Color`
- ColorIcon.java - Now supports "alpha" background for `null`, fully-transparent and semi-transparent `Color`s

Decorations
- AlphaLayerBackground.java - Separated static method for alpha texture creation for reuse in other places

TabbedPane
- WTabbedPaneInputListener.java - Fixed exception that occurs when using mouse wheel on top of tabbed pane with zero tabs
- TabbedPaneLayout.java - Disabled icon will only receive updates if tab is disabled to avoid preemptively generating disabled icon

Tree
- TreePainter.java - Node selection will not occur on disabled tree anymore
- TreePainter.java - Removed unnecessary checks, adjusted used utility methods
- WebTreeCellRenderer.java - Removed redundant logic for disabled icon retrieval, it will become disabled on it's own through renderer component (label)

DateField
- WebDateFieldUI.java - Replaced raster hardcoded button icon with configurable `calendar` and `calendar-hover` icons from `IconManager`

Calendar
- WebCalendar.java - Replaced raster hardcoded button icons with configurable `double-left-big`, `left-big`, `right-big` and `double-right-big` icons from `IconManager`

ColorChooserField
- WebColorChooserField.java - Added support for `null` color, it can be set as `null` or user can erase text in the field to change color to `null`
- WebColorChooserField.java - Default selected color is now `null` instead of `Color.WHITE`
- WebColorChooserField.java - Added support for color's alpha in the text field and on the color icon, popup chooser will have that support added later
- WebColorChooserField.java - Replaced utility color icon with a custom `ColorIcon` implementation

ImageGallery
- WebImageGallery.java - Now stores `BufferedImage` instead of `ImageIcon` for usage convenience and less conversion operations
- WebImageGallery.java - New images are now added to the end by default
- WebImageGallery.java - Removed dead-end try-catch on image addition

LanguageManager
- Dictionary.java - Now uses `Resource` in constructors instead of hardcoded options

PluginManager
- PluginManager.java, Plugin.java, DetectedPlugin.java - Replaced `ImageIcon` usage with simple `Icon` for wider icon types support

StyleEditor
- StyleEditor.java - Minor size adjustment for the left side of split
- StyleEditor.java - Now properly launched on EDT
- magnifierImage.png - Removed as redundant

Utilities
- ImageUtils.java - Completely revamped to provide adequate JavaDoc and consistent approach to image read/creation/modification
- ImageUtils.java - Multiple outdated/unnecessary methods have been removed, they can be replaced with new `ImageUtils` methods and/or common image API
- ImageUtils.java - Multiple old auto-cached image retrieval methods have been removed, image cache should not be handled globally like that
- ImageUtils.java - Icon merge methods were replaced with `StackIcon` implementation, caching must now be done locally if necessary
- ImageUtils.java - Icon combine methods were replaced with `FlowIcon` implementation, caching must now be done locally if necessary
- IOUtils.java - New utility class for working with streams
- ColorUtils.java - Adapted hex color conversion methods to RGBA format, previously only RGB was supported
- ColorUtils.java - Removed redundant color cache, there is no point to cache colors as it only makes their usage slower
- FileUtils.java - Refactored all remaining old code, added `@NotNull` and `@Nullable` annotations to clarify use cases
- FileUtils.java - Modified some methods to use `Resource` instead of hardcoded options
- Scale.java, ScaleConverter.java, XmlUtils.java - New data class for `double` X/Y axis scale values
- Clone.java - Added new preconfigured `reflective` option of `Clone` for cloning any chaotic object structures, `Cloneable` or not
- Clone.java - Removed preconfigured `adaptive` option of `Clone` as redundant
- Clone.java - Clarified use cases in JavaDoc for the class
- NetUtils.java - Converted to fail-fast approach to avoid hiding exceptions
- JavaVersion.java - Added `versionString ()` method to retrieve clean version string separately
- JavaVersion.java - Added logging for possible issues with version read
- JavaVersion.java - Improved text output for JDK version 9 and higher
- Objects.java - Minor code refactoring

Tests
- ColorUtils.java - New test for checking validity of various color-related utilities
- ComponentInstantiationTest.java - Adjusted according to `SvgIcon` API changes

General
- WebLookAndFeel.java - Simplified disabled icon retrieval, cache is now implemented within `ImageUtils`
- WebLookAndFeel.java - Simplified library icons/images retrieval code
- AboutLibraryDialog.java - Renamed for convenience, slightly refactored code
- Added `@NotNull` and `@Nullable` usage across all modified classes

DemoApplication
- DemoApplication.java, demo-language.xml - Removed outdated text in the overlay with library and VM version
- DemoApplication.java - Fixed title updated upon closing last preview in document pane
- demo-dark-extension.xml - Added washed wall background for dark extension to mirror light one

Project
- README.md - Added information about all dependencies and 3rd-party code use in WebLaF library
- README.md - Added a few helpful notes about source code and JavaDoc
- README.md - Added two more JVM options necessary to avoid warnings on JDK9+
- README.md - Added Maven Central release badge with link to search for convenience
- CONTRIBUTING.md - Added new and updated some old notes about code philosophy
@mgarin
Copy link
Owner Author

mgarin commented Nov 22, 2019

All icons provided through IconSets are now easily replaceable.

To do that - you simply need to provide icon with the same identifier in another set and add it later than the first set have been added with an exception of skin/extension IconSets - those always have lower priority as was mentioned above.

There is also a new RuntimeIconSet available for creating custom IconSets in runtime with ease. Also SvgIconData and ImageIconData now both have convenient public constructors asking for all necessary parameters.

@mgarin mgarin closed this as completed Nov 22, 2019
@mgarin
Copy link
Owner Author

mgarin commented Nov 22, 2019

Detailed article with all information about these changes can be found on wiki:
https://github.com/mgarin/weblaf/wiki/How-to-use-IconManager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants