Change orientation of rows and columns of Vaadin Grid - java

How do I rotate or change orientation of rows and columns in the new Grid widget in Vaadin 7?
My requirements are such that I need to change both. a) header-rows and b) cells content. In this image, there are twelve columns (1-12) and eight rows (A-H), so I've to change the orientation of twelve columns into eight rows and eight rows into twelve columns and all its cell content as well.

It seems that Vaadin 7 does not have such feature implemented in new Grid. However, one can manually rotate the items within container to change orientation.

Related

Is there a way to have a GridView with dynamic cell size?

In android, the gridview provides an excellent way to arrange items neatly. However, the cell size for a grid is fixed. That is, in a 3 column by 4 rows grid, if the very first item is 10 dp in height and the second and third items are 20 dp in height, then all the cells in first row will be of 20 dp height.
I want to find a way where in, the view will automatically adjust the cell size for the first cell, so that items below the first item of 10dp height are displayed immediately below it, instead of leaving that extra 10dp gap.
This is the sort of behaviour we can see in Windows live tiles. The items below small tiles move up to fill the gap. I want to implement a similar functionality.
Is there a way to do that?
So turns out, there was already a way to do this. I just didn't know the right term for it.
Android provides a StaggeredGridLayout Layout Manager that does just what I need.
You can take a look at this page
Also, visit this page to see it in action.

Expandable grid Vaadin UI

I have a simple grid. Two columns with a variable amount of rows. I want to make it so i have a header row with an arrow that can collapse and show the whole grid. So when I bring up the app, only the header row is visible with an arrow, and I can click to expand/collapse to show the rest of the grid.
A TreeGrid seems like overkill since I don’t need any hierarchical structure, just the ability to collapse/expand one row. I exclusively use IE and I’ve read that Drawyer doesnt work with IE 8 and above. I return a list of the objects and the object just has two string variables.
Any help with this? I am new to Vaadin 8.
Set grid height (workaround)
As a workaround, you could set the height to be approximately the number of pixels you expect to be the height of the header.
See the Sampler demo. Click the gear icon at top to expose properties of the example Grid object. The last property shown is "Size (W x H)". Change 100% to 100px to see the effect.
Grid height set to 100%
Grid height set to 100px
You can also hide the footer (see checkbox in that property list).
I don't think this can be done with plain Vaadin. But I recommend the following simpler approach:
Initially call grid.setHeightByRows(1.5) (javadoc). This will show exactly one row and a half to indicate more data is available. A scrollbar will appear, too.
Make a new column within the grid that has a button or add a button below the grid that - when clicked - calls setHeightByRows with the number of elements in the grid and hides the button. This will show all rows.

Apache POI (DOCX) XWPFTable asymmetric cell

I want to create a table looks like
this.
but the only way to to this is with an horrible merge of cells.
i try to make two separate table but the top table, follow the cell width of bottom table like this.
There is a way to make an asymmetric table without merge cells?
You don't have to 'merge' cells, but you do have to tell it how many grid columns or rows the cell spans. Picture a grid that has a column that matches every column position, and a row that matches every row position. In your example, you would have a grid with 18 columns and 3 rows. Then for each cell that spans one or more grid column or row, you must have a span attribute that tells how many grid positions are spanned by the cell. The result is the same as merging, and it might even be what you meant by merging, but that is the way the spec reads.

Using MouseListener to select a range of cells in a grid

Linked post: How to use MouseListener to find a specific cell in a grid
I am trying to create a Battleships game, with a 10x10 grid made up of 100 cells. The Grid extends JPanel and the Cell also extends JPanel. Earlier on I made the link above to ask how to implement a MouseListener to do this. As the code is all on that page, I am just going to refer to it.
Someone posted an excellent answer on that link which I accepted. I can now use MouseListener to detect movement, clicks etc in any cell on the grid.
However, I've hit another road block. I am trying to place ships on my grid. I am forgetting about orientation for now (as I'm assuming all ships will be placed horizontally). The first ship will take up five cells. I would like to move my cursor onto a cell on the grid and have four other 'tail' cells, to the right of the cell the cursor is over, highlighted as well. If there aren't five free cells in total (perhaps because the cursor is too near the edge of the grid), the cells will turn red. Otherwise, they will turn green.
After the first ship is placed, the second will need placing. It is four cells long. Therefore, when hovering over a cell it will have a 'tail' of three cells and so on.
I am happy with how to change colours, how to handle orientation and how to change from five ships to four ships and so on. However, I have no idea how to select multiple cells at once.
Does anybody know how to implement this? I would love to post what I have tried but the truth is, I've got nothing.
use JButtons / JToggleButtons instead of JPanels
you can to use Icon (one Image splitted to desired numbers)
by usage of implemented methods in API
use ActionListener for (undecorated) JButton
override ButtonModel for implemented mouse events (without / not required to add MouseListner) in JButton
Generally, selecting a row or column of cells is the same as selecting a rectangle of cells.
The mouseClicked method sets the initial cell.
The mouseMoved method sets the current cell that the mouse is in. This is so you can visually indicate to the user what cells have been "selected".
The mouseReleased method sets the final cell.
You check to see that the initial cell to the final cell makes up a row or a column. The length of the row or column determines which ship you place. This allows you to place the ships in any order, not just largest to smallest.
You'll have to add a MouseMoveListener to use the mouseMoved method.

Is it possible for JTable column headers to be verticaly aligned?

I'm working on a hotel booking timeline feature for hotel management system. I have a JTable where rows represent rooms and columns represent days. If room is booked for that day, the corresponding cell is highlighted. Since these cells don't have any content and only serve to visually represent days when the rooms are booked, it seems rather pointless for them to have width larger then height. But if I adjust them to be equal column headers containing days are shortened and instead of "02.01.2012." all I see is "...". Since this is not an option I was wondering is it possible to "rotate" the header cells so the text in them is aligned vertically.
You may use the method described in Vertical Table Header Cell Renderer to show the header text in a vertical manner.

Categories

Resources