JavaFX get PieChart Color - javafx

Is there a way to get the default Pie Chart color in JavaFX? I've been looking for solutions but I couldn't get any. I have seen a way to set the color of the Pie Chart, and then work my way to get the Color value. However, I want to just use the default color of the PieChart provided by JavaFX, and just return it so I could use it for something else. Is there a way to do it?

With JavaFX 8+ the default CSS theme called Modena and you can find a lot of information in this Github gist. All the charts are using the same color palette which is :
CHART_COLOR_1: #f3622d;
CHART_COLOR_2: #fba71b;
CHART_COLOR_3: #57b757;
CHART_COLOR_4: #41a9c9;
CHART_COLOR_5: #4258c9;
CHART_COLOR_6: #9a42c8;
CHART_COLOR_7: #c84164;
CHART_COLOR_8: #888888;
keep in mind that although the link above is a good way to find some properties is always recommended to read the JavaFX CSS Reference Guide

Related

How do I identify PrimeFaces tooltip backgrouond color?

I'm using PrimeFaces6.1 and my primefaces.THEME is afternoon. I would like to make my panel overlay look the same as the tooltips. Therefore, I need to figure out what the tooltip background color is. It's obvious the font color is white.
I have found information on how to override the tooltip colors and I guess I could do that, but I really like the theme color. Anyone have an idea on this?
You could find out the back-ground color for p:tooltip used in Primefaces 6.1 in components.css
Path: primefaces-6.1.jar\META-INF\resources\primefaces
open the components.css
and search ui-tooltip-text{padding:3px 10px;background-color:#4c4c4c;color:#fff}

wxpython button background color to default

I am looking to change the background color of a button in my GUI application to default.After searching online, i saw that
button1.SetBackgroundColour(wx.NullColor) does not seem to work. I am using python 2.7.
Is there any other way I could set it to default color with out using system colors
A little late, but maybe someone else has the same problem.
Did you try
button1.SetBackgroundColour(wx.NullColour)
So, write "Colour" instead of "Color", the non-American writing. This worked for me.
If wx.NullColour doesn't work, a solution is to decode the RGB code for the colour you seek and apply it to your background.
E.g. the background color on my wx GUI is the light grey from Windows, its RGB code is R=240, G=240, B=240 (you can measure this using Paint for instance).
Then this should work:
button1.SetBackgroundColour(wx.Colour(240, 240, 240))
Of course if you want your GUI to be portable on other systems this isn't the best option since this light grey is only the default colour in Windows.
With Python 2.7.17 and wxPython 3.0.2.0 the following seems to work:
button1.SetBackgroundColour('')
I think that the solutions do not work because wxPython works with a style system. I was able to change foreground & background colours with the SetStyle method.
I was styling a wx.TextCtrl where I needed to highlight the text I search for.
First, I stored the existing colours to variables.
bc = self.te.GetBackgroundColour()
fc = self.te.GetForegroundColour()
self.bcol = wx.Colour(bc[0], bc[1], bc[2], bc[3])
self.fcol = wx.Colour(fc[0], fc[1], fc[2], fc[3])
Change the colours with SetStyle
self.te.SetStyle(x, y, wx.TextAttr(wx.BLACK, wx.LIGHT_GREY))
And reset it back to the original colours:
self.te.SetStyle(0, -1, wx.TextAttr(self.fcol, self.bcol))

Hide axis in javafx 2.2 ScatterChart

Does anybody know, if it is possible to hide the axis in a JavaFX ScatterChart object? Or can anybody think of a simple workaround? I didn't find anything related to this issue in the documentation of the ScatterChart object.
Unfortunately, they are kind of irritating in all kinds of graphs where the axis's values are not, per se, informative (e.g. distance configurations).
Note: the most simple solution to set the visibility attribute of the scales to false unfortunately did not yield the result I was longing for (actually it showed no effect at all).
When you say "Hide the Axis", I'm assuming you mean hide all the tick marks and tick labels. Please let me know if you mean different.
The first step would be to hide the tick labels - this is pretty straight forward:
xAxis.setTickLabelsVisible(false);
yAxis.setTickLabelsVisible(false);
The second step is hiding the tick marks and all the neat graphics stuff that goes along with the tick marks (like the background colors). The best way I found for doing this is through the CSS. So you'll need to create a CSS file (I created one called test.css and placed it in my project's base folder) and load it up. Loading it can be done like this:
sc.getStylesheets().add("test.css");
(where sc is the ScatterChart object)
This is the CSS code I used to remove all the visuals associated with tick marks:
.axis-tick-mark,
.axis-minor-tick-mark,
.chart-vertical-grid-lines,
.chart-horizontal-grid-lines,
.chart-vertical-zero-line,
.chart-horizontal-zero-line {
-fx-stroke: transparent;
}
.chart-alternative-row-fill, .chart-alternative-column-fill{
-fx-fill: #f5f5f5;
}
Oracle puts out a great CSS reference for JavaFX - but in addition to that, I would recommend downloading the default CSS JavaFX uses. Looking at the default helps tons. You'll find instructions in that link under the "Default Style Sheet" section and also on the web with caspian.css for JavaFX 2.2 and modena.css for Java 8.

Qt: Creating style sheets from palette

I have a multi-platform Qt application with a custom palette that we have already set up to produce the look that we want. The palette was set on the top level widget and so this was inherited by all of the child widgets.
I then wanted to dynamically change the text colour of some QPushButtons. Searching around for the best way to do this, I began reading about Style Sheets which I didn't know that much about previously. These seemed to be a good option for changing the look of the push buttons and they did this. However, as soon as I set the text colour using a style sheet, the widget palette jumped to the default. It soon became obvious that style sheets are not compatible with custom palettes and it wasn't possible to mix the two. Most of the info that I found suggested that style sheets should be used rather than custom palettes because, among other things, style sheets offer guarantees across platforms and looks which palette fiddling does not.
From this, it seemed like a good idea to convert my custom palette into a style sheet and set it on the top level widget. Then I would easily be able to change just some parameters of certain child widgets using sub-style-sheets. The problem is that the palette contains many colours that we have set that do not appear to have a style sheet equivalent. Eg, Light, Midlight and Dark. Without being able to set these colours I wasn't able to produce the same look using style sheets as I previously had with the customised palette.
I would like to know if there is a simple way to convert a customised palette into a style sheet or whether there is some documentation to describe the equivalent style sheet settings for each palette colour. I have done searches on google, stackoverflow and the Qt reference docs but have come up short.
Thanks for any info.
ps. I solved my original problem by dynamically modifying the ButtonText attribute of the palette for the QPushButtons. But I would still rather use style sheets instead if possible without changing the main look of my application.
QColor.name() is the hex string for that color. If you want to convert to a stylesheet, just run through all the roles in your palette and print the .name() of that color. You can then find the corresponding stylesheet properties and pseudo states to set the hex colors to.
One thing you may find frustrating from switching from palettes to stylesheets is that CSS
does not allow the use of variables, so you'll have to use the hex string everywhere, rather than just defining named colors and using those.

QTableWidget colors, styles

I'm quite new to Qt and I'd appreciate the ability to customize a QTableWidget. I found a nice CSS-like interface using the stylesheets as shown here
http://doc.trolltech.com/4.3/stylesheet-examples.html#customizing-qtablewidget
However, I need to change some more specific styles (like grid color, items background color and so on).
I couldn't find any documentation describing the properties that might be changed via stylesheets.
Thanks for any help.
EDIT
Thanks, it helped a bit...however i still missed some other properties as grid thickness, but i "solved" it by inserting a row/column with 1px height/width to double the gridline :) And the QTableWidgetItem::setBackgroundColor() was also helpful.
However, I'm still facing some issues with QTableWidgetItem, the text keeps hiding if the column is too slim...only 3 dots appear. Dont you have an idea? I need the text to be visible, even if a bit clipped, but from the problem definition I cannot resize the column.
Isn't
http://doc.trolltech.com/4.3/stylesheet-reference.html#list-of-properties
the list you are looking for?

Resources