diff options
author | Alex Clayton <alex.clayton@isode.com> | 2016-02-26 16:51:13 (GMT) |
---|---|---|
committer | Alex Clayton <alex.clayton@isode.com> | 2016-03-09 16:44:17 (GMT) |
commit | 8f112a856705b800d1a8797bec5d9396a9c00b34 (patch) | |
tree | 6468ad42172e1d1f68138a26679dbaf85b58e6b9 /src/com/isode/stroke/elements/WhiteboardColor.java | |
parent | 8fe752626726ca8d058ce437127a37d5d738a5eb (diff) | |
download | stroke-8f112a856705b800d1a8797bec5d9396a9c00b34.zip stroke-8f112a856705b800d1a8797bec5d9396a9c00b34.tar.bz2 |
Add Whiteboard Functionality
Add the Whiteboard classes to stroke.
Test-information:
Unit tests all pass.
Change-Id: Id409c09d0fc1f82864e5d706c413b9d984a7db82
Diffstat (limited to 'src/com/isode/stroke/elements/WhiteboardColor.java')
-rw-r--r-- | src/com/isode/stroke/elements/WhiteboardColor.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/WhiteboardColor.java b/src/com/isode/stroke/elements/WhiteboardColor.java new file mode 100644 index 0000000..f40f618 --- /dev/null +++ b/src/com/isode/stroke/elements/WhiteboardColor.java @@ -0,0 +1,69 @@ +/* Copyright (c) 2016, Isode Limited, London, England. + * All rights reserved. + * + * Acquisition and use of this software and related materials for any + * purpose requires a written license agreement from Isode Limited, + * or a written license from an organisation licensed by Isode Limited + * to grant such a license. + * + */ +package com.isode.stroke.elements; + +public class WhiteboardColor { + + private final int red_, green_, blue_; + private int alpha_; + + public WhiteboardColor() { + this(0,0,0,255); + } + + public WhiteboardColor(int red,int green,int blue) { + this(red,green,blue,255); + } + + public WhiteboardColor(int red,int green,int blue,int alpha) { + red_ = red; + green_ = green; + blue_ = blue; + alpha_ = alpha; + } + + public WhiteboardColor(String hex) { + alpha_ = 255; + int value = Integer.parseInt(hex.substring(1)); + red_ = (value >> 16) & 0xFF; + green_ = (value >> 8) & 0xFF; + blue_ = value & 0xFF; + } + + public String toHex() { + int value = (red_ << 16) + (green_ << 8) + blue_; + StringBuilder builder = new StringBuilder(Integer.toHexString(value)); + while (builder.length() < 6) { + builder.insert(0, '0'); + } + builder.insert(0, '#'); + return builder.toString(); + } + + public int getRed() { + return red_; + } + + public int getGreen() { + return green_; + } + + public int getBlue() { + return blue_; + } + + public int getAlpha() { + return alpha_; + } + + public void setAlpha(int alpha) { + alpha_ = alpha; + } +} |