New Zealand
Joined: Dec 28, 2014
Post Count: 95
Status:
Offline
Change color plugin
I've been trying to experiment with wall, floor, and furniture colors for a renovation. I got into a bit of a muddle over the assignment of colors to various walls and furniture items. This motivated me to write a plugin that could find where a color had been used and change it.
The ChangeColor plugin provides a dialog with two standard Java Swing color choosers, one for selecting a from-color, and another for selecting a to-color. The standard Swing choosers have been enhanced to include an extra tab for "Colors in use." The Colors-in-use tab displays a swatch for each color used in the model. Each color in-use swatch includes a hover tooltip that lists where the color is used.
Here is a screen shot where the top chooser shows the "Colors in use" tab with an active hover showing where color #E2D3DF is bing used. The bottom chooser is on the RGB tab, where E2E7BE is selected to replace E2D3DF.
Note that undo has not yet been implemented and I only wrote the plugin today. You should back up a copy of your model before using this plugin to make any changes.
I find the plugin quite helpful for temporarily changing a color to some other quite different and unique color, it then becomes quite apparent which walls and items do or don't have the right colors applied.
Future work might including implementing undo, but I'm not sure when I'll find the time. If anyone else would like to have a go at enhancing the plugin, the code base is relatively small.
Please remember to backup a copy of your model before playing with this plugin.
Netherlands
Joined: Sep 26, 2009
Post Count: 4000
Status:
Online
Re: Change color plugin
A few minutes ago, I installed your plug-in. Although it appears and seems to function, I'm not sure it actually does what you describe.
The tab Colors in use gives small rectangles where the borders have the colours in use (but which are not filled with that colour as in your image).
In the lower half the rectangles are present (without fill) and colours can be changed. However, the colours are not applied to the model(s), and there is no Apply button to execute the changes you make.
Maybe I'm doing something wrong? Maybe the plug-in is a bit too much in beta stage?
I'm using a computer with Windows 10 64 bits and SH3D v5.1 64 bits.
Hans
----------------------------------------
Hans
New Zealand
Joined: Dec 28, 2014
Post Count: 95
Status:
Offline
Re: Change color plugin
If you look at the screen shot in the original post, there is a very wide "Apply" button along the whole bottom of the panel labelled Replace from color with to color on matching items - I guess it's not obvious its a button. I need to put a bit more work into the interface, but I thought I'd release it now as I'm unsure of how much free time I will have in coming weeks).
I'm not sure why you aren't seeing the Colors in use filled swatches. It could be a paint/refresh issue, or it may be a Java version/platform issue. Perhaps try clicking on the tab twice - I did have a paint/refresh bug, but I thought I had fixed it, before the fix I had to click twice to get the swatches to appear, but what you are seeing is different, so there may be another bug/issue.
A few minutes ago, I installed your plug-in. Although it appears and seems to function, I'm not sure it actually does what you describe.
The tab Colors in use gives small rectangles where the borders have the colours in use (but which are not filled with that colour as in your image).
In the lower half the rectangles are present (without fill) and colours can be changed. However, the colours are not applied to the model(s), and there is no Apply button to execute the changes you make.
Maybe I'm doing something wrong? Maybe the plug-in is a bit too much in beta stage?
I'm using a computer with Windows 10 64 bits and SH3D v5.1 64 bits.
New Zealand
Joined: Dec 28, 2014
Post Count: 95
Status:
Offline
Re: Change color plugin
I've found one bug. The plugin can't change a color if it is the color of a material and it's the default material color. If you have already changed the material's color to something other than the default, the plugin will work.
I have a fix for this bug and will release it in the next few hours once I have tested it a bit more. The fix is to compare colors without the alpha component (only comparing RGB values). I should probably copy the alpha (transparency) from the from as well.
I should add I'm using OpenSuse Linux 13.1 64 bit and SH3D v5.1 64 bit with the JRE it was shipped with.
I'm using Java JDK 1.7 for development but the compiler is set to 1.6 compliance.
Netherlands
Joined: Sep 26, 2009
Post Count: 4000
Status:
Online
Re: Change color plugin
Michael,
1 - Oops. Indeed, there is a very large button at the bottom of the window. I hadn't recognized it as such. It works. 2 - Double-clicking doesn't change the swatches from outline to filled. 3 - Original colours can't be changed, just as you said.
Very nice plug-in. Thanks!
Hans
----------------------------------------
Hans
New Zealand
Joined: Dec 28, 2014
Post Count: 95
Status:
Offline
Re: Change color plugin
Hans, thanks for the quick feedback, most helpful.
I've uploaded a new version with two fixes:
The plugin now correct alters colors for items with materials where the material is set to its default color.
I've set the opacity of the Colors-in-use swatch buttons in an an item in an attempt to fix the lack off fill color in Windows 10.
Note that the version number changed on the jar, so you will need to removed the 0.1 jar and replace it with the 0.2 jar.
The fix for Windows 10 is a guess based on searching for the symptoms using Google (swing button color issues, as is usual for coding problems, I wound up at http://stackoverflow.com/ ). I don't have a Windows 10 system to test this on. It doesn't seem to cause any issues on my Linux system.
I've noticed that the color alpha values (transparency) seem to be ignored, I guess they're part of the model, not the color. I dropped alpha when making comparisons because the default colors didn't seem to have an alpha value. I was going to attempt to change/preserve alpha values, but this didn't seem to do anything useful - my glass doors stayed transparent and my opaque items stayed opaque no mater what the color alpha was set to.
Netherlands
Joined: Sep 26, 2009
Post Count: 4000
Status:
Online
Re: Change color plugin
Michael,
Thanks for the update. 1 - The original colour is now changed. Good work! 2 - It seems the box that lists where the selected colour is used has disappeared. Or maybe I'm using it the wrong way? Selectively blind? 3 - The swatches are still outlines without fill.
Hans
----------------------------------------
Hans
New Zealand
Joined: Dec 28, 2014
Post Count: 95
Status:
Offline
Re: Change color plugin
Hans,
The box that lists where colors are used is a tooltip. The tooltips only pop up if you hover the mouse over a swatch. This was the quickest way I could think to implement this feature. Perhaps it would be good to also display a permanent panel to the right listing where the colors are used for the currently selected swatch (if any).
Hopefully hovering works for you, otherwise it could be that my opacity change is producing some new Windows 10 issue.
It seems Swing button fill is very platform dependent in behaviour. I will look into a more sure file way to create a swatch/button filled with color. Perhaps by embedding an rectangular colored icon. I will look into this when I have some spare time over the next few days.
Thanks again for the feedback.
Michael,
Thanks for the update. 1 - The original colour is now changed. Good work! 2 - It seems the box that lists where the selected colour is used has disappeared. Or maybe I'm using it the wrong way? Selectively blind? 3 - The swatches are still outlines without fill.