how can I remove the area around a TabPane in javaFx? - javafx-8

I have a simple problem. in the figure you can see, what I need. there is an area above and the left of tab, How can I eradicate that?
Sample Image:

You have to add following CSS for tab Pane..
.tab-pane:top *.tab-header-area {
-fx-background-insets: 0.0, 0.0 0.0 1.0 0.0;
-fx-padding: 0.416667em 0.166667em 0.0em 0.0em;
}

Related

Cocoa printing with Swift: "Any" printer setup has irregular margins/page size, any workaround?

I'm working on a graphics app for Mac OS in Swift and want to have a professional WYSIWYG layout features for printing.
I've isolated a weird behavior of the Cocoa printing system and just wondered if anyone knows of a setup step I'm missing or a workaround. The issue is that the "Any" printer has irregular, non-centered margins even when horizontal+vertical centering is requested. In particular, the left margin of my landscape letter-size docuemnt is 18pt and the right margin is 40pt - bigger than 1/2", which I feel is an unacceptable contraint, not to mention the annoyance of not being able to rely on the requested centering.
My app is NSDocument-based and I set printInfo margins to 0, centered fields to true, and orientation to .landscape.
self.printInfo.topMargin = 0.0
self.printInfo.rightMargin = 0.0
self.printInfo.leftMargin = 0.0
self.printInfo.bottomMargin = 0.0
self.printInfo.isHorizontallyCentered = true
self.printInfo.isVerticallyCentered = true
self.printInfo.orientation = .landscape
let newPrintOp = NSPrintOperation(view: self.printView!, printInfo: self.printInfo)
newPrintOp.showsPrintPanel = true
return newPrintOp
I am using Page Setup in this test. I have an EPSON printer that gives me the choice of regular or borderless printing, and with either option, selecting US Letter landscape, I get reasonable imageablePageBounds reported to draw into.
With the borderless page setup, I get
... imageablePageBounds: (0.0, 0.0, 792.0, 612.0)
and with 'regular' letter/landscape I get
... imageablePageBounds: (8.4000244140625, 8.399999618530273, 775.199951171875, 595.1999759674072)
The latter is setting to some driver minimum, but if you double the 8.4 point offsets and add to height and width you still get 792x612 == 11in x 8.5in
If instead I select "Any" printer in Page Setup and select US Letter, landscape, imageablePageBounds is reported (and enforced, even when printing to PDF) as:
... imageablePageBounds: (18.0, 18.0, 734.0, 576.0)
This gives 1/4" (18-pt) margins left, bottom, and top, but forces a 40-pt margin to the right (since width is only 734 - it should be 756 for a 10.5" drawing area). And indeed, if I try to draw an 10-inch image centered with 36pt margins, the right edge very annoyingly gets clipped unless I scale or shift it. It even gets clipped off with PDF output with this setup. Here's an image in the print panel that shows this clipping - the outer black line is the imageable view bounds given by the printing system, the blue line (right edge cut off) is a centered 10 x 7.5 image.
Does anyone know if there's a fix for this weird behavior? The ideal fix would be to get a reasonable 1/4" border as a default for anything I'm trying to print, but even if I can't get the max default width above 734pt I still want it to be centered so that I can at least work within 1/2" margins without any clipping.
While the original behavior does seem like a bug, it appears that setting printInfo.paperSize field may provide a partial workaround, as long as the Mac has an installed printer available.
In addition to my other setup, if I add the line
self.printInfo.paperSize = CGSize(width: 792.0, height: 612.0)
for my US-Letter landscape document, and still use Page Setup to set printer "Any" and letter/landscape, when the print job actually runs it now shows up having selected the driver from the EPSON driver rather than leaving the buggy "Any" driver's margins - the result is nicely centered with minimal margins as desired.
I tested on a MacBook Pro with no printer set up, and this workaround did not correct the issue - it still shows up with off-center margin and clips the drawing. So the workaround requires some actual printer to be installed.
I've filed a bug via Apple's feedback assistant, will post an update if anything more is discovered or resolved.
Here's my test app, it prints the view on one page without margins, maybe it helps:
Document.swift
override func windowControllerDidLoadNib(_ windowController: NSWindowController) {
let newPrintInfo = NSPrintInfo()
newPrintInfo.leftMargin = 0.0
newPrintInfo.bottomMargin = 0.0
newPrintInfo.rightMargin = 0.0
newPrintInfo.topMargin = 0.0
newPrintInfo.horizontalPagination = .clip
newPrintInfo.verticalPagination = .clip
self.printInfo = newPrintInfo
}
override var printInfo: NSPrintInfo {
didSet {
view.printInfoChanged(printInfo)
}
}
override func printOperation(withSettings printSettings: [NSPrintInfo.AttributeKey : Any]) throws -> NSPrintOperation {
return NSPrintOperation(view: view, printInfo: printInfo)
}
MyView.swift
func printInfoChanged(_ newPrintInfo: NSPrintInfo) {
setFrameSize(newPrintInfo.paperSize)
}
override func locationOfPrintRect(_ rect: NSRect) -> NSPoint {
return NSZeroPoint
}
override func knowsPageRange(_ range: NSRangePointer) -> Bool {
range.pointee.location = 1
range.pointee.length = 1
return true
}
override func rectForPage(_ page: Int) -> NSRect {
return bounds
}
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
NSColor.green.set()
NSBezierPath(rect:bounds).stroke()
NSColor.red.set()
NSBezierPath(ovalIn:bounds).stroke()
}

Unity and VR: offset using "ReadPixels()" function

I've ran into a small issue developing a picture taker for a VR project. I need to take a screenshot of a specific zone, which is a rectangle with variable width and height. To do that, I have a transform anchored to the top right corner of the bounding box that represents where the picture is going to be taken, and one anchored to the lower right corner.
Here's what it should look like. I've added little red circles to show the transforms's position.
Here's what a screencap using the left eye looks like. It's the same result if I use "both eyes" as a target in the Camera settings.
Here's what a screencap using the right eye looks like. So not only is it too far left or right, it's also a tad too high.
Here's the code that creates the Rect, and here's the code that reads the pixels.
When the Main Camera targets the left eye, there's almost half of the Rect's with as an offset to the left, when it targets the right eye, there's that same offset to the right, when it targets both, there's a softer offset to the left, and all of these have a slight vertical offset upwards.
Any help is appreciated. I'll keep this thread updated if I find anything!
public void SubmitPicture()
{
Vector2 upperLeftPosition = mainCamera.WorldToScreenPoint(upperLeftTransform.position);
Vector2 lowerRightPosition = mainCamera.WorldToScreenPoint(lowerRightTransform.position);
pictureBoxRect.x = upperLeftPosition.x;
pictureBoxRect.y = mainCamera.scaledPixelHeight - upperLeftPosition.y;
pictureBoxRect.width = lowerRightPosition.x - upperLeftPosition.x;
pictureBoxRect.height = lowerRightPosition.y - upperLeftPosition.y;
pictureSnapper.OnInput(AbsoluteRect(pictureBoxRect));
}
public void OnInput(Rect pictureBox)
{
if ((int)pictureBox.width > 0 && (int)pictureBox.height > 0)
{
videoPlayer.Stop();
Texture2D videoTexture = new Texture2D((int)pictureBox.width, (int)pictureBox.height);
videoTexture.ReadPixels(pictureBox, 0, 0);
videoTexture.Apply();
byte[] imageData = videoTexture.GetRawTextureData();
if (debug)
{
byte[] imagePng = videoTexture.EncodeToPNG();
File.WriteAllBytes(Application.dataPath + "/" + savename + ".png", imagePng);
}
}
}
private Rect AbsoluteRect(Rect rect)
{
if (rect.width < 0)
{
rect.x -= rect.width;
rect.width = Mathf.Abs(rect.width);
}
if (rect.height < 0)
{
rect.y += rect.height / 2;
rect.height = Mathf.Abs(rect.height);
}
return rect;
}
Updated to add the picture references.

How to slide a panel from right to left using bunifuTransition in c#

I have bunifutransition1 that slides my mainpanel from left to right upon clicking showbutton. (It shows the hidden mainpanel.)
What I want is, when I click closebutton, the mainpanel will slide from right to left (to hide the mainpanel again). It seems that bunifuTransition does not have an animation that reverses the animation of VertSlide or HorizSlide.
What should I do to slide my mainpanel from right to left to hide it again on my form?
I was having the exact same issue but upon reading your question the answer finally became prevalent in my mind. The solution here is to stop using BunifuTranisition altogether and go for the good ol' for loops and the other mods, puns intended.
int originalWidth = panel.width;
int menuClicksIndex = 0;
private void beginTransition()
{
if (menuClickIndex % 2 == 0)
{
//This executes on the first click
for(int i = originalWidth-1; i>=0; i--)
{
// Loops from original width to 0
panel.Width = i;
}
}
else
{
for (int i = 0; i <= originalWidth; i++)
{
panel.Width = i;
}
}
menuClickIndex++;
}
This works for me but it glitches on the way back from left to right. So a mixed version with BunifuTransitions for the opener and the for loop for the closer would be the ideal solution here.
UPDATE 1: It seems as if while changing the width of the panel from 0 to say, 350, the content inside the panel doesn't render until the height is set to the max, but while decreasing the height from 350 to 0, the content is already rendered and so it seems smooth to close but cluttery to open, hence probably explaining why BunifuTransition is unable to do that as well.
Solution Here.
Just go bunifu transition properties
Open or dragdown DefaultAnimation. Find this option in menu ("Side Coeff") It Show value of
X and Y {X=1, Y=0} . You just change this value {X=-1, Y=0}.
Then Start your project and check. Your slider sliding left to right. :)
Keep enjoy.
Regards,
Haris Ali
Use this command: bunifuTransition1.HideSync(guna2Panel1); before any code on event button click!

Adjusting the map's opacity

Hi–I'm trying to set the opacity of a map to 0.6, so I could draw a polygon with 1.0 opacity on it.
Now, setting the polygon's opacity is simple. Is there a way to alter the map style's opacity (streets-v10, in this case)?
Thanks.
A style is just a list of layers, you'd need to iterate over all the layers and set their opacity. Something like this:
map.getStyle().layers.map((layer) => {
if (layer.type === 'symbol') {
map.setPaintProperty(layer.id, `icon-opacity`, 0.5);
map.setPaintProperty(layer.id, `text-opacity`, 0.5);
} else {
map.setPaintProperty(layer.id, `${layer.type}-opacity`, 0.5);
}
})

Raphael-GWT: fill image of a shape (Rect) appears offset. How to resolve this?

I'm wondering about the behavior of {Shape}.attr("fill","url({image.path})").
when applying a fill image to a shape:
public class AppMapCanvas extends Raphael {
public AppMapCanvas(int width, int height) {
super(width, height);
this.hCenter = width / 2;
this.vCenter = height / 2;
...
Rect rect = this.new Rect(hCenter, vCenter, 144, 40, 4);
rect.attr("fill", "url('../images/app-module-1-bg.png')"); // <--
...
}
}
The background image seem to teal accross the canvas behind the shape, thus gets weird positioning (an illustration snapshot is enclosed - i marked the original image borders in red).
This seem to resolve itself in the presence of an animation along a path (a mere path.M(0,0) is sufficiant).
How can i position the fill-image properly in the first place?
The proper way to do this from what I can understand would be to use an SVG pattern declaration to specify the portion and position of the image you would want to use. Then you would use that pattern to fill the rectangle element. Unfortunately, the Raphael javascript library doesn't have support for patterns... so there's no direct way to use an image to fill a rectangle.