It is possible to change the L & F in JavxFX using a button? - javafx-2

I have several designs for my program. I want to load a new design from CSS. I have Java JDK 8 (Update 5) installed.
scene.getStylesheets ( ).add (this.getClass ( ).getResource("lf.css").toExternalForm ( ) );//???
But this causes problems. I need to unload the old css which is assigned in the fxml file:
<stylesheets>
<URL value="#lfdefault.css" />
</stylesheets>
In the end I would like to switch between four designs: caspian, modena and my ones (lfdefault and lf)
Hope you can help me.

Related

Visualization of 3-dimensional grid from X_Y_Z(seperate datasets) on Paraview without using xdmf

Reading netcdf files with Paraview using xdmf
I used to parse netcdf files with an xdmf script in order to create 3DSMesh on paraview. On top of it, I was adding scalar or vector fields. (So 3DSMesh provides physical coordinates).
I never though if it is best way to do that actually. It works, so I was OK. Please let me know if there is more convenient way.
I am able to create a 3-dimensional grid with the following script.
<?xml version="1.0" ?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
<Xdmf xmlns:xi="http://www.w3.org/2001/XInclude" Version="2.0">
<Domain>
<Grid Name="gridxyz">
<Topology TopologyType="3DSMesh" NumberOfElements="0032 0032 0063">
</Topology>
<!-- Read Coordinates -->
<Geometry GeometryType="X_Y_Z">
<DataItem Name="X" Format="HDF" NumberType="Float" Precision="8" Dimensions="0032 0032 0063">
grid_x.nc:/gridx
</DataItem>
<DataItem Name="Y" Format="HDF" NumberType="Float" Precision="8" Dimensions="0032 0032 0063">
grid_y.nc:/gridy
</DataItem>
<DataItem Name="Z" Format="HDF" NumberType="Float" Precision="8" Dimensions="0032 0032 0063">
grid_z.nc:/gridz
</DataItem>
</Geometry>
<!-- Read Scalar -->
<!-- Here I have bunch of scalars stored in different netcdf files -->
</Grid>
</Domain>
</Xdmf>
Pros
xdmf scripts are great when someone needs repetitive tasks.
Cons
this script(s) needs to be generated somehow, or typed by hand. And required to be updated, when the dimensions or variable names are changed
if I want to read another scalar, I need to add a line
grid can be uniform in 2 directions and not uniform on the third one, no need to create 3D grid files, but geometry type dx_dy_dz is not enough to achieve that.
What I am looking for
Recently I realize, I can open netcdf files with paraview just by clicking open(Paraview4.3). So, I do not need these xdmf scripts anymore (few years ago I was not able to open netcdf files on Paraview).
How can I create 3DSMesh via Paraview GUI. Is that possible? Or is there any other simple/faster way (instead of writing a python script) ?
Is there any way read 1D coordinates and create 3D geometry using them ?
That's how I manage to do that. Certainly it's not the fastest way, but it works for me.
When you open a NetCDF file, paraview asks you to choose a reader, I always use NetCDF files generic and CF conventions .
After that, before hitting "Apply" button you have to select the appropriate "Dimensions" in the dropdown menu.
Your data now must be displayed as a UniformGrid, with your data(X,Y,Z) as scalars fields so you must transform to a grid to be more specific a StructuredGrid. In order to do that, apply the "ImageDataToPointSet" filter.
After that, apply a "Calculator" filter check "Coordinate Results" field and do the following:
If your data appears as X, Y , Z colummns put in the calculator field the expression
(X * iHat) + (Y * jHat) + (Z * kHat)
if your data appears with other names, substitute x, y, z with those names
The expression means that x is in the direction of the î vector, y is in the direction of the j vector and so on
Hope it helped!

How to use Modern UI Icons in AppBarButton

I'm developing a Windows 8.1 Store App. I have a CommandBar control with a couple of AppBarButtons inside. Using the standard icons is easy, I just set the icon property to the appropriate string like so :
<AppBarButton Icon="Download" Label="Download Files"/>
I'd like to use a couple of custom icons from the very nice free collection Modern UI Icons. Ideally, I'd like to be able to set the icon property in much the same way :
<AppBarButton Icon="transit.distance.to" Label="Distance to destination"/>
This would refer to this icon : PNG / XAML
Is this possible ?
If not, what are the alternatives ?
Tim Heuer proposes using a font file, although at present the font files available here only cover a sub-set of the icons, and also this code is quite unreadable :
<FontIcon FontFamily="ms-appx:///modernuiicons.ttf#Modern-UI-Icons---Social" Margin="0,2,0,0" Glyph="" FontSize="37.333" />
Would you believe that shows a twitter icon?!
Tim Heuer also proposes using vector data, and one of the commenters explains how the vector data can be rolled into a style. I could do that, but then I would have to copy and paste the path data for each icon I want to include ?
Should I be using the PNG files, as explained in this question ? That looks pretty messy as well.
What a nightmare!
I'm not sure what the nightmare part is -- you want to use a custom icon that isn't present in the 200+ supplied defaults. You have options:
Use SymbolIcon and supply your own font. You note that you don't like that the code feels unreadable. Unicode ranges are universally used for symbol fonts and I agree that Unicode isn't human-readable, but a simple code comment would help ;-) Fonts give you the most ease and flexibility because they are also vectors.
PathIcon. You convert your image into vector geometries we can render. This would be the second best, but also requires a bit fine tuning of the vectors to get right. For people not familiar with working with geometries this can be annoying at first. Blend and Inkscape are helpful tools here.
BitmapIcon. This would allow you to use your PNG, however you now must supply multiple of them for different scales and states. This is my least favorite option as it requires most work, but for some may be the simplest. Now your problem you will hit is there is an issue with BitmapIcon for non-rectangular shapes (which looks like your icon is). This won't have the fidelity you seek due to a bug in rasterizing.
Contact metroicon author and see if he can put it into the font file so you can use option #1 :-)
Maybe this is what you're looking for:
<AppBarButton Label="Transit">
<AppBarButton.Icon>
<PathIcon Data="F1 M 3.912,17.38C 4.89067,17.38 5.688,18.2653 5.688,19.3586C 5.688,20.448 4.89067,21.3333 3.912,21.3333C 2.92667,21.3333 2.136,20.448 2.136,19.3586C 2.136,18.2653 2.92667,17.38 3.912,17.38 Z M 16,17.38C 16.984,17.38 17.776,18.2653 17.776,19.3586C 17.776,20.448 16.984,21.3333 16,21.3333C 15.016,21.3333 14.224,20.448 14.224,19.3586C 14.224,18.2653 15.016,17.38 16,17.38 Z M 21.3333,18.9626L 18.464,18.9626C 18.292,17.62 17.2547,16.5933 16,16.5933C 14.7453,16.5933 13.708,17.62 13.536,18.9626L 6.37467,18.9626C 6.20267,17.62 5.16667,16.5933 3.912,16.5933C 2.656,16.5933 1.62,17.62 1.448,18.9626L 0,18.9626L 0,10.2706C 0,9.396 0.636,8.69196 1.42133,8.69196L 19.5573,8.69196C 20.3387,8.69196 20.9787,9.396 20.9787,10.2706M 20.4427,10.2706L 19.1973,10.2706L 19.1973,15.8013L 20.62,15.8013M 17.776,13.432L 17.776,10.2706L 14.224,10.2706L 14.224,13.432M 13.5107,10.2706L 9.95333,10.2706L 9.95333,13.432L 13.5107,13.432M 9.24533,10.2706L 5.688,10.2706L 5.688,13.432L 9.24533,13.432M 4.97867,10.2706L 1.42133,10.2706L 1.42133,13.432L 4.97867,13.432M 14.5787,2.36932L 12.4427,0L 15.2867,0L 17.776,2.45862L 17.776,0L 19.1973,0L 19.1973,6.31732L 17.776,6.31732L 17.776,3.85864L 15.2867,6.31732L 12.4427,6.31732L 14.5787,3.948L 7.73467,3.948C 7.41733,5.31195 6.30267,6.31732 4.97867,6.31732C 3.40667,6.31732 2.136,4.90533 2.136,3.16132C 2.136,1.41064 3.40667,0 4.97867,0C 6.30267,0 7.41733,1.00531 7.73467,2.36932L 14.5787,2.36932 Z " HorizontalAlignment="Center" VerticalAlignment="Center"/>
</AppBarButton.Icon>
</AppBarButton>
Hope this helps!

XSL-FO conditional-page-master-reference keeps rendering 2+ pages using last page master

I have this layout-master-set definition:
<fo:layout-master-set>
<fo:simple-page-master master-name="all-pages" page-width="210mm" page-height="297mm" margin="20mm 20mm 0mm 20mm" >
<fo:region-body margin-top="25mm" margin-bottom="35mm" />
<fo:region-before extent="20mm" />
<fo:region-after extent="30mm" />
</fo:simple-page-master>
<fo:simple-page-master master-name="last-page" page-width="210mm" page-height="297mm" margin="20mm 20mm 0mm 20mm" >
<fo:region-body margin-top="25mm" margin-bottom="115mm" />
<fo:region-before extent="20mm" />
<fo:region-after extent="110mm" region-name="region-last-page" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="pages">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="last" master-reference="last-page"/>
<fo:conditional-page-master-reference page-position="any" master-reference="all-pages"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
As you can see, I want the last page to render a much bigger region-after, but instead I get the large region-after on all pages after the first, and the all-pages master is only used for the first page?
Does anyone see a problem with that configuration?
PS: using Fop 0.20.5
The configuration looks okay. But you should give all regions a name to remove ambiguity.
The fo:page-sequence-master is correctly defined, the problem is the FOP version you are using: 0.20.5 dates back to 2003 (!) and had several bugs and missing features.
At the moment the latest released version is 1.1, which creates the pages as expected.
Disclosure: I am a FOP developer (although I haven't been very active for years).

Movable Type: How do I generate random number with certain range?

I am not sure this is even possible with just using Movable Type tags but, how do I display random number with in certain range?
For example I have 10 images named 1~10 and every time I rebuild I want to display a random image from that range.
I use MT5.
Thank you in advance!
You can try my version of the MTCollate plugin with random filter. Original documentation is here: http://www.nonplus.net/software/mt/MTCollate.htm - difference is that it adds a sort="~" or "random" filter, but you'll probably be fine using the MTShuffleList block.
I think if you want to show one image and images count is ten, maybe you can show this cord.
<MTSetVarBlock name="imageID"><MTDate format="%S"></MTSetVarBlock>
<MTSetVarBlock name="imageID"><mt:GetVar name="imageID" op="div" value="6" sprintf="%d"></MTSetVarBlock>
<MTSetVar name="imageID" op="++">
src="/images/hoge<mt:GetVar name='imageID'>.jpg"
You can actually do this with PHP if you're so inclined. Movable Type supports the ability to publish to PHP and you can just put the content you want to be randomized inside of a PHP block. All you need to do is change the published archive file type to "php" in the blog settings. Here is the MTML sample:
<?php
$images = array();
<mt:Asset id="1">
$images[] = '<mt:AssetURL/>';
</mt:Asset>
<mt:Asset id="2">
$images[] = '<mt:AssetURL/>';
</mt:Asset>
<mt:Asset id="3">
$images[] = '<mt:AssetURL/>';
</mt:Asset>
$selected_asset = array_rand($images);
?>
Just repeat the Asset tag for each of the specific assets you want. That will generate ten operations to push each image asset's URL into the array. Alternatively, if you want to expose the last ten, you'd just to <mt:Assets lastn="10">

Parsing Tableau xml does not preserve original file

I try to work programmatically on Tableau desktop file (which are just xml file in spite of their .twb extension). I have many problem with lxml which doesn't preserve original content. To facilitate the explanation, imagine you have a test.xml file which contain the following text:
<column caption='Choix Découpage' name='[Aujourd&apos;Hui Parameter (copy 2)]'>
<member name='Nb d&apos;annulations' default-format='n#,##0.00" annulations";-#,##0.00" annulations"' />
<run>
:</run>
<calculation formula='iif([FAC_TYPE] = &apos;Avoir&apos; , [Calculation_1378101492427309057], null)' />
<alias key='"Billetterie Ferroviaire"' value='Train ticketing' />
</column>
Now let's parse it:
tree = etree.parse('test.xml')
root = tree.getroot()
print(etree.tostring(root,pretty_print=True,).decode("utf-8"))
When you run the code we can notice:
' becomes "
é becomes é Edit: resolved for this part
&apos; becomes '
How could i preserve the original ? (It would help me a lot when i try to check the diff with git in spite of showing all the useless change that are operated automatically)
Edit: I notice an other problem, when i run the folowing code:
[node.attrib['key'] for node in root.xpath("//alias")]
I got the result: ['"Billetterie Ferroviaire"'] and I am now unable to query with xpath if i am looking for the node whose attribute "key" is the original "Billetterie Ferroviaire" (root.xpath('//[#key="Billetterie Ferroviaire"]) doesn't work)

Resources