Interface CanvasElement
- All Superinterfaces:
DomQueryable
,Element
,EventTarget
,Node
Canvases are rendered by displaying each pixel as its own TextDisplay
entity. Thus, when using a canvas element, keep in mind the amount of entities that will be used
to render the canvas.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default size of a canvas elementstatic final int
Maximum allowed size for a canvas.static final int
Minimum allowed size for a canvas -
Method Summary
Modifier and TypeMethodDescriptionboolean
Canvas elements cannot have any child nodes.@NotNull Canvas
Get the canvas of this element.int
Get the value of theAttributes.HEIGHT
attribute.int
getWidth()
Get the value of theAttributes.WIDTH
attribute.void
setHeight
(int height) Set the value ofAttributes.HEIGHT
attribute.void
setWidth
(int width) Set the value ofAttributes.WIDTH
attribute.Methods inherited from interface com.juliewoolie.dom.DomQueryable
getElementsByClassName, getElementsByTagName, querySelector, querySelectorAll
Methods inherited from interface com.juliewoolie.dom.Element
appendChild, appendElement, appendText, clearChildren, firstChild, forEachDescendant, getAttribute, getAttributeEntries, getAttributeNames, getChild, getChildCount, getChildren, getClassList, getClassName, getCurrentStyle, getId, getInlineStyle, getTagName, getTextContent, getTitleNode, getTooltip, hasAttribute, hasChild, hasChildren, indexOf, insertAfter, insertBefore, isDescendant, lastChild, matches, prependChild, removeAttribute, removeChild, removeChild, removeMatchingChildren, replaceChild, replaceChild, setAttribute, setClassName, setId, setTextContent, setTitleNode
Methods inherited from interface com.juliewoolie.dom.event.EventTarget
addEventListener, dispatchEvent, getOnAddAttribute, getOnAddOption, getOnAppendChild, getOnAttributeChange, getOnClick, getOnClosing, getOnInput, getOnLoaded, getOnMouseEnter, getOnMouseExit, getOnMouseMove, getOnOptionChange, getOnRemoveAttribute, getOnRemoveChild, getOnRemoveOption, getOnRightClick, getOnSetAttribute, getOnSetOption, getOnSpawned, onAddAttribute, onAddOption, onAppendChild, onAttributeChange, onClick, onClosing, onInput, onLoaded, onMouseEnter, onMouseExit, onMouseMove, onOptionChange, onRemoveAttribute, onRemoveChild, onRemoveOption, onRightClick, onSetAttribute, onSetOption, onSpawned, removeEventListener
Methods inherited from interface com.juliewoolie.dom.Node
enterVisitor, exitVisitor, getDepth, getOwningDocument, getParent, getRenderingBounds, getSiblingIndex, hasFlag, nextSibling, previousSibling
-
Field Details
-
MIN_SIZE
static final int MIN_SIZEMinimum allowed size for a canvas- See Also:
-
MAX_SIZE
static final int MAX_SIZEMaximum allowed size for a canvas.- See Also:
-
DEFAULT_SIZE
static final int DEFAULT_SIZEDefault size of a canvas element- See Also:
-
-
Method Details
-
canHaveChildren
@Contract("-> false") boolean canHaveChildren()Canvas elements cannot have any child nodes.- Specified by:
canHaveChildren
in interfaceElement
- Returns:
false
-
getWidth
int getWidth()Get the value of theAttributes.WIDTH
attribute.If the attribute has no value, or is not a valid number,
DEFAULT_SIZE
is returned.Note: There is a brief window of time when the value returned by this method differs from
getCanvas()
'sCanvas.getWidth()
. This happens when the attribute is changed, as canvas is updated after all attribute change listeners have been called.- Returns:
- Width
-
setWidth
Set the value ofAttributes.WIDTH
attribute.When called, the
getCanvas()
'sCanvas.getWidth()
will not be updated instantly. All attribute update listeners will be called first, then the canvas' size will be updated.When a canvas' size is changed, the canvas is resized, and any existing image data is retained, but the image will be cropped if the size is changed to smaller value than it was before.
- Parameters:
width
- New width- Throws:
IllegalArgumentException
- Ifwidth
is less thanMIN_SIZE
or greater thanMAX_SIZE
.
-
getHeight
int getHeight()Get the value of theAttributes.HEIGHT
attribute.If the attribute has no value, or is not a valid number,
DEFAULT_SIZE
is returned.Note: There is a brief window of time when the value returned by this method differs from
getCanvas()
'sCanvas.getHeight()
. This happens when the attribute is changed, as canvas is updated after all attribute change listeners have been called.- Returns:
- Height
-
setHeight
Set the value ofAttributes.HEIGHT
attribute.When called, the
getCanvas()
'sCanvas.getHeight()
will not be updated instantly. All attribute update listeners will be called first, then the canvas' size will be updated.When a canvas' size is changed, the canvas is resized, and any existing image data is retained, but the image will be cropped if the size is changed to smaller value than it was before.
- Parameters:
height
- New height- Throws:
IllegalArgumentException
- Ifheight
is less thanMIN_SIZE
or greater thanMAX_SIZE
.
-
getCanvas
-