JSplitPane Maximum size for bottom part - height

Is it possible to set the maximum height of the bottom part of a JSplitPane ? I don't want it to be resizable too much.
How to do this ?
Thank you,

JSplitPane has 2 method: .setDividerLocation(int pixels) and .setDividerLocation(double percents). Code will be easy:
jSplitPane.setDividerLocation(0.0); // set maximum height of the bottom part

Related

Finding the center piece from a board

I am stuck on a question regarding obtaining the centerpiece(s) from a board.
For example, if the board was a 3x3, then I would only return "center" if the tile number was "5". If the board was a 2x2, then I would return "center" for every single tile. I am having a problem due to me hard coding this problem. So far I have:
def getMiddle(width, height, tile):
width = width
height = height
tile = tile
while width*height == 1 or 2 or 4:
return "center"
while width*height == 9:
if tile == 5:
return "center"
else:
return "not center"
This has been my general approach but I've been told that this is hard-coding.
I later found out I'm supposed to have these functions at the top of my code and use them within my code. Ex. if row==0: etc etc
row = (tile - 1) // width
col = (tile - 1) % width
I am really lost on how to begin coding this using the above functions to create a general solution so that I am not hard coding. Would greatly appreciate it!
I won't create a solution for you, but try to help you with creating it.
To find a general solution, you need to generalize the problem description (not like board can be 2x2 or 3x3, but in some general terms). So. You have two options: side of board is even or it is odd. And you have two sides, which leads to four possibilities:
Both width and height are odd. This one is the simpliest: center tile is width*(height/2)+width/2+1 (hope it's clear why).
Only width is odd, center tiles would be one in the middle of row height/2-1 and one in the middle of row height/2 (not too difficult to calculate from this point on).
Only height is odd, center tiles are width/2-1 and width/2 in row height/2.
Both width and height are even, there would be four center tiles: width/2-1 and width/2 in rows height/2-1 and height/2.
Having this in mind, I believe you can easily create for if-branches (one for each case) and write a check for a tile being center tile for each case.
Also, in current code, you have width = width, etc, these lines don't do anything useful, so you should probably remove them. And your method name looks like the method should return number of central tile, or something. Better to rename it to something like is_tile_central (note the snake-case, that's not a real mistake, but it is the way we name things in Python)
And fix the indentation please. I guess you have it correct in your actual code, but as indents are essential in Python, you should keep them in order even in questions.

finding object size from speed and change in pixel width

This is very likely a duplicate question but I could not find what I was looking for.
I'm trying to determine the size of an object from the speed of the object(actually the camera is moving but I would guess that it calculates the same), and a change in pixel width . Any help would be appreciated.
speed is roughly 2 m/s
change in pixel width is roughly 3 pixels/frame
I figured out what the problem was:
X width(meters) = ((speed * focal length) / change in pixel width)^.5

Cocos2d-x setScaleX()

So I was programming a game in cocos2d-x and I need one of the sprites to get wider for a certain amount of time, so I tried with the method setScaleX(). The problem is that the content size of the sprite does not actually change, and since my collision system is based on the content size of the sprite, they do not properly work. Here is the code I use for scaling:
bar = Sprite::create( "Bar.png" );
CCLOG("Size: %f,%f.", bar->getContentSize().width, bar->getContentSize().height);
bar->setScaleX(1.5);
CCLOG("Size: %f,%f.", bar->getContentSize().width, bar->getContentSize().height);
The output is exactly the same on both cases. Is there any way of fixing this?
ContentSize represent the original texture size unless you set it using setContentSize method.
You can either multiply size with scale factor or use boundingBox().size to know about current size of scaled sprite(if not rotated or skewed).
cocos2d::Size size1 = cocos2d::CCDirector::getInstance()->getWinSize();
scaleX=size1.width/768;
scaleY=size1.height/1024;
Sprite *sp1=Sprite::create("01.png");
sp1->setScaleX(scaleX);
sp1->setScaleY(scaleY);
this->addChild(sp1);
Scale for Landscape:
cocos2d::Size size = cocos2d::CCDirector::getInstance()->getWinSize();
scaleX=size.width/1024;
scaleY=size.height/768;
Scale for Portrait:
cocos2d::Size size = cocos2d::CCDirector::getInstance()->getWinSize();
scaleX=size.width/768;
scaleY=size.height/1024;
Sprite *sp=Sprite::create("01.png");
sp->setScaleX(scaleX);
sp->setScaleY(scaleY);
this->addChild(sp);

how to set min-height of row of blocktable in rml

How to set min-height of row of blocktable in rml? I read the rml-reference and can't find any related content. I only found the attr: rowHeights, But it seems that it just set a fixed height, the content will flow out. I wanna set a base height,and when the content increases the height of row increases too.
Thanks in advance!
I don't think that's possible for v7 or lower (v8/trunk no idea).
As you've stated right, rowHeights sets fixed heights for rows and without that attribute you will have auto-sized heights.

section covering 100% height of the viewport

I made a lot of research on this site (and others) but I can't solve my problem…
On this website : http://vintagebike.fr/t%C3%A9t%C3%A9/
I want that each sections covers 100% of the height of the viewport…
I set up at min-height : 100% for eachs…
I set up html, body at height : 100%
some code :
html{ overflow-y:scroll; font-size:100%; font-family:Arial,Helvetica,sans-serif; line-height:1.5; background:url(...) repeat top left; font-color:#353232; height:100%;}
body{ height:100%; background:#fff; float:left; width:100%; font-size:.8125em; color:#353232;}
#about{background-color: #cde2f3;position:relative;min-height:100%;}
#elements{background-color: #fbe2e4;position:relative;min-height:100%;}
#pourqui{background-color: #ffedc1;position:relative;min-height:100%;}
#contact{background-color: #ddeee4;position:relative;min-height:100%;}
If I set the height in pixels it's working…
I really don't understand…
Thanks in advance.
(sorry for my english)
Read the specification of percentage height. It has nothing to do with the viewport. Since you have body {height:100%}, as BODY grows, it becomes the element used to represent 100%, not the viewport.
You need to set the section height using JavaScript based on the browser's viewport size.
Bonne chance.
Specifies a percentage height. The percentage is calculated with
respect to the height of the generated box's containing block. If the
height of the containing block is not specified explicitly (i.e., it
depends on content height), and this element is not absolutely
positioned, the value computes to 'auto'. A percentage height on the
root element is relative to the initial containing block. Note: For
absolutely positioned elements whose containing block is based on a
block-level element, the percentage is calculated with respect to the
height of the padding box of that element. This is a change from CSS1,
where the percentage was always calculated with respect to the content
box of the parent element.