Javafx Scene Builder Linear Gradient is what - javafx-8

is there any one knows what on earth is the linear gradient?
How Can I use the right panel, especially the four scroll bar, to adjust the fill of the triangle on the left to make the triangle upper half white but down half black?
Is there any document to help train people how to use this? I am really sorry I can not find it.
Thanks in advance!

General info on linear gradients
The linear-gradient documentation is at:
JavaFX CSS reference.
It is a w3c color stop form.
javadoc of how linear gradients work in JavaFX.
Because the linear gradient in JavaFX CSS is the same syntax as w3c CSS, any tutorial on CSS linear gradients returned by google will probably apply to JavaFX CSS.
Feedback email address for JavaFX documentation is: javasedocs_us#oracle.com
Linear Gradients and SceneBuilder
Scene Builder uses FXML to represent linear gradients. It can also use render linear gradients from CSS, though the gradient editor in SceneBuilder works to edit the FXML representation of gradients and not the CSS representation.
Here is a result of loading the following FXML file into SceneBuilder:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import java.lang.*?>
<?import javafx.scene.shape.*?>
<Polygon xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<points>
<Double fx:value="-50.0" />
<Double fx:value="40.0" />
<Double fx:value="50.0" />
<Double fx:value="40.0" />
<Double fx:value="0.0" />
<Double fx:value="-60.0" />
</points>
<fill>
<LinearGradient startX="0.5" startY="0" endX="0.5" endY="1">
<stops>
<Stop color="WHITE" />
<Stop color="BLACK" offset="1.0" />
</stops>
</LinearGradient>
</fill>
</Polygon>
Scroll Bar Settings
The scroll bar settings are marking the proportional co-ordinates of the start and end properties of the linear gradient. These co-ordinates from a directional vector (line) along which colors in the linear gradient change according to the defined stops. The bars work as follows:
left bar: startY
top bar: startX
right bar: endY
bottom bar: endX
For the above fill, it means start at the top center and travel to the bottom center, varying the color from white to black as you go, so it's a straight top to bottom vertical transition.
Discrete Gradients
If you didn't want a smooth gradient, but instead wanted an abrupt one, then add more stops, for example:
<fill>
<LinearGradient endX="0.5" endY="1" startX="0.5" startY="0">
<stops>
<Stop color="WHITE" />
<Stop color="WHITE" offset="0.5"/>
<Stop color="BLACK" offset="0.5" />
<Stop color="BLACK" offset="1.0" />
</stops>
</LinearGradient>
</fill>

Related

Set Button half the window size in .NET Maui

I'd like to set the size of a button in .NET Maui to take up half of the window size, or some other fraction. I want to have some big buttons, and I can not lie. If I was doing this in html/css, I would set the width to 50%. In .NET Maui, I would think that I would set the widthrequest to 50%. There doesn't seem to be a way to do that because .WidthRequest only takes a double. So, I thought I would get the width of the current window. I try
var width = DeviceDisplay.Current.MainDisplayInfo.Width;
That only seems to return a zero when I try this in windows in debug mode. Googling doesn't seem to be much help. Is there a way to set a button to a width?
TIA
Maui has proportional sizing for grid row and columns. You don't explain where you want your button but you can use multiples of * proportional.
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/layouts/grid?view=net-maui-7.0
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="2*" />
<RowDefinition Height="*" />
If you put a button in that middle row then it will be half the width of the grid and central.
Similarly, define 3 columns with * widths and you have a central cell half the width and half the height of the grid.
I test the code and it work well:
<Button                
x:Name="btn"                
Text="btn"/>
double width= DeviceDisplay.Current.MainDisplayInfo.Width/4;    
public MainPage()
{        
InitializeComponent();        
btn.WidthRequest=width; 
}

Problem importing Bezier curve coordinates in Matlab from .svg

I'm trying to draw Bezier curves from an .svg file using Matlab.
I've opened the .svg in a text editor. One of the lines I'm trying to draw is this one: <path fill="none" stroke="#000000" stroke-miterlimit="10" d="M117.125,310.375c0-77.729,80.738-140.625,180.515-140.625"/>
If I understand things correctly, the start point is (x , y) (117.125 , 310.375), the first control point is (0 , -77.729), the second control point is (80.738 , -140.625) and the end point is (180.515 , -140.625). However this doesn't seem to be correct as the output I get is far from the actual curve.
How it looks:
How it's supposed to look:
The start and end points are all right, but the control points seem wrong... Matlab draws the correct points, I've checked them (the axis may look a bit weird but it's correct)
I'm using the code from Mathworks (https://blogs.mathworks.com/graphics/2014/10/13/bezier-curves/). It needs the start point pt1, the control points pt2 and pt3 and the end point pt4.
The code works, the problem seems to lie with the coordinates of the points.
I've tried entering the coordinates above in an online .svg editor (it only supports integers so every coordinate is positive here, the control points shouldn't 'pull' the curve that much but the output is the same as the one obtained with MatLab): http://www.useragentman.com/tests/textpath/bezier-curve-construction-set.html#path=M%20297%2C%20169%20C%2058%2C%200%2C%2098%2C%2077%2C%2098%2C%20192&imageURL=http://www.useragentman.com/tests/textpath/images/grid.png
Here is the entire file, created with Illustrator CS6:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="595.28px" height="841.89px" viewBox="0 0 595.28 841.89" enable-background="new 0 0 595.28 841.89" xml:space="preserve">
<line fill="none" stroke="#000000" stroke-miterlimit="10" x1="116.083" y1="608.292" x2="117.125" y2="310.375"/>
<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M117.125,310.375c0-77.729,80.738-140.625,180.515-140.625"/>
<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M297.64,169.75c58.959,0,98.652,77.535,98.652,192.708"/>
<line fill="none" stroke="#000000" stroke-miterlimit="10" x1="396.292" y1="362.458" x2="387.958" y2="653.083"/>
</svg>
I'm really hoping someone can help me with this. I'm new to .svg
Thanks to #Paul LeBeau for the link. It turns out ".svg"s are case sensitive and that a C is not a c... You learn things every day. The website I looked at for help before I posted didn't mention this.
2, 3 and 4 are all relative to 1 in this case. I added a few lines of code to my script so that 2 = 1 + 2relative, 3 = 1 + 3relative and 4 = 1 + 4relative, and it works!
Now I can finally clean up my code to do both the lines and the paths at the same time and draw my racing line.
NB: I know the points are reversed for the purple curve. This is due to Illustrator not being able to do a curve "the other way round" without switching the points...

SVG Rendering Error in Batik/Eclipse

I have been using Batik with Eclipse for a year, and came across a rendering error I cannot seem to shake. I have reduced it to a minimal set and placed the image on flickr:https://www.flickr.com/photos/dattatreya/15019722962/. I expect to see a solid wide red line crossing a solid yellow wide line. You can see the artifact (error) in the thin yellow line that crosses the red band (along the top edge of the yellow band). I see similar errors in many images I draw.
The SVG code generated by Batik is below. Interestingly, that code was incorrectly rendered by both Safari and Chrome (but not by IE) some time ago, but right now, all browsers seem to work correctly. Only Batik does not.
This could be a Batik bug; if so, I hope they fix it soon!
SVG code generated by Batik for the image:
========================================================
<svg stroke-dasharray="none" shape-rendering="auto"
xmlns="http://www.w3.org/2000/svg" font-family="&apos;Dialog&apos;"
text-rendering="auto" fill-opacity="1" contentScriptType="text/ecmascript"
color-interpolation="auto" color-rendering="auto"
preserveAspectRatio="xMidYMid meet" font-size="12" fill="black"
xmlns:xlink="http://www.w3.org/1999/xlink" stroke="black"
image-rendering="auto" stroke-miterlimit="10" zoomAndPan="magnify"
version="1.0" stroke-linecap="square" stroke-linejoin="miter"
contentStyleType="text/css" font-style="normal" stroke-width="1"
stroke-dashoffset="0" font-weight="normal" stroke-opacity="1">
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<g fill="red" stroke="red">
<path d="M-106.066 106.066 L893.934 1106.066 L1000 1212.1321 L1212.1321 1000 L1106.066 893.934 L106.066 -106.066 L0 -212.132 L-212.132 0 L-106.066 106.066 Z"
stroke="none"/>
</g>
</g>
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<g fill="yellow" stroke="yellow">
<path d="M106.066 1106.066 L1106.066 106.066 L1212.1321 0 L1000 -212.132 L893.934 -106.066 L-106.066 893.934 L-212.132 1000 L0 1212.1321 L106.066 1106.066 Z"
stroke="none"/>
</g>
</g>
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<defs id="defs1">
<clipPath clipPathUnits="userSpaceOnUse" id="clipPath1">
<path d="M500 287.868 L287.868 500 L287.868 500 L500 712.1321 L500 712.1321 L712.1321 500 L500 287.868 Z"/>
</clipPath>
</defs>
<g fill="red" stroke="red">
<path d="M-106.066 106.066 L893.934 1106.066 L1000 1212.1321 L1212.1321 1000 L1106.066 893.934 L106.066 -106.066 L0 -212.132 L-212.132 0 L-106.066 106.066 Z"
clip-path="url(#clipPath1)" stroke="none"/>
</g>
</g>
</svg>
=================================================================
This is not a Batik bug. It is a "problem" pretty much all graphics libraries will have whether they are SVG renderers or otherwise. It is still visible when I render this in Chrome - it's just less noticeable.
What your SVG does is:
draw a red stripe on the bottom.
then draw a yellow stripe across it
finally it draws a red square to cover the intersection of the two stripes to make it look like the red square is on top.
The reason you are seeing a barely visible yellow line is due to antialiasing. The renderer is drawing partially yellow pixels at the edge of the yellow strip to make the edge of the stripe look more smooth. When you draw the red square on top, some of the yellow pixels are going to remain visible and/or the partially red pixels being drawn on top are letting the yellow show through. The result is a yellowish strip of pixels at the edge.
I guess the question is "why are you not just drawing the red stripe on top of the yellow?" Doing that would fix your problem.

avoid inertia scrollviewer for negative offset Windows 8 App

i would like to know how can i remove the inertia effect of the scrollviewer content when the offset is negative.
In reality the offset is 0.0, but the content moves in negative like a spring.
This is a video that show the effect that i'd like to remove:
http://www.youtube.com/watch?v=3kXce-VK--4&feature=youtu.be
The code is very simple:
<ScrollViewer x:Name="CalendarScrollViewer"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Grid.Column="2" Grid.Row="1"
ZoomMode="Disabled"
HorizontalAlignment="Right"
LayoutUpdated="CalendarScrollViewer_LayoutUpdated" >
<Grid>
...
</Grid>
</ScrollViewer>
Thanks.
Have you tried to set ScrollViewer.IsScrollInertiaEnabled="False" ?

Need GWT SplitLayoutPanel to have max size, dragging is very jumpy

Is there a good way to set the max size for a child of a SplitLayoutPanel? Right now I override its onResize method and call a JSNI function to set the right or width style properties of the parent div of the center panel's div, the right panel's div and the splitter panel's div, if the right/east panel is over 400px wide.
I noticed the splitter and the right panel's size don't even follow the mouse cursor and oscillate wildly between about 4/5 and 2/5 as wide as they should be based on where the mouse pointer currently is.
I have debug in eclipse and tried running it without eclipse and it's the same. I am calling super.onResize(), as well.
If I am understanding your problem correctly, you want to have a SplitLayoutPanel to occupy maximum space of the parent element. For this you can use the percentage property of width like,
SplitLayoutPanel slp = new SplitLayoutPanel();
slp.setWidth( "100%" );
And in the next step you want to add child element into the SplitLayoutPanel and it should occupy maximum area. Then set each child width to 100%
Widget child = // Instantiate any type of widget
child.setWidth( "100%" );
slp.add // Use proper add method and add the child to SplitLayoutPanel
I did not understand what did you mean by dragging is very jumpy. Did you mean Splitter size is too small that you cannot find the splitter. If thas the case, you can increase the splitter size by passing it in the constructor like
int splitter_size_in_pixels = 5;
SplitLayoutPanel slp = new SplitLayoutPanel( splitter_size_in_pixels );
I noticed the splitter and the right panel's size don't even follow the mouse cursor and oscillate wildly between about 4/5 and 2/5 as wide as they should be based on where the mouse pointer currently is.
I too saw jerky movement when dragging the splitter. My south pane contained a vertical panel which contained a label and a table. The fix was to set the VerticalPanel height="100%" . I have appended the uibinder code.
HTH
Julian
<g:SplitLayoutPanel styleName="gwt-SplitLayoutPanelTtc" ui:field="splitLayoutPanel">
<g:north size="40">
...
</g:north>
<g:west size="200">
...
</g:west>
<g:south size="500">
<g:VerticalPanel height="100%" width="100%">
<g:Label ui:field="tableTitle" styleName="tableTitle"></g:Label>
<g:Grid ui:field="table" styleName="gwt-Grid"></g:Grid>
</g:VerticalPanel>
</g:south>
<g:center>
...
</g:center>
</g:SplitLayoutPanel>
You can fix the jerky/jumpy movements by adding intermediate ResizeLayoutPanels.
MyComposite.ui.xml :
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:my="urn:import:my.custom.package.client">
<g:SplitLayoutPanel ui:field="splitLayoutPanel">
<g:west size="250">
<g:ResizeLayoutPanel ui:field="leftMenuOuterPanel">
<my:MenuWidget ui:field="menuWidget" />
</g:ResizeLayoutPanel>
</g:west>
<g:center>
<g:ResizeLayoutPanel ui:field="centerOuterPanel">
<my:AwesomeWidget ui:field="centerWidget" />
</g:ResizeLayoutPanel>
</g:center>
</g:SplitLayoutPanel>
</ui:UiBinder>
thanks to OlivierH answer