-
Notifications
You must be signed in to change notification settings - Fork 85
Outline Pane
Languages: Dutch (Nederlands)
The outline pane is by far the most advanced pane included in this framework. The outline pane takes in items, however, unlike Static Pane, you don't specify the position it will be in. The outline pane starts by putting its items in the top-left corner. Then depending on the orientation it will render in either two ways. If the orientation is set to HORIZONTAL
the items will continue to the right and once the end of the pane has been reached, they'll be added on the next row on the left side (just like what happens when you call addItem on an inventory in Bukkit).
You can also set the orientation to VERTICAL
. The items will still start in the top-left corner, but instead of going to the right, the items will now first go down and once the end of the pane is reached, they'll be added on the next column on the top side. There are different parameters that might alter this basic principle, but these are explained below.
To create an Outline Pane simply call the constructor for it:
OutlinePane pane = new OutlinePane(0, 0, 9, 6);
To add items simply call addItem with the desired item:
pane.addItem(new GuiItem(new ItemStack(Material.STONE)));
This will add the item as last in the list. You can however also insert items at a specific index, like so:
pane.insertItem(new GuiItem(new ItemStack(Material.STONE)), 1);
This inserts the item in the first index of the list (second element). Now this item will be shown as the second one.
When an item is made invisible, the pane is displayed as if the item was never added to the pane. This means that there won't be an empty space, but the items beyond the hidden item will move back to fill up the space where the item would otherwise be. This is different from adding an empty item (air) to the pane, which will leave an empty spot.
If you want to change the orientation of the pane as described in the first paragraph, you can call setOrientation
with the preferred orientation:
pane.setOrientation(Orientable.Orientation.VERTICAL);
This changes the orientation to VERTICAL
.
You can also flip the items in the pane horizontally or vertically or both at the same time. When flipping the items horizontally all items are moved along the x-axis and when flipping the items vertically all items are moved along the y-axis. You can flip the pane horizontally and vertically respectively as follows:
pane.flipHorizontally(true);
pane.flipVertically(true);
Just like the Static Pane the Outline Pane can also have a rotation, which works exactly the same. There are four different rotations; 0, 90, 180, 270. These rotations are in degrees. Every rotation that is or exceeds 360 will be trimmed to fall into the bounds [0,360) (e.g. 540 becomes 180). Only panes which have the same length as height can use the rotation (this is due to how two dimensional rotations on a grid work). Each rotation is applied clockwise, if you want a counter-clockwise rotation, you'll have to calculate the amount of degrees the pane would be rotated if you went clockwise. You can set the rotation as follows:
pane.setRotation(90);
This will have set the rotation of the pane to ninety degrees.
You can also specify a gap for the pane. A gap is the amount of empty spots in between each item. If you set the gap to one, in between every item there will be one empty spot, with a gap of two, two empty spots, etc. Note that empty spots also wrap around the pane, e.g. if you have an item on the right side of one row/column, an empty spot will appear on the left/top side of the next row/column. A too large gap, or too much items may result in the items potentially going outside of the pane. Any items that would go outside the pane will be ignored. To set the gap, simply call setGap
, like so:
pane.setGap(1);
Now there will be one empty spot in between every item.
You can also make the items repeat until the pane is full. If you, for example, have three items, only these three items will be shown. However if you set the pane to repeat, once the last item is inside the pane, the first item will be added to the pane again after the third, continuing the cycle until the pane is full. To set repeat on/off, simply call setRepeat
.
pane.setRepeat(true);
Now the items in the pane will repeat for the entire pane's size.
You can specify a mask for the pane. A mask is a way to specify which slots are allowed to have an item and which slots should be skipped and therefore not get an item. Unlike the gap property explained above, this allows you to specify any amount of slots in any configuration you like, whereas the gap only indicates that every n slots should be skipped. To create a mask, you first have to call the Mask
constructor, with the items you'd like to be taken into consideration.
new Mask(
"01",
"10"
);
This creates a mask, where only the slot in the top-right corner and the slot in the bottom-left corner will be filled with items: the other positions, the top-left corner and bottom-right corner, will not be filled with any items. To apply this mask to the OutlinePane
, simply call applyMask
.
pane.applyMask(myMask);
When a mask is specified on the pane, the gap property will not skip every n slots like normal, but will only skip n slots that are taken into consideration. As an example, if a mask is specified with four 'activated' slots and a gap of one is specified, only the first and third slot that are specified by the mask, will get an item: the second and fourth slot will not, regardless of where those slots might be positioned in relation to the other slots.
Last of all, an alignment can be specified. By default, the alignment is set to begin
, where the items are aligned to the left/top (depending on the orientation). Alternatively, you can set the alignment to center, to center the items inside the pane. Centering will center based on the orientation, so for horizontal it centers horizontally and for vertical, it centers vertically. Note that the center is relative to the mask, so items may not visually look centered if the mask has certain slots disabled. If there are two slots that are the center, then the items will be placed in the slot to the left/top.
pane.align(OutlinePane.Alignment.CENTER);
Everything shown at Panes can be used on the Outline Pane as well.
The element name for an Outline Pane is outlinepane
so use that when you want an Outline Pane inside your XML file.
<outlinepane x="0" y="0" length="9" height="6"/>
In case you want to skip a slot when adding items, you can add the following element to keep that slot empty.
<empty/>
First of all, you can set the orientation of the pane by setting the orientation
attribute to either HORIZONTAL
or VERTICAL
(case doesn't matter). By default the orientation is HORIZONTAL
.
<outlinepane x="0" y="0" length="9" height="6" orientation="vertical"/>
You can flip the pane horizontally and/or vertically by adding the following attributes to your pane:
<outlinepane x="0" y="0" length="9" height="6" flipHorizontally="true"/>
<outlinepane x="0" y="0" length="9" height="6" flipVertically="true"/>
You can also set the rotation in the same way as with the Static Pane by adding the rotate
attribute to the pane with the amount of degrees as value. By default the pane has no rotation (0 degrees).
<outlinepane x="0" y="0" length="9" height="6" rotation="90"/>
Next you can set the gap to any value by specifying the gap
attribute with the amount of empty spots you want in between each item.
<outlinepane x="0" y="0" length="9" height="6" gap="1"/>
You can set repeat on/off by adding the repeat
attribute and providing either true
or false
as the value.
<outlinepane x="0" y="0" length="9" height="6" repeat="true"/>
Last of all, you can set the alignment by adding the alignment
attribute and providing either begin
or center
as the value.
<outlinepane x="0" y="0" length="9" height="6" alignment="center"/>