Package com.iizix.prop.ui.device
Class GSimpleDevice
- java.lang.Object
- com.iizix.prop.ui.device.GSimpleDevice
public class GSimpleDevice extends java.lang.Object
Class for a simple panel device, i.e. without orientation, device pixel ratio, etc.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static GSimpleDevice
BROWSER
The browser device has size 0.static GSimpleDevice
IPAD_LANDSCAPE
The iPad device in landscape mode.static GSimpleDevice
IPAD_PORTRAIT
The iPad device in portrait mode.static GSimpleDevice
IPHONE5_LANDSCAPE
The iPhone 5 device (or iPhone SE) in landscape mode.static GSimpleDevice
IPHONE5_PORTRAIT
The iPhone 5 device (or iPhone SE) in portrait mode.static GSimpleDevice
PANEL_PART
The panel part has the size of the panel part container.
Constructor Summary
Constructors Constructor Description GSimpleDevice(ReadTransaction trans)
Constructs the device from a transaction.GSimpleDevice(java.lang.String string)
Creates from a string representation "width={integer},height={integer},canChangeOrientation={boolean},name".GSimpleDevice(java.lang.String name, int pixelX, int pixelY)
Constructs the device.GSimpleDevice(java.lang.String name, int pixelX, int pixelY, boolean canChangeOrientation)
Constructs the device.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(SendTransaction trans)
Appends the device to a transaction.boolean
canChangeOrientation()
Checks if orientation can be changed.GSimpleDevice
changeOrientation()
Creates a new simple device with changed orientation type (portrait/landscape).java.lang.String
dataToString()
The data string representation.boolean
equals(java.lang.Object o)
Compares two devices.boolean
equalsNoOrientation(GSimpleDevice d)
Compares two devices without caring about orientation.int
getHeight()
Gets the height.java.lang.String
getName()
Gets the name of the device.int
getWidth()
Gets the width.int
hashCode()
The hash code.boolean
isBrowser()
Checks if the device is the browser device.boolean
isLandscape()
Gets the orientation.boolean
isPanelPart()
Checks if the device is for a panel part.boolean
isPortrait()
Gets the orientation.java.lang.String
toString()
Returns a string representation of this class instance and its values.
Field Detail
BROWSER
public static final GSimpleDevice BROWSER
The browser device has size 0.
PANEL_PART
public static final GSimpleDevice PANEL_PART
The panel part has the size of the panel part container.
IPHONE5_LANDSCAPE
public static final GSimpleDevice IPHONE5_LANDSCAPE
The iPhone 5 device (or iPhone SE) in landscape mode.
IPHONE5_PORTRAIT
public static final GSimpleDevice IPHONE5_PORTRAIT
The iPhone 5 device (or iPhone SE) in portrait mode.
IPAD_LANDSCAPE
public static final GSimpleDevice IPAD_LANDSCAPE
The iPad device in landscape mode.
IPAD_PORTRAIT
public static final GSimpleDevice IPAD_PORTRAIT
The iPad device in portrait mode.
Constructor Detail
GSimpleDevice
public GSimpleDevice(java.lang.String name, int pixelX, int pixelY)
Constructs the device.- Parameters:
name
- The device name.pixelX
- The pixel size in X.pixelY
- The pixel size in Y.- Throws:
java.lang.NullPointerException
- If the name is null.java.lang.IllegalArgumentException
- For illegal definitions.
GSimpleDevice
public GSimpleDevice(java.lang.String name, int pixelX, int pixelY, boolean canChangeOrientation)
Constructs the device.- Parameters:
name
- The device name.pixelX
- The pixel size in X.pixelY
- The pixel size in Y.- Throws:
java.lang.NullPointerException
- If the name is null.java.lang.IllegalArgumentException
- For illegal definitions.
GSimpleDevice
public GSimpleDevice(java.lang.String string)
Creates from a string representation "width={integer},height={integer},canChangeOrientation={boolean},name".- Parameters:
string
- The string.- Throws:
java.lang.IllegalArgumentException
- For illegal definitions.java.lang.NumberFormatException
- For value errors.java.util.NoSuchElementException
- For format errors.
GSimpleDevice
public GSimpleDevice(ReadTransaction trans)
Constructs the device from a transaction.
Method Detail
isBrowser
public boolean isBrowser()
Checks if the device is the browser device.
isPanelPart
public boolean isPanelPart()
Checks if the device is for a panel part.
append
public void append(SendTransaction trans)
Appends the device to a transaction.
getName
public java.lang.String getName()
Gets the name of the device.
isPortrait
public boolean isPortrait()
Gets the orientation.- Returns:
- true if it's portrait sized.
isLandscape
public boolean isLandscape()
Gets the orientation.- Returns:
- true if it's landscape sized.
getWidth
public int getWidth()
Gets the width.- Returns:
- A value for pixels in HTML.
getHeight
public int getHeight()
Gets the height.- Returns:
- A value for pixels in HTML.
equals
public boolean equals(java.lang.Object o)
Compares two devices.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- The device to compare with.- Returns:
- true if equal.
hashCode
public int hashCode()
The hash code.- Overrides:
hashCode
in classjava.lang.Object
equalsNoOrientation
public boolean equalsNoOrientation(GSimpleDevice d)
Compares two devices without caring about orientation.- Parameters:
d
- The device to compare with.- Returns:
- true if equal.
dataToString
public java.lang.String dataToString()
The data string representation.
toString
public java.lang.String toString()
Returns a string representation of this class instance and its values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this class instance.
canChangeOrientation
public boolean canChangeOrientation()
Checks if orientation can be changed.- Returns:
- Some devices do not support orientation changes, e.g. a TV.
changeOrientation
public GSimpleDevice changeOrientation()
Creates a new simple device with changed orientation type (portrait/landscape).- Returns:
- The new simple device if not same width and height, otherwise it's the same instance.