Class DesignerGuides
$guides child of the panel's $designer container, an EditorDataPropCnr holding one EditorPropCnr per guide.A guide is an integer pixel position relative to the top-left corner of the panel it belongs to, so guides are unique to one panel and are never copied or moved between panels. The name of a guide's container carries the axis and the order: x for a guide holding an x-position (a vertical line) and y for one holding a y-position (a horizontal line), followed by an integer starting at one - x1, x2, y1. The letter names the coordinate the guide stores, not the direction the line runs. The position itself is the IntProp named POSITION inside the guide's container, so that a guide can carry more than its position later without changing its shape.
EditorPropCnr is not index-based: usesPropIndex() is false, as for every PropCnr that does not override it, so nothing in the container enforces the order of its children and createUniqueAtom("x") would name the first guide x and the second x2. The number in the name is therefore what orders the guides, addGuide(UIPanelBase, char, int) chooses it, and getGuides(UIPanelBase, char) sorts by it. The whole store lives under $designer, which the property factory drops on every non-Designer load, so the runtime never receives a guide.
Nothing here paints, snaps or handles the pointer: this is storage, read by the client-side guide code. A guide change marks the panel changed through the property framework alone: $guides is an EditorDataPropCnr, which the file's save comparison sees, so a guide moved, added or removed compares against the state saved or loaded, and moved back it compares clean again.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe axis letter of a guide holding an x-position, i.e.static final charThe axis letter of a guide holding a y-position, i.e.static final StringThe name of the guides container under$designer.static final AtomThe atom of the guides container.static final StringThe name of the integer position property inside a guide's container.Method Summary
Modifier and TypeMethodDescriptionstatic EditorPropCnraddGuide(UIPanelBase panel, char axis, int position) Adds a guide to a panel, named with the next free number on its axis:x1when the panel has no x-guide, otherwise one past the highest number in use, so that a name is never reused while a higher one exists.static booleanclearGuides(UIPanelBase panel) Removes every guide of a panel.static int[]getGuides(UIPanelBase panel, char axis) Gets the guides of a panel on one axis, ordered by the number in their names, not by their position in the container.static EditorPropCnrgetGuidesCnr(UIPanelBase panel, boolean doCreate) Gets the guides container of a panel:$designer/$guides.static booleanhasGuides(UIPanelBase panel) Checks if a panel has any guide.static intThe order number of a guide name on an axis: the positive integer after the axis letter, without a leading zero.
Field Details
GUIDES
GUIDES_ATOM
The atom of the guides container.POSITION
The name of the integer position property inside a guide's container.- See Also:
AXIS_X
public static final char AXIS_XThe axis letter of a guide holding an x-position, i.e. a vertical line.- See Also:
AXIS_Y
public static final char AXIS_YThe axis letter of a guide holding a y-position, i.e. a horizontal line.- See Also:
Method Details
getGuidesCnr
Gets the guides container of a panel:$designer/$guides. Created, it is anEditorDataPropCnr; found, it is whatever the file holds, so a panel saved before$guidesbecame Designer data still answers its plainEditorPropCnr, whose guides paint but do not mark the panel changed until they are drawn again.- Parameters:
panel- The panel.doCreate- Flag to create$designerand$guideswhen not present.- Returns:
- The guides container, or null if not present and not created, or if the panel is not an editor panel.
hasGuides
Checks if a panel has any guide.- Parameters:
panel- The panel.- Returns:
- true if there is at least one guide on either axis.
getGuides
Gets the guides of a panel on one axis, ordered by the number in their names, not by their position in the container.- Parameters:
panel- The panel.axis-AXIS_XorAXIS_Y.- Returns:
- The positions in name order, an empty array for none.
- Throws:
IllegalArgumentException- If the axis is not'x'or'y'.
addGuide
Adds a guide to a panel, named with the next free number on its axis:x1when the panel has no x-guide, otherwise one past the highest number in use, so that a name is never reused while a higher one exists.- Parameters:
panel- The panel.axis-AXIS_XorAXIS_Y.position- The pixel position relative to the top-left corner of the panel.- Returns:
- The guide's container, added under
$guides, or null if it could not be added. - Throws:
IllegalArgumentException- If the axis is not'x'or'y'.
clearGuides
Removes every guide of a panel. The$guidescontainer is removed with them, so a panel without guides carries no empty container in its file.- Parameters:
panel- The panel.- Returns:
- true if there was a guides container to remove, false otherwise.
numberOf
The order number of a guide name on an axis: the positive integer after the axis letter, without a leading zero. Public so that the client-side guide code and the tests share the one definition of what a guide name is.