Class SlideElement

java.lang.Object
com.codename1.presentation.SlideElement
Direct Known Subclasses:
ChartElement, DiagramElement, GroupElement, PictureElement, ShapeElement, TableElement

public abstract class SlideElement extends Object
Something placed on a slide: a shape, a picture, a table, a chart, a diagram or a group of them. Every element has an id unique in its presentation, a box in points from the slide's top left corner, and a rotation about the box's centre. Elements are immutable; the with... methods answer changed copies.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final boolean
    True when mirrored left to right.
    final boolean
    True when mirrored top to bottom.
    final float
    The box's height in points, at least 0.
    final String
    The id, unique within the presentation.
    final String
    A name for people and screen readers, or null.
    final float
    Clockwise rotation in degrees about the box's centre.
    final float
    The box's width in points, at least 0.
    final float
    The box's left edge in points.
    final float
    The box's top edge in points.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SlideElement(String id, String name, float x, float y, float width, float height, float rotation, boolean flipH, boolean flipV)
    Base constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(float px, float py)
    True when the point, in slide points, is inside the element's rotated box.
    protected final int
    A hash of the base fields.
    The text of the element for search, outlines and screen readers.
    protected final boolean
    True when the base fields equal another element's.
    withBounds(float nx, float ny, float nw, float nh)
    This element moved and resized, keeping its rotation and flips.
    abstract SlideElement
    withId(String value)
    This element with another id, for copies.
    withRotation(float degrees)
    This element rotated to an angle.
    abstract SlideElement
    withTransform(float x, float y, float width, float height, float rotation, boolean flipH, boolean flipV)
    This element moved, resized, rotated or flipped.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • id

      public final String id
      The id, unique within the presentation.
    • name

      public final String name
      A name for people and screen readers, or null.
    • x

      public final float x
      The box's left edge in points.
    • y

      public final float y
      The box's top edge in points.
    • width

      public final float width
      The box's width in points, at least 0.
    • height

      public final float height
      The box's height in points, at least 0.
    • rotation

      public final float rotation
      Clockwise rotation in degrees about the box's centre.
    • flipH

      public final boolean flipH
      True when mirrored left to right.
    • flipV

      public final boolean flipV
      True when mirrored top to bottom.
  • Constructor Details

    • SlideElement

      protected SlideElement(String id, String name, float x, float y, float width, float height, float rotation, boolean flipH, boolean flipV)

      Base constructor.

      Parameters
      • id: the id, not empty

      • name: a name, or null

      • x: left edge in points

      • y: top edge

      • width: width

      • height: height

      • rotation: degrees clockwise

      • flipH: mirrored horizontally

      • flipV: mirrored vertically

  • Method Details

    • withTransform

      public abstract SlideElement withTransform(float x, float y, float width, float height, float rotation, boolean flipH, boolean flipV)

      This element moved, resized, rotated or flipped.

      Parameters
      • x: left edge

      • y: top edge

      • width: width

      • height: height

      • rotation: degrees clockwise

      • flipH: mirrored horizontally

      • flipV: mirrored vertically

      Returns

      the changed element

    • withId

      public abstract SlideElement withId(String value)

      This element with another id, for copies.

      Parameters
      • value: the id
      Returns

      the element

    • withBounds

      public SlideElement withBounds(float nx, float ny, float nw, float nh)

      This element moved and resized, keeping its rotation and flips.

      Parameters
      • nx: left edge

      • ny: top edge

      • nw: width

      • nh: height

      Returns

      the element

    • withRotation

      public SlideElement withRotation(float degrees)

      This element rotated to an angle.

      Parameters
      • degrees: clockwise
      Returns

      the element

    • plainText

      public String plainText()

      The text of the element for search, outlines and screen readers.

      Returns

      the text, empty when there is none

    • contains

      public boolean contains(float px, float py)

      True when the point, in slide points, is inside the element's rotated box.

      Parameters
      • px: x

      • py: y

      Returns

      true when inside

    • sameFrame

      protected final boolean sameFrame(SlideElement e)

      True when the base fields equal another element's.

      Parameters
      • e: the other
      Returns

      true when equal

    • frameHash

      protected final int frameHash()

      A hash of the base fields.

      Returns

      the hash