JavaFx 2 - Combobox rendering color choice - colors

I have a
ComboBox cmb = new ComboBox();
I would like to display a list of colors, if possible ordered from brighter to darkest, but I haven't find any working example
How to render a combobox in order to display a list of color?
Any help really appreciated
Thanks
Edit: question closed, solved by myself, thanks all.

To calculate brightness (for sorting) use the luminosity coefficients:
var color = Color.FromArgb(240,230,210); // use whatever color you're wanting to rank
var luminosity = 0.299*color.R + 0.587*color.G+ 0.114*color.B;
As for rendering it into a combobox, I know it can't be done with the standard Window Forms Combobox. But, it wouldn't be too hard to make your own ComboBox control. I would guess you could do it pretty readily in WPF. As for the approach to take - you'll need to generate a graphics object and draw rectangles of the color onto the control - or draw to an in-memory bitmap and set a picturebox's image property to that image. Good luck!

Related

How to color specific vtkCells?

I have a 3D model loaded into a vtkActor and I need to be able to color specific vtkCells of this actor after selecting (clicking on those vtkCells). I know how to retrieve the selected cells from the vtkUnstructuredGrid but have no idea of how to set color to them. I've read a bit about vtkLookUpTables and think that might be it but I don't understand how it works, or if it really is what I need.
Thanks.
You can use vtkExtractCells to fetch all special cells and form a vtkDataObject, then create vtkDataSetMapper and vtkActor objects to color and shot it.

Select polygons of an object by color in Blender

I have a scan of a body and I want to select it's t-shirt only but all the polygons belong to the same object. Is there a way to select polygons by color and then delete those unselected, so I can have an obj containing only the t-shirt?
edit: I want something similar than you do with gimp or photoshop with 2d images, selecting pixels by colors.
A 3D scan would most likely use a photo that is uv mapped onto a mesh object. In this setup there is no easy way to select part of the mesh based on the material colour. In fact each polygon in the mesh maps to an area of an image that can contain any number of colours.
There are several selection tools available, I expect using box select B and/or circle select C (sometimes called paint select) and then using X to delete the vertices/faces you don't want would be the approach to use.
It is possible to use multiple materials on a model with each face being assigned a different material, if this is the case you have an option to select or deselect the faces using a material in the material properties.

Custom drawing MT.D borders

I've been playing around with MT.D a bit and love the simplicity of it all.
I have now been working on a completely owner drawn cell using a UIView to do all the drawing and an Element that allows me to use it with MT.D.
Now the only thing I seem to be missing is the ability to control how borders are drawn (or not drawn). If I set the mode to Grouped then I get the indented and rounded borders and Plain I get the simple horizontal border.
But lets say I want to use an image or thicker border for my borders, how do I go about customising this?

displaying multi line rich text box in poi excel

I am using poi3.5 api to create excel report. Now I need a mutiline rich text box on excel sheet. I am not able to find the exact solution.Please guide me on this, if anyone has solution.
Thanks in advance.
Take a look at: http://poi.apache.org/spreadsheet/how-to.html
you may find the answers there.
Create a textbox with anchor and you are good to go. Following code will create textbox with 20px text, no border.
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFTextbox textbox1 = patriarch.createTextbox(new HSSFClientAnchor(0,0,1023,255,(short)4,2,(short)6,3));;
HSSFRichTextString rt1 = new HSSFRichTextString("This is title");
HSSFFont font = workbook.createFont();
font.setFontHeight((short)400);
rt1.applyFont(font);
textbox1.setString(rt1);
textbox1.setLineStyle(HSSFShape.LINESTYLE_NONE);
One thing to note is that coordinates in client anchor has limits and those limits are 1023 and 255. If you are not changing coordinates, textbox will reside between row1,row2 and col1,col2.

User control that will internally calculate how much text to show

I want to develop an user control using Windows.Forms.Label that will internally calculate how much text to show based on the current height and length of the control.
Does anybody have the solution for it.
Thanks in advance.
The simple solution would be to put a Label on your UserControl, and set it to Dock to fill. Set the label's Autosize to false.
If you want to go a step further and an ellipsis to your label, you'll need to look into Graphics.MeasureString.

Resources