How to eliminate the empty space of a dialog/pie chart in JavaFX? - javafx-11

I'm new to JavaFX and encountering this problem.
Pie chart/dialog with extra dead space.
My code is
Dialog dialog = new Dialog();
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
pieChartData.addAll(new PieChart.Data("Win", 45), new PieChart.Data("Loss", 55));
PieChart chart = new PieChart(pieChartData);
dialog.setGraphic(chart);
How can I eliminate this space? Any help would be appreciated.

dialog.getDialogPane().setMaxWidth(500); to set a fixed width of the dialog.
But I haven't figured out why the pie chart has this extra space.

Related

libGDX button layout with no spacing

I'm using a table to layout my menu buttons, but the spacing between buttons is big enough to drive a car through. What can I do to gain more control over the apparent cell padding? I've searched StackOverflow posts, read through the API, typed '.' after table and actor to browse the autocompletes, manually adjusted values in the skin file, and looked at other people's projects on Github. Some of the methods I've tried include sizeBy(), scaleBy(), pad(), setFillParent(), space(), fillY(), and grow()
A helpful answer would describe how to get buttons to stack on top of each other, touching.
Gdx.input.setInputProcessor(stage);
// Create a table that fills the screen. Everything else will go inside this table.
Table table = new Table();
table.setFillParent(true);
table.setDebug(true);
stage.addActor(table);
table.setBackground(new TiledDrawable(background));
//create buttons
TextButton newGame = new TextButton("New Game", skin);
TextButton preferences = new TextButton("Preferences", skin);
TextButton exit = new TextButton("Exit", skin);
TextButtonStyle tbs = new TextButtonStyle(newGame.getStyle());
NinePatch np = new NinePatch(skin.getPatch("button"));
np.setColor(np.getColor().sub(0f, 0f, 0f, .4f));
tbs.up = new NinePatchDrawable(np);
newGame.setStyle(tbs);
preferences.setStyle(tbs);
exit.setStyle(tbs);
table.bottom().right().padBottom(40f).padRight(40f);
//add buttons to table
table.add(newGame).bottom().right().fillX().uniformX();
table.row();//.pad(1, 0, 1, 0);
table.add(preferences).bottom().right().fillX().uniformX();
table.row();
table.add(exit).bottom().right().fillX().uniformX();
It was my skin. I used the sample "Rusty Robot UI", but it doesn't crop it's button images tightly. Tried another one and saw the stacking I was looking for.

Dart google_maps issue

i have a weird behavior of Google maps using dart !! here
as you see the link responsible for making th map appears is "Géolocalisation" until now i have no problem! but when i reclick, or when i visit another link then returning back to "Géo.." it gaves me this and i really don't know what to do! this is my first try at GMap so i need a littel bit of help please.
i must mention that the page doesn't refresh when i click at the link it's only delets the old content from the container div then add the new elements also i must mention that i'm using bootstrap3,this is the code for the page géo
import 'package:google_maps/google_maps.dart';
import '../view.dart';
import 'dart:html';
//view Map
class viewMap extends View{
panelCoreBuilder(){
//creating the container layout and it is a div row
DivElement layout = new DivElement()..className="row";
//adding a style element for the map element inside the container
layout.children.add(new StyleElement()..text="#mapblock{margin: 0;padding: 0; height: 500px; width: 100%;");
DivElement cellone = new DivElement()..className="col-md-3";
//naming the block that contains the map
DivElement celltow = new DivElement()..className="col-md-9"..id="mapblock";
//adding the cells to the layout
layout.children.addAll([cellone,celltow]);
//creating the map
visualRefresh = true;
final mapOptions = new MapOptions()
..zoom = 8
..center = new LatLng(34.034453, -5.885925)
..mapTypeId = MapTypeId.ROADMAP;
final map = new GMap(celltow, mapOptions);
//returning the layout to the MainContainer...
return layout;
}
}
so that's it i hope you can give me any solution ,hypotheses ,or even a hint
and if i fond the solution first i'll post it here!
This is likely that your <div> has an empty size (or not displayed) when the new GMap is called. The map is not aware of the <div> container resizing by default. You have to manually trigger a resize event when you display it on the screen with :
event.trigger(map, 'resize', []);

AS3 - Changing size of Label on Button component

I would like to increase the size of the label on a Button in flash. The label seems to only be about 3/4 the width and 3/4 the height of the button. I would like to make the label be the full width and height of the button.
The label field is just a string, and changing the width/height on the textField property of the button does not seem to change anything. Also textFormat doesn't have options for changing text width/height.
I'm out of ideas. Any help would be greatly appreciated!
The only way I know is to do it via code.
var myTextFormat:TextFormat = new TextFormat();
myTextFormat.size = 20
var myButton:Button = new Button();
myButton.label = "Click Me";
myButton.setStyle("textFormat", myTextFormat);
myButton.setSize(120, 60);
myButton.x = 0;
myButton.y = 0;
addChild(myButton);
After much reading, I found a few that might help future viewers of this question. I am using AS3, CS5.5. 'bw' is the instance name of the button. These can be used if you are using a button 'Component'.
bw.setStyle("textFormat", new TextFormat("Verdana", 20, "bold", "italic", "underline", true));
bw.label = "Dog Snacks"; // can be also set via properties, but this is handy if you want the text to change after clicking
bw.setSize(280, 30); // can also be set via properties

Flex 4 List with InteractionMode Touch : how to force a scrollbar visible

I'm using the last Flex 4 sdk Hero.
i setup a classic List component with InteractionMode="Touch". Thus, my vertical scroll bar is not visible until i drag the list ,which is normal.
My customer ask me to add some "page down" button on the list. I've done it as follow, which work perfectly :
private function handleDownButton(event:*):void {
var currentPosition:Number = wcList.scroller.viewport.verticalScrollPosition;
var nextPosition:Number = currentPosition+((wcList.dataGroup.layout) as VerticalLayout).getVerticalScrollPositionDelta(NavigationUnit.PAGE_DOWN);
var anim:Animate = new Animate(wcList.scroller.viewport);
anim.motionPaths = new <MotionPath>[
new MotionPath("verticalScrollPosition")];
anim.motionPaths[0].keyframes = new <Keyframe>[
new Keyframe(0), new Keyframe(500, nextPosition)];
anim.play();
if ((nextPosition+wcList.height)>=wcList.scroller.viewport.contentHeight) {
buttonDown.enabled=false;
}
buttonUp.enabled = true;
}
My big problem is that my customer also want the vertical scroll bar to be visible during the animation, but i can't find a solution for this (wcList.scroller.verticalScrollBar.visible = true don't work at all).
Any idea of how doing this?
Thanks.
A hack that might work for you...
http://flexponential.com/2011/06/21/using-drag-and-drop-with-a-spark-list-in-a-mobile-flex-application/

how do I increase the clickable area of an icon in google maps

We are trying to increase the clickable area of a marker on a google map. The reason we want to do that clicking on the icon sometimes misses the anchor point. We rather not reduce the size of the icon size
We are assuming that one of the properties of the GIcon objects is what we need to change and tried changing the iconAnchor and and infoWindowAnchor property of the GIcon but that doesnt seem to work.
anyone point us in the right direction?
I know its been a while but I had the same issue, lets say your icon is 51 pixels wide and 32 pixels tall:
var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.imageMap = [0,0 , 51,0, 51,32 , 0,32];
Basically you're just inputting x,y co-ordinates
If you have different icons, it's a good idea to create the imageMap dynamically:
function getImgSize(imgSrc) {
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
return [height,width];
}
var icon = new GIcon(G_DEFAULT_ICON,iconUrl);
var iconSize = getImgSize(iconUrl);
icon.iconSize = new GSize(iconSize[1], iconSize[0]); // set icon size
icon.imageMap = [0,0, icon.iconSize.width,0, icon.iconSize.width,icon.iconSize.height,0,icon.iconSize.height]; // set click area
icon.shadowSize = new GSize(0, 0); // disable shadow
Reference: http://code.google.com/apis/maps/documentation/reference.html#GIcon
iconAnchor and infoWindowAnchor set where in the image the actual point on the map and the info window are respectively.
If you want a bigger clickable area, you may be able to do something with the imageMap property for non-IE (I've never tried). However, I think your best bet would be to define a custom GIcon that uses a larger image(padded with transparent space. Unfortunately, that's quite a bit of a hack -- maybe someone else knows of a better way.
In the end, we reduced the size of the image. We had not noticed the recommended graphic size was 19x19