Placing Objects in a certain layout(For game) - java

So this what i want to do, i have a scene right now, and i want to create "Pages" on the scene with level icons i create.
Now i want to be able to set the amount of levels i want to have. for example,
int levels = 100;
Then i want it to be able to create "Pages". What i mean by pages is it will be space between each of the level sections.
I would like to be able to set the rows and columns like this:
int rowsPerPage = 5;
int colPerPage = 10;
Each of my level icons are 80x80 width and height.
So with this information i would like be able to place the level icons on rows per page bases and column per page basis.
Each level icon should have some padding space between them.
Once it reaches its makes row and column per page on the first page i would like to create a second page making some space between the first set of rows and columns. Once it reaches is max icon per row it should then start a new row on that page
Right now im not sure where to begin. The reason i am using this is because i have set up gesture detection so my users can scroll from "Page" to "Page" to select a level.
I know this isnt a place to just ask for code, but im stuck on my current project because of this and it would be really great to get some assistance.
Thank you guys in advance.
Thank you.

No one will write your code for you if you haven't even attempted it yourself...
This is from google... It may not be exactly what you want. However, it is a start :)
http://www.andengine.org/forums/tutorials/menu-scroll-example-t5740.html

Related

very weird behavior with dragAndDropBy(), dragAndDrop(), moveToElement, etc

Not sure if its due to how the application im automating has its UI set up but what Im trying to do is open up a side drawer that holds a couple table rows. I need to drag a table row into another specific area and drop it there to move it.
So heres an Idea of what the interface looks like:
NOTE: All that whitespace is not a valid area to drop the table row the tablerows are only droppable in a very specific area that becomes visible when the tablerow is right above it.
Im trying to drag the items on the right hand drawer to the left hand side.
When I try to use dragAndDropBy to move to the respective x and y offsets it looks like it doesnt move to the correct location.
I have modified my code now to at least help me see whats wrong and it seems like its not moving to the x coordinate set in my code below:
Actions actions = new Actions(driver);
System.out.println(productArrangement.getLocation());
actions.clickAndHold(productArrangement).moveByOffset(-408, 308).perform();
System.out.println(productArrangement.getLocation());
Thread.sleep(4000);
As you guys can see all this is trying to do at the moment is see where my element is being moved too and logging if the element is actually moving to the respective direction and it seems like its not being moved at the x coordinate and is moving at the wrong Y coordinate(but at least its moving).
here is my console
I would expect the second coordinate log to have moved to the specified offSets I put in but I have gotten similar behavior for all the methods I've tried so far.
Please advise assistance would be greatly appreciated.
Use direct dargAndDrop method like below:
Actions actions = new Actions(driver);
actions.dragAndDropBy(productArrangement,-408, 308).perform();

Tracking data offset of data in a table to retrieve the previous/next subset on table scroll

I am writing a browser based application using GWT and making use of websql (yes, I know it is deprecated). I have created a custom table widget (based on FlexTable) and enabled it to scroll with the help of some CSS trickery. What I am striving to achieve (without much success) is that when the user scrolls to the start/end of the current data in the table, an event is fired and the next subset of X rows is returned from the websql DB and replaces the data currently in the table. In order for this to work, I need to keep track of the data offset in the table widget so that I can pass this to the query and use the limit and offset functions of SQL to return the required data. However, I just cannot seem to get the logic right to implement the data offset tracker within the widget. Another complication is that I need the table to be able to scroll 'into the past' (so to speak), so that it can retrieve data from before the initial start point when the table loads.
I have been at this for a number of days now and just cannot seem to get it right. So I was wondering/hoping that someone might be able to point me in the right direction (PLEASE!).
Thanks in advance
Tim
I am not sure why this is causing a problem.
int page = 0;
// when you hit the bottom
page++;
loadData(page);
// when you hit the top
if (page > 0) {
page--;
loadData(page);
}
Tim I think it is not a good idea controlling the scroll with CSS trickery.
I have done something similar soon and controlling all the logic (pagination, scroll positions,...).
What I suggest to use is a gwt's scrollPanel, a HasData widget (like a cellList) your custom AbstractCell (class which is rendered for each row of your list) and asyncDataProvider ( which gives you the onRangeChange handler for asking to your server when the range data display has changed).
You can force/fire that event when in scrollPanel.addScrollHandler detects you are arriving to the end.
If you want to see all of this in action have a look into (click on source code): http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCellList
EDIT [according comment below]:
A. If you want to override the data (in the example is X+X+X...) with the new retrieved just maintain always the same range of data displayed [display.setVisibleRange(0, newPageSize);], and start from 0 when you render the new data (on your RangeChange listener).
B. If you need to have control over up and down scrolls instead of taking advantage of the used events internally on the cellList (basically onRangeChange), you can create your custom events and fire them (this option could be easier for your colleagues for understanding everything). And do not worry about controlling up and down scrolls, inside the ShowMorePagerPanel.java you can see a simple example of knowing up and down controls.
Anyway, I did not explain more detailed because I did not see you very convinced to use CellList approach (and I was using my tablet :D ).
If you change your mind, just let me know and I write for you a proper example step by step (this part could be tricky, so if you are lost it is normal ;) ).

set scroll bar position in JTable/SWT Table

I would like to ask question that is not directly related to any technology but it’s a logic level question. Forgive me if I am wrong.
I am trying to solve this issue in Java side.
We have a list view (may be JTable or SWT Table). We are displaying records from a table in to that list. The table may have millions of records. And the table size is keeps increasing. As the table size is huge and it keeps increasing we are keeping a cache of 3000 records and displaying the cache in the table. So at a single point only 3000 records will be there in the view. At this time, the scroll bar of the view (JTable or SWT Table) shall be set based on the cache only (in this case 3000 records).
And based on the user events like, PgUP, PgDwn, DownKey, UpKey, Mouse Scroll etc we are refreshing the cache so that the view will be refreshed.
But we need to give users an actual feel that the scroll position based on the records in the table. I think it is not possible as the scroll position is set by the OS based on the number records in the display. Can somebody can assist me with an alternate method. If I am not explained my question correctly, I will explain this in details. Please help.
Usually a scrollbar is set at the top of the list, or at the bottom, depending on if the property "AutoScroll" is set to true or false.
I believe there IS a method where you can set the scrollbar at a specific point, but last time I tried using it, it was kinda clunky.
It sounds like you're trying to make the scroll bar do two things at once, and that can be confusing. You could use a separate control to the do the paging. A row of buttons in a JToolBar looks nice, but a JComboBox will take up less room. There's some good answers about this here.

Extended JTable clipping problem

Hi I'm using set of classes I found on internet that extends JTable capabilities making me able to merge or split some cells.
Mentioned capability works ok but I have two problems with how the table is displayed. The extended JTable is stored in JScrollPane and it is stored in Box.
The first issue is that when I have a lot of collumns the last one or last two ( depends on how many collumns I have ) is being clipped ( when I move scrollbar to the right edge I don't see last collumn or it is clipped so only the part of the data is visible.)
I did some experiments and I add some empty collumns and that helped so I assume it is something connected with how JScrollPane gets the width of the table it should display but I could not figure out how can I change that. I was trying to call table_.setPreferredScrollableViewportSize(new Dimension()); with Dimentsion set to something really big but it did not help.
Second issue is that when I click on a cell that is placed closer to the right edge then the next cell is being selected. The further the cell is from the left edge the further cell to its right is being selected. I can't see selection when I click on the cell from last collumn.
If there is no easy answer maybe someone knows some open source alternative to display data in table with merging capabilities. I found only commercial ones which cost a lot of money.

How to set JtextArea to keep fixed no of rows?

How can i keep no of rows constant in text area.
I need to create a console window for my application.
If rows exceeds predefined no of rows first rows must get disposed.
As if first written row will be destroyed first when i append anything which exceeds no of rows set.
One more thing , i need to keep vertical scroll bar. That means no of rows must not be the whatever rows are visible when text area it opened.
For example : - no of visible rows on view port are 30.
It should keep 120 rows information, which will can be seen with the help of scroll bar.
Sounds like what you want to do is create your own Document implementation. See Document.
The Message Console shows one way.

Categories

Resources